[PATCH v1 1/1] s390/pgtable: Unconditionally clear _PAGE_UNUSED
From: Claudio Imbrenda
Date: Fri Jun 12 2026 - 10:50:27 EST
When setting ptes with set_ptes(), unconditionally clear the
_PAGE_UNUSED flag.
The flag has only sense when the pte is being unmapped to be swapped,
it will be set by KVM when unmapping unused pages. Setting it in any
other way does not make sense and can lead to guest corruption.
Fixes: c98175b7917f ("KVM: s390: Add gmap_helper_set_unused()")
Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
---
arch/s390/include/asm/pgtable.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 2c6cee8241e0..9174aa02b699 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -1332,8 +1332,7 @@ pgprot_t pgprot_writecombine(pgprot_t prot);
static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
pte_t *ptep, pte_t entry, unsigned int nr)
{
- if (pte_present(entry))
- entry = clear_pte_bit(entry, __pgprot(_PAGE_UNUSED));
+ entry = clear_pte_bit(entry, __pgprot(_PAGE_UNUSED));
page_table_check_ptes_set(mm, addr, ptep, entry, nr);
for (;;) {
set_pte(ptep, entry);
--
2.54.0