Skip to content

Commit fd7bc61

Browse files
author
Claudio Imbrenda
committed
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: e38c884 ("KVM: s390: Switch to new gmap") Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
1 parent 0f2b760 commit fd7bc61

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

arch/s390/kvm/gaccess.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,13 +1436,19 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, union
14361436

14371437
if (!pgste_get_trylock(ptep_h, &pgste))
14381438
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+
}
14451449
pgste_set_unlock(ptep_h, pgste);
1450+
if (rc)
1451+
return rc;
14461452

14471453
newpte = _pte(f->pfn, 0, !p, 0);
14481454
if (!pgste_get_trylock(ptep, &pgste))
@@ -1477,6 +1483,9 @@ static int _do_shadow_crste(struct gmap *sg, gpa_t raddr, union crste *host, uni
14771483
newcrste.h.p &= oldcrste.h.p;
14781484
newcrste.s.fc1.vsie_notif = 1;
14791485
newcrste.s.fc1.prefix_notif = oldcrste.s.fc1.prefix_notif;
1486+
newcrste.s.fc1.s = oldcrste.s.fc1.s;
1487+
if (!newcrste.h.p && !f->writable)
1488+
return -EOPNOTSUPP;
14801489
} while (!_gmap_crstep_xchg_atomic(sg->parent, host, oldcrste, newcrste, f->gfn, false));
14811490

14821491
newcrste = _crste_fc1(f->pfn, oldcrste.h.tt, 0, !p);

0 commit comments

Comments
 (0)