Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH 0/2] x86: replace stack cookie hack with named address space
@ 2026-11-27 14:23 Ard Biesheuvel
  2026-11-27 14:23 ` [PATCH 1/2] compiler.h: Use the symbol's own pointer type in __ADDRESSABLE() Ard Biesheuvel
  2026-11-27 14:23 ` [PATCH 2/2] x86/stackprotector: Use a named address space for the Clang stack guard Ard Biesheuvel
  0 siblings, 2 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2026-11-27 14:23 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Ard Biesheuvel, Uros Bizjak, Nathan Chancellor, Nick Desaulniers,
	llvm

From: Ard Biesheuvel <ardb@kernel.org>

Currently, on x86, the C name of the stack check cookie per-CPU variable
is deliberately different from the one passed to the compiler command
line option -mstack-check-guard-symbol=

This was done to work around a Clang issue, where a non-TLS C
declaration of the variable results in Clang dropping the segment
prefixes.

As it turns out, all Clang versions that Linux supports today have some
support for address space annotations, and annotating the C declaration
with the correct address space is sufficient to coerce Clang into
generating the appropriate prefixes for the memory operands. This means
the linker and asm hacks can be dropped.

Patch #1 makes EXPORT_SYMBOL() work as expected for symbols with an
address space annotation, so that patch #2 can export __stack_chk_guard
normally, rather than from an unrelated .S file.

Cc: Uros Bizjak <ubizjak@gmail.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: llvm@lists.linux.dev

Ard Biesheuvel (2):
  compiler.h: Use the symbol's own pointer type in __ADDRESSABLE()
  x86/stackprotector: Use a named address space for the Clang stack
    guard

 arch/x86/Makefile                     |  2 +-
 arch/x86/entry/entry.S                | 14 ----------
 arch/x86/include/asm/asm-prototypes.h |  4 ---
 arch/x86/include/asm/percpu.h         | 10 +++----
 arch/x86/include/asm/stackprotector.h | 29 ++++++++++++++++++--
 arch/x86/kernel/cpu/common.c          |  4 +--
 arch/x86/kernel/vmlinux.lds.S         |  3 --
 include/linux/compiler.h              |  4 +--
 8 files changed, 35 insertions(+), 35 deletions(-)

-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-27 14:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 14:23 [PATCH 0/2] x86: replace stack cookie hack with named address space Ard Biesheuvel
2026-11-27 14:23 ` [PATCH 1/2] compiler.h: Use the symbol's own pointer type in __ADDRESSABLE() Ard Biesheuvel
2026-11-27 14:23 ` [PATCH 2/2] x86/stackprotector: Use a named address space for the Clang stack guard Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox