From: Segher Boessenkool <segher@kernel.crashing.org>
To: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, hbathini@linux.ibm.com,
venkat88@linux.ibm.com, yeswanth@linux.ibm.com
Subject: Re: [PATCH] powerpc/irq: Fix missing r2 clobber in PCREL inline assembly
Date: Mon, 20 Jul 2026 05:25:18 -0500 [thread overview]
Message-ID: <al33jmn9PmMJwYlz@gate> (raw)
In-Reply-To: <dc021f42afa10396052499cbeda1772e30b7ca64.1784530547.git.skb99@linux.ibm.com>
Hi!
On Mon, Jul 20, 2026 at 12:43:47PM +0530, Saket Kumar Bhaskar wrote:
> In CONFIG_PPC_KERNEL_PCREL mode, r2 is no longer reserved for the TOC
> pointer and is available as a caller-saved register [0].
Just like on many more ABIs. Yeah. It's the first that PowerPC Linux
supports though :-)
> Both call_do_irq() and call_do_softirq() use inline assembly to call
> functions with stack switching, but fail to list r2 in their clobber
> lists. This causes the compiler to assume r2 is preserved across these
> calls, leading to register corruption when the called functions
> (__do_irq and __do_softirq) clobber r2.
Yeah.
> index a0e8b998c9b5..26df38bdd334 100644
> --- a/arch/powerpc/kernel/irq.c
> +++ b/arch/powerpc/kernel/irq.c
> @@ -218,7 +218,12 @@ static __always_inline void call_do_softirq(const void *sp)
> [callee] "i" (__do_softirq)
> : // Clobbers
> "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6",
> - "cr7", "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
> + "cr7", "r0",
> + /* r2 is clobbered in PCREL mode */
"Note that r2 may be clobbered in the call, when using the ELF V2 ABI"?
PCREL has nothing to do with it. Well, not directly :-) And the
clobber list does not specify registers that definitely *are* clobbered,
but registers that *may be* clobbered, instead :-) Registers that *are*
clobbered are in the output list (and given a name there so that the new
value can be accessed, etc.)
> +#ifdef CONFIG_PPC_KERNEL_PCREL
> + "r2",
> +#endif
> + "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
> "r11", "r12"
> );
> }
> @@ -276,7 +281,12 @@ static __always_inline void call_do_irq(struct pt_regs *regs, void *sp)
> [callee] "i" (__do_irq)
> : // Clobbers
> "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6",
> - "cr7", "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
> + "cr7", "r0",
> + /* r2 is clobbered in PCREL mode */
> +#ifdef CONFIG_PPC_KERNEL_PCREL
> + "r2",
> +#endif
> + "r4", "r5", "r6", "r7", "r8", "r9", "r10",
> "r11", "r12"
> );
> }
Segher
next prev parent reply other threads:[~2026-07-20 10:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 7:13 [PATCH] powerpc/irq: Fix missing r2 clobber in PCREL inline assembly Saket Kumar Bhaskar
2026-07-20 10:25 ` Segher Boessenkool [this message]
2026-07-22 10:41 ` Saket Kumar Bhaskar
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=al33jmn9PmMJwYlz@gate \
--to=segher@kernel.crashing.org \
--cc=chleroy@kernel.org \
--cc=hbathini@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=skb99@linux.ibm.com \
--cc=venkat88@linux.ibm.com \
--cc=yeswanth@linux.ibm.com \
/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