[PATCH 4/5] x86: shstk: Use the new common vm_mmap_shadow_stack() helper
Edgecombe, Rick P
rick.p.edgecombe at intel.com
Tue Feb 24 11:47:14 PST 2026
On Tue, 2026-02-24 at 17:57 +0000, Catalin Marinas wrote:
> Replace part of the x86 alloc_shstk() content with a call to
> vm_mmap_shadow_stack().
>
I ran it through the selftest. It would be nice to have a bit more information
in the log, like that there is no functional change. Otherwise,
Reviewed-by: Rick Edgecombe <rick.p.edgecombe at intel.com>
Tested-by: Rick Edgecombe <rick.p.edgecombe at intel.com>
> Signed-off-by: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Thomas Gleixner <tglx at kernel.org>
> Cc: Ingo Molnar <mingo at redhat.com>
> Cc: Borislav Petkov <bp at alien8.de>
> Cc: Dave Hansen <dave.hansen at linux.intel.com>
> Cc: H. Peter Anvin <hpa at zytor.com>
> Cc: Rick Edgecombe <rick.p.edgecombe at intel.com>
> ---
> arch/x86/kernel/shstk.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c
> index 978232b6d48d..9725e7d89b1e 100644
> --- a/arch/x86/kernel/shstk.c
> +++ b/arch/x86/kernel/shstk.c
> @@ -100,17 +100,9 @@ static int create_rstor_token(unsigned long ssp, unsigned long *token_addr)
> static unsigned long alloc_shstk(unsigned long addr, unsigned long size,
> unsigned long token_offset, bool set_res_tok)
> {
> - int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_ABOVE4G;
> - struct mm_struct *mm = current->mm;
> - unsigned long mapped_addr, unused;
> + unsigned long mapped_addr;
>
> - if (addr)
> - flags |= MAP_FIXED_NOREPLACE;
> -
> - mmap_write_lock(mm);
> - mapped_addr = do_mmap(NULL, addr, size, PROT_READ, flags,
> - VM_SHADOW_STACK | VM_WRITE, 0, &unused, NULL);
> - mmap_write_unlock(mm);
> + mapped_addr = vm_mmap_shadow_stack(addr, size, MAP_ABOVE4G);
>
> if (!set_res_tok || IS_ERR_VALUE(mapped_addr))
> goto out;
More information about the linux-arm-kernel
mailing list