Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: s390: vsie: Fix nested guest memory shadowing

Fix _do_shadow_pte() to use the correct pointer (guest pte instead of
nested guest) to set up the new pte.

Add a check to return -EOPNOTSUPP if the mapping for the nested guest
is writeable but the same page in the guest is only read-only.

Fixes: e38c884df921 ("KVM: s390: Switch to new gmap")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

+15 -6
+15 -6
arch/s390/kvm/gaccess.c
··· 1436 1436 1437 1437 if (!pgste_get_trylock(ptep_h, &pgste)) 1438 1438 return -EAGAIN; 1439 - newpte = _pte(f->pfn, f->writable, !p, 0); 1440 - newpte.s.d |= ptep->s.d; 1441 - newpte.s.sd |= ptep->s.sd; 1442 - newpte.h.p &= ptep->h.p; 1443 - pgste = _gmap_ptep_xchg(sg->parent, ptep_h, newpte, pgste, f->gfn, false); 1444 - pgste.vsie_notif = 1; 1439 + newpte = _pte(f->pfn, f->writable, !p, ptep_h->s.s); 1440 + newpte.s.d |= ptep_h->s.d; 1441 + newpte.s.sd |= ptep_h->s.sd; 1442 + newpte.h.p &= ptep_h->h.p; 1443 + if (!newpte.h.p && !f->writable) { 1444 + rc = -EOPNOTSUPP; 1445 + } else { 1446 + pgste = _gmap_ptep_xchg(sg->parent, ptep_h, newpte, pgste, f->gfn, false); 1447 + pgste.vsie_notif = 1; 1448 + } 1445 1449 pgste_set_unlock(ptep_h, pgste); 1450 + if (rc) 1451 + return rc; 1446 1452 1447 1453 newpte = _pte(f->pfn, 0, !p, 0); 1448 1454 if (!pgste_get_trylock(ptep, &pgste)) ··· 1483 1477 newcrste.h.p &= oldcrste.h.p; 1484 1478 newcrste.s.fc1.vsie_notif = 1; 1485 1479 newcrste.s.fc1.prefix_notif = oldcrste.s.fc1.prefix_notif; 1480 + newcrste.s.fc1.s = oldcrste.s.fc1.s; 1481 + if (!newcrste.h.p && !f->writable) 1482 + return -EOPNOTSUPP; 1486 1483 } while (!_gmap_crstep_xchg_atomic(sg->parent, host, oldcrste, newcrste, f->gfn, false)); 1487 1484 1488 1485 newcrste = _crste_fc1(f->pfn, oldcrste.h.tt, 0, !p);