Commit 9029496a authored by Claudio Imbrenda's avatar Claudio Imbrenda
Browse files

KVM: s390: Properly reset zero bit in PGSTE



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: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
Fixes: a2c17f92 ("KVM: s390: New gmap code")
Reviewed-by: default avatarSteffen Eiden <seiden@linux.ibm.com>
Signed-off-by: default avatarChristian Borntraeger <borntraeger@linux.ibm.com>
parent a488e753
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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));
}