interrupt.h (98db179a78dd8379e9d2cbfc3f00224168a9344c) interrupt.h (3db8aa10de9a478b3086db7894e0266def3d77af)
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#ifndef _ASM_POWERPC_INTERRUPT_H
3#define _ASM_POWERPC_INTERRUPT_H
4
5#include <linux/context_tracking.h>
6#include <linux/hardirq.h>
7#include <asm/cputime.h>
8#include <asm/ftrace.h>

--- 135 unchanged lines hidden (view full) ---

144 nap_adjust_return(regs);
145
146 irq_exit();
147 interrupt_exit_prepare(regs, state);
148}
149
150struct interrupt_nmi_state {
151#ifdef CONFIG_PPC64
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#ifndef _ASM_POWERPC_INTERRUPT_H
3#define _ASM_POWERPC_INTERRUPT_H
4
5#include <linux/context_tracking.h>
6#include <linux/hardirq.h>
7#include <asm/cputime.h>
8#include <asm/ftrace.h>

--- 135 unchanged lines hidden (view full) ---

144 nap_adjust_return(regs);
145
146 irq_exit();
147 interrupt_exit_prepare(regs, state);
148}
149
150struct interrupt_nmi_state {
151#ifdef CONFIG_PPC64
152#ifdef CONFIG_PPC_BOOK3S_64
153 u8 irq_soft_mask;
154 u8 irq_happened;
152 u8 irq_soft_mask;
153 u8 irq_happened;
155#endif
156 u8 ftrace_enabled;
157#endif
158};
159
154 u8 ftrace_enabled;
155#endif
156};
157
158static inline bool nmi_disables_ftrace(struct pt_regs *regs)
159{
160 /* Allow DEC and PMI to be traced when they are soft-NMI */
161 if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) {
162 if (TRAP(regs) == 0x900)
163 return false;
164 if (TRAP(regs) == 0xf00)
165 return false;
166 }
167 if (IS_ENABLED(CONFIG_PPC_BOOK3E)) {
168 if (TRAP(regs) == 0x260)
169 return false;
170 }
171
172 return true;
173}
174
160static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
161{
162#ifdef CONFIG_PPC64
175static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct interrupt_nmi_state *state)
176{
177#ifdef CONFIG_PPC64
163#ifdef CONFIG_PPC_BOOK3S_64
164 state->irq_soft_mask = local_paca->irq_soft_mask;
165 state->irq_happened = local_paca->irq_happened;
166
167 /*
168 * Set IRQS_ALL_DISABLED unconditionally so irqs_disabled() does
169 * the right thing, and set IRQ_HARD_DIS. We do not want to reconcile
170 * because that goes through irq tracing which we don't want in NMI.
171 */
172 local_paca->irq_soft_mask = IRQS_ALL_DISABLED;
173 local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
174
175 /* Don't do any per-CPU operations until interrupt state is fixed */
178 state->irq_soft_mask = local_paca->irq_soft_mask;
179 state->irq_happened = local_paca->irq_happened;
180
181 /*
182 * Set IRQS_ALL_DISABLED unconditionally so irqs_disabled() does
183 * the right thing, and set IRQ_HARD_DIS. We do not want to reconcile
184 * because that goes through irq tracing which we don't want in NMI.
185 */
186 local_paca->irq_soft_mask = IRQS_ALL_DISABLED;
187 local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
188
189 /* Don't do any per-CPU operations until interrupt state is fixed */
176#endif
177 /* Allow DEC and PMI to be traced when they are soft-NMI */
178 if (TRAP(regs) != 0x900 && TRAP(regs) != 0xf00 && TRAP(regs) != 0x260) {
190
191 if (nmi_disables_ftrace(regs)) {
179 state->ftrace_enabled = this_cpu_get_ftrace_enabled();
180 this_cpu_set_ftrace_enabled(0);
181 }
182#endif
183
184 /*
185 * Do not use nmi_enter() for pseries hash guest taking a real-mode
186 * NMI because not everything it touches is within the RMA limit.

--- 12 unchanged lines hidden (view full) ---

199 nmi_exit();
200
201 /*
202 * nmi does not call nap_adjust_return because nmi should not create
203 * new work to do (must use irq_work for that).
204 */
205
206#ifdef CONFIG_PPC64
192 state->ftrace_enabled = this_cpu_get_ftrace_enabled();
193 this_cpu_set_ftrace_enabled(0);
194 }
195#endif
196
197 /*
198 * Do not use nmi_enter() for pseries hash guest taking a real-mode
199 * NMI because not everything it touches is within the RMA limit.

--- 12 unchanged lines hidden (view full) ---

212 nmi_exit();
213
214 /*
215 * nmi does not call nap_adjust_return because nmi should not create
216 * new work to do (must use irq_work for that).
217 */
218
219#ifdef CONFIG_PPC64
207 if (TRAP(regs) != 0x900 && TRAP(regs) != 0xf00 && TRAP(regs) != 0x260)
220 if (nmi_disables_ftrace(regs))
208 this_cpu_set_ftrace_enabled(state->ftrace_enabled);
209
221 this_cpu_set_ftrace_enabled(state->ftrace_enabled);
222
210#ifdef CONFIG_PPC_BOOK3S_64
211 /* Check we didn't change the pending interrupt mask. */
212 WARN_ON_ONCE((state->irq_happened | PACA_IRQ_HARD_DIS) != local_paca->irq_happened);
213 local_paca->irq_happened = state->irq_happened;
214 local_paca->irq_soft_mask = state->irq_soft_mask;
215#endif
223 /* Check we didn't change the pending interrupt mask. */
224 WARN_ON_ONCE((state->irq_happened | PACA_IRQ_HARD_DIS) != local_paca->irq_happened);
225 local_paca->irq_happened = state->irq_happened;
226 local_paca->irq_soft_mask = state->irq_soft_mask;
227#endif
216#endif
217}
218
219/*
220 * Don't use noinstr here like x86, but rather add NOKPROBE_SYMBOL to each
221 * function definition. The reason for this is the noinstr section is placed
222 * after the main text section, i.e., very far away from the interrupt entry
223 * asm. That creates problems with fitting linker stubs when building large
224 * kernels.

--- 196 unchanged lines hidden (view full) ---

421DECLARE_INTERRUPT_HANDLER_ASYNC(machine_check_exception);
422#else
423DECLARE_INTERRUPT_HANDLER_NMI(machine_check_exception);
424#endif
425DECLARE_INTERRUPT_HANDLER(SMIException);
426DECLARE_INTERRUPT_HANDLER(handle_hmi_exception);
427DECLARE_INTERRUPT_HANDLER(unknown_exception);
428DECLARE_INTERRUPT_HANDLER_ASYNC(unknown_async_exception);
228}
229
230/*
231 * Don't use noinstr here like x86, but rather add NOKPROBE_SYMBOL to each
232 * function definition. The reason for this is the noinstr section is placed
233 * after the main text section, i.e., very far away from the interrupt entry
234 * asm. That creates problems with fitting linker stubs when building large
235 * kernels.

--- 196 unchanged lines hidden (view full) ---

432DECLARE_INTERRUPT_HANDLER_ASYNC(machine_check_exception);
433#else
434DECLARE_INTERRUPT_HANDLER_NMI(machine_check_exception);
435#endif
436DECLARE_INTERRUPT_HANDLER(SMIException);
437DECLARE_INTERRUPT_HANDLER(handle_hmi_exception);
438DECLARE_INTERRUPT_HANDLER(unknown_exception);
439DECLARE_INTERRUPT_HANDLER_ASYNC(unknown_async_exception);
440DECLARE_INTERRUPT_HANDLER_NMI(unknown_nmi_exception);
429DECLARE_INTERRUPT_HANDLER(instruction_breakpoint_exception);
430DECLARE_INTERRUPT_HANDLER(RunModeException);
431DECLARE_INTERRUPT_HANDLER(single_step_exception);
432DECLARE_INTERRUPT_HANDLER(program_check_exception);
433DECLARE_INTERRUPT_HANDLER(emulation_assist_interrupt);
434DECLARE_INTERRUPT_HANDLER(alignment_exception);
435DECLARE_INTERRUPT_HANDLER(StackOverflow);
436DECLARE_INTERRUPT_HANDLER(stack_overflow_exception);

--- 7 unchanged lines hidden (view full) ---

444DECLARE_INTERRUPT_HANDLER_NMI(performance_monitor_exception_nmi);
445DECLARE_INTERRUPT_HANDLER_ASYNC(performance_monitor_exception_async);
446DECLARE_INTERRUPT_HANDLER_RAW(performance_monitor_exception);
447DECLARE_INTERRUPT_HANDLER(DebugException);
448DECLARE_INTERRUPT_HANDLER(altivec_assist_exception);
449DECLARE_INTERRUPT_HANDLER(CacheLockingException);
450DECLARE_INTERRUPT_HANDLER(SPEFloatingPointException);
451DECLARE_INTERRUPT_HANDLER(SPEFloatingPointRoundException);
441DECLARE_INTERRUPT_HANDLER(instruction_breakpoint_exception);
442DECLARE_INTERRUPT_HANDLER(RunModeException);
443DECLARE_INTERRUPT_HANDLER(single_step_exception);
444DECLARE_INTERRUPT_HANDLER(program_check_exception);
445DECLARE_INTERRUPT_HANDLER(emulation_assist_interrupt);
446DECLARE_INTERRUPT_HANDLER(alignment_exception);
447DECLARE_INTERRUPT_HANDLER(StackOverflow);
448DECLARE_INTERRUPT_HANDLER(stack_overflow_exception);

--- 7 unchanged lines hidden (view full) ---

456DECLARE_INTERRUPT_HANDLER_NMI(performance_monitor_exception_nmi);
457DECLARE_INTERRUPT_HANDLER_ASYNC(performance_monitor_exception_async);
458DECLARE_INTERRUPT_HANDLER_RAW(performance_monitor_exception);
459DECLARE_INTERRUPT_HANDLER(DebugException);
460DECLARE_INTERRUPT_HANDLER(altivec_assist_exception);
461DECLARE_INTERRUPT_HANDLER(CacheLockingException);
462DECLARE_INTERRUPT_HANDLER(SPEFloatingPointException);
463DECLARE_INTERRUPT_HANDLER(SPEFloatingPointRoundException);
452DECLARE_INTERRUPT_HANDLER(WatchdogException);
464DECLARE_INTERRUPT_HANDLER_NMI(WatchdogException);
453DECLARE_INTERRUPT_HANDLER(kernel_bad_stack);
454
455/* slb.c */
456DECLARE_INTERRUPT_HANDLER_RAW(do_slb_fault);
457DECLARE_INTERRUPT_HANDLER(do_bad_slb_fault);
458
459/* hash_utils.c */
460DECLARE_INTERRUPT_HANDLER_RAW(do_hash_fault);

--- 29 unchanged lines hidden ---
465DECLARE_INTERRUPT_HANDLER(kernel_bad_stack);
466
467/* slb.c */
468DECLARE_INTERRUPT_HANDLER_RAW(do_slb_fault);
469DECLARE_INTERRUPT_HANDLER(do_bad_slb_fault);
470
471/* hash_utils.c */
472DECLARE_INTERRUPT_HANDLER_RAW(do_hash_fault);

--- 29 unchanged lines hidden ---