Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/64s: Mask NIP before checking against SRR0

When CONFIG_PPC_RFI_SRR_DEBUG=y we check that NIP and SRR0 match when
returning from interrupts. This can trigger falsely if NIP has either of
its two low bits set via sigreturn or ptrace, while SRR0 has its low two
bits masked in hardware.

As a quick fix make sure to mask the low bits before doing the check.

Fixes: 59dc5bfca0cb ("powerpc/64s: avoid reloading (H)SRR registers if they are still valid")
Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Link: https://lore.kernel.org/r/20211221135101.2085547-1-mpe@ellerman.id.au

+2
+2
arch/powerpc/kernel/interrupt_64.S
··· 30 30 .ifc \srr,srr 31 31 mfspr r11,SPRN_SRR0 32 32 ld r12,_NIP(r1) 33 + clrrdi r12,r12,2 33 34 100: tdne r11,r12 34 35 EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE) 35 36 mfspr r11,SPRN_SRR1 ··· 40 39 .else 41 40 mfspr r11,SPRN_HSRR0 42 41 ld r12,_NIP(r1) 42 + clrrdi r12,r12,2 43 43 100: tdne r11,r12 44 44 EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE) 45 45 mfspr r11,SPRN_HSRR1