x86/asm: Avoid adding register pressure for the init case in static_cpu_has()
authorH. Peter Anvin <hpa@zytor.com>
Fri, 10 Sep 2021 19:59:10 +0000 (12:59 -0700)
committerBorislav Petkov <bp@suse.de>
Mon, 13 Sep 2021 17:48:21 +0000 (19:48 +0200)
commit0507503671f9b1c867e889cbec0f43abf904f23c
treedc450d3175376738a808e4e62505b34e3d6f3cc1
parentf87bc8dc7a7c438c70f97b4e51c76a183313272e
x86/asm: Avoid adding register pressure for the init case in static_cpu_has()

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().

While making changes, modernize the code to use
.pushsection...popsection instead of .section...previous.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210910195910.2542662-4-hpa@zytor.com
arch/x86/include/asm/cpufeature.h