Commit 4f8e0910 authored by Rohan McLure's avatar Rohan McLure Committed by Michael Ellerman

powerpc/kcsan: Prevent recursive instrumentation with IRQ save/restores

Instrumented memory accesses provided by KCSAN will access core-local
memories (which will save and restore IRQs) as well as restoring IRQs
directly. Avoid recursive instrumentation by applying __no_kcsan
annotation to IRQ restore routines.
Signed-off-by: default avatarRohan McLure <rmclure@linux.ibm.com>
[mpe: Resolve merge conflict with IRQ replay recursion changes]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230206021801.105268-5-rmclure@linux.ibm.com
parent b6e25929
...@@ -94,7 +94,7 @@ static inline bool irq_happened_test_and_clear(u8 irq) ...@@ -94,7 +94,7 @@ static inline bool irq_happened_test_and_clear(u8 irq)
return false; return false;
} }
static void __replay_soft_interrupts(void) static __no_kcsan void __replay_soft_interrupts(void)
{ {
struct pt_regs regs; struct pt_regs regs;
...@@ -171,7 +171,7 @@ static void __replay_soft_interrupts(void) ...@@ -171,7 +171,7 @@ static void __replay_soft_interrupts(void)
local_paca->irq_happened &= ~PACA_IRQ_REPLAYING; local_paca->irq_happened &= ~PACA_IRQ_REPLAYING;
} }
void replay_soft_interrupts(void) __no_kcsan void replay_soft_interrupts(void)
{ {
irq_enter(); /* See comment in arch_local_irq_restore */ irq_enter(); /* See comment in arch_local_irq_restore */
__replay_soft_interrupts(); __replay_soft_interrupts();
...@@ -179,7 +179,7 @@ void replay_soft_interrupts(void) ...@@ -179,7 +179,7 @@ void replay_soft_interrupts(void)
} }
#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_KUAP) #if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_KUAP)
static inline void replay_soft_interrupts_irqrestore(void) static inline __no_kcsan void replay_soft_interrupts_irqrestore(void)
{ {
unsigned long kuap_state = get_kuap(); unsigned long kuap_state = get_kuap();
...@@ -203,7 +203,7 @@ static inline void replay_soft_interrupts_irqrestore(void) ...@@ -203,7 +203,7 @@ static inline void replay_soft_interrupts_irqrestore(void)
#define replay_soft_interrupts_irqrestore() __replay_soft_interrupts() #define replay_soft_interrupts_irqrestore() __replay_soft_interrupts()
#endif #endif
notrace void arch_local_irq_restore(unsigned long mask) notrace __no_kcsan void arch_local_irq_restore(unsigned long mask)
{ {
unsigned char irq_happened; unsigned char irq_happened;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment