mirror of https://lore.kernel.org/lkml/
 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 1/2] compiler.h: Use the symbol's own pointer type in __ADDRESSABLE()
Date: Fri, 27 Nov 2026 15:23:48 +0100	[thread overview]
Message-ID: <20261127142346.788995-5-ardb+git@google.com> (raw)
In-Reply-To: <20261127142346.788995-4-ardb+git@google.com>

From: Ard Biesheuvel <ardb@kernel.org>

Casting the address of a variable in a named address space to void * is
rejected by GCC, which is why it is currently cast via uintptr_t. Clang
folds that into an addrspacecast, which it cannot emit in a static
initializer, preventing such variables from being exported.

Use a pointer of the symbol's own type instead, which needs no cast at
all.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 include/linux/compiler.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 0ea7150dba7b..9983f8eed085 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -286,8 +286,8 @@ static inline void *offset_to_ptr(const int *off)
  * visible to the compiler.
  */
 #define ___ADDRESSABLE(sym, __attrs)						\
-	static void * __used __attrs						\
-	__UNIQUE_ID(__PASTE(addressable_, sym)) = (void *)(uintptr_t)&sym;
+	static typeof(&sym) __used __attrs					\
+	__UNIQUE_ID(__PASTE(addressable_, sym)) = &sym;
 
 #define __ADDRESSABLE(sym) \
 	___ADDRESSABLE(sym, __section(".discard.addressable"))
-- 
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 [PATCH 0/2] x86: replace stack cookie hack with named address space Ard Biesheuvel
2026-11-27 14:23 ` Ard Biesheuvel [this message]
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-5-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

all inboxes | Powered by JetHome®