From: Heiko Carstens <hca@linux.ibm.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Mike Rapoport <rppt@kernel.org>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings
Date: Thu, 3 Dec 2026 11:33:40 +0100 [thread overview]
Message-ID: <20261203103345.1206548-13-hca@linux.ibm.com> (raw)
In-Reply-To: <20261203103345.1206548-1-hca@linux.ibm.com>
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
next prev parent reply other threads:[~2026-12-03 10:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [PATCH 03/17] s390/mm: Serialize kernel page table changes with init_mm mmap lock Heiko Carstens
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 ` [PATCH 05/17] s390/mm: Show write-combining attribute in page table dump Heiko Carstens
2026-12-03 10:33 ` [PATCH 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP Heiko Carstens
2026-12-03 10:33 ` [PATCH 07/17] s390/mm: Implement HAVE_ARCH_HUGE_VMALLOC Heiko Carstens
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 ` [PATCH 09/17] s390/mm: Add _SEGMENT_ENTRY_TYPE Heiko Carstens
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 ` [PATCH 11/17] s390/pageattr: Avoid splitting mappings if permissions do not change Heiko Carstens
2026-12-03 10:33 ` Heiko Carstens [this message]
2026-12-03 10:33 ` [PATCH 13/17] s390/pageattr: Collapse kernel mappings after changing page attributes Heiko Carstens
2026-12-03 10:33 ` [PATCH 14/17] s390/mm: Add PAGE_KERNEL_ROX Heiko Carstens
2026-12-03 10:33 ` [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range Heiko Carstens
2026-12-03 10:33 ` [PATCH 16/17] s390/execmem: Add EXECMEM_FTRACE range Heiko Carstens
2026-12-03 10:33 ` [PATCH 17/17] s390/execmem: Enable EXECMEM_ARCH_ROX Heiko Carstens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203103345.1206548-13-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=rppt@kernel.org \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox