KVM: s390: fix shadow table handling for nested guests

Some odd-ball cases (real-space designation ASCEs) are handled wrong
 for the shadow page tables. Fix it.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.14 (GNU/Linux)
 
 iQIcBAABAgAGBQJZS6aoAAoJEBF7vIC1phx8Y9gP/0UO7OBobxB10k3SP3aQtisw
 oILlXRxvEskkv6RiTUJGvHwILHiigIVXtIWFIDx+tpX70ifx0/id7KtLiQoEnuqm
 bmt2lsU1VQnO7siJmGvXZvZ4Da6BonlqT6bJkGSHiP2oOGgZByQFlQ3E04ZtyTJ+
 Uc8nSAAsZrZDMCT+2P9OXLT/t3/dGw5C1vI5fiBmyweR4qXjXxGvWw5VtvA0nT4/
 m/vTuEevTymmQeV7LyV0x/Ru3RV9yU2QUVQrctcPrkWicvTdWO/Ml+z+/Q0OHh2A
 5B3sjlS0Dq5qqF6dRlh0YHDV00uuyrOuBSSH2p5Dhdo3+55fy44U243zZayDzarK
 1xrv13iOus0e2GbMxhhB3hWE8E8gw4t9XUyl4ipJdiTGH0IRCS3Wi/yz8aqCS0w/
 1bY858p3cvV+SqTfmeQdvN0ZhcYDGaIPwxheeClE6DKHKr2PBqW2NnSHDBy3tyhD
 5Lz1Xkn0RFxybb8TJhNdY0i2MxprFQdHAvVmhBvLTfspintO0nYygZjPme2OtYhZ
 P7bS2p8F8aR32HyDsN1nUGwwlYpuBAGcwQ/yuGdz11uEfcOPnI40GrWyHakBMzx4
 krrK9WnF7WT1bcqgmB46YvUc+hAuG5smqsUxa1XqLkxOKRvkncYKgYAPj9dg+o8E
 Y+i+/SKxAqhTJcf2loHP
 =SHME
 -----END PGP SIGNATURE-----

Merge tag 'kvm-s390-master-4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux

KVM: s390: fix shadow table handling for nested guests

Some odd-ball cases (real-space designation ASCEs) are handled wrong
for the shadow page tables. Fix it.
This commit is contained in:
Radim Krčmář 2017-06-22 16:13:06 +02:00
commit d6aa07c169

View File

@ -977,11 +977,12 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
ptr = asce.origin * 4096;
if (asce.r) {
*fake = 1;
ptr = 0;
asce.dt = ASCE_TYPE_REGION1;
}
switch (asce.dt) {
case ASCE_TYPE_REGION1:
if (vaddr.rfx01 > asce.tl && !asce.r)
if (vaddr.rfx01 > asce.tl && !*fake)
return PGM_REGION_FIRST_TRANS;
break;
case ASCE_TYPE_REGION2:
@ -1009,8 +1010,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
union region1_table_entry rfte;
if (*fake) {
/* offset in 16EB guest memory block */
ptr = ptr + ((unsigned long) vaddr.rsx << 53UL);
ptr += (unsigned long) vaddr.rfx << 53;
rfte.val = ptr;
goto shadow_r2t;
}
@ -1036,8 +1036,7 @@ shadow_r2t:
union region2_table_entry rste;
if (*fake) {
/* offset in 8PB guest memory block */
ptr = ptr + ((unsigned long) vaddr.rtx << 42UL);
ptr += (unsigned long) vaddr.rsx << 42;
rste.val = ptr;
goto shadow_r3t;
}
@ -1064,8 +1063,7 @@ shadow_r3t:
union region3_table_entry rtte;
if (*fake) {
/* offset in 4TB guest memory block */
ptr = ptr + ((unsigned long) vaddr.sx << 31UL);
ptr += (unsigned long) vaddr.rtx << 31;
rtte.val = ptr;
goto shadow_sgt;
}
@ -1101,8 +1099,7 @@ shadow_sgt:
union segment_table_entry ste;
if (*fake) {
/* offset in 2G guest memory block */
ptr = ptr + ((unsigned long) vaddr.sx << 20UL);
ptr += (unsigned long) vaddr.sx << 20;
ste.val = ptr;
goto shadow_pgt;
}