Re: [PATCH 4/5] x86: shstk: Use the new common vm_mmap_shadow_stack() helper
From: Edgecombe, Rick P
Date: Tue Feb 24 2026 - 14:47:43 EST
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@xxxxxxxxx>
Tested-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
> Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Cc: H. Peter Anvin <hpa@xxxxxxxxx>
> Cc: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
> ---
> 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;