[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFULd4aY7bb6252YTFdPS4EZWi85Ra2MVr+4hVAP5X5_B8hvyQ@mail.gmail.com>
Date: Sat, 15 Mar 2025 10:09:16 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>, Peter Zijlstra <peterz@...radead.org>,
Borislav Petkov <bp@...en8.de>, "H. Peter Anvin" <hpa@...or.com>, Andrew Cooper <andrew.cooper3@...rix.com>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH 18/20] x86/smap: Use alternative_io() in smap_{save,restore}()
On Fri, Mar 14, 2025 at 10:42 PM Josh Poimboeuf <jpoimboe@...nel.org> wrote:
>
> Use the standard alternative_io() interface.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
> ---
> arch/x86/include/asm/smap.h | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
> index 60ea21b4c8b7..8b77ddcb37e7 100644
> --- a/arch/x86/include/asm/smap.h
> +++ b/arch/x86/include/asm/smap.h
> @@ -39,20 +39,22 @@ static __always_inline unsigned long smap_save(void)
> {
> unsigned long flags;
>
> - asm volatile ("# smap_save\n\t"
> - ALTERNATIVE("",
> - "pushf; pop %[flags]; clac\n\t", X86_FEATURE_SMAP)
> - : [flags] "=rm" (flags) : : "memory", "cc");
> + alternative_io("",
> + "pushf; pop %[flags]; clac\n\t", X86_FEATURE_SMAP,
Please merge two lines above (if possible, otherwise put feature
condition in the next line. Please also remove trailing \n\t.
> + ARG([flags] "=rm" (flags)),
> + ARG(),
> + ARG("memory", "cc"));
>
> return flags;
> }
>
> static __always_inline void smap_restore(unsigned long flags)
> {
> - asm volatile ("# smap_restore\n\t"
> - ALTERNATIVE("",
> - "push %[flags]; popf\n\t", X86_FEATURE_SMAP)
> - : : [flags] "g" (flags) : "memory", "cc");
> + alternative_io("",
> + "push %[flags]; popf\n\t", X86_FEATURE_SMAP,
As above.
> + ARG(),
> + ARG([flags] "g" (flags)),
Uh, a build failure waiting to happen here. Please use "rme" instead
of "g". PUSH doesn't support 64bit immediates ("i") on x86_64 ("g"
expands to "rmi").
Thanks,
Uros.
Powered by blists - more mailing lists