KVM: s390: Fixes for vsie (nested hypervisors)

- Several fixes for corner cases of nesting. Still relevant as it might
   crash host or first level guest or temporarily leak memory.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJejGBFAAoJEBF7vIC1phx8aMkP/R5LNqloyrEE7ysMbrrLgF9T
 OZ9phn9R1+wVST1Ktf8XAJDronmENaiqMNHUfEaIzmxv8IERkcTrhGcUwFCdjL4c
 ozMBIS7lYN/6o3Gh/Bbslovh1GscpsCBZT2AgHPDo6KsJsBCJIlBI6hNzGgg/6LI
 tci92q6JeFdhJNrYYB4odwFpG5Kl3o6S9rLaBjVFCKh6p/wrOMj6WV4+prKBLcJq
 udJZFzzzkxGAvIUSFamLRXsKXCxze+nLW7ao1SN8t1zjqiB+Geksju6CJZ37xv5L
 CZ4bJpwy2qc6kFN1ym1rto9g5xG/hxf+aZc+j6T7v0pURxGhLVwTwN3qDi63Mt6s
 eZE0WyyQVEHt3dypJMMKh/BNcMJKTixv1aav2yjR7PBpwjUCNFXnqel3OpICgO1k
 VBD8t5oQjvxvVrX9ekEinKY8vfk3MbsmCaYMwL6wDiUylra1f11aHvwjN/ew3qm3
 RyCdl01q0Pdb7kpcuXz1uvli6rZQMi7tIZouKRhHWmRxheZKVVrJwmgJqGdA9Ru0
 yEs+iuARCcB/Kw1nTRZuQvV8VJpPx2kIIRtCp2IrnPJuMEn558qpsMR+GRkmsKxk
 mCzpQMSBr8NkKbxfDEkXQyDIPCDDGLuDSNHiYH5PcG05o03ld3U0COtbwjkvWk2r
 S9uWVz1+R4XuR2nsOyTo
 =oinE
 -----END PGP SIGNATURE-----

Merge tag 'kvm-s390-master-5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD

KVM: s390: Fixes for vsie (nested hypervisors)

- Several fixes for corner cases of nesting. Still relevant as it might
  crash host or first level guest or temporarily leak memory.
This commit is contained in:
Paolo Bonzini 2020-04-07 08:31:44 -04:00
commit 1b0c58a34b
2 changed files with 7 additions and 1 deletions

View File

@ -1202,6 +1202,7 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
scb_s->iprcc = PGM_ADDRESSING;
scb_s->pgmilc = 4;
scb_s->gpsw.addr = __rewind_psw(scb_s->gpsw, 4);
rc = 1;
}
return rc;
}

View File

@ -787,14 +787,18 @@ static void gmap_call_notifier(struct gmap *gmap, unsigned long start,
static inline unsigned long *gmap_table_walk(struct gmap *gmap,
unsigned long gaddr, int level)
{
const int asce_type = gmap->asce & _ASCE_TYPE_MASK;
unsigned long *table;
if ((gmap->asce & _ASCE_TYPE_MASK) + 4 < (level * 4))
return NULL;
if (gmap_is_shadow(gmap) && gmap->removed)
return NULL;
if (gaddr & (-1UL << (31 + ((gmap->asce & _ASCE_TYPE_MASK) >> 2)*11)))
if (asce_type != _ASCE_TYPE_REGION1 &&
gaddr & (-1UL << (31 + (asce_type >> 2) * 11)))
return NULL;
table = gmap->table;
switch (gmap->asce & _ASCE_TYPE_MASK) {
case _ASCE_TYPE_REGION1:
@ -1840,6 +1844,7 @@ int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
goto out_free;
} else if (*table & _REGION_ENTRY_ORIGIN) {
rc = -EAGAIN; /* Race with shadow */
goto out_free;
}
crst_table_init(s_r3t, _REGION3_ENTRY_EMPTY);
/* mark as invalid as long as the parent table is not protected */