Skip to contentSkip to conversation

KVM: s390: some vSIE and UCONTROL fixes

PATCH Superseded Claudio Imbrenda 3 participants 15 messages May 12 – May 19

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Claudio Imbrenda

author maintainer
#0 lore raw

v2 cover KVM: s390: some vSIE and UCONTROL fixes

Fix some memory issues and some hangs in vSIE.

This is still a fallout from the gmap rewrite.

v1->v2:
* Fix potential leak of struct kvm_s390_mmu_cache in gmap_set_limit()
* Refactor and improve the checks to determine whether an unshadowing is needed
* Set and propagate vsie_gmem properly
* Properly mask the address passed to gmap_insert_rmap() to prevent creating multiple redundant rmaps when shadowing
* Clear the pgste.zero flag when needed, to prevent pages from getting accidentally discarded

Claudio Imbrenda (5):
KVM: s390: vsie: Fix memory leak when unshadowing
KVM: s390: Fix leaking kvm_s390_mmu_cache in case of errors
KVM: s390: vsie: Fix unshadowing logic
KVM: s390: vsie: Fix redundant rmap entries
KVM: s390: Properly reset zero bit in PGSTE

 arch/s390/kvm/dat.c     |  1 +
 arch/s390/kvm/dat.h     |  3 ++-
 arch/s390/kvm/gaccess.c |  1 +
 arch/s390/kvm/gmap.c    | 18 +++++++++++-------
 arch/s390/kvm/gmap.h    | 23 ++++++++++++++++++++---
 5 files changed, 35 insertions(+), 11 deletions(-)
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH v2 1/5 KVM: s390: vsie: Fix memory leak when unshadowing

When performing a partial unshadowing, the rmap was being leaked.

Add the missing kfree().

Fixes a2c17f9270cc ("KVM: s390: New gmap code")
---
 arch/s390/kvm/gmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap.c +3 -1
index 3c26e35af0ef..fd1927761980 100644
@@ -1143,8 +1143,10 @@ void _gmap_handle_vsie_unshadow_event(struct gmap *parent, gfn_t gfn)
 		}
 		scoped_guard(spinlock, &sg->host_to_rmap_lock)
 			head = radix_tree_delete(&sg->host_to_rmap, gfn);
-		gmap_for_each_rmap_safe(rmap, rnext, head)
+		gmap_for_each_rmap_safe(rmap, rnext, head) {
 			gmap_unshadow_level(sg, rmap->r_gfn, rmap->level);
+			kfree(rmap);
+		}
 	}
 }
 
Signature · 1 line
2.54.0
Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] KVM: s390: vsie: Fix memory leak when unshadowing

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 7 lines

When performing a partial unshadowing, the rmap was being leaked.

Add the missing kfree().

Fixes a2c17f9270cc ("KVM: s390: New gmap code")
Quoted 20 lines
---
  arch/s390/kvm/gmap.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap.c +3 -1
index 3c26e35af0ef..fd1927761980 100644
@@ -1143,8 +1143,10 @@ void _gmap_handle_vsie_unshadow_event(struct gmap *parent, gfn_t gfn)
  		}
  		scoped_guard(spinlock, &sg->host_to_rmap_lock)
  			head = radix_tree_delete(&sg->host_to_rmap, gfn);
-		gmap_for_each_rmap_safe(rmap, rnext, head)
+		gmap_for_each_rmap_safe(rmap, rnext, head) {
  			gmap_unshadow_level(sg, rmap->r_gfn, rmap->level);
+			kfree(rmap);
+		}
  	}
  }
 
author maintainer
#3 lore raw

PATCH v2 2/5 KVM: s390: Fix leaking kvm_s390_mmu_cache in case of errors

In reply to Claudio Imbrenda

Fix a memory leak that can happen if gmap_ucas_map_one() or kvm_s390_mmu_cache_topup() return error values.

Also fix a similar issue in gmap_set_limit().

Fixes a2c17f9270cc ("KVM: s390: New gmap code")
---
 arch/s390/kvm/gmap.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/s390/kvm/gmap.c +3 -4
index fd1927761980..10c98c8cc1d8 100644
@@ -125,7 +125,7 @@ struct gmap *gmap_new_child(struct gmap *parent, gfn_t limit)
 
 int gmap_set_limit(struct gmap *gmap, gfn_t limit)
 {
-	struct kvm_s390_mmu_cache *mc;
+	struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
 	int rc, type;
 
 	type = gmap_limit_to_type(limit);
@@ -142,7 +142,6 @@ int gmap_set_limit(struct gmap *gmap, gfn_t limit)
 			rc = dat_set_asce_limit(mc, &gmap->asce, type);
 	} while (rc == -ENOMEM);
 
-	kvm_s390_free_mmu_cache(mc);
 	return 0;
 }
 
@@ -822,8 +821,8 @@ int gmap_ucas_translate(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, gpa_t
 
 int gmap_ucas_map(struct gmap *gmap, gfn_t p_gfn, gfn_t c_gfn, unsigned long count)
 {
-	struct kvm_s390_mmu_cache *mc;
-	int rc;
+	struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
+	int rc = 0;
 
 	mc = kvm_s390_new_mmu_cache();
 	if (!mc)
Signature · 1 line
2.54.0
Reviewed-by on v2 2/5
#4 lore raw

Re: [PATCH v2 2/5] KVM: s390: Fix leaking kvm_s390_mmu_cache in case of errors

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 8 lines

Fix a memory leak that can happen if gmap_ucas_map_one() or kvm_s390_mmu_cache_topup() return error values.

Also fix a similar issue in gmap_set_limit().

Fixes a2c17f9270cc ("KVM: s390: New gmap code")
Quoted 36 lines
---
  arch/s390/kvm/gmap.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
arch/s390/kvm/gmap.c +3 -4
index fd1927761980..10c98c8cc1d8 100644
@@ -125,7 +125,7 @@ struct gmap *gmap_new_child(struct gmap *parent, gfn_t limit)
 
  int gmap_set_limit(struct gmap *gmap, gfn_t limit)
  {
-	struct kvm_s390_mmu_cache *mc;
+	struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
  	int rc, type;
 
  	type = gmap_limit_to_type(limit);
@@ -142,7 +142,6 @@ int gmap_set_limit(struct gmap *gmap, gfn_t limit)
  			rc = dat_set_asce_limit(mc, &gmap->asce, type);
  	} while (rc == -ENOMEM);
 
-	kvm_s390_free_mmu_cache(mc);
  	return 0;
  }
 
@@ -822,8 +821,8 @@ int gmap_ucas_translate(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, gpa_t
 
  int gmap_ucas_map(struct gmap *gmap, gfn_t p_gfn, gfn_t c_gfn, unsigned long count)
  {
-	struct kvm_s390_mmu_cache *mc;
-	int rc;
+	struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
+	int rc = 0;
 
  	mc = kvm_s390_new_mmu_cache();
  	if (!mc)
author maintainer
#5 lore raw

PATCH v2 3/5 KVM: s390: vsie: Fix unshadowing logic

In reply to Claudio Imbrenda

In some cases (i.e. under extreme memory pressure on the host), attempting to shadow memory will result in the same memory being unshadowed, causing a loop.

Add a PGSTE bit to distinguish between shadowed memory and shadowed DAT tables, fix the unshadowing logic in _gmap_ptep_xchg() to prevent unnecessary unshadowing and perform better checks.

Also fix the unshadowing logic in _gmap_crstep_xchg_atomic() which did not unshadow properly when the large page would become unprotected.

Opportunistilcally add a check in gmap_protect_rmap() to make sure it won't be called with level == TABLE_TYPE_PAGE_TABLE.

Fixes a2c17f9270cc ("KVM: s390: New gmap code")
---
 arch/s390/kvm/dat.c     |  1 +
 arch/s390/kvm/dat.h     |  3 ++-
 arch/s390/kvm/gaccess.c |  1 +
 arch/s390/kvm/gmap.c    |  3 ++-
 arch/s390/kvm/gmap.h    | 22 +++++++++++++++++++---
 5 files changed, 25 insertions(+), 5 deletions(-)
arch/s390/kvm/dat.c +1 -0
index 7b8d70fe406d..4a41c0247ffa 100644
@@ -267,6 +267,7 @@ static int dat_split_ste(struct kvm_s390_mmu_cache *mc, union pmd *pmdp, gfn_t g
 			/* No need to take locks as the page table is not installed yet. */
 			pgste_init.prefix_notif = old.s.fc1.prefix_notif;
 			pgste_init.vsie_notif = old.s.fc1.vsie_notif;
+			pgste_init.vsie_gmem = old.s.fc1.vsie_notif;
 			pgste_init.pcl = uses_skeys && init.h.i;
 			dat_init_pgstes(pt, pgste_init.val);
 		} else {
arch/s390/kvm/dat.h +2 -1
index 8f8278c44879..873e13ac5a27 100644
@@ -145,7 +145,8 @@ union pgste {
 		unsigned long cmma_d       : 1; /* Dirty flag for CMMA bits */
 		unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */
 		unsigned long vsie_notif   : 1; /* Referenced in a shadow table */
-		unsigned long              : 5;
+		unsigned long vsie_gmem    : 1; /* Contains nested guest memory */
+		unsigned long              : 4;
 		unsigned long              : 8;
 	};
 	struct {
arch/s390/kvm/gaccess.c +1 -0
index b07accd19618..4f8d5592c9a9 100644
@@ -1445,6 +1445,7 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, union
 	} else {
 		pgste = _gmap_ptep_xchg(sg->parent, ptep_h, newpte, pgste, f->gfn, false);
 		pgste.vsie_notif = 1;
+		pgste.vsie_gmem = 1;
 	}
 	pgste_set_unlock(ptep_h, pgste);
 	if (rc)
arch/s390/kvm/gmap.c +2 -1
index 10c98c8cc1d8..8cff0cf5ce24 100644
@@ -1031,7 +1031,8 @@ int gmap_protect_rmap(struct kvm_s390_mmu_cache *mc, struct gmap *sg, gfn_t p_gf
 	union pte pte;
 	int flags, rc;
 
-	KVM_BUG_ON(!is_shadow(sg), sg->kvm);
+	if (KVM_BUG_ON(!is_shadow(sg) || level <= TABLE_TYPE_PAGE_TABLE, sg->kvm))
+		return -EINVAL;
 	lockdep_assert_held(&sg->parent->children_lock);
 
 	flags = DAT_WALK_SPLIT_ALLOC | (uses_skeys(sg->parent) ? DAT_WALK_USES_SKEYS : 0);
arch/s390/kvm/gmap.h +19 -3
index 96ee1395a592..e490f2995a26 100644
@@ -167,6 +167,15 @@ static inline bool gmap_unmap_prefix(struct gmap *gmap, gfn_t gfn, gfn_t end)
 	return _gmap_unmap_prefix(gmap, gfn, end, false);
 }
 
+static inline bool pte_needs_unshadow(union pte oldpte, union pte newpte, union pgste pgste)
+{
+	if (!pgste.vsie_notif)
+		return false;
+	if (pgste.vsie_gmem)
+		return (oldpte.h.p != newpte.h.p) || newpte.h.i;
+	return !newpte.h.p || !newpte.s.pr;
+}
+
 static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, union pte newpte,
 					  union pgste pgste, gfn_t gfn, bool needs_lock)
 {
@@ -180,8 +189,9 @@ static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, un
 		pgste.prefix_notif = 0;
 		gmap_unmap_prefix(gmap, gfn, gfn + 1);
 	}
-	if (pgste.vsie_notif && (ptep->h.p != newpte.h.p || newpte.h.i)) {
+	if (pte_needs_unshadow(*ptep, newpte, pgste)) {
 		pgste.vsie_notif = 0;
+		pgste.vsie_gmem = 0;
 		if (needs_lock)
 			gmap_handle_vsie_unshadow_event(gmap, gfn);
 		else
@@ -198,6 +208,13 @@ static inline union pgste gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, uni
 	return _gmap_ptep_xchg(gmap, ptep, newpte, pgste, gfn, true);
 }
 
+static inline bool crste_needs_unshadow(union crste oldcrste, union crste newcrste)
+{
+	if (!oldcrste.s.fc1.vsie_notif)
+		return false;
+	return (newcrste.h.p != oldcrste.h.p) || newcrste.h.i || !newcrste.s.fc1.vsie_notif;
+}
+
 static inline bool __must_check _gmap_crstep_xchg_atomic(struct gmap *gmap, union crste *crstep,
 							 union crste oldcrste, union crste newcrste,
 							 gfn_t gfn, bool needs_lock)
@@ -216,8 +233,7 @@ static inline bool __must_check _gmap_crstep_xchg_atomic(struct gmap *gmap, unio
 		newcrste.s.fc1.prefix_notif = 0;
 		gmap_unmap_prefix(gmap, gfn, gfn + align);
 	}
-	if (crste_leaf(oldcrste) && oldcrste.s.fc1.vsie_notif &&
-	    (newcrste.h.p || newcrste.h.i || !newcrste.s.fc1.vsie_notif)) {
+	if (crste_leaf(oldcrste) && crste_needs_unshadow(oldcrste, newcrste)) {
 		newcrste.s.fc1.vsie_notif = 0;
 		if (needs_lock)
 			gmap_handle_vsie_unshadow_event(gmap, gfn);
Signature · 1 line
2.54.0
#6 lore raw

Re: [PATCH v2 3/5] KVM: s390: vsie: Fix unshadowing logic

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 4 lines

In some cases (i.e. under extreme memory pressure on the host), attempting to shadow memory will result in the same memory being unshadowed, causing a loop.

Quoted 8 lines

Add a PGSTE bit to distinguish between shadowed memory and shadowed DAT tables, fix the unshadowing logic in _gmap_ptep_xchg() to prevent unnecessary unshadowing and perform better checks.

Also fix the unshadowing logic in _gmap_crstep_xchg_atomic() which did not unshadow properly when the large page would become unprotected.

Opportunistilcally add a check in gmap_protect_rmap() to make sure it

              ^

Opportunistically

[...]

arch/s390/kvm/gmap.h static inline bool gmap_unmap_prefix(struct gmap *gmap, gfn_t gfn, gfn_t end) · line 178

Quoted 9 lines
arch/s390/kvm/gmap.h +9 -0
+static inline bool pte_needs_unshadow(union pte oldpte, union pte newpte, union pgste pgste)
+{
+	if (!pgste.vsie_notif)
+		return false;
+	if (pgste.vsie_gmem)
+		return (oldpte.h.p != newpte.h.p) || newpte.h.i;
+	return !newpte.h.p || !newpte.s.pr;
+}
+

The newpte.s.pr part is new and seems not related to the vsie_gmem change but I cannot find anything about this in the patch description. And I dont understand this part. So either some explanation here, in the patch description or a comment maybe?

Quoted 14 lines

static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, union pte newpte,
union pgste pgste, gfn_t gfn, bool needs_lock)
{

arch/s390/kvm/gmap.h +2 -1
@@ -180,8 +189,9 @@ static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, un
  		pgste.prefix_notif = 0;
  		gmap_unmap_prefix(gmap, gfn, gfn + 1);
  	}
-	if (pgste.vsie_notif && (ptep->h.p != newpte.h.p || newpte.h.i)) {
+	if (pte_needs_unshadow(*ptep, newpte, pgste)) {
  		pgste.vsie_notif = 0;
+		pgste.vsie_gmem = 0;
  		if (needs_lock)
  			gmap_handle_vsie_unshadow_event(gmap, gfn);
  		else

[...]

author maintainer
#7 lore raw

Re: [PATCH v2 3/5] KVM: s390: vsie: Fix unshadowing logic

Quoted 9 lines · On Mon, 18 May 2026 13:28:44 +0200 Christian Borntraeger…

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 8 lines

In some cases (i.e. under extreme memory pressure on the host), attempting to shadow memory will result in the same memory being unshadowed, causing a loop.

Add a PGSTE bit to distinguish between shadowed memory and shadowed DAT tables, fix the unshadowing logic in _gmap_ptep_xchg() to prevent unnecessary unshadowing and perform better checks.

Quoted 6 lines
Quoted 4 lines

Also fix the unshadowing logic in _gmap_crstep_xchg_atomic() which did not unshadow properly when the large page would become unprotected.

Opportunistilcally add a check in gmap_protect_rmap() to make sure it

               ^

Opportunistically

oops

Quoted 14 lines

[...]

arch/s390/kvm/gmap.h static inline bool gmap_unmap_prefix(struct gmap *gmap, gfn_t gfn, gfn_t end) · line 178

Quoted 9 lines
arch/s390/kvm/gmap.h +9 -0
+static inline bool pte_needs_unshadow(union pte oldpte, union pte newpte, union pgste pgste)
+{
+	if (!pgste.vsie_notif)
+		return false;
+	if (pgste.vsie_gmem)
+		return (oldpte.h.p != newpte.h.p) || newpte.h.i;
+	return !newpte.h.p || !newpte.s.pr;
+}
+  

The newpte.s.pr part is new and seems not related to the vsie_gmem change but I cannot find anything about this in the patch description. And I dont

it's part of "fix unshadowing logic"

Quoted 2 lines

understand this part. So either some explanation here, in the patch description or a comment maybe?

I think a comment explaining what's going on is the best option

Quoted 16 lines
Quoted 15 lines

static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, union pte newpte,
union pgste pgste, gfn_t gfn, bool needs_lock)
{

arch/s390/kvm/gmap.h +2 -1
@@ -180,8 +189,9 @@ static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, un
  		pgste.prefix_notif = 0;
  		gmap_unmap_prefix(gmap, gfn, gfn + 1);
  	}
-	if (pgste.vsie_notif && (ptep->h.p != newpte.h.p || newpte.h.i)) {
+	if (pte_needs_unshadow(*ptep, newpte, pgste)) {
  		pgste.vsie_notif = 0;
+		pgste.vsie_gmem = 0;
  		if (needs_lock)
  			gmap_handle_vsie_unshadow_event(gmap, gfn);
  		else  

[...]

author maintainer
#8 lore raw

PATCH v2 4/5 KVM: s390: vsie: Fix redundant rmap entries

In reply to Claudio Imbrenda

The address passed to the gmap rmap was not being masked. As a consequence several different (but functionally equivalent) rmap entries were being created for each shadowed table.

Fix this by properly masking the address depending on the table level.

---
 arch/s390/kvm/gmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap.c +3 -1
index 8cff0cf5ce24..957126ab991c 100644
@@ -1025,6 +1025,7 @@ int gmap_insert_rmap(struct gmap *sg, gfn_t p_gfn, gfn_t r_gfn, int level)
 int gmap_protect_rmap(struct kvm_s390_mmu_cache *mc, struct gmap *sg, gfn_t p_gfn, gfn_t r_gfn,
 		      kvm_pfn_t pfn, int level, bool wr)
 {
+	unsigned long bitmask;
 	union crste *crstep;
 	union pgste pgste;
 	union pte *ptep;
@@ -1041,8 +1042,9 @@ int gmap_protect_rmap(struct kvm_s390_mmu_cache *mc, struct gmap *sg, gfn_t p_gf
 	if (rc)
 		return rc;
 	if (level <= TABLE_TYPE_REGION1) {
+		bitmask = -1UL << (8 + 11 * level);
 		scoped_guard(spinlock, &sg->host_to_rmap_lock)
-			rc = gmap_insert_rmap(sg, p_gfn, r_gfn, level);
+			rc = gmap_insert_rmap(sg, p_gfn, r_gfn & bitmask, level);
 	}
 	if (rc)
 		return rc;
Signature · 1 line
2.54.0
Reviewed-by on v2 4/5
#9 lore raw

Re: [PATCH v2 4/5] KVM: s390: vsie: Fix redundant rmap entries

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 7 lines

The address passed to the gmap rmap was not being masked. As a consequence several different (but functionally equivalent) rmap entries were being created for each shadowed table.

Fix this by properly masking the address depending on the table level.

Quoted 27 lines
---
  arch/s390/kvm/gmap.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap.c +3 -1
index 8cff0cf5ce24..957126ab991c 100644
@@ -1025,6 +1025,7 @@ int gmap_insert_rmap(struct gmap *sg, gfn_t p_gfn, gfn_t r_gfn, int level)
  int gmap_protect_rmap(struct kvm_s390_mmu_cache *mc, struct gmap *sg, gfn_t p_gfn, gfn_t r_gfn,
  		      kvm_pfn_t pfn, int level, bool wr)
  {
+	unsigned long bitmask;
  	union crste *crstep;
  	union pgste pgste;
  	union pte *ptep;
@@ -1041,8 +1042,9 @@ int gmap_protect_rmap(struct kvm_s390_mmu_cache *mc, struct gmap *sg, gfn_t p_gf
  	if (rc)
  		return rc;
  	if (level <= TABLE_TYPE_REGION1) {
+		bitmask = -1UL << (8 + 11 * level);
  		scoped_guard(spinlock, &sg->host_to_rmap_lock)
-			rc = gmap_insert_rmap(sg, p_gfn, r_gfn, level);
+			rc = gmap_insert_rmap(sg, p_gfn, r_gfn & bitmask, level);
  	}
  	if (rc)
  		return rc;
author maintainer
#10 lore raw

PATCH v2 5/5 KVM: s390: Properly reset zero bit in PGSTE

In reply to Claudio Imbrenda

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

---
 arch/s390/kvm/gmap.h | 1 +
 1 file changed, 1 insertion(+)
arch/s390/kvm/gmap.h +1 -0
index e490f2995a26..4de9ed8d58ba 100644
@@ -199,6 +199,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));
 }
 
Signature · 1 line
2.54.0
#12 lore raw

Re: [PATCH v2 5/5] KVM: s390: Properly reset zero bit in PGSTE

In reply to Claudio Imbrenda

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 3 lines

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

Ideally have some example in the patch description, that makes review easier.>

Quoted 1 line

Was this broken before the rework as well? Do we need a stable backport into 6.19 and older?

Quoted 16 lines
---
  arch/s390/kvm/gmap.h | 1 +
  1 file changed, 1 insertion(+)
arch/s390/kvm/gmap.h +1 -0
index e490f2995a26..4de9ed8d58ba 100644
@@ -199,6 +199,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));
  }
 
author maintainer
#13 lore raw

Re: [PATCH v2 5/5] KVM: s390: Properly reset zero bit in PGSTE

Quoted 6 lines · On Mon, 18 May 2026 13:44:45 +0200 Christian Borntraeger…

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 3 lines

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

Ideally have some example in the patch description, that makes review easier.>

will do

Quoted 4 lines
Quoted 1 line

Was this broken before the rework as well? Do we need a stable backport into 6.19 and older?

no, this breakage is a product of the gmap rewrite

Quoted 18 lines
Quoted 17 lines
---
  arch/s390/kvm/gmap.h | 1 +
  1 file changed, 1 insertion(+)
arch/s390/kvm/gmap.h +1 -0
index e490f2995a26..4de9ed8d58ba 100644
@@ -199,6 +199,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));
  }
 
#14 lore raw

Re: [PATCH v2 5/5] KVM: s390: Properly reset zero bit in PGSTE

Am 19.05.26 um 13:38 schrieb Claudio Imbrenda:

Quoted 10 lines
Quoted 6 lines · On Mon, 18 May 2026 13:44:45 +0200 Christian Borntraeger…

Am 12.05.26 um 19:52 schrieb Claudio Imbrenda:

Quoted 3 lines

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

Ideally have some example in the patch description, that makes review easier.>

Quoted 8 lines

will do

Quoted 4 lines
Quoted 1 line

Was this broken before the rework as well? Do we need a stable backport into 6.19 and older?

no, this breakage is a product of the gmap rewrite

Then please add a Fixes tag.