]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: Properly reset zero bit in PGSTE
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 19 May 2026 15:01:14 +0000 (17:01 +0200)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Fri, 22 May 2026 09:25:11 +0000 (11:25 +0200)
In case of memory pressure, it's possible that a guest page gets freed
and then almost immediately reused by the guest. If CMMA is enabled,
_essa_clear_cbrl() will discard all pages that are either unused or
zero. If a discarded page is reused before _essa_clear_cbrl() is called,
and the pgste.zero bit is not cleared, the page will be discarded
despite not being unused.

When calling _gmap_ptep_xchg(), always clear the pgste.zero bit. This
prevents the page from being accidentally discarded when not unused.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Fixes: a2c17f9270cc ("KVM: s390: New gmap code")
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
arch/s390/kvm/gmap.h

index 6e51ec6066b4d0872ead2100f0a1fa9fc2e0f764..742e42a317445e131ab9fd55cd4d62ed15e50c65 100644 (file)
@@ -220,6 +220,7 @@ static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, un
        }
        if (!ptep->s.d && newpte.s.d && !newpte.s.s)
                SetPageDirty(pfn_to_page(newpte.h.pfra));
+       pgste.zero = 0;
        return __dat_ptep_xchg(ptep, pgste, newpte, gfn, gmap->asce, uses_skeys(gmap));
 }