[PATCH 2/3] sparc64: use the fault address for si_addr on window fixup faults

From: Stian Halseth

Date: Fri Aug 28 2026 - 08:38:08 EST


do_fault_siginfo() prefers an address decoded from the instruction at
regs->tpc whenever one could be probed, falling back to the fault time
address only when it could not.

That premise does not hold for a fault taken during a register window
spill or fill. There the instruction at regs->tpc is the one being
resumed, not the access that faulted, so compute_effective_address()
fabricates an address out of unrelated register contents. In one
capture it decoded a branch and reported the value it found in %g5 as
si_addr.

Use the fault time address for FAULT_CODE_WINFIXUP. It may only have
page granularity, but it is the address that actually faulted.

Fixes: 70ffc6ebaead ("sparc64: Fix top-level fault handling bugs.")
Link: https://github.com/sparclinux/issues/issues/87
Signed-off-by: Stian Halseth <stian@xxxxxx>
---
arch/sparc/mm/fault_64.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
index e326caf708c6..c37b24f757f4 100644
--- a/arch/sparc/mm/fault_64.c
+++ b/arch/sparc/mm/fault_64.c
@@ -165,6 +165,15 @@ static void do_fault_siginfo(int code, int sig, struct pt_regs *regs,

if (fault_code & FAULT_CODE_ITLB) {
addr = regs->tpc;
+ } else if (fault_code & FAULT_CODE_WINFIXUP) {
+ /* The fault came from a register window spill or fill, so
+ * the instruction at regs->tpc is the one being resumed,
+ * not the access that faulted. Decoding it would fabricate
+ * an address out of unrelated register contents; the fault
+ * time provided address is the real one, even if it only
+ * has page granularity.
+ */
+ addr = fault_addr;
} else {
/* If we were able to probe the faulting instruction, use it
* to compute a precise fault address. Otherwise use the fault
--
2.43.0