x86/stackprotector/64: Convert to normal per-CPU variable
authorBrian Gerst <brgerst@gmail.com>
Thu, 23 Jan 2025 19:07:39 +0000 (14:07 -0500)
committerIngo Molnar <mingo@kernel.org>
Tue, 18 Feb 2025 09:15:09 +0000 (10:15 +0100)
commit80d47defddc000271502057ebd7efa4fd6481542
tree8b352a713b9f87567eb3d3a4ac1bcc55bc9311ed
parent78c4374ef8b842c6abf195d6f963853c7ec464d2
x86/stackprotector/64: Convert to normal per-CPU variable

Older versions of GCC fixed the location of the stack protector canary
at %gs:40.  This constraint forced the percpu section to be linked at
absolute address 0 so that the canary could be the first data object in
the percpu section.  Supporting the zero-based percpu section requires
additional code to handle relocations for RIP-relative references to
percpu data, extra complexity to kallsyms, and workarounds for linker
bugs due to the use of absolute symbols.

GCC 8.1 supports redefining where the canary is located, allowing it to
become a normal percpu variable instead of at a fixed location.  This
removes the constraint that the percpu section must be zero-based.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250123190747.745588-8-brgerst@gmail.com
arch/x86/Makefile
arch/x86/entry/entry.S
arch/x86/entry/entry_64.S
arch/x86/include/asm/processor.h
arch/x86/include/asm/stackprotector.h
arch/x86/kernel/asm-offsets_64.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/head_64.S
arch/x86/xen/xen-head.S