From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Koakuma <koachan@protonmail.com>,
Andreas Larsson <andreas@gaisler.com>,
Sasha Levin <sashal@kernel.org>,
nathan@kernel.org, alexander.deucher@amd.com,
alexandre.f.demers@gmail.com, llvm@lists.linux.dev
Subject: [PATCH AUTOSEL 6.17-5.4] sparc/module: Add R_SPARC_UA64 relocation handling
Date: Sat, 25 Oct 2025 12:01:24 -0400 [thread overview]
Message-ID: <20251025160905.3857885-453-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>
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
prev parent reply other threads:[~2025-10-25 16:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 ` Sasha Levin [this message]
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=20251025160905.3857885-453-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=alexander.deucher@amd.com \
--cc=alexandre.f.demers@gmail.com \
--cc=andreas@gaisler.com \
--cc=koachan@protonmail.com \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=patches@lists.linux.dev \
--cc=stable@vger.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