[PATCH v2] compiler: remove __ADDRESSABLE_ASM{_STR,}() again

Jan Beulich posted 1 patch 10 months ago
There is a newer version of this series
[PATCH v2] compiler: remove __ADDRESSABLE_ASM{_STR,}() again
Posted by Jan Beulich 10 months ago
__ADDRESSABLE_ASM_STR() is where the necessary stringification happens.
As long as "sym" doesn't contain any odd characters, no quoting is
required for its use with .quad / .long. In fact the quotation gets in
the way with gas 2.25; it's only from 2.26 onwards that quoted symbols
are half-way properly supported.

However, assembly being different from C anyway, drop
__ADDRESSABLE_ASM_STR() and its helper macro altogether. A simple
.global directive will suffice to get the symbol "declared", i.e. into
the symbol table. While there also stop open-coding STATIC_CALL_TRAMP()
and STATIC_CALL_KEY().

Fixes: 0ef8047b737d ("x86/static-call: provide a way to do very early static-call updates")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: stable@vger.kernel.org
---
v2: Drop constructs instead of fixing them. Use STATIC_CALL_KEY().
---
Whether the "ADDRESSABLE" in __ADDRESSABLE_xen_hypercall is still
meaningful to keep I'm uncertain about. The situation, as said, is quite
different in assembly, compared to C's requirements.

--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -242,14 +242,6 @@ static inline void *offset_to_ptr(const
 #define __ADDRESSABLE(sym) \
 	___ADDRESSABLE(sym, __section(".discard.addressable"))
 
-#define __ADDRESSABLE_ASM(sym)						\
-	.pushsection .discard.addressable,"aw";				\
-	.align ARCH_SEL(8,4);						\
-	ARCH_SEL(.quad, .long) __stringify(sym);			\
-	.popsection;
-
-#define __ADDRESSABLE_ASM_STR(sym) __stringify(__ADDRESSABLE_ASM(sym))
-
 /*
  * This returns a constant expression while determining if an argument is
  * a constant expression, most importantly without evaluating the argument.
--- a/arch/x86/include/asm/xen/hypercall.h
+++ b/arch/x86/include/asm/xen/hypercall.h
@@ -94,12 +94,13 @@ DECLARE_STATIC_CALL(xen_hypercall, xen_h
 #ifdef MODULE
 #define __ADDRESSABLE_xen_hypercall
 #else
-#define __ADDRESSABLE_xen_hypercall __ADDRESSABLE_ASM_STR(__SCK__xen_hypercall)
+#define __ADDRESSABLE_xen_hypercall \
+	__stringify(.global STATIC_CALL_KEY(xen_hypercall);)
 #endif
 
 #define __HYPERCALL					\
 	__ADDRESSABLE_xen_hypercall			\
-	"call __SCT__xen_hypercall"
+	__stringify(call STATIC_CALL_TRAMP(xen_hypercall))
 
 #define __HYPERCALL_ENTRY(x)	"a" (x)
Re: [PATCH v2] compiler: remove __ADDRESSABLE_ASM{_STR,}() again
Posted by Josh Poimboeuf 10 months ago
On Mon, Feb 17, 2025 at 05:40:09PM +0100, Jan Beulich wrote:
> __ADDRESSABLE_ASM_STR() is where the necessary stringification happens.
> As long as "sym" doesn't contain any odd characters, no quoting is
> required for its use with .quad / .long. In fact the quotation gets in
> the way with gas 2.25; it's only from 2.26 onwards that quoted symbols
> are half-way properly supported.
> 
> However, assembly being different from C anyway, drop
> __ADDRESSABLE_ASM_STR() and its helper macro altogether. A simple
> .global directive will suffice to get the symbol "declared", i.e. into
> the symbol table. While there also stop open-coding STATIC_CALL_TRAMP()
> and STATIC_CALL_KEY().
> 
> Fixes: 0ef8047b737d ("x86/static-call: provide a way to do very early static-call updates")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Cc: stable@vger.kernel.org
> ---
> v2: Drop constructs instead of fixing them. Use STATIC_CALL_KEY().
> ---
> Whether the "ADDRESSABLE" in __ADDRESSABLE_xen_hypercall is still
> meaningful to keep I'm uncertain about. The situation, as said, is quite
> different in assembly, compared to C's requirements.

The .global still makes it "addressable", so IMO it's named
appropriately.

Thanks!

Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>

-- 
Josh
Re: [PATCH v2] compiler: remove __ADDRESSABLE_ASM{_STR,}() again
Posted by Jan Beulich 9 months, 1 week ago
On 17.02.2025 21:29, Josh Poimboeuf wrote:
> On Mon, Feb 17, 2025 at 05:40:09PM +0100, Jan Beulich wrote:
>> __ADDRESSABLE_ASM_STR() is where the necessary stringification happens.
>> As long as "sym" doesn't contain any odd characters, no quoting is
>> required for its use with .quad / .long. In fact the quotation gets in
>> the way with gas 2.25; it's only from 2.26 onwards that quoted symbols
>> are half-way properly supported.
>>
>> However, assembly being different from C anyway, drop
>> __ADDRESSABLE_ASM_STR() and its helper macro altogether. A simple
>> .global directive will suffice to get the symbol "declared", i.e. into
>> the symbol table. While there also stop open-coding STATIC_CALL_TRAMP()
>> and STATIC_CALL_KEY().
>>
>> Fixes: 0ef8047b737d ("x86/static-call: provide a way to do very early static-call updates")
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> Cc: stable@vger.kernel.org
>> ---
>> v2: Drop constructs instead of fixing them. Use STATIC_CALL_KEY().
>> ---
>> Whether the "ADDRESSABLE" in __ADDRESSABLE_xen_hypercall is still
>> meaningful to keep I'm uncertain about. The situation, as said, is quite
>> different in assembly, compared to C's requirements.
> 
> The .global still makes it "addressable", so IMO it's named
> appropriately.
> 
> Thanks!
> 
> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>

Since this is addressing a (mild) regression, I wonder if this could still
make 6.14?

Jan