* [PATCH 01/17] s390/boot: Initialize asce_limit for init_mm properly
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:01 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 02/17] s390/pageattr: Only account direct mapping in direct map page counters Heiko Carstens
` (16 subsequent siblings)
17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
asce_limit of init_mm is always zero instead of reflecting the
address space size.
The mm_pxd_folded() helpers used in pxd_free() require a proper
asce_limit to work correctly. With asce_limit of init_mm being
zero the pxd_free() functions never free page tables, since
mm_pxd_folded(&init_mm) evaluates to true.
As of now there are only a few corner cases where this matters,
e.g. during concurrent vmalloc allocation races or KASAN shadow
unmapping, leading to memory leaks.
Fix this and initialize asce_limit of init_mm.
Fixes: 2416cefc504b ("s390/mm: add mm_pxd_folded() checks to pxd_free()")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/boot/vmem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c
index ff6d58a476ba..3111a96e68e9 100644
--- a/arch/s390/boot/vmem.c
+++ b/arch/s390/boot/vmem.c
@@ -554,5 +554,6 @@ void setup_vmem(unsigned long kernel_start, unsigned long kernel_end, unsigned l
local_ctl_load(13, &get_lowcore()->kernel_asce);
init_mm.context.asce = get_lowcore()->kernel_asce.val;
+ init_mm.context.asce_limit = asce_limit;
init_mm.pgd = init_mm_pgd;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 01/17] s390/boot: Initialize asce_limit for init_mm properly
2026-12-03 10:33 ` [PATCH 01/17] s390/boot: Initialize asce_limit for init_mm properly Heiko Carstens
@ 2026-12-03 11:01 ` sashiko-bot
0 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:01 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] s390/mm: crst_table_free() fails to handle PageReserved boot
CRST tables
--
commit 5e9062421f6de1bcabdbba28757388ac9f8205cd
Author: Heiko Carstens <hca@linux.ibm.com>
s390/boot: Initialize asce_limit for init_mm properly
This commit initializes init_mm.context.asce_limit in setup_vmem() so that
mm_pxd_folded(&init_mm) reflects the kernel address space size and pxd_free()
can free init_mm page tables.
> diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c
> index ff6d58a476bae..3111a96e68e9e 100644
> --- a/arch/s390/boot/vmem.c
> +++ b/arch/s390/boot/vmem.c
> @@ -554,5 +554,6 @@ void setup_vmem(unsigned long kernel_start, unsigned long kernel_end, unsigned l
> local_ctl_load(13, &get_lowcore()->kernel_asce);
>
> init_mm.context.asce = get_lowcore()->kernel_asce.val;
> + init_mm.context.asce_limit = asce_limit;
> init_mm.pgd = init_mm_pgd;
> }
[Severity: Medium]
Can setting init_mm.context.asce_limit cause crst_table_free() to pass a
boot-allocated PageReserved CRST table to pagetable_free()?
Previously, mm_pmd_folded(&init_mm) and mm_pud_folded(&init_mm) always
returned true, so pmd_free(&init_mm, ...) and pud_free(&init_mm, ...) never
called crst_table_free(). Unlike page_table_free(), crst_table_free() does
not check pagetable_is_reserved(ptdesc) and calls pagetable_free() directly.
Under CONFIG_KASAN with standby memory making ident_map_size unaligned to
16GB above a 16GB-aligned online end, kasan_populate_shadow() allocates a
boot_crst_alloc() PMD table (non-compound, PG_reserved, order
CRST_ALLOC_ORDER) with only its upper zero-shadow entries populated.
When a ZONE_DEVICE or dcssblk mapping covering that upper range is removed
via kasan_remove_zero_shadow() -> kasan_free_pmd() -> pmd_free(&init_mm, ...),
all entries become pmd_none and crst_table_free() calls __free_pages(page, 0)
on that reserved page.
With page checks enabled, free_page_is_bad() reports a bad page state and
leaks all 4 pages; without them, page 0 is freed without updating
managed_pages while the other 3 pages leak.
Should crst_table_free() check pagetable_is_reserved(ptdesc) and free the
table with free_reserved_pages(ptdesc_page(ptdesc), CRST_ALLOC_ORDER)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 02/17] s390/pageattr: Only account direct mapping in direct map page counters
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
2026-12-03 10:33 ` [PATCH 01/17] s390/boot: Initialize asce_limit for init_mm properly Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 03/17] s390/mm: Serialize kernel page table changes with init_mm mmap lock Heiko Carstens
` (15 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
The kernel image is not part of the direct mapping, however applying
permission changes to the kernel mapping via set_memory() incorrectly
update the direct map page counters.
Fix this and update the counters only for addresses within the direct
mapping. That is the identity mapping and the range up to max_mappable,
which includes mappings added with vmem_add_mapping(), e.g. for DCSS.
Fixes: 693d41f7c938 ("s390/mm: Restore mapping of kernel image using large pages")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/mm/pageattr.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index e744a61651b9..d75817d80b78 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -120,6 +120,18 @@ static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,
return 0;
}
+static bool is_direct_map_addr(unsigned long addr)
+{
+ return addr >= __identity_base && addr - __identity_base < max_mappable;
+}
+
+/* Only the direct mapping is accounted in direct_pages_count[] */
+static void update_direct_map_count(unsigned long addr, int level, long count)
+{
+ if (is_direct_map_addr(addr))
+ update_page_count(level, count);
+}
+
static int split_pmd_page(pmd_t *pmdp, unsigned long addr)
{
unsigned long pte_addr, prot;
@@ -145,8 +157,8 @@ static int split_pmd_page(pmd_t *pmdp, unsigned long addr)
}
new = __pmd(__pa(pt_dir) | _SEGMENT_ENTRY);
pgt_set((unsigned long *)pmdp, pmd_val(new), addr, CRDTE_DTT_SEGMENT);
- update_page_count(PG_DIRECT_MAP_4K, PTRS_PER_PTE);
- update_page_count(PG_DIRECT_MAP_1M, -1);
+ update_direct_map_count(addr, PG_DIRECT_MAP_4K, PTRS_PER_PTE);
+ update_direct_map_count(addr, PG_DIRECT_MAP_1M, -1);
return 0;
}
@@ -237,8 +249,8 @@ int split_pud_page(pud_t *pudp, unsigned long addr)
}
new = __pud(__pa(pm_dir) | _REGION3_ENTRY);
pgt_set((unsigned long *)pudp, pud_val(new), addr, CRDTE_DTT_REGION3);
- update_page_count(PG_DIRECT_MAP_1M, PTRS_PER_PMD);
- update_page_count(PG_DIRECT_MAP_2G, -1);
+ update_direct_map_count(addr, PG_DIRECT_MAP_1M, PTRS_PER_PMD);
+ update_direct_map_count(addr, PG_DIRECT_MAP_2G, -1);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 03/17] s390/mm: Serialize kernel page table changes with init_mm mmap lock
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
2026-12-03 10:33 ` [PATCH 01/17] s390/boot: Initialize asce_limit for init_mm properly Heiko Carstens
2026-12-03 10:33 ` [PATCH 02/17] s390/pageattr: Only account direct mapping in direct map page counters Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables Heiko Carstens
` (14 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
s390 serializes kernel mapping changes with two unrelated mutexes:
cpa_mutex for pageattr and vmem_mutex for memory hotplug.
Both modify the kernel direct mapping, and can split e.g. the same
2GB region-third table concurrently, which can lead to an inconsistent
mapping.
Use mmap_write_lock(&init_mm) everywhere, and drop the old locks.
This also matches riscv, loongarch and what the generic page table
walkers and ptdump expect.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/set_memory.h | 4 ----
arch/s390/mm/dump_pagetables.c | 2 --
arch/s390/mm/pageattr.c | 6 ++----
arch/s390/mm/vmem.c | 26 ++++++++++++--------------
4 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/arch/s390/include/asm/set_memory.h b/arch/s390/include/asm/set_memory.h
index 036295215a1a..b453dd2d6a8e 100644
--- a/arch/s390/include/asm/set_memory.h
+++ b/arch/s390/include/asm/set_memory.h
@@ -2,10 +2,6 @@
#ifndef _ASMS390_SET_MEMORY_H
#define _ASMS390_SET_MEMORY_H
-#include <linux/mutex.h>
-
-extern struct mutex cpa_mutex;
-
enum {
_SET_MEMORY_RO_BIT,
_SET_MEMORY_RW_BIT,
diff --git a/arch/s390/mm/dump_pagetables.c b/arch/s390/mm/dump_pagetables.c
index a23a0bd4d8a8..7533dc22e0e9 100644
--- a/arch/s390/mm/dump_pagetables.c
+++ b/arch/s390/mm/dump_pagetables.c
@@ -247,9 +247,7 @@ static int ptdump_show(struct seq_file *m, void *v)
.marker = markers,
};
- mutex_lock(&cpa_mutex);
ptdump_walk_pgd(&st.ptdump, &init_mm, NULL);
- mutex_unlock(&cpa_mutex);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(ptdump);
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index d75817d80b78..9ca30ed46179 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -337,8 +337,6 @@ static int walk_p4d_level(pgd_t *pgd, unsigned long addr, unsigned long end,
return rc;
}
-DEFINE_MUTEX(cpa_mutex);
-
static int change_page_attr(unsigned long addr, unsigned long end,
unsigned long flags)
{
@@ -413,13 +411,13 @@ int __set_memory(unsigned long addr, unsigned long numpages, unsigned long flags
return 0;
addr &= PAGE_MASK;
end = addr + numpages * PAGE_SIZE;
- mutex_lock(&cpa_mutex);
+ mmap_write_lock(&init_mm);
rc = change_page_attr(addr, end, flags);
if (rc)
goto out;
rc = change_page_attr_alias(addr, end, flags);
out:
- mutex_unlock(&cpa_mutex);
+ mmap_write_unlock(&init_mm);
return rc;
}
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 317bd01dca86..66071085f5a3 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -26,8 +26,6 @@
#include <asm/set_memory.h>
#include <asm/physmem_info.h>
-static DEFINE_MUTEX(vmem_mutex);
-
static void __ref *vmem_alloc_pages(unsigned int order)
{
unsigned long size = PAGE_SIZE << order;
@@ -513,12 +511,12 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
{
int ret;
- mutex_lock(&vmem_mutex);
+ mmap_write_lock(&init_mm);
/* We don't care about the node, just use NUMA_NO_NODE on allocations */
ret = add_pagetable(start, end, false, altmap);
if (ret)
remove_pagetable(start, end, false, altmap);
- mutex_unlock(&vmem_mutex);
+ mmap_write_unlock(&init_mm);
return ret;
}
@@ -527,18 +525,18 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
void vmemmap_free(unsigned long start, unsigned long end,
struct vmem_altmap *altmap)
{
- mutex_lock(&vmem_mutex);
+ mmap_write_lock(&init_mm);
remove_pagetable(start, end, false, altmap);
- mutex_unlock(&vmem_mutex);
+ mmap_write_unlock(&init_mm);
}
#endif
void vmem_remove_mapping(unsigned long start, unsigned long size)
{
- mutex_lock(&vmem_mutex);
+ mmap_write_lock(&init_mm);
vmem_remove_range(start, size);
- mutex_unlock(&vmem_mutex);
+ mmap_write_unlock(&init_mm);
}
struct range arch_get_mappable_range(void)
@@ -560,11 +558,11 @@ int vmem_add_mapping(unsigned long start, unsigned long size)
start + size < start)
return -ERANGE;
- mutex_lock(&vmem_mutex);
+ mmap_write_lock(&init_mm);
ret = vmem_add_range(start, size);
if (ret)
vmem_remove_range(start, size);
- mutex_unlock(&vmem_mutex);
+ mmap_write_unlock(&init_mm);
return ret;
}
@@ -652,9 +650,9 @@ int vmem_map_4k_page(unsigned long addr, unsigned long phys, pgprot_t prot)
{
int rc;
- mutex_lock(&vmem_mutex);
+ mmap_write_lock(&init_mm);
rc = __vmem_map_4k_page(addr, phys, prot, true);
- mutex_unlock(&vmem_mutex);
+ mmap_write_unlock(&init_mm);
return rc;
}
@@ -662,11 +660,11 @@ void vmem_unmap_4k_page(unsigned long addr)
{
pte_t *ptep;
- mutex_lock(&vmem_mutex);
+ mmap_write_lock(&init_mm);
ptep = virt_to_kpte(addr);
__ptep_ipte(addr, ptep, 0, 0, IPTE_GLOBAL);
pte_clear(&init_mm, addr, ptep);
- mutex_unlock(&vmem_mutex);
+ mmap_write_unlock(&init_mm);
}
void __init vmem_map_init(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (2 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 03/17] s390/mm: Serialize kernel page table changes with init_mm mmap lock Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:02 ` sashiko-bot
2026-12-03 18:36 ` kernel test robot
2026-12-03 10:33 ` [PATCH 05/17] s390/mm: Show write-combining attribute in page table dump Heiko Carstens
` (13 subsequent siblings)
17 siblings, 2 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
CRST and page tables allocated with __get_free_pages() or memblock in
vmem_crst_alloc() and vmem_pte_alloc() are not accounted as page tables,
and cannot be freed by generic code.
Use generic page table allocators (pXd_alloc_one() and page_table_alloc())
as soon as slab is available. Also update vmem_crst_free() and
vmem_pte_free() to handle both early memblock and generic page table
allocations.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/pgalloc.h | 1 +
arch/s390/mm/vmem.c | 52 +++++++++++++++++++++++----------
2 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h
index d554c475c61f..f5adddc10946 100644
--- a/arch/s390/include/asm/pgalloc.h
+++ b/arch/s390/include/asm/pgalloc.h
@@ -168,6 +168,7 @@ void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable);
void vmem_map_init(void);
void *vmem_crst_alloc(unsigned long val);
pte_t *vmem_pte_alloc(void);
+void vmem_pte_free(unsigned long *table);
unsigned long base_asce_alloc(unsigned long addr, unsigned long num_pages);
void base_asce_free(unsigned long asce);
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 66071085f5a3..0436b81d9bc5 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -26,15 +26,6 @@
#include <asm/set_memory.h>
#include <asm/physmem_info.h>
-static void __ref *vmem_alloc_pages(unsigned int order)
-{
- unsigned long size = PAGE_SIZE << order;
-
- if (slab_is_available())
- return (void *)__get_free_pages(GFP_KERNEL, order);
- return memblock_alloc(size, size);
-}
-
static void vmem_free_pages(unsigned long addr, int order, struct vmem_altmap *altmap)
{
struct page *page;
@@ -52,11 +43,29 @@ static void vmem_free_pages(unsigned long addr, int order, struct vmem_altmap *a
}
}
-void *vmem_crst_alloc(unsigned long val)
+/*
+ * Allocate a crst table. Use generic page table allocators as soon
+ * as slab is available, so that the tables can be freed by generic
+ * code as well.
+ */
+void __ref *vmem_crst_alloc(unsigned long val)
{
+ unsigned long size = PAGE_SIZE << CRST_ALLOC_ORDER;
unsigned long *table;
- table = vmem_alloc_pages(CRST_ALLOC_ORDER);
+ if (slab_is_available()) {
+ switch (val) {
+ case _REGION2_ENTRY_EMPTY:
+ return p4d_alloc_one(&init_mm, 0);
+ case _REGION3_ENTRY_EMPTY:
+ return pud_alloc_one(&init_mm, 0);
+ case _SEGMENT_ENTRY_EMPTY:
+ return pmd_alloc_one(&init_mm, 0);
+ default:
+ return NULL;
+ }
+ }
+ table = memblock_alloc(size, size);
if (!table)
return NULL;
crst_table_init(table, val);
@@ -64,6 +73,14 @@ void *vmem_crst_alloc(unsigned long val)
return table;
}
+static void vmem_crst_free(unsigned long *table)
+{
+ if (PageTable(virt_to_page(table)))
+ crst_table_free(&init_mm, table);
+ else
+ vmem_free_pages((unsigned long)table, CRST_ALLOC_ORDER, NULL);
+}
+
pte_t __ref *vmem_pte_alloc(void)
{
pte_t *pte;
@@ -79,9 +96,12 @@ pte_t __ref *vmem_pte_alloc(void)
return pte;
}
-static void vmem_pte_free(unsigned long *table)
+void vmem_pte_free(unsigned long *table)
{
- page_table_free(&init_mm, table);
+ if (slab_is_available())
+ page_table_free(&init_mm, table);
+ else
+ memblock_free(table, PAGE_SIZE);
}
#define PAGE_UNUSED 0xFD
@@ -306,7 +326,7 @@ static void try_free_pmd_table(pud_t *pud, unsigned long start)
for (i = 0; i < PTRS_PER_PMD; i++, pmd++)
if (!pmd_none(pmdp_get(pmd)))
return;
- vmem_free_pages(pud_deref(pudp_get(pud)), CRST_ALLOC_ORDER, NULL);
+ vmem_crst_free((unsigned long *)pud_deref(pudp_get(pud)));
pud_clear(pud);
}
@@ -377,7 +397,7 @@ static void try_free_pud_table(p4d_t *p4d, unsigned long start)
if (!pud_none(pudp_get(pud)))
return;
}
- vmem_free_pages(p4d_deref(p4dp_get(p4d)), CRST_ALLOC_ORDER, NULL);
+ vmem_crst_free((unsigned long *)p4d_deref(p4dp_get(p4d)));
p4d_clear(p4d);
}
@@ -423,7 +443,7 @@ static void try_free_p4d_table(pgd_t *pgd, unsigned long start)
if (!p4d_none(p4dp_get(p4d)))
return;
}
- vmem_free_pages(pgd_deref(pgdp_get(pgd)), CRST_ALLOC_ORDER, NULL);
+ vmem_crst_free((unsigned long *)pgd_deref(pgdp_get(pgd)));
pgd_clear(pgd);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables
2026-12-03 10:33 ` [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables Heiko Carstens
@ 2026-12-03 11:02 ` sashiko-bot
2026-12-03 18:36 ` kernel test robot
1 sibling, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:02 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] s390/vmem: missing __ref on vmem_pte_free() calling
memblock_free()
--
commit eb7d1e0bc98d30f332834afa2eecf8dd1866e8b9
Author: Heiko Carstens <hca@linux.ibm.com>
s390/vmem: Use generic page table allocators for vmem page tables
This commit switches vmem CRST and PTE allocations to the generic page
table allocators once slab is available, and updates vmem_crst_free() and
vmem_pte_free() to handle both early memblock and generic page table
allocations.
> diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
> index 66071085f5a30..0436b81d9bc5a 100644
> --- a/arch/s390/mm/vmem.c
> +++ b/arch/s390/mm/vmem.c
[ ... ]
> @@ -79,9 +96,12 @@ pte_t __ref *vmem_pte_alloc(void)
> return pte;
> }
>
> -static void vmem_pte_free(unsigned long *table)
> +void vmem_pte_free(unsigned long *table)
> {
> - page_table_free(&init_mm, table);
> + if (slab_is_available())
> + page_table_free(&init_mm, table);
> + else
> + memblock_free(table, PAGE_SIZE);
> }
[Severity: Medium]
Does vmem_pte_free() need a __ref annotation like vmem_crst_alloc() and
vmem_pte_alloc()?
memblock_free() is marked __init_memblock, which expands to __init when
CONFIG_MEMORY_HOTPLUG is disabled (s390 does not select
CONFIG_ARCH_KEEP_MEMBLOCK). Without __ref, modpost reports a .text to
.init.text section mismatch, breaking builds with CONFIG_WERROR=y.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=4
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables
2026-12-03 10:33 ` [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables Heiko Carstens
2026-12-03 11:02 ` sashiko-bot
@ 2026-12-03 18:36 ` kernel test robot
1 sibling, 0 replies; 28+ messages in thread
From: kernel test robot @ 2026-12-03 18:36 UTC (permalink / raw)
To: Heiko Carstens, Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: llvm, oe-kbuild-all, linux-kernel, linux-s390
Hi Heiko,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 799dd936553182df5770dde7f38d94c8337df75a]
url: https://github.com/intel-lab-lkp/linux/commits/Heiko-Carstens/s390-boot-Initialize-asce_limit-for-init_mm-properly/20261203-113329
base: 799dd936553182df5770dde7f38d94c8337df75a
patch link: https://lore.kernel.org/r/20261203103345.1206548-5-hca%40linux.ibm.com
patch subject: [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables
config: s390-allnoconfig (https://download.01.org/0day-ci/archive/20261204/20261204022410.JRnLDpP1-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 63b30c97f6082ebf34b31bdd81bb50df7672b67b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261204/20261204022410.JRnLDpP1-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261204022410.JRnLDpP1-lkp@intel.com/
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> WARNING: modpost: vmlinux: section mismatch in reference: vmem_pte_free+0x4a (section: .text) -> memblock_free (section: .init.text)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 05/17] s390/mm: Show write-combining attribute in page table dump
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (3 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP Heiko Carstens
` (12 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Print "WC" for mappings with the MIO write-back bit set, so they are no
longer merged with otherwise identical non-WC mappings.
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/mm/dump_pagetables.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/s390/mm/dump_pagetables.c b/arch/s390/mm/dump_pagetables.c
index 7533dc22e0e9..21eb1243c9d2 100644
--- a/arch/s390/mm/dump_pagetables.c
+++ b/arch/s390/mm/dump_pagetables.c
@@ -31,7 +31,7 @@ struct pg_state {
struct ptdump_state ptdump;
struct seq_file *seq;
int level;
- unsigned int current_prot;
+ unsigned long current_prot;
bool check_wx;
unsigned long wx_pages;
unsigned long start_address;
@@ -54,7 +54,7 @@ struct pg_state {
seq_puts(__m, fmt); \
})
-static void print_prot(struct seq_file *m, unsigned int pr, int level)
+static void print_prot(struct seq_file *m, unsigned long pr, int level)
{
static const char * const level_name[] =
{ "ASCE", "PGD", "PUD", "PMD", "PTE" };
@@ -65,7 +65,10 @@ static void print_prot(struct seq_file *m, unsigned int pr, int level)
return;
}
pt_dump_seq_puts(m, (pr & _PAGE_PROTECT) ? "RO " : "RW ");
- pt_dump_seq_puts(m, (pr & _PAGE_NOEXEC) ? "NX\n" : "X\n");
+ pt_dump_seq_puts(m, (pr & _PAGE_NOEXEC) ? "NX" : "X");
+ if (pr & mio_wb_bit_mask)
+ pt_dump_seq_puts(m, " WC");
+ pt_dump_seq_puts(m, "\n");
}
static void note_prot_wx(struct pg_state *st, unsigned long addr)
@@ -92,7 +95,7 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr)
st->wx_pages += (addr - st->start_address) / PAGE_SIZE;
}
-static void note_page_update_state(struct pg_state *st, unsigned long addr, unsigned int prot, int level)
+static void note_page_update_state(struct pg_state *st, unsigned long addr, unsigned long prot, int level)
{
struct seq_file *m = st->seq;
@@ -114,11 +117,11 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
unsigned long delta;
struct pg_state *st;
struct seq_file *m;
- unsigned int prot;
+ unsigned long prot;
st = container_of(pt_st, struct pg_state, ptdump);
m = st->seq;
- prot = val & (_PAGE_PROTECT | _PAGE_NOEXEC);
+ prot = val & (_PAGE_PROTECT | _PAGE_NOEXEC | mio_wb_bit_mask);
if (level == 4 && (val & _PAGE_INVALID))
prot = _PAGE_INVALID;
/* For pmd_none() & friends val gets passed as zero. */
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (4 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 05/17] s390/mm: Show write-combining attribute in page table dump Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:03 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 07/17] s390/mm: Implement HAVE_ARCH_HUGE_VMALLOC Heiko Carstens
` (11 subsequent siblings)
17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Add the required plumbing to enable huge mappings for vmap() and
ioremap() on s390.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
.../features/vm/huge-vmap/arch-support.txt | 2 +-
arch/s390/Kconfig | 1 +
arch/s390/include/asm/vmalloc.h | 16 ++++
arch/s390/mm/pgtable.c | 81 +++++++++++++++++++
4 files changed, 99 insertions(+), 1 deletion(-)
diff --git a/Documentation/features/vm/huge-vmap/arch-support.txt b/Documentation/features/vm/huge-vmap/arch-support.txt
index 2d6de7b04538..10dc2d215c27 100644
--- a/Documentation/features/vm/huge-vmap/arch-support.txt
+++ b/Documentation/features/vm/huge-vmap/arch-support.txt
@@ -21,7 +21,7 @@
| parisc: | TODO |
| powerpc: | ok |
| riscv: | ok |
- | s390: | TODO |
+ | s390: | ok |
| sh: | TODO |
| sparc: | TODO |
| um: | TODO |
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 2cfd7e60e200..7f51a95e4d71 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -192,6 +192,7 @@ config S390
select HAVE_ALIGNED_STRUCT_PAGE
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_GET_SECUREBOOT
+ select HAVE_ARCH_HUGE_VMAP
select HAVE_ARCH_JUMP_LABEL
select HAVE_ARCH_JUMP_LABEL_RELATIVE
select HAVE_ARCH_KASAN
diff --git a/arch/s390/include/asm/vmalloc.h b/arch/s390/include/asm/vmalloc.h
index 3ba3a6bdca25..444422590d0b 100644
--- a/arch/s390/include/asm/vmalloc.h
+++ b/arch/s390/include/asm/vmalloc.h
@@ -1,4 +1,20 @@
#ifndef _ASM_S390_VMALLOC_H
#define _ASM_S390_VMALLOC_H
+#include <linux/cpufeature.h>
+
+#define IOREMAP_MAX_ORDER PUD_SHIFT
+
+#define arch_vmap_pud_supported arch_vmap_pud_supported
+static inline bool arch_vmap_pud_supported(pgprot_t prot)
+{
+ return cpu_has_edat2();
+}
+
+#define arch_vmap_pmd_supported arch_vmap_pmd_supported
+static inline bool arch_vmap_pmd_supported(pgprot_t prot)
+{
+ return cpu_has_edat1();
+}
+
#endif /* _ASM_S390_VMALLOC_H */
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index da076928b63b..0cb65f1475ce 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -353,3 +353,84 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp)
return pgtable;
}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+
+int p4d_set_huge(p4d_t *p4dp, phys_addr_t addr, pgprot_t prot)
+{
+ return 0;
+}
+
+void p4d_clear_huge(p4d_t *p4dp)
+{
+}
+
+int p4d_free_pud_page(p4d_t *p4dp, unsigned long addr)
+{
+ return 0;
+}
+
+int pud_set_huge(pud_t *pudp, phys_addr_t addr, pgprot_t prot)
+{
+ unsigned long val, pte_prot;
+
+ pte_prot = pgprot_val(prot);
+ val = pgprot_val((pte_prot & _PAGE_PROTECT) ? REGION3_KERNEL_RO : REGION3_KERNEL);
+ if (!(pte_prot & _PAGE_NOEXEC))
+ val &= ~_REGION_ENTRY_NOEXEC;
+ val |= pte_prot & mio_wb_bit_mask;
+ set_pud(pudp, __pud(addr | val));
+ return 1;
+}
+
+int pud_clear_huge(pud_t *pudp)
+{
+ if (!pud_leaf(pudp_get(pudp)))
+ return 0;
+ pud_clear(pudp);
+ return 1;
+}
+
+int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
+{
+ pmd_t *pmdp;
+ pud_t old;
+ int i;
+
+ old = pudp_xchg_direct(&init_mm, addr, pudp, __pud(_REGION3_ENTRY_EMPTY));
+ pmdp = (pmd_t *)pud_deref(old);
+ for (i = 0; i < PTRS_PER_PMD; i++) {
+ if (!pmd_none(pmdp_get(&pmdp[i])))
+ pte_free_kernel(&init_mm, (pte_t *)pmd_deref(pmdp_get(&pmdp[i])));
+ }
+ pmd_free(&init_mm, pmdp);
+ return 1;
+}
+
+int pmd_set_huge(pmd_t *pmdp, phys_addr_t addr, pgprot_t prot)
+{
+ unsigned long val, pte_prot;
+
+ pte_prot = pgprot_val(prot);
+ val = pgprot_val((pte_prot & _PAGE_PROTECT) ? SEGMENT_KERNEL_RO : SEGMENT_KERNEL);
+ if (!(pte_prot & _PAGE_NOEXEC))
+ val &= ~_SEGMENT_ENTRY_NOEXEC;
+ val |= pte_prot & mio_wb_bit_mask;
+ set_pmd(pmdp, __pmd(addr | val));
+ return 1;
+}
+
+int pmd_clear_huge(pmd_t *pmdp)
+{
+ if (!pmd_leaf(pmdp_get(pmdp)))
+ return 0;
+ pmd_clear(pmdp);
+ return 1;
+}
+
+int pmd_free_pte_page(pmd_t *pmdp, unsigned long addr)
+{
+ pmd_t old;
+
+ old = pmdp_xchg_direct(&init_mm, addr, pmdp, __pmd(_SEGMENT_ENTRY_EMPTY));
+ pte_free_kernel(&init_mm, (pte_t *)pmd_deref(old));
+ return 1;
+}
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP
2026-12-03 10:33 ` [PATCH 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP Heiko Carstens
@ 2026-12-03 11:03 ` sashiko-bot
0 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:03 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] s390/mm: pmd_pfn() and pud_pfn() corrupt huge PCI MIO
physical addresses
--
commit b614d2b3a4e7719aa09a492c3e0cd3673b3dea6f
Author: Heiko Carstens <hca@linux.ibm.com>
s390/mm: Implement HAVE_ARCH_HUGE_VMAP
This commit selects HAVE_ARCH_HUGE_VMAP on s390 and implements the huge
P4D, PUD, and PMD set, clear, and page-table-free helpers for vmap() and
ioremap().
> diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
> index da076928b63ba..0cb65f1475ce6 100644
> --- a/arch/s390/mm/pgtable.c
> +++ b/arch/s390/mm/pgtable.c
> @@ -353,3 +353,84 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp)
[ ... ]
> +int pud_set_huge(pud_t *pudp, phys_addr_t addr, pgprot_t prot)
> +{
> + unsigned long val, pte_prot;
> +
> + pte_prot = pgprot_val(prot);
> + val = pgprot_val((pte_prot & _PAGE_PROTECT) ? REGION3_KERNEL_RO : REGION3_KERNEL);
> + if (!(pte_prot & _PAGE_NOEXEC))
> + val &= ~_REGION_ENTRY_NOEXEC;
> + val |= pte_prot & mio_wb_bit_mask;
> + set_pud(pudp, __pud(addr | val));
> + return 1;
> +}
[ ... ]
> +int pmd_set_huge(pmd_t *pmdp, phys_addr_t addr, pgprot_t prot)
> +{
> + unsigned long val, pte_prot;
> +
> + pte_prot = pgprot_val(prot);
> + val = pgprot_val((pte_prot & _PAGE_PROTECT) ? SEGMENT_KERNEL_RO : SEGMENT_KERNEL);
> + if (!(pte_prot & _PAGE_NOEXEC))
> + val &= ~_SEGMENT_ENTRY_NOEXEC;
> + val |= pte_prot & mio_wb_bit_mask;
> + set_pmd(pmdp, __pmd(addr | val));
> + return 1;
> +}
[Severity: Medium]
Can installing PCI MIO addresses here cause pmd_pfn() and pud_pfn() to
return corrupted PFNs?
pud_set_huge() and pmd_set_huge() let ioremap_wc() and pci_iomap_wc() map
huge leaf entries with PCI MIO addresses and mio_wb_bit_mask, which can
reach or exceed __kaslr_offset. In arch/s390/include/asm/pgtable.h,
pmd_pfn() and pud_pfn() round-trip the address through __va() and __pa().
For any x >= __kaslr_offset, __pa_nodebug() takes the kernel-image branch
(x - __kaslr_offset + __kaslr_offset_phys) instead of subtracting
__identity_base. When set_memory_*() splits a huge MIO mapping,
split_pmd_page() and split_pud_page() then install wrong physical addresses.
Under CONFIG_KASAN and CONFIG_DEBUG_VIRTUAL, ptdump_pud_entry() and
ptdump_pmd_entry() also call pud_page()/pmd_page() before pud_leaf()/
pmd_leaf(), risking a VIRTUAL_BUG_ON() panic in __phys_addr() if __va(phys)
falls in [VMALLOC_START, MODULES_END).
Masking and shifting the entry value directly in pmd_pfn() and pud_pfn(),
matching pgd_pfn(), p4d_pfn(), and pte_pfn(), avoids the round-trip.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=6
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 07/17] s390/mm: Implement HAVE_ARCH_HUGE_VMALLOC
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (5 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 08/17] s390/pageattr: Add helpers to replace kernel page table entries Heiko Carstens
` (10 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Select HAVE_ARCH_HUGE_VMALLOC, so that vmalloc users which pass
VM_ALLOW_HUGE_VMAP (vmalloc_huge(), kvmalloc()) can be backed by 1MB
mappings if EDAT1 is available.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 7f51a95e4d71..04b401e9b680 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -192,6 +192,7 @@ config S390
select HAVE_ALIGNED_STRUCT_PAGE
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_GET_SECUREBOOT
+ select HAVE_ARCH_HUGE_VMALLOC
select HAVE_ARCH_HUGE_VMAP
select HAVE_ARCH_JUMP_LABEL
select HAVE_ARCH_JUMP_LABEL_RELATIVE
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 08/17] s390/pageattr: Add helpers to replace kernel page table entries
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (6 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 07/17] s390/mm: Implement HAVE_ARCH_HUGE_VMALLOC Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 09/17] s390/mm: Add _SEGMENT_ENTRY_TYPE Heiko Carstens
` (9 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Add pXdp_replace_kernel() helpers which can be used to replace live
kernel page table entries. The new helpers avoid having to use casts,
and passing non-obvious CRDTE_DTT_* constants, when calling pgt_set()
or pgt_replace().
Replace all existing pgt_set() callers with them.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/pgtable.h | 24 +++++++++++++++++++++++
arch/s390/mm/pageattr.c | 34 +++++++++++++++++++++------------
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 2d5c2ab06de9..a4ad6eb361d3 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -1681,6 +1681,30 @@ pmd_t pmdp_xchg_direct(struct mm_struct *, unsigned long, pmd_t *, pmd_t);
pmd_t pmdp_xchg_lazy(struct mm_struct *, unsigned long, pmd_t *, pmd_t);
pud_t pudp_xchg_direct(struct mm_struct *, unsigned long, pud_t *, pud_t);
+unsigned long pgt_replace(unsigned long *entry, unsigned long new,
+ unsigned long addr, unsigned long dtt);
+
+/*
+ * pXdp_replace_kernel() - replace a valid kernel page table entry without an
+ * intermediate invalid entry and without stale TLB entries.
+ * Return the old entry.
+ */
+#define DEFINE_PXD_REPLACE_KERNEL(type, dtt) \
+static inline type##_t type##p_replace_kernel(type##_t *type##p, type##_t new, \
+ unsigned long addr) \
+{ \
+ unsigned long old; \
+ \
+ old = pgt_replace((unsigned long *)type##p, type##_val(new), addr, dtt); \
+ return __##type(old); \
+}
+
+DEFINE_PXD_REPLACE_KERNEL(pte, CRDTE_DTT_PAGE)
+DEFINE_PXD_REPLACE_KERNEL(pmd, CRDTE_DTT_SEGMENT)
+DEFINE_PXD_REPLACE_KERNEL(pud, CRDTE_DTT_REGION3)
+DEFINE_PXD_REPLACE_KERNEL(p4d, CRDTE_DTT_REGION2)
+DEFINE_PXD_REPLACE_KERNEL(pgd, CRDTE_DTT_REGION1)
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define __HAVE_ARCH_PGTABLE_DEPOSIT
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index 9ca30ed46179..ae9171d9259a 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -51,14 +51,23 @@ void arch_report_meminfo(struct seq_file *m)
}
#endif /* CONFIG_PROC_FS */
-static void pgt_set(unsigned long *old, unsigned long new, unsigned long addr,
- unsigned long dtt)
+unsigned long pgt_replace(unsigned long *entry, unsigned long new,
+ unsigned long addr, unsigned long dtt)
{
- unsigned long *table, mask;
+ unsigned long *table, mask, old;
- mask = 0;
+ old = *entry;
+ if (old == new)
+ return old;
if (cpu_has_edat2()) {
+ mask = 0;
switch (dtt) {
+ case CRDTE_DTT_REGION1:
+ mask = ~(PTRS_PER_PGD * sizeof(pgd_t) - 1);
+ break;
+ case CRDTE_DTT_REGION2:
+ mask = ~(PTRS_PER_P4D * sizeof(p4d_t) - 1);
+ break;
case CRDTE_DTT_REGION3:
mask = ~(PTRS_PER_PUD * sizeof(pud_t) - 1);
break;
@@ -69,11 +78,12 @@ static void pgt_set(unsigned long *old, unsigned long new, unsigned long addr,
mask = ~(PTRS_PER_PTE * sizeof(pte_t) - 1);
break;
}
- table = (unsigned long *)((unsigned long)old & mask);
- crdte(*old, new, table, dtt, addr, get_lowcore()->kernel_asce.val);
+ table = (unsigned long *)((unsigned long)entry & mask);
+ crdte(old, new, table, dtt, addr, get_lowcore()->kernel_asce.val);
} else {
- cspg(old, *old, new);
+ cspg(entry, old, new);
}
+ return old;
}
static bool is_identity_range(unsigned long addr, unsigned long end)
@@ -112,7 +122,7 @@ static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,
new = __pte(pte_val(new) & PAGE_MASK);
new = set_pte_bit(new, PAGE_KERNEL);
}
- pgt_set((unsigned long *)ptep, pte_val(new), addr, CRDTE_DTT_PAGE);
+ ptep_replace_kernel(ptep, new, addr);
skip:
ptep++;
addr += PAGE_SIZE;
@@ -156,7 +166,7 @@ static int split_pmd_page(pmd_t *pmdp, unsigned long addr)
ptep++;
}
new = __pmd(__pa(pt_dir) | _SEGMENT_ENTRY);
- pgt_set((unsigned long *)pmdp, pmd_val(new), addr, CRDTE_DTT_SEGMENT);
+ pmdp_replace_kernel(pmdp, new, addr);
update_direct_map_count(addr, PG_DIRECT_MAP_4K, PTRS_PER_PTE);
update_direct_map_count(addr, PG_DIRECT_MAP_1M, -1);
return 0;
@@ -181,7 +191,7 @@ static void modify_pmd_page(pmd_t *pmdp, unsigned long addr,
new = __pmd(pmd_val(new) & PMD_MASK);
new = set_pmd_bit(new, SEGMENT_KERNEL);
}
- pgt_set((unsigned long *)pmdp, pmd_val(new), addr, CRDTE_DTT_SEGMENT);
+ pmdp_replace_kernel(pmdp, new, addr);
}
static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end,
@@ -248,7 +258,7 @@ int split_pud_page(pud_t *pudp, unsigned long addr)
pmdp++;
}
new = __pud(__pa(pm_dir) | _REGION3_ENTRY);
- pgt_set((unsigned long *)pudp, pud_val(new), addr, CRDTE_DTT_REGION3);
+ pudp_replace_kernel(pudp, new, addr);
update_direct_map_count(addr, PG_DIRECT_MAP_1M, PTRS_PER_PMD);
update_direct_map_count(addr, PG_DIRECT_MAP_2G, -1);
return 0;
@@ -273,7 +283,7 @@ static void modify_pud_page(pud_t *pudp, unsigned long addr,
new = __pud(pud_val(new) & PUD_MASK);
new = set_pud_bit(new, REGION3_KERNEL);
}
- pgt_set((unsigned long *)pudp, pud_val(new), addr, CRDTE_DTT_REGION3);
+ pudp_replace_kernel(pudp, new, addr);
}
static int walk_pud_level(p4d_t *p4d, unsigned long addr, unsigned long end,
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 09/17] s390/mm: Add _SEGMENT_ENTRY_TYPE
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (7 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 08/17] s390/pageattr: Add helpers to replace kernel page table entries Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 10/17] s390/pageattr: Use common helper to change kernel page table permissions Heiko Carstens
` (8 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Add missing _SEGMENT_ENTRY_TYPE to page table definitions.
Required by subsequent code changes, but completes the existing
definitions in any case.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/pgtable.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index a4ad6eb361d3..a09055f3eb58 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -310,6 +310,7 @@ void setup_protection_map(void);
#define _SEGMENT_ENTRY_NOEXEC 0x100 /* segment no-execute bit */
#define _SEGMENT_ENTRY_INVALID 0x20 /* invalid segment table entry */
#define _SEGMENT_ENTRY_TYPE_MASK 0x0c /* segment table type mask */
+#define _SEGMENT_ENTRY_TYPE 0x00 /* segment table type */
#define _SEGMENT_ENTRY (_SEGMENT_ENTRY_PRESENT)
#define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INVALID)
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 10/17] s390/pageattr: Use common helper to change kernel page table permissions
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (8 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 09/17] s390/mm: Add _SEGMENT_ENTRY_TYPE Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 11/17] s390/pageattr: Avoid splitting mappings if permissions do not change Heiko Carstens
` (7 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Introduce a common pgt_apply_perm() helper across all page table levels
to modify hardware bits directly, instead of using user space helpers
like pte_wrprotect(). Make sure software bits match PAGE_KERNEL and
PAGE_KERNEL_RO.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/mm/pageattr.c | 126 +++++++++++++++++++++-------------------
1 file changed, 66 insertions(+), 60 deletions(-)
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index ae9171d9259a..980f32bea83a 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -93,6 +93,69 @@ static bool is_identity_range(unsigned long addr, unsigned long end)
return addr >= __identity_base && end <= identity_end;
}
+/* Page tables have no table type bits, use a fake type */
+#define _PAGE_ENTRY_TYPE -1
+
+static unsigned long pgt_apply_perm(unsigned long val, unsigned long flags, int type)
+{
+ unsigned long protect, write, noexec, invalid, mask, def;
+
+ switch (type) {
+ case _PAGE_ENTRY_TYPE:
+ protect = _PAGE_PROTECT;
+ write = _PAGE_WRITE | _PAGE_DIRTY;
+ noexec = _PAGE_NOEXEC;
+ invalid = _PAGE_INVALID;
+ mask = PAGE_MASK;
+ def = pgprot_val(PAGE_KERNEL);
+ break;
+ case _SEGMENT_ENTRY_TYPE:
+ protect = _SEGMENT_ENTRY_PROTECT;
+ write = _SEGMENT_ENTRY_WRITE | _SEGMENT_ENTRY_DIRTY;
+ noexec = _SEGMENT_ENTRY_NOEXEC;
+ invalid = _SEGMENT_ENTRY_INVALID;
+ mask = PMD_MASK;
+ def = pgprot_val(SEGMENT_KERNEL);
+ break;
+ case _REGION_ENTRY_TYPE_R3:
+ protect = _REGION_ENTRY_PROTECT;
+ write = _REGION3_ENTRY_WRITE | _REGION3_ENTRY_DIRTY;
+ noexec = _REGION_ENTRY_NOEXEC;
+ invalid = _REGION_ENTRY_INVALID;
+ mask = PUD_MASK;
+ def = pgprot_val(REGION3_KERNEL);
+ break;
+ }
+ if (flags & SET_MEMORY_RO)
+ val = (val & ~write) | protect;
+ else if (flags & SET_MEMORY_RW)
+ val = (val | write) & ~protect;
+ if (flags & SET_MEMORY_NX)
+ val |= noexec;
+ else if (flags & SET_MEMORY_X)
+ val &= ~noexec;
+ if (flags & SET_MEMORY_INV)
+ val |= invalid;
+ else if (flags & SET_MEMORY_DEF)
+ val = (val & mask) | def;
+ return val;
+}
+
+static pte_t pte_apply_flags(pte_t pte, unsigned long flags)
+{
+ return __pte(pgt_apply_perm(pte_val(pte), flags, _PAGE_ENTRY_TYPE));
+}
+
+static pmd_t pmd_apply_flags(pmd_t pmd, unsigned long flags)
+{
+ return __pmd(pgt_apply_perm(pmd_val(pmd), flags, _SEGMENT_ENTRY_TYPE));
+}
+
+static pud_t pud_apply_flags(pud_t pud, unsigned long flags)
+{
+ return __pud(pgt_apply_perm(pud_val(pud), flags, _REGION_ENTRY_TYPE_R3));
+}
+
static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,
unsigned long flags)
{
@@ -108,20 +171,7 @@ static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,
return -EINVAL;
goto skip;
}
- if (flags & SET_MEMORY_RO)
- new = pte_wrprotect(new);
- else if (flags & SET_MEMORY_RW)
- new = pte_mkwrite_novma(pte_mkdirty(new));
- if (flags & SET_MEMORY_NX)
- new = set_pte_bit(new, __pgprot(_PAGE_NOEXEC));
- else if (flags & SET_MEMORY_X)
- new = clear_pte_bit(new, __pgprot(_PAGE_NOEXEC));
- if (flags & SET_MEMORY_INV) {
- new = set_pte_bit(new, __pgprot(_PAGE_INVALID));
- } else if (flags & SET_MEMORY_DEF) {
- new = __pte(pte_val(new) & PAGE_MASK);
- new = set_pte_bit(new, PAGE_KERNEL);
- }
+ new = pte_apply_flags(new, flags);
ptep_replace_kernel(ptep, new, addr);
skip:
ptep++;
@@ -172,28 +222,6 @@ static int split_pmd_page(pmd_t *pmdp, unsigned long addr)
return 0;
}
-static void modify_pmd_page(pmd_t *pmdp, unsigned long addr,
- unsigned long flags)
-{
- pmd_t new = pmdp_get(pmdp);
-
- if (flags & SET_MEMORY_RO)
- new = pmd_wrprotect(new);
- else if (flags & SET_MEMORY_RW)
- new = pmd_mkwrite_novma(pmd_mkdirty(new));
- if (flags & SET_MEMORY_NX)
- new = set_pmd_bit(new, __pgprot(_SEGMENT_ENTRY_NOEXEC));
- else if (flags & SET_MEMORY_X)
- new = clear_pmd_bit(new, __pgprot(_SEGMENT_ENTRY_NOEXEC));
- if (flags & SET_MEMORY_INV) {
- new = set_pmd_bit(new, __pgprot(_SEGMENT_ENTRY_INVALID));
- } else if (flags & SET_MEMORY_DEF) {
- new = __pmd(pmd_val(new) & PMD_MASK);
- new = set_pmd_bit(new, SEGMENT_KERNEL);
- }
- pmdp_replace_kernel(pmdp, new, addr);
-}
-
static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end,
unsigned long flags)
{
@@ -221,7 +249,7 @@ static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end,
return rc;
continue;
}
- modify_pmd_page(pmdp, addr, flags);
+ pmdp_replace_kernel(pmdp, pmd_apply_flags(pmd, flags), addr);
} else {
rc = walk_pte_level(pmdp, addr, next, flags);
if (rc)
@@ -264,28 +292,6 @@ int split_pud_page(pud_t *pudp, unsigned long addr)
return 0;
}
-static void modify_pud_page(pud_t *pudp, unsigned long addr,
- unsigned long flags)
-{
- pud_t new = pudp_get(pudp);
-
- if (flags & SET_MEMORY_RO)
- new = pud_wrprotect(new);
- else if (flags & SET_MEMORY_RW)
- new = pud_mkwrite(pud_mkdirty(new));
- if (flags & SET_MEMORY_NX)
- new = set_pud_bit(new, __pgprot(_REGION_ENTRY_NOEXEC));
- else if (flags & SET_MEMORY_X)
- new = clear_pud_bit(new, __pgprot(_REGION_ENTRY_NOEXEC));
- if (flags & SET_MEMORY_INV) {
- new = set_pud_bit(new, __pgprot(_REGION_ENTRY_INVALID));
- } else if (flags & SET_MEMORY_DEF) {
- new = __pud(pud_val(new) & PUD_MASK);
- new = set_pud_bit(new, REGION3_KERNEL);
- }
- pudp_replace_kernel(pudp, new, addr);
-}
-
static int walk_pud_level(p4d_t *p4d, unsigned long addr, unsigned long end,
unsigned long flags)
{
@@ -313,7 +319,7 @@ static int walk_pud_level(p4d_t *p4d, unsigned long addr, unsigned long end,
break;
continue;
}
- modify_pud_page(pudp, addr, flags);
+ pudp_replace_kernel(pudp, pud_apply_flags(pud, flags), addr);
} else {
rc = walk_pmd_level(pudp, addr, next, flags);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 11/17] s390/pageattr: Avoid splitting mappings if permissions do not change
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (9 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 10/17] s390/pageattr: Use common helper to change kernel page table permissions Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings Heiko Carstens
` (6 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Follow x86 and avoid splitting large mappings if the resulting entry is
identical to the existing one, regardless of range alignment.
SET_MEMORY_4K still always splits.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/mm/pageattr.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index 980f32bea83a..2b4c574da474 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -225,9 +225,9 @@ static int split_pmd_page(pmd_t *pmdp, unsigned long addr)
static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end,
unsigned long flags)
{
+ pmd_t *pmdp, pmd, new;
unsigned long next;
- pmd_t *pmdp, pmd;
- int need_split;
+ bool need_split;
int rc = 0;
pmdp = pmd_offset(pudp, addr);
@@ -240,16 +240,19 @@ static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end,
goto skip;
}
if (pmd_leaf(pmd)) {
- need_split = !!(flags & SET_MEMORY_4K);
- need_split |= !!(addr & ~PMD_MASK);
- need_split |= !!(addr + PMD_SIZE > next);
+ new = pmd_apply_flags(pmd, flags);
+ need_split = flags & SET_MEMORY_4K;
+ if (pmd_val(new) != pmd_val(pmd)) {
+ need_split |= addr & ~PMD_MASK;
+ need_split |= addr + PMD_SIZE > next;
+ }
if (need_split) {
rc = split_pmd_page(pmdp, addr);
if (rc)
return rc;
continue;
}
- pmdp_replace_kernel(pmdp, pmd_apply_flags(pmd, flags), addr);
+ pmdp_replace_kernel(pmdp, new, addr);
} else {
rc = walk_pte_level(pmdp, addr, next, flags);
if (rc)
@@ -295,9 +298,9 @@ int split_pud_page(pud_t *pudp, unsigned long addr)
static int walk_pud_level(p4d_t *p4d, unsigned long addr, unsigned long end,
unsigned long flags)
{
+ pud_t *pudp, pud, new;
unsigned long next;
- pud_t *pudp, pud;
- int need_split;
+ bool need_split;
int rc = 0;
pudp = pud_offset(p4d, addr);
@@ -310,16 +313,19 @@ static int walk_pud_level(p4d_t *p4d, unsigned long addr, unsigned long end,
goto skip;
}
if (pud_leaf(pud)) {
- need_split = !!(flags & SET_MEMORY_4K);
- need_split |= !!(addr & ~PUD_MASK);
- need_split |= !!(addr + PUD_SIZE > next);
+ new = pud_apply_flags(pud, flags);
+ need_split = flags & SET_MEMORY_4K;
+ if (pud_val(new) != pud_val(pud)) {
+ need_split |= addr & ~PUD_MASK;
+ need_split |= addr + PUD_SIZE > next;
+ }
if (need_split) {
rc = split_pud_page(pudp, addr);
if (rc)
break;
continue;
}
- pudp_replace_kernel(pudp, pud_apply_flags(pud, flags), addr);
+ pudp_replace_kernel(pudp, new, addr);
} else {
rc = walk_pmd_level(pudp, addr, next, flags);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (10 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 11/17] s390/pageattr: Avoid splitting mappings if permissions do not change Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:00 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 13/17] s390/pageattr: Collapse kernel mappings after changing page attributes Heiko Carstens
` (5 subsequent siblings)
17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
In preparation for collapsing kernel mappings, mark intentional 4k mappings
with _PAGE_KERNEL_4K (reusing _PAGE_UNUSED) so they can be distinguished
from split mappings and are not collapsed back into large pages.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/pgtable.h | 1 +
arch/s390/mm/pageattr.c | 13 +++++++++----
arch/s390/mm/vmem.c | 2 ++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index a09055f3eb58..2f21ce7b545e 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -183,6 +183,7 @@ void setup_protection_map(void);
#define _PAGE_WRITE 0x020 /* SW pte write bit */
#define _PAGE_SPECIAL 0x040 /* SW associated with special page */
#define _PAGE_UNUSED 0x080 /* SW bit for pgste usage state */
+#define _PAGE_KERNEL_4K _PAGE_UNUSED /* SW bit for kernel ptes which must not be collapsed */
#ifdef CONFIG_MEM_SOFT_DIRTY
#define _PAGE_SOFT_DIRTY 0x002 /* SW pte soft dirty bit */
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index 2b4c574da474..28f1e5fb8e01 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -106,7 +106,7 @@ static unsigned long pgt_apply_perm(unsigned long val, unsigned long flags, int
write = _PAGE_WRITE | _PAGE_DIRTY;
noexec = _PAGE_NOEXEC;
invalid = _PAGE_INVALID;
- mask = PAGE_MASK;
+ mask = PAGE_MASK | _PAGE_KERNEL_4K;
def = pgprot_val(PAGE_KERNEL);
break;
case _SEGMENT_ENTRY_TYPE:
@@ -138,6 +138,10 @@ static unsigned long pgt_apply_perm(unsigned long val, unsigned long flags, int
val |= invalid;
else if (flags & SET_MEMORY_DEF)
val = (val & mask) | def;
+ if (flags & SET_MEMORY_4K) {
+ if (type == _PAGE_ENTRY_TYPE)
+ val |= _PAGE_KERNEL_4K;
+ }
return val;
}
@@ -161,8 +165,6 @@ static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,
{
pte_t *ptep, new;
- if (flags == SET_MEMORY_4K)
- return 0;
ptep = pte_offset_kernel(pmdp, addr);
do {
new = ptep_get(ptep);
@@ -172,7 +174,10 @@ static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,
goto skip;
}
new = pte_apply_flags(new, flags);
- ptep_replace_kernel(ptep, new, addr);
+ if (flags == SET_MEMORY_4K)
+ set_pte(ptep, new);
+ else
+ ptep_replace_kernel(ptep, new, addr);
skip:
ptep++;
addr += PAGE_SIZE;
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 0436b81d9bc5..56f88fb25784 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -189,6 +189,8 @@ static int __ref modify_pte_table(pmd_t *pmd, unsigned long addr,
pte_t *pte, entry;
prot = pgprot_val(PAGE_KERNEL);
+ if (direct && debug_pagealloc_enabled())
+ prot |= _PAGE_KERNEL_4K;
pte = pte_offset_kernel(pmd, addr);
for (; addr < end; addr += PAGE_SIZE, pte++) {
entry = ptep_get(pte);
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings
2026-12-03 10:33 ` [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings Heiko Carstens
@ 2026-12-03 11:00 ` sashiko-bot
0 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:00 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] s390/pageattr: set_pte() strips _PAGE_KERNEL_4K aliased to
_PAGE_UNUSED
--
commit 096b6065239ba4a2322c8abe5f72bd2b041bcd18
Author: Heiko Carstens <hca@linux.ibm.com>
s390/pageattr: Mark intentional 4k kernel mappings
This commit defines _PAGE_KERNEL_4K as an alias of _PAGE_UNUSED and sets it
on intentional 4k kernel mappings created via SET_MEMORY_4K or
debug_pagealloc direct mappings so they are not collapsed later.
> diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> index a09055f3eb586..2f21ce7b545e8 100644
> --- a/arch/s390/include/asm/pgtable.h
> +++ b/arch/s390/include/asm/pgtable.h
> @@ -183,6 +183,7 @@ void setup_protection_map(void);
> #define _PAGE_WRITE 0x020 /* SW pte write bit */
> #define _PAGE_SPECIAL 0x040 /* SW associated with special page */
> #define _PAGE_UNUSED 0x080 /* SW bit for pgste usage state */
> +#define _PAGE_KERNEL_4K _PAGE_UNUSED /* SW bit for kernel ptes which must not be collapsed */
>
> #ifdef CONFIG_MEM_SOFT_DIRTY
> #define _PAGE_SOFT_DIRTY 0x002 /* SW pte soft dirty bit */
[Severity: High]
Does aliasing _PAGE_KERNEL_4K to _PAGE_UNUSED cause set_pte() to strip the
bit before it is written?
arch/s390/include/asm/pgtable.h:set_pte() {
if (pte_present(pte))
pte = clear_pte_bit(pte, __pgprot(_PAGE_UNUSED));
WRITE_ONCE(*ptep, pte);
}
Mapped kernel PTEs have _PAGE_PRESENT set, so set_pte() clears
_PAGE_KERNEL_4K in walk_pte_level() for SET_MEMORY_4K, in
modify_pte_table() for debug_pagealloc direct mappings, and in
__kernel_map_pages() when a KFENCE or debug_pagealloc page is remapped.
As a result, intentional 4k kernel mappings are never marked (or lose
their marker on remap), so collapsing code cannot distinguish them from
split mappings and can collapse a PMD containing KFENCE or
debug_pagealloc pages.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=12
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 13/17] s390/pageattr: Collapse kernel mappings after changing page attributes
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (11 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:10 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 14/17] s390/mm: Add PAGE_KERNEL_ROX Heiko Carstens
` (4 subsequent siblings)
17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
After a successful set_memory_rox(), replace page tables with 1MB
mappings if alignment and permissions allow. Support for collapsing
into 2GB mappings is added for the sake of completeness, although
this cannot happen at the moment.
Like on x86, only ROX mappings are collapsed. Direct map aliases and
intentional 4k mappings (_PAGE_KERNEL_4K) are left alone.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/pgalloc.h | 1 +
arch/s390/mm/pageattr.c | 119 ++++++++++++++++++++++++++++++++
arch/s390/mm/vmem.c | 2 +-
3 files changed, 121 insertions(+), 1 deletion(-)
diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h
index f5adddc10946..9754085399b9 100644
--- a/arch/s390/include/asm/pgalloc.h
+++ b/arch/s390/include/asm/pgalloc.h
@@ -167,6 +167,7 @@ void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable);
void vmem_map_init(void);
void *vmem_crst_alloc(unsigned long val);
+void vmem_crst_free(unsigned long *table);
pte_t *vmem_pte_alloc(void);
void vmem_pte_free(unsigned long *table);
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index 28f1e5fb8e01..0a22f8c7bbe1 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -389,6 +389,119 @@ static int change_page_attr(unsigned long addr, unsigned long end,
return rc;
}
+#define PTE_COLLAPSE_BITS (PAGE_MASK | _PAGE_PROTECT | _PAGE_NOEXEC | \
+ _PAGE_INVALID | _PAGE_KERNEL_4K)
+
+#define PMD_COLLAPSE_BITS (_SEGMENT_ENTRY_ORIGIN_LARGE | _SEGMENT_ENTRY_LARGE | \
+ _SEGMENT_ENTRY_PROTECT | _SEGMENT_ENTRY_NOEXEC | \
+ _SEGMENT_ENTRY_INVALID)
+
+static bool collapse_pmd_page(pmd_t *pmdp, unsigned long addr)
+{
+ unsigned long first, expected, prot, pa;
+ pmd_t old, new;
+ pte_t *ptep;
+ bool ro, nx;
+ int i;
+
+ if (!cpu_has_edat1())
+ return false;
+ ptep = pte_offset_kernel(pmdp, addr);
+ first = pte_val(ptep_get(ptep)) & PTE_COLLAPSE_BITS;
+ if (first & (_PAGE_INVALID | _PAGE_KERNEL_4K))
+ return false;
+ pa = first & PAGE_MASK;
+ if (!IS_ALIGNED(pa, PMD_SIZE))
+ return false;
+ expected = first;
+ for (i = 1, ptep++; i < PTRS_PER_PTE; i++, ptep++) {
+ expected += PAGE_SIZE;
+ if ((pte_val(ptep_get(ptep)) & PTE_COLLAPSE_BITS) != expected)
+ return false;
+ }
+ ro = first & _PAGE_PROTECT;
+ nx = first & _PAGE_NOEXEC;
+ prot = pgprot_val(ro ? SEGMENT_KERNEL_RO : SEGMENT_KERNEL);
+ if (!nx)
+ prot &= ~_SEGMENT_ENTRY_NOEXEC;
+ new = __pmd(pa | prot);
+ old = pmdp_replace_kernel(pmdp, new, addr);
+ vmem_pte_free((unsigned long *)pmd_deref(old));
+ update_direct_map_count(addr, PG_DIRECT_MAP_4K, -PTRS_PER_PTE);
+ update_direct_map_count(addr, PG_DIRECT_MAP_1M, 1);
+ return true;
+}
+
+static void collapse_pud_page(pud_t *pudp, unsigned long addr)
+{
+ unsigned long first, expected, prot, pa;
+ pud_t old, new;
+ pmd_t *pmdp;
+ bool ro, nx;
+ int i;
+
+ if (!cpu_has_edat2())
+ return;
+ pmdp = pmd_offset(pudp, addr & PUD_MASK);
+ first = pmd_val(pmdp_get(pmdp)) & PMD_COLLAPSE_BITS;
+ if (!(first & _SEGMENT_ENTRY_LARGE) || (first & _SEGMENT_ENTRY_INVALID))
+ return;
+ pa = first & _SEGMENT_ENTRY_ORIGIN_LARGE;
+ if (!IS_ALIGNED(pa, PUD_SIZE))
+ return;
+ expected = first;
+ for (i = 1, pmdp++; i < PTRS_PER_PMD; i++, pmdp++) {
+ expected += PMD_SIZE;
+ if ((pmd_val(pmdp_get(pmdp)) & PMD_COLLAPSE_BITS) != expected)
+ return;
+ }
+ ro = first & _SEGMENT_ENTRY_PROTECT;
+ nx = first & _SEGMENT_ENTRY_NOEXEC;
+ prot = pgprot_val(ro ? REGION3_KERNEL_RO : REGION3_KERNEL);
+ if (!nx)
+ prot &= ~_REGION_ENTRY_NOEXEC;
+ new = __pud(pa | prot);
+ old = pudp_replace_kernel(pudp, new, addr);
+ vmem_crst_free((unsigned long *)pud_deref(old));
+ update_direct_map_count(addr, PG_DIRECT_MAP_1M, -PTRS_PER_PMD);
+ update_direct_map_count(addr, PG_DIRECT_MAP_2G, 1);
+}
+
+static void collapse_page_attr_one(unsigned long addr)
+{
+ pgd_t *pgdp;
+ p4d_t *p4dp;
+ pud_t *pudp;
+ pmd_t *pmdp;
+ pmd_t pmd;
+ pud_t pud;
+
+ addr &= PMD_MASK;
+ pgdp = pgd_offset_k(addr);
+ if (pgd_none(pgdp_get(pgdp)))
+ return;
+ p4dp = p4d_offset(pgdp, addr);
+ if (p4d_none(p4dp_get(p4dp)))
+ return;
+ pudp = pud_offset(p4dp, addr);
+ pud = pudp_get(pudp);
+ if (pud_none(pud) || pud_leaf(pud))
+ return;
+ pmdp = pmd_offset(pudp, addr);
+ pmd = pmdp_get(pmdp);
+ if (pmd_none(pmd) || pmd_leaf(pmd))
+ return;
+ if (!collapse_pmd_page(pmdp, addr))
+ return;
+ collapse_pud_page(pudp, addr);
+}
+
+static void collapse_page_attr(unsigned long addr, unsigned long end)
+{
+ for (addr &= PMD_MASK; addr < end; addr += PMD_SIZE)
+ collapse_page_attr_one(addr);
+}
+
static int change_page_attr_alias(unsigned long addr, unsigned long end,
unsigned long flags)
{
@@ -428,8 +541,10 @@ static int change_page_attr_alias(unsigned long addr, unsigned long end,
int __set_memory(unsigned long addr, unsigned long numpages, unsigned long flags)
{
unsigned long end;
+ bool collapse;
int rc;
+ collapse = flags == (SET_MEMORY_RO | SET_MEMORY_X);
if (!cpu_has_nx())
flags &= ~(SET_MEMORY_NX | SET_MEMORY_X);
if (!flags)
@@ -443,6 +558,10 @@ int __set_memory(unsigned long addr, unsigned long numpages, unsigned long flags
if (rc)
goto out;
rc = change_page_attr_alias(addr, end, flags);
+ if (rc)
+ goto out;
+ if (collapse)
+ collapse_page_attr(addr, end);
out:
mmap_write_unlock(&init_mm);
return rc;
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 56f88fb25784..05f31ac599e6 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -73,7 +73,7 @@ void __ref *vmem_crst_alloc(unsigned long val)
return table;
}
-static void vmem_crst_free(unsigned long *table)
+void vmem_crst_free(unsigned long *table)
{
if (PageTable(virt_to_page(table)))
crst_table_free(&init_mm, table);
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 13/17] s390/pageattr: Collapse kernel mappings after changing page attributes
2026-12-03 10:33 ` [PATCH 13/17] s390/pageattr: Collapse kernel mappings after changing page attributes Heiko Carstens
@ 2026-12-03 11:10 ` sashiko-bot
0 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:10 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] s390/vmem: vmem_crst_free() lacks !slab_is_available()
memblock_free() path
- [Medium] s390/pageattr: collapse_pmd_page() races with lockless
__vmalloc_to_page()
- [Medium] s390/pageattr: set_pte() clears _PAGE_KERNEL_4K on present
kernel PTEs
- [Low] s390/mm: collapse_page_attr_one() skips 2GB collapse on 1MB leaf
PMDs
- [Low] s390/vmem: missing __ref on vmem_pte_free() calling
__init_memblock
--
commit 28c06261f37ae1ca620f60e322d1e3723878d47d
Author: Heiko Carstens <hca@linux.ibm.com>
s390/pageattr: Collapse kernel mappings after changing page attributes
This commit collapses kernel page tables into 1MB (and 2GB) leaf mappings
after a successful set_memory_rox() when alignment and permissions allow,
leaving direct map aliases and _PAGE_KERNEL_4K mappings alone.
> diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
> index 28f1e5fb8e010..0a22f8c7bbe16 100644
> --- a/arch/s390/mm/pageattr.c
> +++ b/arch/s390/mm/pageattr.c
> @@ -389,6 +389,119 @@ static int change_page_attr(unsigned long addr, unsigned long end,
> return rc;
> }
>
> +#define PTE_COLLAPSE_BITS (PAGE_MASK | _PAGE_PROTECT | _PAGE_NOEXEC | \
> + _PAGE_INVALID | _PAGE_KERNEL_4K)
> +
> +#define PMD_COLLAPSE_BITS (_SEGMENT_ENTRY_ORIGIN_LARGE | _SEGMENT_ENTRY_LARGE | \
> + _SEGMENT_ENTRY_PROTECT | _SEGMENT_ENTRY_NOEXEC | \
> + _SEGMENT_ENTRY_INVALID)
> +
> +static bool collapse_pmd_page(pmd_t *pmdp, unsigned long addr)
> +{
> + unsigned long first, expected, prot, pa;
> + pmd_t old, new;
> + pte_t *ptep;
> + bool ro, nx;
> + int i;
> +
> + if (!cpu_has_edat1())
> + return false;
> + ptep = pte_offset_kernel(pmdp, addr);
> + first = pte_val(ptep_get(ptep)) & PTE_COLLAPSE_BITS;
> + if (first & (_PAGE_INVALID | _PAGE_KERNEL_4K))
> + return false;
[Severity: Medium]
Can _PAGE_KERNEL_4K ever be set on a present kernel PTE here?
_PAGE_KERNEL_4K is aliased to _PAGE_UNUSED in arch/s390/include/asm/pgtable.h,
and set_pte() unconditionally clears _PAGE_UNUSED whenever pte_present(pte)
is true:
arch/s390/include/asm/pgtable.h:set_pte() {
if (pte_present(pte))
pte = clear_pte_bit(pte, __pgprot(_PAGE_UNUSED));
WRITE_ONCE(*ptep, pte);
}
Every path that sets _PAGE_KERNEL_4K on mapped kernel PTEs -- including
walk_pte_level() for set_memory_4k() and modify_pte_table() for
debug_pagealloc_enabled() -- writes the entry through set_pte(), so the bit
is immediately stripped.
If set_memory_rox() is called on a 1MB-aligned range covering intentional
4k mappings, collapse_pmd_page() will collapse them into a 1MB leaf PMD,
causing later virt_to_kpte() lookups in __kernel_map_pages() to treat the
1MB frame as a page table.
[ ... ]
> + new = __pmd(pa | prot);
> + old = pmdp_replace_kernel(pmdp, new, addr);
> + vmem_pte_free((unsigned long *)pmd_deref(old));
[Severity: Medium]
Can freeing the old PTE table here race with lockless init_mm page table
walkers such as __vmalloc_to_page()?
collapse_pmd_page() runs under mmap_write_lock(&init_mm) and frees the
replaced PTE page immediately via vmem_pte_free() without RCU deferral
(collapse_pud_page() does the same with vmem_crst_free()).
Meanwhile, /proc/kcore reads live vmalloc and module ranges via
read_kcore_iter() -> vread_iter() -> aligned_vread_iter() ->
__vmalloc_to_page() without holding init_mm.mmap_lock:
CPU0 CPU1
__set_memory()
mmap_write_lock(&init_mm)
collapse_pmd_page()
aligned_vread_iter()
__vmalloc_to_page()
pmd = pmd_offset(pud, addr)
if (pmd_leaf(*pmd)) ... // false
ptep = pte_offset_kernel(pmd, addr)
pmdp_replace_kernel(...)
vmem_pte_free(old)
// page reused/unmapped
pte = ptep_get(ptep) <-- use-after-free
If pmdp_replace_kernel() instead runs between pmd_leaf(*pmd) and
pte_offset_kernel(pmd, addr), pte_offset_kernel() re-reads *pmd as a 1MB
leaf and reads executable code as a PTE. Either race can pass a bogus
struct page pointer to copy_page_to_iter_nofault() and crash or leak data.
[Severity: Low]
Does vmem_pte_free() need a __ref annotation?
vmem_pte_free() in arch/s390/mm/vmem.c calls memblock_free() when
slab_is_available() is false, and memblock_free() is marked __init_memblock
(which expands to __init on s390 when CONFIG_MEMORY_HOTPLUG=n).
Unlike vmem_crst_alloc() and vmem_pte_alloc(), vmem_pte_free() lacks __ref,
causing a modpost section mismatch warning (or build failure with
CONFIG_SECTION_MISMATCH_WARN_ONLY=n) when CONFIG_MEMORY_HOTPLUG=n.
[ ... ]
> +static void collapse_page_attr_one(unsigned long addr)
> +{
[ ... ]
> + pmdp = pmd_offset(pudp, addr);
> + pmd = pmdp_get(pmdp);
> + if (pmd_none(pmd) || pmd_leaf(pmd))
> + return;
> + if (!collapse_pmd_page(pmdp, addr))
> + return;
> + collapse_pud_page(pudp, addr);
> +}
[Severity: Low]
Will returning early on pmd_leaf(pmd) skip 2GB PUD collapse when the
modified PMDs are already 1MB leaf entries?
When set_memory_rox() updates a 1MB-aligned leaf PMD, walk_pmd_level()
replaces it in place via pmdp_replace_kernel() without splitting it to 4KB
PTEs.
Because pmd_leaf(pmd) is already true, collapse_page_attr_one() returns
before calling collapse_pud_page(pudp, addr), leaving a collapsible 2GB PUD
fragmented at 1MB granularity unless a PMD was collapsed from 4KB PTEs.
[ ... ]
> diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
> index 56f88fb257845..05f31ac599e63 100644
> --- a/arch/s390/mm/vmem.c
> +++ b/arch/s390/mm/vmem.c
> @@ -73,7 +73,7 @@ void __ref *vmem_crst_alloc(unsigned long val)
> return table;
> }
>
> -static void vmem_crst_free(unsigned long *table)
> +void vmem_crst_free(unsigned long *table)
> {
> if (PageTable(virt_to_page(table)))
> crst_table_free(&init_mm, table);
[Severity: Medium]
Is vmem_crst_free() safe to call before slab_is_available() is true?
collapse_pud_page() is reachable during early boot via vmem_map_init() ->
__set_memory_rox() before sparse_init() and kmem_cache_init(), and
vmemmap_populate() error rollback can also call vmem_crst_free() before
slab is available.
Unlike vmem_crst_alloc() and vmem_pte_free(), vmem_crst_free() calls
virt_to_page() and falls back to vmem_free_pages(), which will crash on
unmapped vmemmap or corrupt an uninitialized buddy allocator.
Checking !slab_is_available() to call memblock_free(table,
PAGE_SIZE << CRST_ALLOC_ORDER) and marking vmem_crst_free() __ref would
match vmem_crst_alloc() and vmem_pte_free().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=13
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 14/17] s390/mm: Add PAGE_KERNEL_ROX
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (12 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 13/17] s390/pageattr: Collapse kernel mappings after changing page attributes Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 10:33 ` [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range Heiko Carstens
` (3 subsequent siblings)
17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Add PAGE_KERNEL_ROX, which is PAGE_KERNEL_RO without the no-execute
bit, i.e. the read-only and executable kernel mapping that
set_memory_rox() creates. This allows to allocate read-only and
executable kernel mappings directly, without the need to change the
permissions afterwards.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/pgtable.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 2f21ce7b545e..52ee989ac88a 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -432,6 +432,8 @@ void setup_protection_map(void);
_PAGE_YOUNG | _PAGE_DIRTY | _PAGE_NOEXEC)
#define __PAGE_KERNEL_RO (_PAGE_PRESENT | _PAGE_READ | _PAGE_YOUNG | \
_PAGE_PROTECT | _PAGE_NOEXEC)
+#define __PAGE_KERNEL_ROX (_PAGE_PRESENT | _PAGE_READ | _PAGE_YOUNG | \
+ _PAGE_PROTECT)
extern unsigned long page_noexec_mask;
@@ -445,6 +447,7 @@ extern unsigned long page_noexec_mask;
#define PAGE_SHARED __pgprot_page_mask(__PAGE_SHARED)
#define PAGE_KERNEL __pgprot_page_mask(__PAGE_KERNEL)
#define PAGE_KERNEL_RO __pgprot_page_mask(__PAGE_KERNEL_RO)
+#define PAGE_KERNEL_ROX __pgprot_page_mask(__PAGE_KERNEL_ROX)
/*
* Segment entry (large page) protection definitions.
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (13 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 14/17] s390/mm: Add PAGE_KERNEL_ROX Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:03 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 16/17] s390/execmem: Add EXECMEM_FTRACE range Heiko Carstens
` (2 subsequent siblings)
17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Add an EXECMEM_KPROBES range with PAGE_KERNEL_ROX protection, so that
execmem_alloc(EXECMEM_KPROBES, ...) returns ROX memory. This makes the
s390 specific alloc_insn_page(), which calls set_memory_rox(),
obsolete. Remove it in favor of the generic implementation.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/kernel/kprobes.c | 16 ----------------
arch/s390/mm/init.c | 7 +++++++
2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 9bfff628c9bf..d97fd3b9e3db 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -21,9 +21,7 @@
#include <linux/slab.h>
#include <linux/hardirq.h>
#include <linux/ftrace.h>
-#include <linux/execmem.h>
#include <asm/text-patching.h>
-#include <asm/set_memory.h>
#include <asm/sections.h>
#include <asm/dis.h>
#include "entry.h"
@@ -33,20 +31,6 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
struct kretprobe_blackpoint kretprobe_blacklist[] = { };
-void *alloc_insn_page(void)
-{
- void *page;
-
- page = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
- if (!page)
- return NULL;
- if (set_memory_rox((unsigned long)page, 1)) {
- execmem_free(page);
- return NULL;
- }
- return page;
-}
-
static void copy_instruction(struct kprobe *p)
{
kprobe_opcode_t insn[MAX_INSN_SIZE];
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index b9fd795cf788..062b2b5325af 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -331,6 +331,13 @@ struct execmem_info __init *execmem_arch_setup(void)
.pgprot = PAGE_KERNEL,
.alignment = MODULE_ALIGN,
},
+ [EXECMEM_KPROBES] = {
+ .flags = EXECMEM_KASAN_SHADOW,
+ .start = start,
+ .end = MODULES_END,
+ .pgprot = PAGE_KERNEL_ROX,
+ .alignment = MODULE_ALIGN,
+ },
},
};
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range
2026-12-03 10:33 ` [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range Heiko Carstens
@ 2026-12-03 11:03 ` sashiko-bot
0 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:03 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] s390/execmem: EXECMEM_KPROBES skips set_memory_rox()
direct-map protection
--
commit 67943fd0e30c5ced8f7dc99734b2146fc3684f54
Author: Heiko Carstens <hca@linux.ibm.com>
s390/execmem: Add EXECMEM_KPROBES range
This commit adds an EXECMEM_KPROBES range with PAGE_KERNEL_ROX protection
and removes the s390-specific alloc_insn_page() implementation in favor of
the generic one.
> diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
> index 9bfff628c9bf1..d97fd3b9e3dbb 100644
> --- a/arch/s390/kernel/kprobes.c
> +++ b/arch/s390/kernel/kprobes.c
[ ... ]
> @@ -33,20 +31,6 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
>
> struct kretprobe_blackpoint kretprobe_blacklist[] = { };
>
> -void *alloc_insn_page(void)
> -{
> - void *page;
> -
> - page = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
> - if (!page)
> - return NULL;
> - if (set_memory_rox((unsigned long)page, 1)) {
> - execmem_free(page);
> - return NULL;
> - }
> - return page;
> -}
> -
> static void copy_instruction(struct kprobe *p)
> {
> kprobe_opcode_t insn[MAX_INSN_SIZE];
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index b9fd795cf788e..062b2b5325aff 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -331,6 +331,13 @@ struct execmem_info __init *execmem_arch_setup(void)
> .pgprot = PAGE_KERNEL,
> .alignment = MODULE_ALIGN,
> },
> + [EXECMEM_KPROBES] = {
> + .flags = EXECMEM_KASAN_SHADOW,
> + .start = start,
> + .end = MODULES_END,
> + .pgprot = PAGE_KERNEL_ROX,
> + .alignment = MODULE_ALIGN,
> + },
> },
> };
[Severity: Medium]
Does this leave kprobe instruction pages writable through the kernel direct
mapping?
Without EXECMEM_ROX_CACHE, execmem_alloc() calls execmem_vmalloc() directly
with PAGE_KERNEL_ROX, which updates only the vmalloc PTE. Because
alloc_insn_page() no longer calls set_memory_rox() ->
change_page_attr_alias(), the backing page's direct-map alias stays writable.
At this commit, large direct-map mappings on EDAT1 systems are also not split
at allocation time, deferring splitting to free_insn_page() -> vfree() ->
vm_reset_perms() -> set_area_direct_map(), where -ENOMEM triggers
WARN_ON_ONCE() and skips direct-map invalidation.
Commit "s390/execmem: Enable EXECMEM_ARCH_ROX" later enables
EXECMEM_ROX_CACHE when cpu_has_edat1() is true, but systems without EDAT1
(for example with facilities=!8) still omit EXECMEM_ROX_CACHE while keeping
PAGE_KERNEL_ROX, leaving the direct-map alias writable there.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=15
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 16/17] s390/execmem: Add EXECMEM_FTRACE range
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (14 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:04 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 17/17] s390/execmem: Enable EXECMEM_ARCH_ROX Heiko Carstens
2026-12-03 11:11 ` [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache sashiko-bot
17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Add an EXECMEM_FTRACE range with PAGE_KERNEL_ROX protection, so that
execmem_alloc(EXECMEM_FTRACE, ...) returns ROX memory. This makes the
explicit set_memory_rox() call for the module ftrace hotpatch
trampolines obsolete. Remove it.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/kernel/module.c | 11 +----------
arch/s390/mm/init.c | 7 +++++++
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
index 8538d8b53a32..5ad84066aa11 100644
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -28,7 +28,6 @@
#include <asm/nospec-branch.h>
#include <asm/facility.h>
#include <asm/ftrace.lds.h>
-#include <asm/set_memory.h>
#include <asm/setup.h>
#include <asm/asm-offsets.h>
@@ -473,20 +472,12 @@ static int module_alloc_ftrace_hotpatch_trampolines(struct module *me,
const Elf_Shdr *s)
{
char *start, *end;
- int numpages;
size_t size;
- int rc;
size = FTRACE_HOTPATCH_TRAMPOLINES_SIZE(s->sh_size);
- numpages = DIV_ROUND_UP(size, PAGE_SIZE);
- start = execmem_alloc(EXECMEM_FTRACE, numpages * PAGE_SIZE);
+ start = execmem_alloc(EXECMEM_FTRACE, PAGE_ALIGN(size));
if (!start)
return -ENOMEM;
- rc = set_memory_rox((unsigned long)start, numpages);
- if (rc) {
- execmem_free(start);
- return rc;
- }
end = start + size;
me->arch.trampolines_start = (struct ftrace_hotpatch_trampoline *)start;
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 062b2b5325af..0cac76ddb700 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -338,6 +338,13 @@ struct execmem_info __init *execmem_arch_setup(void)
.pgprot = PAGE_KERNEL_ROX,
.alignment = MODULE_ALIGN,
},
+ [EXECMEM_FTRACE] = {
+ .flags = EXECMEM_KASAN_SHADOW,
+ .start = start,
+ .end = MODULES_END,
+ .pgprot = PAGE_KERNEL_ROX,
+ .alignment = MODULE_ALIGN,
+ },
},
};
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 16/17] s390/execmem: Add EXECMEM_FTRACE range
2026-12-03 10:33 ` [PATCH 16/17] s390/execmem: Add EXECMEM_FTRACE range Heiko Carstens
@ 2026-12-03 11:04 ` sashiko-bot
0 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:04 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] s390/execmem: EXECMEM_FTRACE skips set_memory_rox()
direct-map alias update
--
commit a1342c4b90743d50be481c2d40f949a00ca93131
Author: Heiko Carstens <hca@linux.ibm.com>
s390/execmem: Add EXECMEM_FTRACE range
This commit adds an EXECMEM_FTRACE range with PAGE_KERNEL_ROX protection in
execmem_arch_setup() and removes the explicit set_memory_rox() call from
module_alloc_ftrace_hotpatch_trampolines().
> diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
> index 8538d8b53a322..5ad84066aa11c 100644
> --- a/arch/s390/kernel/module.c
> +++ b/arch/s390/kernel/module.c
[ ... ]
> @@ -473,20 +472,12 @@ static int module_alloc_ftrace_hotpatch_trampolines(struct module *me,
> const Elf_Shdr *s)
> {
> char *start, *end;
> - int numpages;
> size_t size;
> - int rc;
>
> size = FTRACE_HOTPATCH_TRAMPOLINES_SIZE(s->sh_size);
> - numpages = DIV_ROUND_UP(size, PAGE_SIZE);
> - start = execmem_alloc(EXECMEM_FTRACE, numpages * PAGE_SIZE);
> + start = execmem_alloc(EXECMEM_FTRACE, PAGE_ALIGN(size));
> if (!start)
> return -ENOMEM;
> - rc = set_memory_rox((unsigned long)start, numpages);
> - if (rc) {
> - execmem_free(start);
> - return rc;
> - }
> end = start + size;
>
> me->arch.trampolines_start = (struct ftrace_hotpatch_trampoline *)start;
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index 062b2b5325aff..0cac76ddb700b 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -338,6 +338,13 @@ struct execmem_info __init *execmem_arch_setup(void)
> .pgprot = PAGE_KERNEL_ROX,
> .alignment = MODULE_ALIGN,
> },
> + [EXECMEM_FTRACE] = {
> + .flags = EXECMEM_KASAN_SHADOW,
> + .start = start,
> + .end = MODULES_END,
> + .pgprot = PAGE_KERNEL_ROX,
> + .alignment = MODULE_ALIGN,
> + },
> },
> };
[Severity: Medium]
Does removing set_memory_rox() leave the direct-map aliases of module
ftrace hotpatch trampoline pages writable?
When EXECMEM_ROX_CACHE is not set, execmem_alloc() calls execmem_vmalloc()
-> __vmalloc_node_range() directly with PAGE_KERNEL_ROX and never invokes
set_memory_rox(). On s390, direct-map aliases are only marked read-only
in __set_memory() -> change_page_attr_alias(), so they remain writable.
Commit "s390/execmem: Enable EXECMEM_ARCH_ROX" later enables
EXECMEM_ROX_CACHE when cpu_has_edat1() is true, but systems without EDAT1
still omit EXECMEM_ROX_CACHE while keeping PAGE_KERNEL_ROX and retain this
regression.
At this commit, skipping set_memory_rox() also defers splitting 1M/2G
direct-map mappings until module teardown in vfree() -> vm_reset_perms()
-> set_area_direct_map(), where a page-table allocation failure can only
trigger WARN_ON_ONCE() instead of failing module load cleanly.
Calling set_memory_rox() when !execmem_is_rox(EXECMEM_FTRACE) would keep
the direct-map aliases read-only when EXECMEM_ROX_CACHE is disabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=16
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 17/17] s390/execmem: Enable EXECMEM_ARCH_ROX
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (15 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 16/17] s390/execmem: Add EXECMEM_FTRACE range Heiko Carstens
@ 2026-12-03 10:33 ` Heiko Carstens
2026-12-03 11:09 ` sashiko-bot
2026-12-03 11:11 ` [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache sashiko-bot
17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2026-12-03 10:33 UTC (permalink / raw)
To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
Christian Borntraeger, Mike Rapoport, Gerald Schaefer
Cc: linux-kernel, linux-s390
Select ARCH_HAS_EXECMEM_ROX and use the execmem ROX cache for module
text, kprobes and ftrace allocations if EDAT1 is available. This allows
executable memory in the module area to be mapped with large read-only
pages.
Add the required execmem_fill_trapping_insns(), which fills memory with
invalid opcodes.
Define the EXECMEM_BPF and EXECMEM_MODULE_DATA ranges explicitly, since
they need writable memory and must not use the ROX cache.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/Kconfig | 1 +
arch/s390/mm/init.c | 39 +++++++++++++++++++++++++++++++++++----
2 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 04b401e9b680..da468b01d6b6 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -97,6 +97,7 @@ config S390
select ARCH_HAS_DEVMEM_IS_ALLOWED
select ARCH_HAS_DMA_OPS if PCI
select ARCH_HAS_ELF_RANDOMIZE
+ select ARCH_HAS_EXECMEM_ROX if STRICT_MODULE_RWX || STRICT_KERNEL_RWX
select ARCH_HAS_FORCE_DMA_UNENCRYPTED
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 0cac76ddb700..139ca6461fc8 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -312,39 +312,70 @@ void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
#ifdef CONFIG_EXECMEM
static struct execmem_info execmem_info __ro_after_init;
+#ifdef CONFIG_ARCH_HAS_EXECMEM_ROX
+void execmem_fill_trapping_insns(void *ptr, size_t size)
+{
+ memset(ptr, 0, size);
+}
+#endif
+
struct execmem_info __init *execmem_arch_setup(void)
{
unsigned long module_load_offset = 0;
+ enum execmem_range_flags flags;
unsigned long start;
+ pgprot_t pgprot;
if (kaslr_enabled())
module_load_offset = get_random_u32_inclusive(1, 1024) * PAGE_SIZE;
start = MODULES_VADDR + module_load_offset;
+ if (IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX) && cpu_has_edat1()) {
+ pgprot = PAGE_KERNEL_ROX;
+ flags = EXECMEM_KASAN_SHADOW | EXECMEM_ROX_CACHE;
+ } else {
+ pgprot = PAGE_KERNEL;
+ flags = EXECMEM_KASAN_SHADOW;
+ }
+
execmem_info = (struct execmem_info){
.ranges = {
[EXECMEM_DEFAULT] = {
- .flags = EXECMEM_KASAN_SHADOW,
+ .flags = flags,
.start = start,
.end = MODULES_END,
- .pgprot = PAGE_KERNEL,
+ .pgprot = pgprot,
.alignment = MODULE_ALIGN,
},
[EXECMEM_KPROBES] = {
- .flags = EXECMEM_KASAN_SHADOW,
+ .flags = flags,
.start = start,
.end = MODULES_END,
.pgprot = PAGE_KERNEL_ROX,
.alignment = MODULE_ALIGN,
},
[EXECMEM_FTRACE] = {
- .flags = EXECMEM_KASAN_SHADOW,
+ .flags = flags,
.start = start,
.end = MODULES_END,
.pgprot = PAGE_KERNEL_ROX,
.alignment = MODULE_ALIGN,
},
+ [EXECMEM_BPF] = {
+ .flags = EXECMEM_KASAN_SHADOW,
+ .start = start,
+ .end = MODULES_END,
+ .pgprot = PAGE_KERNEL,
+ .alignment = MODULE_ALIGN,
+ },
+ [EXECMEM_MODULE_DATA] = {
+ .flags = EXECMEM_KASAN_SHADOW,
+ .start = start,
+ .end = MODULES_END,
+ .pgprot = PAGE_KERNEL,
+ .alignment = MODULE_ALIGN,
+ },
},
};
--
2.53.0
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 17/17] s390/execmem: Enable EXECMEM_ARCH_ROX
2026-12-03 10:33 ` [PATCH 17/17] s390/execmem: Enable EXECMEM_ARCH_ROX Heiko Carstens
@ 2026-12-03 11:09 ` sashiko-bot
0 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:09 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] s390/execmem: zero-sized EXECMEM_FTRACE alloc corrupts ROX
cache maple trees
- [Medium] s390/mm: change_page_attr_alias() shatters direct-map PMDs on
ROX cache refill
- [Low] s390/execmem: commit subject references nonexistent
EXECMEM_ARCH_ROX
--
commit 6a59e81aa86e998734bf155ab53f0430bb991904
Author: Heiko Carstens <hca@linux.ibm.com>
s390/execmem: Enable EXECMEM_ARCH_ROX
This commit selects ARCH_HAS_EXECMEM_ROX on s390, adds
execmem_fill_trapping_insns(), and enables EXECMEM_ROX_CACHE for
EXECMEM_DEFAULT, EXECMEM_KPROBES, and EXECMEM_FTRACE when EDAT1 is
available, while defining EXECMEM_BPF and EXECMEM_MODULE_DATA as writable.
> s390/execmem: Enable EXECMEM_ARCH_ROX
[Severity: Low]
This isn't a bug, but the subject names EXECMEM_ARCH_ROX instead of
ARCH_HAS_EXECMEM_ROX.
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index 0cac76ddb700b..139ca6461fc81 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -312,39 +312,70 @@ void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
[ ... ]
> + if (IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX) && cpu_has_edat1()) {
> + pgprot = PAGE_KERNEL_ROX;
> + flags = EXECMEM_KASAN_SHADOW | EXECMEM_ROX_CACHE;
> + } else {
> + pgprot = PAGE_KERNEL;
> + flags = EXECMEM_KASAN_SHADOW;
> + }
[Severity: Medium]
Does enabling EXECMEM_ROX_CACHE shatter 1MB direct-map PMDs on every cache
refill?
Each refill in execmem_vmalloc_rox() allocates a 1MB huge vmalloc block and
calls set_memory_rox() on the 256-page range. change_page_attr_alias()
ignores vm_area_page_order(area) and updates the direct-map alias one 4KB
page at a time.
On the first page, walk_pmd_level() splits the 1MB direct-map PMD into 256
4KB PTEs, causing 256 global crdte/cspg shootdowns under
mmap_write_lock(&init_mm). The PMD is never collapsed back, so a later
vfree() in execmem_cache_clean() triggers another 512 per-page shootdowns.
Updating contiguous direct-map spans at PMD granularity in
change_page_attr_alias() would avoid both the split and the shootdowns.
[ ... ]
> [EXECMEM_FTRACE] = {
> - .flags = EXECMEM_KASAN_SHADOW,
> + .flags = flags,
> .start = start,
> .end = MODULES_END,
> .pgprot = PAGE_KERNEL_ROX,
> .alignment = MODULE_ALIGN,
> },
[Severity: High]
Can a zero-sized EXECMEM_FTRACE allocation corrupt the ROX cache maple trees
and cause a use-after-free?
When loading a module with an empty __mcount_loc section (s->sh_size == 0),
module_finalize() -> module_alloc_ftrace_hotpatch_trampolines() calls
execmem_alloc(EXECMEM_FTRACE, 0). Previously __vmalloc_node_range()
rejected size 0 and returned NULL.
With EXECMEM_ROX_CACHE enabled, execmem_alloc() passes size 0 into
execmem_cache_alloc_locked(), where addr + size - 1 underflows to addr - 1.
That stores an inverted [addr, addr - 1] range in busy_areas while
re-inserting [addr, last] into free_areas and returning addr.
A subsequent allocation then reuses addr, and unloading the first module
calls execmem_free(mod->arch.trampolines_start), overwriting live code with
trapping zeroes via execmem_fill_trapping_insns().
Rejecting size == 0 in execmem_alloc() or skipping empty sections in
module_alloc_ftrace_hotpatch_trampolines() would prevent this regression.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=17
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
` (16 preceding siblings ...)
2026-12-03 10:33 ` [PATCH 17/17] s390/execmem: Enable EXECMEM_ARCH_ROX Heiko Carstens
@ 2026-12-03 11:11 ` sashiko-bot
17 siblings, 0 replies; 28+ messages in thread
From: sashiko-bot @ 2026-12-03 11:11 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-s390, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Sashiko has finished reviewing this 17-patch series:
- Patches 2, 3, 5, 7-11, and 14: no issues found.
- Patch 1 ("s390/boot: Initialize asce_limit for init_mm properly"): 1
potential issue (1 Medium)
- Patch 4 ("s390/vmem: Use generic page table allocators for vme..."): 1
potential issue (1 Medium)
- Patch 6 ("s390/mm: Implement HAVE_ARCH_HUGE_VMAP"): 1 potential issue
(1 Medium)
- Patch 12 ("s390/pageattr: Mark intentional 4k kernel mappings"): 1
potential issue (1 High)
- Patch 13 ("s390/pageattr: Collapse kernel mappings after changi..."):
5 potential issues (3 Medium, 2 Low)
- Patch 15 ("s390/execmem: Add EXECMEM_KPROBES range"): 1 potential
issue (1 Medium)
- Patch 16 ("s390/execmem: Add EXECMEM_FTRACE range"): 1 potential issue
(1 Medium)
- Patch 17 ("s390/execmem: Enable EXECMEM_ARCH_ROX"): 3 potential issues
(1 High, 1 Medium, 1 Low)
Detailed reviews have been sent as separate replies to patches 1, 4, 6,
12, 13, and 15-17.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com
^ permalink raw reply [flat|nested] 28+ messages in thread