Re: [PATCH v2 0/2] x86/asm: avoid register pressure from static_cpu_has()

From: Borislav Petkov
Date: Fri Sep 10 2021 - 05:17:01 EST


On Thu, Sep 09, 2021 at 03:08:16PM -0700, H. Peter Anvin (Intel) wrote:
> gcc will sometimes manifest the address of boot_cpu_data in a register
> as part of constant propagation. When multiple static_cpu_has() are
> used this may foul the mainline code with a register load which will
> only be used on the fallback path, which is unused after
> initialization.
>
> Explicitly force gcc to use immediate (rip-relative) addressing for
> the fallback path, thus removing any possible register use from
> static_cpu_has().

Right, maybe I'm missing something but what is wrong with the immediate
addressing variant, i.e., that thing:

testb $0x8,0xffffffff89346eea

and you need to *force* %rip-relative?

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette