Re: [PATCH] x86/speculation: Simplify and make CALL_NOSPEC consistent
From: Andrew Cooper
Date: Wed Feb 26 2025 - 19:50:01 EST
On 26/02/2025 9:03 pm, Pawan Gupta wrote:
> @@ -420,20 +420,28 @@ static inline void call_depth_return_thunk(void) {}
>
> #ifdef CONFIG_X86_64
>
> +/*
> + * Equivalent to -mindirect-branch-cs-prefix; emit the 5 byte jmp/call
> + * to the retpoline thunk with a CS prefix when the register requires
> + * a REX prefix byte to encode. Also see apply_retpolines().
> + */
Technically, both comments aren't quite accurate. __CS_PREFIX() emits a
conditional CS prefix in a manner compatible with
-mindirect-branch-cs-prefix, not the full 5/6 byte jmp/call.
> +#define __CS_PREFIX(reg) \
> + .irp rs,r8,r9,r10,r11,r12,r13,r14,r15; \
> + .ifc \\rs, \reg; \
Why are these escaped differently? Given they're all \r of some form or
another, I guess something is going wonky with __stringify(), but its
still weird for them to be different.
Do you have a fully pre-processed source to hand to see how CALL_NOSPEC
ends up?
~Andrew