]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: s390: vsie: Fix check for pre-existing shadow mapping
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Thu, 26 Mar 2026 13:17:12 +0000 (14:17 +0100)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Thu, 26 Mar 2026 15:12:07 +0000 (16:12 +0100)
When shadowing a nested guest, a check is performed and no shadowing is
attempted if the nested guest is already shadowed.

The existing check was incomplete; fix it by also checking whether the
leaf DAT table entry in the existing shadow gmap has the same protection
as the one specified in the guest DAT entry.

Fixes: e38c884df921 ("KVM: s390: Switch to new gmap")
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
arch/s390/kvm/gaccess.c

index 4ee862424ca07a341a10d945b5f12576d696a6d0..8fd690255e1b14dbc3e2b90dda70a45f85a02ca9 100644 (file)
@@ -1506,8 +1506,9 @@ static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg,
        if (rc)
                return rc;
 
-       /* A race occourred. The shadow mapping is already valid, nothing to do */
-       if ((ptep && !ptep->h.i) || (!ptep && crste_leaf(*table)))
+       /* A race occurred. The shadow mapping is already valid, nothing to do */
+       if ((ptep && !ptep->h.i && ptep->h.p == w->p) ||
+           (!ptep && crste_leaf(*table) && !table->h.i && table->h.p == w->p))
                return 0;
 
        gl = get_level(table, ptep);