* [PATCH AUTOSEL 6.17-5.4] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8
[not found] <20251025160905.3857885-1-sashal@kernel.org>
@ 2025-10-25 15:54 ` Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.4] sparc/module: Add R_SPARC_UA64 relocation handling Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2025-10-25 15:54 UTC (permalink / raw)
To: patches, stable
Cc: Wake Liu, Jakub Kicinski, Sasha Levin, davem, edumazet, pabeni,
nathan, netdev, llvm
From: Wake Liu <wakel@google.com>
[ Upstream commit c36748e8733ef9c5f4cd1d7c4327994e5b88b8df ]
The `__WORDSIZE` macro, defined in the non-standard `<bits/wordsize.h>`
header, is a GNU extension and not universally available with all
toolchains, such as Clang when used with musl libc.
This can lead to build failures in environments where this header is
missing.
The intention of the code is to determine the bit width of a C `long`.
Replace the non-portable `__WORDSIZE` with the standard and portable
`sizeof(long) * 8` expression to achieve the same result.
This change also removes the inclusion of the now-unused
`<bits/wordsize.h>` header.
Signed-off-by: Wake Liu <wakel@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES
- What it fixes
- Fixes selftest build failures on toolchains without GNU
`<bits/wordsize.h>` (e.g., Clang with musl). The current code
directly includes a GNU-internal header and uses a GNU extension
macro.
- Evidence: direct inclusion at
`tools/testing/selftests/net/psock_tpacket.c:36` and use of
`__WORDSIZE` at `tools/testing/selftests/net/psock_tpacket.c:788`.
- Change details
- Removes non-standard header include: `#include <bits/wordsize.h>`
(tools/testing/selftests/net/psock_tpacket.c:36).
- Replaces non-portable `__WORDSIZE` with the portable and standard-
compliant `sizeof(long) * 8` inside `test_user_bit_width()`
(tools/testing/selftests/net/psock_tpacket.c:788 → now returns
`sizeof(long) * 8`).
- No other functional changes; all behavior, interfaces, and test
logic remain intact.
- Behavioral impact
- The intent of `test_user_bit_width()` is to report the userspace
“word” width as used by the test to decide whether to skip
TPACKET_V1 when user/kernel bit widths differ (see its use in
`test_tpacket()` adjacent to
tools/testing/selftests/net/psock_tpacket.c:811).
- On Linux ABIs, `__WORDSIZE` effectively matches the bit width of
`long`. Using `sizeof(long) * 8` is semantically equivalent across
LP64 and ILP32, including x86_64 ILP32 (x32), where it returns 32
and properly triggers the intended skip path when comparing to the
kernel’s 64-bit width parsed from `/proc/kallsyms`.
- Therefore, no functional change to test behavior, only improved
portability.
- Scope and risk
- Selftests-only change (single file), no kernel code touched.
- Very small and contained: removal of one include and a one-line
return expression change.
- No architectural changes; no side effects beyond enabling builds on
non-glibc toolchains.
- Aligns with existing tools-side practice:
`tools/include/linux/bitops.h` already falls back to a portable
definition of `__WORDSIZE` via `__SIZEOF_LONG__ * 8`, reinforcing
that using the C type width is the right approach.
- Stable backport criteria
- Addresses a real user-facing bug: selftests fail to build on
legitimate toolchains (Clang + musl).
- Minimal risk and fully contained to a test; no runtime kernel
impact.
- Not a new feature; purely a portability/build fix.
- Touches a non-critical subtree (selftests), commonly accepted for
stable when it fixes build or test breakages.
Conclusion: This is a low-risk, portability/build fix for selftests with
no kernel runtime impact and should be backported to stable.
tools/testing/selftests/net/psock_tpacket.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
index 221270cee3eaa..0dd909e325d93 100644
--- a/tools/testing/selftests/net/psock_tpacket.c
+++ b/tools/testing/selftests/net/psock_tpacket.c
@@ -33,7 +33,6 @@
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
-#include <bits/wordsize.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
@@ -785,7 +784,7 @@ static int test_kernel_bit_width(void)
static int test_user_bit_width(void)
{
- return __WORDSIZE;
+ return sizeof(long) * 8;
}
static const char *tpacket_str[] = {
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH AUTOSEL 6.17-5.4] sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers
[not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.4] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8 Sasha Levin
@ 2025-10-25 15:57 ` Sasha Levin
2025-10-27 8:09 ` Andreas Larsson
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.4] sparc/module: Add R_SPARC_UA64 relocation handling Sasha Levin
2 siblings, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2025-10-25 15:57 UTC (permalink / raw)
To: patches, stable
Cc: Thomas Huth, David S. Miller, Andreas Larsson, sparclinux,
Sasha Levin, nathan, alexandre.f.demers, alexander.deucher, llvm
From: Thomas Huth <thuth@redhat.com>
[ Upstream commit d6fb6511de74bd0d4cb4cabddae9b31d533af1c1 ]
__ASSEMBLY__ is only defined by the Makefile of the kernel, so
this is not really useful for uapi headers (unless the userspace
Makefile defines it, too). Let's switch to __ASSEMBLER__ which
gets set automatically by the compiler when compiling assembly
code.
This is a completely mechanical patch (done with a simple "sed -i"
statement).
Cc: David S. Miller <davem@davemloft.net>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES – Replacing the guard macro with `__ASSEMBLER__` in the SPARC UAPI
headers fixes a real user-space build break for assembly consumers with
negligible regression risk.
- `arch/sparc/include/uapi/asm/ptrace.h:18`,
`arch/sparc/include/uapi/asm/signal.h:108`,
`arch/sparc/include/uapi/asm/traps.h:13`, and
`arch/sparc/include/uapi/asm/utrap.h:47` now test `__ASSEMBLER__`,
which every assembler run by GCC/Clang defines automatically;
previously the check keyed on `__ASSEMBLY__`, a macro only injected by
the kernel’s own Makefiles.
- With the old guard, external SPARC assembly that includes these public
headers would see the C struct/type definitions and fail to assemble;
the new guard restores the intended split between C and assembly
views, so this is a direct usability fix for real-world toolchains.
- Normal C compilation remains untouched because neither `__ASSEMBLY__`
nor `__ASSEMBLER__` are defined there, so the change is behavior-
neutral for existing C users.
- Kernel-internal headers already rely on `__ASSEMBLER__` (e.g.,
`arch/sparc/include/asm/ptrace.h:8`), so this aligns the UAPI side
with established SPARC practice and does not introduce new concepts.
- The patch is purely mechanical and localized to guard macros, touching
no generated code or data layouts, which keeps regression risk
extremely low while resolving the user-visible build failure.
arch/sparc/include/uapi/asm/ptrace.h | 24 ++++++++++++------------
arch/sparc/include/uapi/asm/signal.h | 4 ++--
arch/sparc/include/uapi/asm/traps.h | 4 ++--
arch/sparc/include/uapi/asm/utrap.h | 4 ++--
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/arch/sparc/include/uapi/asm/ptrace.h b/arch/sparc/include/uapi/asm/ptrace.h
index abe640037a55d..2eb677f4eb6ab 100644
--- a/arch/sparc/include/uapi/asm/ptrace.h
+++ b/arch/sparc/include/uapi/asm/ptrace.h
@@ -15,7 +15,7 @@
*/
#define PT_REGS_MAGIC 0x57ac6c00
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
#include <linux/types.h>
@@ -88,7 +88,7 @@ struct sparc_trapf {
unsigned long _unused;
struct pt_regs *regs;
};
-#endif /* (!__ASSEMBLY__) */
+#endif /* (!__ASSEMBLER__) */
#else
/* 32 bit sparc */
@@ -97,7 +97,7 @@ struct sparc_trapf {
/* This struct defines the way the registers are stored on the
* stack during a system call and basically all traps.
*/
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
#include <linux/types.h>
@@ -125,11 +125,11 @@ struct sparc_stackf {
unsigned long xargs[6];
unsigned long xxargs[1];
};
-#endif /* (!__ASSEMBLY__) */
+#endif /* (!__ASSEMBLER__) */
#endif /* (defined(__sparc__) && defined(__arch64__))*/
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
#define TRACEREG_SZ sizeof(struct pt_regs)
#define STACKFRAME_SZ sizeof(struct sparc_stackf)
@@ -137,7 +137,7 @@ struct sparc_stackf {
#define TRACEREG32_SZ sizeof(struct pt_regs32)
#define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
-#endif /* (!__ASSEMBLY__) */
+#endif /* (!__ASSEMBLER__) */
#define UREG_G0 0
#define UREG_G1 1
@@ -161,30 +161,30 @@ struct sparc_stackf {
#if defined(__sparc__) && defined(__arch64__)
/* 64 bit sparc */
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
-#else /* __ASSEMBLY__ */
+#else /* __ASSEMBLER__ */
/* For assembly code. */
#define TRACEREG_SZ 0xa0
#define STACKFRAME_SZ 0xc0
#define TRACEREG32_SZ 0x50
#define STACKFRAME32_SZ 0x60
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLER__ */
#else /* (defined(__sparc__) && defined(__arch64__)) */
/* 32 bit sparc */
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
-#else /* (!__ASSEMBLY__) */
+#else /* (!__ASSEMBLER__) */
/* For assembly code. */
#define TRACEREG_SZ 0x50
#define STACKFRAME_SZ 0x60
-#endif /* (!__ASSEMBLY__) */
+#endif /* (!__ASSEMBLER__) */
#endif /* (defined(__sparc__) && defined(__arch64__)) */
diff --git a/arch/sparc/include/uapi/asm/signal.h b/arch/sparc/include/uapi/asm/signal.h
index b613829247250..9c64d7cb85c2a 100644
--- a/arch/sparc/include/uapi/asm/signal.h
+++ b/arch/sparc/include/uapi/asm/signal.h
@@ -105,7 +105,7 @@
#define __old_sigaction32 sigaction32
#endif
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
typedef unsigned long __old_sigset_t; /* at least 32 bits */
@@ -176,6 +176,6 @@ typedef struct sigaltstack {
} stack_t;
-#endif /* !(__ASSEMBLY__) */
+#endif /* !(__ASSEMBLER__) */
#endif /* _UAPI__SPARC_SIGNAL_H */
diff --git a/arch/sparc/include/uapi/asm/traps.h b/arch/sparc/include/uapi/asm/traps.h
index 930db746f8bd7..43fe5b8fe8be1 100644
--- a/arch/sparc/include/uapi/asm/traps.h
+++ b/arch/sparc/include/uapi/asm/traps.h
@@ -10,8 +10,8 @@
#define NUM_SPARC_TRAPS 255
-#ifndef __ASSEMBLY__
-#endif /* !(__ASSEMBLY__) */
+#ifndef __ASSEMBLER__
+#endif /* !(__ASSEMBLER__) */
/* For patching the trap table at boot time, we need to know how to
* form various common Sparc instructions. Thus these macros...
diff --git a/arch/sparc/include/uapi/asm/utrap.h b/arch/sparc/include/uapi/asm/utrap.h
index d890b7fc6e835..a489b08b6a33d 100644
--- a/arch/sparc/include/uapi/asm/utrap.h
+++ b/arch/sparc/include/uapi/asm/utrap.h
@@ -44,9 +44,9 @@
#define UTH_NOCHANGE (-1)
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
typedef int utrap_entry_t;
typedef void *utrap_handler_t;
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLER__ */
#endif /* !(__ASM_SPARC64_PROCESSOR_H) */
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH AUTOSEL 6.17-5.4] sparc/module: Add R_SPARC_UA64 relocation handling
[not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.4] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8 Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers Sasha Levin
@ 2025-10-25 16:01 ` Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2025-10-25 16:01 UTC (permalink / raw)
To: patches, stable
Cc: Koakuma, Andreas Larsson, Sasha Levin, nathan, alexander.deucher,
alexandre.f.demers, llvm
From: Koakuma <koachan@protonmail.com>
[ Upstream commit 05457d96175d25c976ab6241c332ae2eb5e07833 ]
This is needed so that the kernel can handle R_SPARC_UA64 relocations,
which is emitted by LLVM's IAS.
Signed-off-by: Koakuma <koachan@protonmail.com>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES – this patch fixes a real module-loading bug for sparc64 systems
without touching unrelated code.
- `arch/sparc/include/asm/elf_64.h:61` adds the missing ABI constant
`R_SPARC_UA64` (value 54), so the loader can even recognise
relocations that LLVM’s integrated assembler already emits.
- `arch/sparc/kernel/module.c:90` folds `R_SPARC_UA64` into the existing
`R_SPARC_64` handler, writing the eight relocation bytes individually
just like the aligned case. Without this case the switch drops into
the default branch (`module.c:134`) and aborts module loading with
“Unknown relocation” and `-ENOEXEC`, so clang-built modules simply
cannot load today.
- Scope and risk stay minimal: the bytes written are identical to the
long-standing `R_SPARC_64` path, so nothing changes for GCC-produced
objects; the new code only runs when the UA64 relocation is present,
avoiding regressions elsewhere.
Given it unbreaks a supported toolchain configuration with a tiny, well-
contained fix, this is an appropriate stable backport.
arch/sparc/include/asm/elf_64.h | 1 +
arch/sparc/kernel/module.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
index 8fb09eec8c3e7..694ed081cf8d9 100644
--- a/arch/sparc/include/asm/elf_64.h
+++ b/arch/sparc/include/asm/elf_64.h
@@ -58,6 +58,7 @@
#define R_SPARC_7 43
#define R_SPARC_5 44
#define R_SPARC_6 45
+#define R_SPARC_UA64 54
/* Bits present in AT_HWCAP, primarily for Sparc32. */
#define HWCAP_SPARC_FLUSH 0x00000001
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index b8c51cc23d969..6e3d4dde4f9ab 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -87,6 +87,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
break;
#ifdef CONFIG_SPARC64
case R_SPARC_64:
+ case R_SPARC_UA64:
location[0] = v >> 56;
location[1] = v >> 48;
location[2] = v >> 40;
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH AUTOSEL 6.17-5.4] sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers Sasha Levin
@ 2025-10-27 8:09 ` Andreas Larsson
2025-11-04 14:14 ` Sasha Levin
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Larsson @ 2025-10-27 8:09 UTC (permalink / raw)
To: Sasha Levin, patches, stable
Cc: Thomas Huth, David S. Miller, sparclinux, nathan,
alexandre.f.demers, alexander.deucher, llvm
On 2025-10-25 17:57, Sasha Levin wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> [ Upstream commit d6fb6511de74bd0d4cb4cabddae9b31d533af1c1 ]
>
> __ASSEMBLY__ is only defined by the Makefile of the kernel, so
> this is not really useful for uapi headers (unless the userspace
> Makefile defines it, too). Let's switch to __ASSEMBLER__ which
> gets set automatically by the compiler when compiling assembly
> code.
>
> This is a completely mechanical patch (done with a simple "sed -i"
> statement).
>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Andreas Larsson <andreas@gaisler.com>
> Cc: sparclinux@vger.kernel.org
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Andreas Larsson <andreas@gaisler.com>
> Signed-off-by: Andreas Larsson <andreas@gaisler.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
The upstream commit dc356bf3c173 ("sparc: Drop the "-ansi" from the asflags") is
a prerequisite to d6fb6511de74 ("sparc: Replace __ASSEMBLY__ with __ASSEMBLER__
in uapi headers") that here is planned to be picked up to stable branches. If
this prerequisite is not picked up first the kernel will not compile [1].
[1] https://lore.kernel.org/all/810a8ec4-e416-42b6-97bf-8a56f41deea1@redhat.com/
Cheers,
Andreas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH AUTOSEL 6.17-5.4] sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers
2025-10-27 8:09 ` Andreas Larsson
@ 2025-11-04 14:14 ` Sasha Levin
0 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2025-11-04 14:14 UTC (permalink / raw)
To: Andreas Larsson
Cc: patches, stable, Thomas Huth, David S. Miller, sparclinux, nathan,
alexandre.f.demers, alexander.deucher, llvm
On Mon, Oct 27, 2025 at 09:09:17AM +0100, Andreas Larsson wrote:
>On 2025-10-25 17:57, Sasha Levin wrote:
>> From: Thomas Huth <thuth@redhat.com>
>>
>> [ Upstream commit d6fb6511de74bd0d4cb4cabddae9b31d533af1c1 ]
>>
>> __ASSEMBLY__ is only defined by the Makefile of the kernel, so
>> this is not really useful for uapi headers (unless the userspace
>> Makefile defines it, too). Let's switch to __ASSEMBLER__ which
>> gets set automatically by the compiler when compiling assembly
>> code.
>>
>> This is a completely mechanical patch (done with a simple "sed -i"
>> statement).
>>
>> Cc: David S. Miller <davem@davemloft.net>
>> Cc: Andreas Larsson <andreas@gaisler.com>
>> Cc: sparclinux@vger.kernel.org
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> Reviewed-by: Andreas Larsson <andreas@gaisler.com>
>> Signed-off-by: Andreas Larsson <andreas@gaisler.com>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>> ---
>
>The upstream commit dc356bf3c173 ("sparc: Drop the "-ansi" from the asflags") is
>a prerequisite to d6fb6511de74 ("sparc: Replace __ASSEMBLY__ with __ASSEMBLER__
>in uapi headers") that here is planned to be picked up to stable branches. If
>this prerequisite is not picked up first the kernel will not compile [1].
I'll drop this commit. Thanks!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-04 14:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.4] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8 Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers Sasha Levin
2025-10-27 8:09 ` Andreas Larsson
2025-11-04 14:14 ` Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.4] sparc/module: Add R_SPARC_UA64 relocation handling Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox