From: Catalin Marinas <catalin.marinas@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Mark Brown <broonie@kernel.org>, Will Deacon <will@kernel.org>,
David Hildenbrand <david@kernel.org>,
Emanuele Rocca <emanuele.rocca@arm.com>,
Mark Rutland <mark.rutland@arm.com>
Subject: [PATCH 3/3] arm64: gcs: Do not map the guarded control stack as THP
Date: Fri, 20 Feb 2026 14:05:31 +0000 [thread overview]
Message-ID: <20260220140532.285011-4-catalin.marinas@arm.com> (raw)
In-Reply-To: <20260220140532.285011-1-catalin.marinas@arm.com>
The default GCS size allocated on first prctl() for the main thread or
subsequently on clone() is either half of RLIMIT_STACK or half of a
thread's stack size. Both of these are likely to be suitable for a THP
allocation and the kernel is more aggressive in creating such mappings.
However, it does not make much sense to use a huge page as it didn't
make sense for the normal stacks either. See commit c4608d1bf7c6 ("mm:
mmap: map MAP_STACK to VM_NOHUGEPAGE").
Force VM_NOHUGEPAGE when allocating/mapping the GCS. As per commit
7190b3c8bd2b ("mm: mmap: map MAP_STACK to VM_NOHUGEPAGE only if THP is
enabled"), only pass this flag if TRANSPARENT_HUGEPAGE is enabled as not
to confuse CRIU tools.
While at it, use the PROT_WRITE prot argument rather than the VM_WRITE
flag when calling do_mmap().
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
---
arch/arm64/mm/gcs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/mm/gcs.c b/arch/arm64/mm/gcs.c
index 6e93f78de79b..bbdb62ae47cd 100644
--- a/arch/arm64/mm/gcs.c
+++ b/arch/arm64/mm/gcs.c
@@ -13,15 +13,19 @@
static unsigned long alloc_gcs(unsigned long addr, unsigned long size)
{
int flags = MAP_ANONYMOUS | MAP_PRIVATE;
+ vm_flags_t vm_flags = VM_SHADOW_STACK;
struct mm_struct *mm = current->mm;
unsigned long mapped_addr, unused;
if (addr)
flags |= MAP_FIXED_NOREPLACE;
+ if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
+ vm_flags |= VM_NOHUGEPAGE;
+
mmap_write_lock(mm);
- mapped_addr = do_mmap(NULL, addr, size, PROT_READ, flags,
- VM_SHADOW_STACK | VM_WRITE, 0, &unused, NULL);
+ mapped_addr = do_mmap(NULL, addr, size, PROT_READ | PROT_WRITE,
+ flags, vm_flags, 0, &unused, NULL);
mmap_write_unlock(mm);
return mapped_addr;
next prev parent reply other threads:[~2026-02-20 14:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 14:05 [PATCH 0/3] arm64: Assorted GCS fixes Catalin Marinas
2026-02-20 14:05 ` [PATCH 1/3] arm64: gcs: Do not set PTE_SHARED on GCS mappings if FEAT_LPA2 is enabled Catalin Marinas
2026-02-20 15:56 ` David Hildenbrand (Arm)
2026-02-20 16:45 ` Catalin Marinas
2026-02-20 16:47 ` Catalin Marinas
2026-02-20 14:05 ` [PATCH 2/3] arm64: gcs: Allow PAGE_NONE mappings for NUMA balancing Catalin Marinas
2026-02-20 16:16 ` David Hildenbrand (Arm)
2026-02-20 19:52 ` Catalin Marinas
2026-02-20 14:05 ` Catalin Marinas [this message]
2026-02-20 14:34 ` [PATCH 3/3] arm64: gcs: Do not map the guarded control stack as THP Mark Brown
2026-02-20 15:13 ` Catalin Marinas
2026-02-20 16:17 ` Mark Brown
2026-02-20 15:33 ` David Hildenbrand (Arm)
2026-02-20 15:36 ` Mark Brown
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=20260220140532.285011-4-catalin.marinas@arm.com \
--to=catalin.marinas@arm.com \
--cc=broonie@kernel.org \
--cc=david@kernel.org \
--cc=emanuele.rocca@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=will@kernel.org \
/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