From: Stian Halseth <stian@itx.no>
To: "David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Naveen N Rao <naveen@kernel.org>,
Danish Khateeb <danishkhateeb03@gmail.com>,
sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org, Stian Halseth <stian@itx.no>
Subject: [PATCH v2 2/4] sparc64: kprobes: Fix up register and FP branches after single-step
Date: Fri, 13 Nov 2026 15:40:55 +0100 [thread overview]
Message-ID: <20261113144057.1697874-3-stian@itx.no> (raw)
In-Reply-To: <20261113144057.1697874-1-stian@itx.no>
relbranch_fixup() moves the target of a PC-relative branch from the
single-step slot back to the probed instruction. It only knows call,
Bicc and BPcc. A taken BPr (brz, brnz, ...) or FBPfcc/FBfcc is left
alone. Execution resumes at the target relative to the slot:
Unable to handle kernel paging request at virtual address 000000000fffff98
TPC: <0xfffff98>
Treat them like the other PC-relative branches.
Link: https://github.com/sparclinux/issues/issues/110
Signed-off-by: Stian Halseth <stian@itx.no>
---
arch/sparc/kernel/kprobes.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/sparc/kernel/kprobes.c b/arch/sparc/kernel/kprobes.c
index 608efda8cb948..38e6d9b51a207 100644
--- a/arch/sparc/kernel/kprobes.c
+++ b/arch/sparc/kernel/kprobes.c
@@ -219,12 +219,15 @@ static unsigned long __kprobes relbranch_fixup(u32 insn, struct kprobe *p,
if (regs->tnpc == regs->tpc + 0x4UL)
return real_pc + 0x8UL;
- /* The three cases are call, branch w/prediction,
- * and traditional branch.
+ /* The cases are call and the branches BPcc, Bicc, BPr, FBPfcc
+ * and FBfcc.
*/
if ((insn & 0xc0000000) == 0x40000000 ||
(insn & 0xc1c00000) == 0x00400000 ||
- (insn & 0xc1c00000) == 0x00800000) {
+ (insn & 0xc1c00000) == 0x00800000 ||
+ (insn & 0xc1c00000) == 0x00c00000 ||
+ (insn & 0xc1c00000) == 0x01400000 ||
+ (insn & 0xc1c00000) == 0x01800000) {
unsigned long ainsn_addr;
ainsn_addr = (unsigned long) &p->ainsn.insn[0];
--
2.43.0
next prev parent reply other threads:[~2026-11-13 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 14:40 [PATCH v2 0/4] sparc64: kprobes: Make kprobes work on sun4v Stian Halseth
2026-11-13 14:40 ` [PATCH v2 1/4] sparc64: kprobes: Single-step from an executable instruction slot Stian Halseth
2026-11-13 14:40 ` Stian Halseth [this message]
2026-11-13 14:40 ` [PATCH v2 3/4] sparc64: kprobes: Resume after a delay slot at the saved next PC Stian Halseth
2026-11-13 14:47 ` sashiko-bot
2026-11-13 14:40 ` [PATCH v2 4/4] sparc64: kprobes: Handle annulled branches Stian Halseth
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=20261113144057.1697874-3-stian@itx.no \
--to=stian@itx.no \
--cc=andreas@gaisler.com \
--cc=danishkhateeb03@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen@kernel.org \
--cc=sparclinux@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