powerpc/kcsan: Prevent recursive instrumentation with IRQ save/restores
authorRohan McLure <rmclure@linux.ibm.com>
Mon, 6 Feb 2023 02:18:00 +0000 (13:18 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 10 Feb 2023 11:19:56 +0000 (22:19 +1100)
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: Rohan McLure <rmclure@linux.ibm.com>
[mpe: Resolve merge conflict with IRQ replay recursion changes]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230206021801.105268-5-rmclure@linux.ibm.com
arch/powerpc/kernel/irq_64.c

index 9dc0ad3..c788c55 100644 (file)
@@ -94,7 +94,7 @@ static inline bool irq_happened_test_and_clear(u8 irq)
        return false;
 }
 
-static void __replay_soft_interrupts(void)
+static __no_kcsan void __replay_soft_interrupts(void)
 {
        struct pt_regs regs;
 
@@ -171,7 +171,7 @@ static void __replay_soft_interrupts(void)
        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 */
        __replay_soft_interrupts();
@@ -179,7 +179,7 @@ void replay_soft_interrupts(void)
 }
 
 #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();
 
@@ -203,7 +203,7 @@ static inline void replay_soft_interrupts_irqrestore(void)
 #define replay_soft_interrupts_irqrestore() __replay_soft_interrupts()
 #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;