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 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP
Date: Thu, 3 Dec 2026 11:33:34 +0100 [thread overview]
Message-ID: <20261203103345.1206548-7-hca@linux.ibm.com> (raw)
In-Reply-To: <20261203103345.1206548-1-hca@linux.ibm.com>
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
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 ` Heiko Carstens [this message]
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 ` [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings Heiko Carstens
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-7-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
all inboxes | Powered by JetHome®