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

From: Brian Gerst
Date: Tue Nov 30 2021 - 15:58:06 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 how the percpu
section is linked.

Changes from v1:
- Remove fixed location stack protector support

Brian Gerst (6):
x86: Remove stack protector test scripts
x86-64: Convert stack protector to normal percpu variable
x86-64: Use relative per-cpu offsets
x86-64: Remove inverse relocations
kallsyms: Remove KALLSYMS_ABSOLUTE_PERCPU
percpu: Remove PER_CPU_FIRST_SECTION

arch/x86/Kconfig | 7 +-
arch/x86/Makefile | 19 +--
arch/x86/boot/compressed/misc.c | 14 +--
arch/x86/entry/entry_64.S | 2 +-
arch/x86/include/asm/percpu.h | 22 ----
arch/x86/include/asm/processor.h | 25 +---
arch/x86/include/asm/stackprotector.h | 36 ++----
arch/x86/kernel/asm-offsets_64.c | 6 -
arch/x86/kernel/cpu/common.c | 8 +-
arch/x86/kernel/head_64.S | 10 +-
arch/x86/kernel/irq_64.c | 1 -
arch/x86/kernel/setup_percpu.c | 12 +-
arch/x86/kernel/vmlinux.lds.S | 33 -----
arch/x86/tools/relocs.c | 145 +---------------------
arch/x86/xen/xen-head.S | 10 +-
include/asm-generic/vmlinux.lds.h | 1 -
include/linux/percpu-defs.h | 12 --
init/Kconfig | 11 +-
kernel/kallsyms.c | 12 +-
scripts/gcc-x86_32-has-stack-protector.sh | 8 --
scripts/gcc-x86_64-has-stack-protector.sh | 4 -
scripts/kallsyms.c | 68 ++--------
scripts/link-vmlinux.sh | 4 -
23 files changed, 56 insertions(+), 414 deletions(-)
delete mode 100755 scripts/gcc-x86_32-has-stack-protector.sh
delete mode 100755 scripts/gcc-x86_64-has-stack-protector.sh

--
2.31.1