Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb+git@google.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>, Uros Bizjak <ubizjak@gmail.com>,
	 Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	llvm@lists.linux.dev
Subject: [PATCH 0/2] x86: replace stack cookie hack with named address space
Date: Fri, 27 Nov 2026 15:23:47 +0100	[thread overview]
Message-ID: <20261127142346.788995-4-ardb+git@google.com> (raw)

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


             reply	other threads:[~2026-11-27 14:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 14:23 Ard Biesheuvel [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127142346.788995-4-ardb+git@google.com \
    --to=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=ubizjak@gmail.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox