Re: [PATCH 17/20] x86/smap: Use named asm operands in smap_{save,restore}()

From: Andrew Cooper
Date: Fri Mar 14 2025 - 18:51:46 EST


On 14/03/2025 9:41 pm, Josh Poimboeuf wrote:
> @@ -50,9 +50,9 @@ static __always_inline unsigned long smap_save(void)
> static __always_inline void smap_restore(unsigned long flags)
> {
> asm volatile ("# smap_restore\n\t"
> - ALTERNATIVE("", "push %0; popf\n\t",
> - X86_FEATURE_SMAP)
> - : : "g" (flags) : "memory", "cc");
> + ALTERNATIVE("",
> + "push %[flags]; popf\n\t", X86_FEATURE_SMAP)
> + : : [flags] "g" (flags) : "memory", "cc");
> }
>
> /* These macros can be used in asm() statements */

The problem with ASM_CALL_CONSTRAINT and asm_call() is that it's not
just call instructions.  It's any transient stack adjustment.

Peeking forwards the other half of the series, you convert IRET to
asm_call(), but leave these alone.

These need converting, and hopefully someone can think of a better name
than "call" to be used for the wrapper.

~Andrew