[PATCH 0/3] x86-64: Stack protector and percpu improvements

From: Brian Gerst
Date: Sat Nov 13 2021 - 07:41:46 EST


Currently, x86-64 uses an unusual per-cpu layout, where the percpu section
is linked at absolute address 0. The reason behind this is that older GCC
versions placed the stack protector (if enabled) at a fixed offset from the
GS segment base. Since the GS segement is also used for percpu variables,
this forced the current layout.

GCC since version 8.1 supports a configurable location for the stack
protector value, which allows removal of the restriction on where the percpu
data is linked. Compatibility with older compilers is maintained until
the minimum compiler version is raised.

Brian Gerst (3):
x86-64: Use per-cpu stack canary if supported by compiler
x86/relocs: Make absolute percpu relocations conditional
x86_64: Use relative per-cpu offsets

arch/x86/Kconfig | 9 +++++++++
arch/x86/Makefile | 21 ++++++++++++++-------
arch/x86/boot/compressed/Makefile | 3 ++-
arch/x86/entry/entry_64.S | 6 +++++-
arch/x86/include/asm/percpu.h | 4 ++--
arch/x86/include/asm/processor.h | 14 +++++++++++---
arch/x86/include/asm/stackprotector.h | 17 ++++++-----------
arch/x86/kernel/asm-offsets_64.c | 2 +-
arch/x86/kernel/cpu/common.c | 14 ++++++++------
arch/x86/kernel/head_64.S | 12 ++++++++----
arch/x86/kernel/setup_percpu.c | 2 +-
arch/x86/kernel/vmlinux.lds.S | 16 +++++++---------
arch/x86/tools/relocs.c | 4 ++--
arch/x86/tools/relocs.h | 4 ++--
arch/x86/tools/relocs_common.c | 11 ++++++++---
arch/x86/xen/xen-head.S | 10 ++++------
init/Kconfig | 1 -
17 files changed, 90 insertions(+), 60 deletions(-)

--
2.31.1