On 9/5/20 5:43 PM, Nicholas Piggin wrote:
This moves the common NMI entry and exit code into the interrupt handler
wrappers.

This changes the behaviour of soft-NMI (watchdog) and HMI interrupts, and
also MCE interrupts on 64e, by adding missing parts of the NMI entry to
them.

Signed-off-by: Nicholas Piggin <npig...@gmail.com>
---
  arch/powerpc/include/asm/interrupt.h | 26 +++++++++++++++++++
  arch/powerpc/kernel/mce.c            | 12 ---------
  arch/powerpc/kernel/traps.c          | 38 +++++-----------------------
  arch/powerpc/kernel/watchdog.c       | 10 +++-----
  4 files changed, 37 insertions(+), 49 deletions(-)

diff --git a/arch/powerpc/include/asm/interrupt.h 
b/arch/powerpc/include/asm/interrupt.h
index 83fe1d64cf23..69eb8a432984 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -31,6 +31,27 @@ static inline void interrupt_enter_prepare(struct pt_regs 
*regs)
  }
  #endif /* CONFIG_PPC_BOOK3S_64 */
+struct interrupt_nmi_state {
+#ifdef CONFIG_PPC64
+       u8 ftrace_enabled;
+#endif
+};
+
+static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct 
interrupt_nmi_state *state)
+{
+       this_cpu_set_ftrace_enabled(0);
+
+       nmi_enter();
+}
+
+static inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct 
interrupt_nmi_state *state)
+{
+       nmi_exit();
+
+       this_cpu_set_ftrace_enabled(state->ftrace_enabled);

PPC32 build:

In file included from arch/powerpc/kernel/irq.c:57:0:
./arch/powerpc/include/asm/interrupt.h: In function ‘interrupt_nmi_exit_prepare’: ./arch/powerpc/include/asm/interrupt.h:96:35: error: ‘struct interrupt_nmi_state’ has no member named ‘ftrace_enabled’
  this_cpu_set_ftrace_enabled(state->ftrace_enabled);
                                   ^

+}
+
+
  /**
   * DECLARE_INTERRUPT_HANDLER_RAW - Declare raw interrupt handler function
   * @func:     Function name of the entry point
@@ -177,10 +198,15 @@ static __always_inline long ___##func(struct pt_regs 
*regs);              \
                                                                        \
  __visible noinstr long func(struct pt_regs *regs)                     \
  {                                                                     \
+       struct interrupt_nmi_state state;                               \
        long ret;                                                       \
                                                                        \
+       interrupt_nmi_enter_prepare(regs, &state);                  \
+                                                                       \
        ret = ___##func (regs);                                         \
                                                                        \
+       interrupt_nmi_exit_prepare(regs, &state);                   \
+                                                                       \
        return ret;                                                     \
  }                                                                     \
                                                                        \

Christophe

Reply via email to