[PATCH Dovetail v2 2/6] arm: irq_pipeline: Move fault_entry() fault_exit() into separate header
Florian Bezdeka <[email protected]>
| Newsgroups | dev.linux.lists.xenomai |
|---|---|
| Message-ID | <20260610-wip-flo-v7-1-arm-pipelining-fixes-v2-2-62c9c477f8f2@siemens.com> |
Introducing a new header allows us to keep the implementation as static inline function. Moving them into asm/dovetail.h or asm/irq_pipeline.h would require us to rewrite those helpers as macros. Signed-off-by: Florian Bezdeka <[email protected]> --- arch/arm/include/asm/trap_entry.h | 82 +++++++++++++++++++++++++++++++++++++++ arch/arm/mm/fault.c | 65 +------------------------------ 2 files changed, 83 insertions(+), 64 deletions(-) diff --git a/arch/arm/include/asm/trap_entry.h b/arch/arm/include/asm/trap_entry.h new file mode 100644 index 0000000000000000000000000000000000000000..56cf3352c38d9347e989f9b4f6be0b7d649d9b13 --- /dev/null +++ b/arch/arm/include/asm/trap_entry.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASMARM_TRAP_ENTRY_H +#define _ASMARM_TRAP_ENTRY_H + +#include <asm/dovetail.h> +#include <asm/trace/exceptions.h> + +#ifdef CONFIG_MMU +#ifdef CONFIG_IRQ_PIPELINE +/* + * We need to synchronize the virtual interrupt state with the hard + * interrupt state we received on entry, then turn hardirqs back on to + * allow code which does not require strict serialization to be + * preempted by an out-of-band activity. + */ +static inline unsigned long fault_entry(int exception, struct pt_regs *regs) +{ + unsigned long flags; + + trace_ARM_trap_entry(exception, regs); + + flags = hard_local_save_flags(); + + /* + * The companion core must demote the current context to + * in-band stage if running oob on entry. + */ + mark_trap_entry(exception, regs); + + if (raw_irqs_disabled_flags(flags)) { + stall_inband(); + trace_hardirqs_off(); + } + + hard_local_irq_enable(); + + return flags; +} + +static inline void fault_exit(int exception, struct pt_regs *regs, + unsigned long flags) +{ + WARN_ON_ONCE(irq_pipeline_debug() && hard_irqs_disabled()); + + /* + * We expect kentry_exit_pipelined() to clear the stall bit if + * kentry_enter_pipelined() observed it that way. + */ + mark_trap_exit(exception, regs); + trace_ARM_trap_exit(exception, regs); + hard_local_irq_restore(flags); +} + +#else /* !CONFIG_IRQ_PIPELINE */ + +#define fault_entry(__exception, __regs) \ + do { \ + (void)(__exception); \ + (void)(__regs); \ + } while (0) + +#define fault_exit(__exception, __regs, __flags) \ + do { \ + (void)(__exception); \ + (void)(__regs); \ + (void)(__flags); \ + } while (0) + +#endif /* !CONFIG_IRQ_PIPELINE */ + +#else /* CONFIG_MMU */ +unsigned long fault_entry(int exception, struct pt_regs *regs) +{ + return 0; +} + +static inline void fault_exit(int exception, struct pt_regs *regs, + unsigned long combo) +{ } +#endif /* !CONFIG_MMU */ + +#endif diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 7a5c0a5a825df5f76eec6aa341d910c3efa63f88..60982ec0627464dd389e1c9b106858bc92ccf260 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -24,6 +24,7 @@ #include <asm/system_info.h> #include <asm/tlbflush.h> #include <asm/dovetail.h> +#include <asm/trap_entry.h> #define CREATE_TRACE_POINTS #include <asm/trace/exceptions.h> @@ -38,61 +39,6 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) return addr >= TASK_SIZE && ULONG_MAX - addr >= size; } -#ifdef CONFIG_IRQ_PIPELINE -/* - * We need to synchronize the virtual interrupt state with the hard - * interrupt state we received on entry, then turn hardirqs back on to - * allow code which does not require strict serialization to be - * preempted by an out-of-band activity. - */ -static inline -unsigned long fault_entry(int exception, struct pt_regs *regs) -{ - unsigned long flags; - - trace_ARM_trap_entry(exception, regs); - - flags = hard_local_save_flags(); - - /* - * The companion core must demote the current context to - * in-band stage if running oob on entry. - */ - mark_trap_entry(exception, regs); - - if (raw_irqs_disabled_flags(flags)) { - stall_inband(); - trace_hardirqs_off(); - } - - hard_local_irq_enable(); - - return flags; -} - -static inline -void fault_exit(int exception, struct pt_regs *regs, - unsigned long flags) -{ - WARN_ON_ONCE(irq_pipeline_debug() && hard_irqs_disabled()); - - /* - * We expect kentry_exit_pipelined() to clear the stall bit if - * kentry_enter_pipelined() observed it that way. - */ - mark_trap_exit(exception, regs); - trace_ARM_trap_exit(exception, regs); - hard_local_irq_restore(flags); -} - -#else /* !CONFIG_IRQ_PIPELINE */ - -#define fault_entry(__exception, __regs) ({ 0; }) -#define fault_exit(__exception, __regs, __flags) \ - do { (void)(__flags); } while (0) - -#endif /* !CONFIG_IRQ_PIPELINE */ - /* * This is useful to dump out the page tables associated with * 'addr' in mm 'mm'. @@ -165,15 +111,6 @@ void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr) pr_cont("\n"); } #else /* CONFIG_MMU */ -unsigned long fault_entry(int exception, struct pt_regs *regs) -{ - return 0; -} - -static inline void fault_exit(int exception, struct pt_regs *regs, - unsigned long combo) -{ } - void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr) { } #endif /* CONFIG_MMU */ -- 2.54.0