diff mbox series

[1/2] powerpc: Apply __always_inline to interrupt_{enter,exit}_prepare()

Message ID 20240404044535.642122-2-rmclure@linux.ibm.com (mailing list archive)
State New
Headers show
Series [1/2] powerpc: Apply __always_inline to interrupt_{enter,exit}_prepare() | expand

Commit Message

Rohan McLure April 4, 2024, 4:45 a.m. UTC
In keeping with the advice given by Documentation/core-api/entry.rst,
entry and exit handlers for interrupts should not be instrumented.
Guarantee that the interrupt_{enter,exit}_prepare() routines are inlined
so that they will inheret instrumentation from their caller.

KCSAN kernels were observed to compile without inlining these routines,
which would lead to grief on NMI handlers.

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
---
 arch/powerpc/include/asm/interrupt.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Christophe Leroy April 4, 2024, 6:14 a.m. UTC | #1
Le 04/04/2024 à 06:45, Rohan McLure a écrit :
> In keeping with the advice given by Documentation/core-api/entry.rst,
> entry and exit handlers for interrupts should not be instrumented.
> Guarantee that the interrupt_{enter,exit}_prepare() routines are inlined
> so that they will inheret instrumentation from their caller.
> 
> KCSAN kernels were observed to compile without inlining these routines,
> which would lead to grief on NMI handlers.
> 
> Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/include/asm/interrupt.h | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h
> index 7b610864b364..f4343e0bfb13 100644
> --- a/arch/powerpc/include/asm/interrupt.h
> +++ b/arch/powerpc/include/asm/interrupt.h
> @@ -150,7 +150,7 @@ static inline void booke_restore_dbcr0(void)
>   #endif
>   }
>   
> -static inline void interrupt_enter_prepare(struct pt_regs *regs)
> +static __always_inline void interrupt_enter_prepare(struct pt_regs *regs)
>   {
>   #ifdef CONFIG_PPC64
>   	irq_soft_mask_set(IRQS_ALL_DISABLED);
> @@ -215,11 +215,11 @@ static inline void interrupt_enter_prepare(struct pt_regs *regs)
>    * However interrupt_nmi_exit_prepare does return directly to regs, because
>    * NMIs do not do "exit work" or replay soft-masked interrupts.
>    */
> -static inline void interrupt_exit_prepare(struct pt_regs *regs)
> +static __always_inline void interrupt_exit_prepare(struct pt_regs *regs)
>   {
>   }
>   
> -static inline void interrupt_async_enter_prepare(struct pt_regs *regs)
> +static __always_inline void interrupt_async_enter_prepare(struct pt_regs *regs)
>   {
>   #ifdef CONFIG_PPC64
>   	/* Ensure interrupt_enter_prepare does not enable MSR[EE] */
> @@ -238,7 +238,7 @@ static inline void interrupt_async_enter_prepare(struct pt_regs *regs)
>   	irq_enter();
>   }
>   
> -static inline void interrupt_async_exit_prepare(struct pt_regs *regs)
> +static __always_inline void interrupt_async_exit_prepare(struct pt_regs *regs)
>   {
>   	/*
>   	 * Adjust at exit so the main handler sees the true NIA. This must
> @@ -278,7 +278,7 @@ static inline bool nmi_disables_ftrace(struct pt_regs *regs)
>   	return true;
>   }
>   
> -static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
> +static __always_inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
>   {
>   #ifdef CONFIG_PPC64
>   	state->irq_soft_mask = local_paca->irq_soft_mask;
> @@ -340,7 +340,7 @@ static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte
>   	nmi_enter();
>   }
>   
> -static inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
> +static __always_inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
>   {
>   	if (mfmsr() & MSR_DR) {
>   		// nmi_exit if relocations are on
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h
index 7b610864b364..f4343e0bfb13 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -150,7 +150,7 @@  static inline void booke_restore_dbcr0(void)
 #endif
 }
 
-static inline void interrupt_enter_prepare(struct pt_regs *regs)
+static __always_inline void interrupt_enter_prepare(struct pt_regs *regs)
 {
 #ifdef CONFIG_PPC64
 	irq_soft_mask_set(IRQS_ALL_DISABLED);
@@ -215,11 +215,11 @@  static inline void interrupt_enter_prepare(struct pt_regs *regs)
  * However interrupt_nmi_exit_prepare does return directly to regs, because
  * NMIs do not do "exit work" or replay soft-masked interrupts.
  */
-static inline void interrupt_exit_prepare(struct pt_regs *regs)
+static __always_inline void interrupt_exit_prepare(struct pt_regs *regs)
 {
 }
 
-static inline void interrupt_async_enter_prepare(struct pt_regs *regs)
+static __always_inline void interrupt_async_enter_prepare(struct pt_regs *regs)
 {
 #ifdef CONFIG_PPC64
 	/* Ensure interrupt_enter_prepare does not enable MSR[EE] */
@@ -238,7 +238,7 @@  static inline void interrupt_async_enter_prepare(struct pt_regs *regs)
 	irq_enter();
 }
 
-static inline void interrupt_async_exit_prepare(struct pt_regs *regs)
+static __always_inline void interrupt_async_exit_prepare(struct pt_regs *regs)
 {
 	/*
 	 * Adjust at exit so the main handler sees the true NIA. This must
@@ -278,7 +278,7 @@  static inline bool nmi_disables_ftrace(struct pt_regs *regs)
 	return true;
 }
 
-static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
+static __always_inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
 {
 #ifdef CONFIG_PPC64
 	state->irq_soft_mask = local_paca->irq_soft_mask;
@@ -340,7 +340,7 @@  static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte
 	nmi_enter();
 }
 
-static inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
+static __always_inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
 {
 	if (mfmsr() & MSR_DR) {
 		// nmi_exit if relocations are on