SError rework (- RAS & IESB for firmware first support)
v4 cover SError rework (- RAS & IESB for firmware first support)
Hello,
This is repost of the SError Rework bits of the bigger series [0]. None of these patches have changed since v3.
Thanks,
James
[0] https://www.spinics.net/lists/arm-kernel/msg612870.html
James Morse (8):
arm64: explicitly mask all exceptions
arm64: introduce an order for exceptions
arm64: Move the async/fiq helpers to explicitly set process context
flags
arm64: Mask all exceptions during kernel_exit
arm64: entry.S: Remove disable_dbg
arm64: entry.S: convert el1_sync
arm64: entry.S convert el0_sync
arm64: entry.S: convert elX_irq
Xie XiuQi (1):
arm64: entry.S: move SError handling into a C function for future
expansion
arch/arm64/Kconfig | 2 +- arch/arm64/include/asm/assembler.h | 46 ++++++++++++-------- arch/arm64/include/asm/daifflags.h | 72 +++++++++++++++++++++++++++++++ arch/arm64/include/asm/irqflags.h | 40 ++++++------------ arch/arm64/kernel/debug-monitors.c | 5 ++- arch/arm64/kernel/entry.S | 86 ++++++++++++++++++++++---------------- arch/arm64/kernel/hibernate.c | 5 ++- arch/arm64/kernel/machine_kexec.c | 4 +- arch/arm64/kernel/setup.c | 8 ++-- arch/arm64/kernel/signal.c | 8 +++- arch/arm64/kernel/smp.c | 12 ++---- arch/arm64/kernel/suspend.c | 7 ++-- arch/arm64/kernel/traps.c | 16 ++++++- arch/arm64/mm/proc.S | 9 ++-- 14 files changed, 211 insertions(+), 109 deletions(-) create mode 100644 arch/arm64/include/asm/daifflags.h
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 1/9 arm64: explicitly mask all exceptions
There are a few places where we want to mask all exceptions. Today we do this in a piecemeal fashion, typically we expect the caller to have masked irqs and the arch code masks debug exceptions, ignoring serror which is probably masked.
Make it clear that 'mask all exceptions' is the intention by adding helpers to do exactly that.
This will let us unmask SError without having to add 'oh and SError' to these paths.
==
Remove the disable IRQs comment above cpu_die(): we return from idle via cpu_resume. This comment is confusing once the local_irq_disable() call is changed.
Changes since v3:
* Split local_mask_daif into a save and mask versions,
* swapped verb/daif word-order.
* Removed {asm,linux} includes - one will always include the other
--- arch/arm64/include/asm/assembler.h | 17 ++++++++++ arch/arm64/include/asm/daifflags.h | 69 ++++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/hibernate.c | 5 +-- arch/arm64/kernel/machine_kexec.c | 4 +-- arch/arm64/kernel/smp.c | 9 ++--- arch/arm64/kernel/suspend.c | 7 ++-- arch/arm64/kernel/traps.c | 3 +- arch/arm64/mm/proc.S | 9 +++-- 8 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 arch/arm64/include/asm/daifflags.h
arch/arm64/include/asm/assembler.h +17 -0
@@ -31,6 +31,23 @@#include <asm/ptrace.h> #include <asm/thread_info.h> + .macro save_and_disable_daif, flags + mrs \flags, daif + msr daifset, #0xf + .endm + + .macro disable_daif + msr daifset, #0xf + .endm + + .macro enable_daif + msr daifclr, #0xf + .endm + + .macro restore_daif, flags:req + msr daif, \flags + .endm +/* * Enable and disable interrupts. */
arch/arm64/include/asm/daifflags.h new file +69 -0
69 lines not on this page · raw message
arch/arm64/kernel/hibernate.c +3 -2
@@ -27,6 +27,7 @@#include <asm/barrier.h> #include <asm/cacheflush.h> #include <asm/cputype.h> +#include <asm/daifflags.h> #include <asm/irqflags.h> #include <asm/kexec.h> #include <asm/memory.h>
@@ -285,7 +286,7 @@ int swsusp_arch_suspend(void)return -EBUSY ; } -local_dbg_save (flags); + flags =local_daif_save ();if (__cpu_suspend_enter (&state)) {/* make the crash dump kernel image visible/saveable */
@@ -315,7 +316,7 @@ int swsusp_arch_suspend(void)__cpu_suspend_exit (); } -local_dbg_restore (flags); +local_daif_restore (flags);return ret; }
arch/arm64/kernel/machine_kexec.c +2 -2
@@ -18,6 +18,7 @@#include <asm/cacheflush.h> #include <asm/cpu_ops.h> +#include <asm/daifflags.h> #include <asm/memory.h> #include <asm/mmu.h> #include <asm/mmu_context.h>
@@ -195,8 +196,7 @@ void machine_kexec(struct kimage *kimage)pr_info ("Bye!\n" ); -/* Disable all DAIF exceptions. */ - asmvolatile ("msr daifset, #0xf" : : :"memory" ); +local_daif_mask ();/* * cpu_soft_restart will shutdown the MMU, disable data caches, then
arch/arm64/kernel/smp.c +3 -6
@@ -47,6 +47,7 @@#include <asm/cpu.h> #include <asm/cputype.h> #include <asm/cpu_ops.h> +#include <asm/daifflags.h> #include <asm/mmu_context.h> #include <asm/numa.h> #include <asm/pgtable.h>
@@ -368,10 +369,6 @@ void __cpu_die(unsigned int cpu)/* * Called from the idle thread for the CPU which has been shutdown. * -* Note that we disable IRQs here, but do not re-enable them -* before returning to the caller. This is also the behaviour -* of the other hotplug-cpu capable cores, so presumably coming -* out of idle fixes this. */ void cpu_die (void ) {
@@ -379,7 +376,7 @@ void cpu_die(void)idle_task_exit (); -local_irq_disable (); +local_daif_mask ();/* Tell __cpu_die() that this CPU is now safe to dispose of */ (void )cpu_report_death ();
@@ -837,7 +834,7 @@ static void ipi_cpu_stop(unsigned int cpu) {set_cpu_online (cpu, false); -local_irq_disable (); +local_daif_mask ();while (1 )cpu_relax ();
arch/arm64/kernel/suspend.c +4 -3
@@ -4,6 +4,7 @@#include <asm/alternative.h> #include <asm/cacheflush.h> #include <asm/cpufeature.h> +#include <asm/daifflags.h> #include <asm/debug-monitors.h> #include <asm/exec.h> #include <asm/pgtable.h>
@@ -57,7 +58,7 @@ void notrace __cpu_suspend_exit(void)/* * Restore HW breakpoint registers to sane values * before debug exceptions are possibly reenabled -* through local_dbg_restore. +* by cpu_suspend()s local_daif_restore() call. */ if (hw_breakpoint_restore)hw_breakpoint_restore (cpu);
@@ -81,7 +82,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))* updates to mdscr register (saved and restored along with * general purpose registers) from kernel debuggers. */ -local_dbg_save (flags); + flags =local_daif_save ();/* * Function graph tracer state gets incosistent when the kernel
@@ -114,7 +115,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))* restored, so from this point onwards, debugging is fully * renabled if it was enabled when core started shutdown. */ -local_dbg_restore (flags); +local_daif_restore (flags);return ret; }
arch/arm64/kernel/traps.c +2 -1
@@ -38,6 +38,7 @@#include <asm/atomic.h> #include <asm/bug.h> +#include <asm/daifflags.h> #include <asm/debug-monitors.h> #include <asm/esr.h> #include <asm/insn.h>
@@ -642,7 +643,7 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr) esr_get_class_string(esr));die ("Oops - bad mode" , regs,0 ); -local_irq_disable (); +local_daif_mask ();panic ("bad mode" ); }
arch/arm64/mm/proc.S +4 -5
@@ -109,10 +109,10 @@ ENTRY(cpu_do_resume) /* * __cpu_setup() cleared MDSCR_EL1.MDE and friends, before unmasking * debug exceptions. By restoring MDSCR_EL1 here, we may take a debug - * exception. Mask them until local_dbg_restore() in cpu_suspend() + * exception. Mask them until local_daif_restore() in cpu_suspend() * resets them. */ - disable_dbg + disable_daif msr mdscr_el1, x10 msr sctlr_el1, x12
@@ -155,8 +155,7 @@ ENDPROC(cpu_do_switch_mm) * called by anything else. It can only be executed from a TTBR0 mapping. */ ENTRY(idmap_cpu_replace_ttbr1) - mrs x2, daif - msr daifset, #0xf + save_and_disable_daif flags=x2 adrp x1, empty_zero_page msr ttbr1_el1, x1
@@ -169,7 +168,7 @@ ENTRY(idmap_cpu_replace_ttbr1) msr ttbr1_el1, x0 isb - msr daif, x2 + restore_daif x2 ret ENDPROC(idmap_cpu_replace_ttbr1)
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 2/9 arm64: introduce an order for exceptions
In reply to James MorseCurrently SError is always masked in the kernel. To support RAS exceptions using SError on hardware with the v8.2 RAS Extensions we need to unmask SError as much as possible.
Let's define an order for masking and unmasking exceptions. 'dai' is memorable and effectively what we have today.
Disabling debug exceptions should cause all other exceptions to be masked. Masking SError should mask irq, but not disable debug exceptions. Masking irqs has no side effects for other flags. Keeping to this order makes it easier for entry.S to know which exceptions should be unmasked.
FIQ is never expected, but we mask it when we mask debug exceptions, and unmask it at all other times.
Given masking debug exceptions masks everything, we don't need macros to save/restore that bit independently. Remove them and switch the last caller over to use the daif calls.
==
Changes since v3:
* Use save_daif version, swapped verb/daif word-order.
* tweak last sentence of commit message.
--- arch/arm64/include/asm/irqflags.h | 34 +++++++++++++--------------------- arch/arm64/kernel/debug-monitors.c | 5 +++-- 2 files changed, 16 insertions(+), 23 deletions(-)
arch/arm64/include/asm/irqflags.h +13 -21
@@ -20,6 +20,19 @@#include <asm/ptrace.h> +/* +* Aarch64 has flags for masking: Debug, Asynchronous (serror), Interrupts and +* FIQ exceptions, in the 'daif' register. We mask and unmask them in 'dai' +* order: +* Masking debug exceptions causes all other exceptions to be masked too/ +* Masking SError masks irq, but not debug exceptions. Masking irqs has no +* side effects for other flags. Keeping to this order makes it easier for +* entry.S to know which exceptions should be unmasked. +* +* FIQ is never expected, but we mask it when we disable debug exceptions, and +* unmask it at all other times. +*/ +/* * CPU interrupt mask handling. */
@@ -89,26 +102,5 @@ static inline int arch_irqs_disabled_flags(unsigned long flags) {return flags &PSR_I_BIT ; } - -/* -* save and restore debug state -*/ -#define local_dbg_save (flags) \ - do { \ - typecheck(unsigned long, flags); \ - asm volatile( \ - "mrs %0, daif // local_dbg_save\n" \ - "msr daifset, #8" \ - : "=r" (flags) : : "memory"); \ - } while (0) - -#define local_dbg_restore (flags) \ - do { \ - typecheck(unsigned long, flags); \ - asm volatile( \ - "msr daif, %0 // local_dbg_restore\n" \ - : : "r" (flags) : "memory"); \ - } while (0) -#endif #endif
arch/arm64/kernel/debug-monitors.c +3 -2
@@ -30,6 +30,7 @@#include <asm/cpufeature.h> #include <asm/cputype.h> +#include <asm/daifflags.h> #include <asm/debug-monitors.h> #include <asm/system_misc.h>
@@ -46,9 +47,9 @@ u8 debug_monitors_arch(void)static void mdscr_write (u32 mdscr) {unsigned long flags; -local_dbg_save (flags); + flags =local_daif_save ();write_sysreg (mdscr, mdscr_el1); -local_dbg_restore (flags); +local_daif_restore (flags); }NOKPROBE_SYMBOL (mdscr_write);
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 3/9 arm64: Move the async/fiq helpers to explicitly set process context flags
In reply to James MorseRemove the local_{async,fiq}_{en,dis}able macros as they don't respect our newly defined order and are only used to set the flags for process context when we bring CPUs online.
Add a helper to do this. The IRQ flag varies as we want it masked on the boot CPU until we are ready to handle interrupts.
The boot CPU unmasks SError during early boot once it can print an error message. If we can print an error message about SError, we can do the same for FIQ. Debug exceptions are already enabled by __cpu_setup(), which has also configured MDSCR_EL1 to disable MDE and KDE.
==
Changes since v3:
* swapped verb/daif word-order.
--- arch/arm64/include/asm/daifflags.h | 3 +++ arch/arm64/include/asm/irqflags.h | 6 ------ arch/arm64/kernel/setup.c | 8 +++++--- arch/arm64/kernel/smp.c | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-)
arch/arm64/include/asm/daifflags.h +3 -0
@@ -18,6 +18,9 @@#include <linux/irqflags.h> +#define DAIF_PROCCTX 0 +#define DAIF_PROCCTX_NOIRQ PSR_I_BIT +/* mask/save/unmask/restore all exceptions, including interrupts. */ static inline void local_daif_mask (void ) {
arch/arm64/include/asm/irqflags.h +0 -6
@@ -66,12 +66,6 @@ static inline void arch_local_irq_disable(void) : "memory"); } -#define local_fiq_enable () asm("msr daifclr, #1" : : : "memory") -#define local_fiq_disable () asm("msr daifset, #1" : : : "memory") - -#define local_async_enable () asm("msr daifclr, #4" : : : "memory") -#define local_async_disable () asm("msr daifset, #4" : : : "memory") -/* * Save the current interrupt enable state. */
arch/arm64/kernel/setup.c +5 -3
@@ -48,6 +48,7 @@#include <asm/fixmap.h> #include <asm/cpu.h> #include <asm/cputype.h> +#include <asm/daifflags.h> #include <asm/elf.h> #include <asm/cpufeature.h> #include <asm/cpu_ops.h>
@@ -262,10 +263,11 @@ void __init setup_arch(char **cmdline_p)parse_early_param ();/* -* Unmask asynchronous aborts after bringing up possible earlycon. -* (Report possible System Errors once we can report this occurred) +* Unmask asynchronous aborts and fiq after bringing up possible +* earlycon. (Report possible System Errors once we can report this +* occurred). */ -local_async_enable (); +local_daif_restore (DAIF_PROCCTX_NOIRQ );/* * TTBR0 is only used for the identity mapping at this stage. Make it
arch/arm64/kernel/smp.c +1 -2
@@ -272,8 +272,7 @@ asmlinkage void secondary_start_kernel(void)set_cpu_online (cpu, true);complete (&cpu_running); -local_irq_enable (); -local_async_enable (); +local_daif_restore (DAIF_PROCCTX );/* * OK, it's off to the idle thread for us
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 4/9 arm64: Mask all exceptions during kernel_exit
In reply to James MorseTo take RAS Exceptions as quickly as possible we need to keep SError unmasked as much as possible. We need to mask it during kernel_exit as taking an error from this code will overwrite the exception-registers.
Adding a naked 'disable_daif' to kernel_exit causes a performance problem for micro-benchmarks that do no real work, (e.g. calling getpid() in a loop). This is because the ret_to_user loop has already masked IRQs so that the TIF_WORK_MASK thread flags can't change underneath it, adding disable_daif is an additional self-synchronising operation.
In the future, the RAS APEI code may need to modify the TIF_WORK_MASK flags from an SError, in which case the ret_to_user loop must mask SError while it examines the flags.
Disable all exceptions for return to EL1. For return to EL0 get the ret_to_user loop to leave all exceptions masked once it has done its work, this avoids an extra pstate-write.
==
Changes since v3:
* swapped verb/daif word-order.
--- arch/arm64/kernel/entry.S | 10 +++++----- arch/arm64/kernel/signal.c | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-)
arch/arm64/kernel/entry.S +5 -5
@@ -221,6 +221,8 @@ alternative_else_nop_endif .macro kernel_exit, el .if \el != 0 + disable_daif + /* Restore the task's original addr_limit. */ ldr x20, [sp, #S_ORIG_ADDR_LIMIT] str x20, [tsk, #TSK_TI_ADDR_LIMIT]
@@ -517,8 +519,6 @@ el1_da: mov x2, sp // struct pt_regs bl do_mem_abort - // disable interrupts before pulling preserved data off the stack - disable_irq kernel_exit 1 el1_sp_pc: /*
@@ -793,7 +793,7 @@ ENDPROC(el0_irq) * and this includes saving x0 back into the kernel stack. */ ret_fast_syscall: - disable_irq // disable interrupts + disable_daif str x0, [sp, #S_X0] // returned x0 ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing and x2, x1, #_TIF_SYSCALL_WORK
@@ -803,7 +803,7 @@ ret_fast_syscall: enable_step_tsk x1, x2 kernel_exit 0 ret_fast_syscall_trace: - enable_irq // enable interrupts + enable_daif b __sys_trace_return_skipped // we already saved x0 /*
@@ -821,7 +821,7 @@ work_pending: * "slow" syscall return path. */ ret_to_user: - disable_irq // disable interrupts + disable_daif ldr x1, [tsk, #TSK_TI_FLAGS] and x2, x1, #_TIF_WORK_MASK cbnz x2, work_pending
arch/arm64/kernel/signal.c +6 -2
@@ -31,6 +31,7 @@#include <linux/ratelimit.h> #include <linux/syscalls.h> +#include <asm/daifflags.h> #include <asm/debug-monitors.h> #include <asm/elf.h> #include <asm/cacheflush.h>
@@ -756,9 +757,12 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,addr_limit_user_check ();if (thread_flags & _TIF_NEED_RESCHED) { +/* Unmask Debug and SError for the next task */ +local_daif_restore (DAIF_PROCCTX_NOIRQ ); +schedule (); }else { -local_irq_enable (); +local_daif_restore (DAIF_PROCCTX );if (thread_flags & _TIF_UPROBE)uprobe_notify_resume (regs);
@@ -775,7 +779,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,fpsimd_restore_current_state (); } -local_irq_disable (); +local_daif_mask (); thread_flags =READ_ONCE (current_thread_info ()->flags); }while (thread_flags & _TIF_WORK_MASK); }
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 5/9 arm64: entry.S: Remove disable_dbg
In reply to James Morseenable_step_tsk is the only user of disable_dbg, which doesn't respect our 'dai' order for exception masking. enable_step_tsk may enable single-step, so previously needed to mask debug exceptions to prevent us from single-stepping kernel_exit. enable_step_tsk is called at the end of the ret_to_user loop, which has already masked all exceptions so this is no longer needed.
Remove disable_dbg, add a comment that enable_step_tsk's caller should have masked debug.
--- arch/arm64/include/asm/assembler.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
arch/arm64/include/asm/assembler.h +1 -8
@@ -68,13 +68,6 @@ msr daif, \flags .endm -/* - * Enable and disable debug exceptions. - */ - .macro disable_dbg - msr daifset, #8 - .endm - .macro enable_dbg msr daifclr, #8 .endm
@@ -88,9 +81,9 @@ 9990: .endm +/* call with daif masked */ .macro enable_step_tsk, flgs, tmp tbz \flgs, #TIF_SINGLESTEP, 9990f -disable_dbg mrs \tmp, mdscr_el1 orr \tmp, \tmp, #1 msr mdscr_el1, \tmp
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 6/9 arm64: entry.S: convert el1_sync
In reply to James Morseel1_sync unmasks exceptions on a case-by-case basis, debug exceptions are unmasked, unless this was a debug exception. IRQs are unmasked for instruction and data aborts only if the interupted context had irqs unmasked.
Following our 'dai' order, el1_dbg should run with everything masked. For the other cases we can inherit whatever we interrupted.
Add a macro inherit_daif to set daif based on the interrupted pstate.
--- arch/arm64/include/asm/assembler.h | 6 ++++++ arch/arm64/kernel/entry.S | 12 ++++-------- 2 files changed, 10 insertions(+), 8 deletions(-)
arch/arm64/include/asm/assembler.h +6 -0
@@ -48,6 +48,12 @@ msr daif, \flags .endm + /* Only on aarch64 pstate, PSR_D_BIT is different for aarch32 */ + .macro inherit_daif, pstate:req, tmp:req + and \tmp, \pstate, #(PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) + msr daif, \tmp + .endm +/* * Enable and disable interrupts. */
arch/arm64/kernel/entry.S +4 -8
@@ -510,11 +510,7 @@ el1_da: * Data abort handling */ mrs x3, far_el1 - enable_dbg - // re-enable interrupts if they were enabled in the aborted context - tbnz x23, #7, 1f // PSR_I_BIT - enable_irq -1: + inherit_daif pstate=x23, tmp=x2 clear_address_tag x0, x3 mov x2, sp // struct pt_regs bl do_mem_abort
@@ -525,7 +521,7 @@ el1_sp_pc: * Stack or PC alignment exception handling */ mrs x0, far_el1 - enable_dbg + inherit_daif pstate=x23, tmp=x2 mov x2, sp bl do_sp_pc_abort ASM_BUG()
@@ -533,7 +529,7 @@ el1_undef: /* * Undefined instruction */ - enable_dbg + inherit_daif pstate=x23, tmp=x2 mov x0, sp bl do_undefinstr ASM_BUG()
@@ -550,7 +546,7 @@ el1_dbg: kernel_exit 1 el1_inv: // TODO: add support for undefined instructions in kernel mode - enable_dbg + inherit_daif pstate=x23, tmp=x2 mov x0, sp mov x2, x1 mov x1, #BAD_SYNC
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 7/9 arm64: entry.S convert el0_sync
In reply to James Morseel0_sync also unmasks exceptions on a case-by-case basis, debug exceptions are enabled, unless this was a debug exception. Irqs are unmasked for some exception types but not for others.
el0_dbg should run with everything masked to prevent us taking a debug exception from do_debug_exception. For the other cases we can unmask everything. This changes the behaviour of fpsimd_{acc,exc} and el0_inv which previously ran with irqs masked.
This patch removed the last user of enable_dbg_and_irq, remove it.
--- arch/arm64/include/asm/assembler.h | 9 --------- arch/arm64/kernel/entry.S | 24 ++++++++++-------------- 2 files changed, 10 insertions(+), 23 deletions(-)
arch/arm64/include/asm/assembler.h +0 -9
@@ -96,15 +96,6 @@ 9990: .endm -/* -* Enable both debug exceptions and interrupts. This is likely to be -* faster than two daifclr operations, since writes to this register -* are self-synchronising. -*/ - .macro enable_dbg_and_irq - msr daifclr, #(8 | 2) - .endm -/* * SMP data memory barrier */
arch/arm64/kernel/entry.S +10 -14
@@ -670,8 +670,7 @@ el0_da: * Data abort handling */ mrs x26, far_el1 - // enable interrupts before calling the main handler - enable_dbg_and_irq + enable_daif ct_user_exit clear_address_tag x0, x26 mov x1, x25
@@ -683,8 +682,7 @@ el0_ia: * Instruction abort handling */ mrs x26, far_el1 - // enable interrupts before calling the main handler - enable_dbg_and_irq + enable_daif ct_user_exit mov x0, x26 mov x1, x25
@@ -695,7 +693,7 @@ el0_fpsimd_acc: /* * Floating Point or Advanced SIMD access */ - enable_dbg + enable_daif ct_user_exit mov x0, x25 mov x1, sp
@@ -705,7 +703,7 @@ el0_fpsimd_exc: /* * Floating Point or Advanced SIMD exception */ - enable_dbg + enable_daif ct_user_exit mov x0, x25 mov x1, sp
@@ -716,8 +714,7 @@ el0_sp_pc: * Stack or PC alignment exception handling */ mrs x26, far_el1 - // enable interrupts before calling the main handler - enable_dbg_and_irq + enable_daif ct_user_exit mov x0, x26 mov x1, x25
@@ -728,8 +725,7 @@ el0_undef: /* * Undefined instruction */ - // enable interrupts before calling the main handler - enable_dbg_and_irq + enable_daif ct_user_exit mov x0, sp bl do_undefinstr
@@ -738,7 +734,7 @@ el0_sys: /* * System instructions, for trapped cache maintenance instructions */ - enable_dbg_and_irq + enable_daif ct_user_exit mov x0, x25 mov x1, sp
@@ -753,11 +749,11 @@ el0_dbg: mov x1, x25 mov x2, sp bl do_debug_exception - enable_dbg + enable_daif ct_user_exit b ret_to_user el0_inv: - enable_dbg + enable_daif ct_user_exit mov x0, sp mov x1, #BAD_SYNC
@@ -836,7 +832,7 @@ el0_svc: mov wsc_nr, #__NR_syscalls el0_svc_naked: // compat entry point stp x0, xscno, [sp, #S_ORIG_X0] // save the original x0 and syscall number - enable_dbg_and_irq + enable_daif ct_user_exit 1 ldr x16, [tsk, #TSK_TI_FLAGS] // check for syscall hooks
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 8/9 arm64: entry.S: convert elX_irq
In reply to James MorseFollowing our 'dai' order, irqs should be processed with debug and serror exceptions unmasked.
Add a helper to unmask these two, (and fiq for good measure).
==
Changes since v3:
* Added comment against enable_da_f
--- arch/arm64/include/asm/assembler.h | 5 +++++ arch/arm64/kernel/entry.S | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-)
arch/arm64/include/asm/assembler.h +5 -0
@@ -54,6 +54,11 @@ msr daif, \tmp .endm + /* IRQ is the lowest priority flag, unconditionally unmask the rest. */ + .macro enable_da_f + msr daifclr, #(8 | 4 | 1) + .endm +/* * Enable and disable interrupts. */
arch/arm64/kernel/entry.S +2 -2
@@ -557,7 +557,7 @@ ENDPROC(el1_sync) .align 6 el1_irq: kernel_entry 1 - enable_dbg + enable_da_f #ifdef CONFIG_TRACE_IRQFLAGS bl trace_hardirqs_off #endif
@@ -766,7 +766,7 @@ ENDPROC(el0_sync) el0_irq: kernel_entry 0 el0_irq_naked: - enable_dbg + enable_da_f #ifdef CONFIG_TRACE_IRQFLAGS bl trace_hardirqs_off #endif
Signature · 1 line
2.15.0.rc2
PATCH RESEND v4 9/9 arm64: entry.S: move SError handling into a C function for future expansion
In reply to James MorseFrom: Xie XiuQi <[email protected]>
Today SError is taken using the inv_entry macro that ends up in bad_mode.
SError can be used by the RAS Extensions to notify either the OS or firmware of CPU problems, some of which may have been corrected.
To allow this handling to be added, add a do_serror() C function that just panic()s. Add the entry.S boiler plate to save/restore the CPU registers and unmask debug exceptions. Future patches may change do_serror() to return if the SError Interrupt was notification of a corrected error.
[Split out of a bigger patch, added compat path, renamed, enabled debug
exceptions]
--- arch/arm64/Kconfig | 2 +- arch/arm64/kernel/entry.S | 36 +++++++++++++++++++++++++++++------- arch/arm64/kernel/traps.c | 13 +++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-)
arch/arm64/Kconfig +1 -1
@@ -98,7 +98,7 @@ config ARM64 select HAVE_IRQ_TIME_ACCOUNTING select HAVE_MEMBLOCK select HAVE_MEMBLOCK_NODE_MAP if NUMA - select HAVE_NMI if ACPI_APEI_SEA + select HAVE_NMI select HAVE_PATA_PLATFORM select HAVE_PERF_EVENTS select HAVE_PERF_REGS
arch/arm64/kernel/entry.S +29 -7
@@ -375,18 +375,18 @@ ENTRY(vectors) kernel_ventry el1_sync // Synchronous EL1h kernel_ventry el1_irq // IRQ EL1h kernel_ventry el1_fiq_invalid // FIQ EL1h - kernel_ventry el1_error_invalid // Error EL1h + kernel_ventry el1_error // Error EL1h kernel_ventry el0_sync // Synchronous 64-bit EL0 kernel_ventry el0_irq // IRQ 64-bit EL0 kernel_ventry el0_fiq_invalid // FIQ 64-bit EL0 - kernel_ventry el0_error_invalid // Error 64-bit EL0 + kernel_ventry el0_error // Error 64-bit EL0 #ifdef CONFIG_COMPAT kernel_ventry el0_sync_compat // Synchronous 32-bit EL0 kernel_ventry el0_irq_compat // IRQ 32-bit EL0 kernel_ventry el0_fiq_invalid_compat // FIQ 32-bit EL0 - kernel_ventry el0_error_invalid_compat // Error 32-bit EL0 + kernel_ventry el0_error_compat // Error 32-bit EL0 #else kernel_ventry el0_sync_invalid // Synchronous 32-bit EL0 kernel_ventry el0_irq_invalid // IRQ 32-bit EL0
@@ -455,10 +455,6 @@ ENDPROC(el0_error_invalid) el0_fiq_invalid_compat: inv_entry 0, BAD_FIQ, 32 ENDPROC(el0_fiq_invalid_compat) - -el0_error_invalid_compat: - inv_entry 0, BAD_ERROR, 32 -ENDPROC(el0_error_invalid_compat) #endif el1_sync_invalid:
@@ -663,6 +659,10 @@ el0_svc_compat: el0_irq_compat: kernel_entry 0, 32 b el0_irq_naked + +el0_error_compat: + kernel_entry 0, 32 + b el0_error_naked #endif el0_da:
@@ -780,6 +780,28 @@ el0_irq_naked: b ret_to_user ENDPROC(el0_irq) +el1_error: + kernel_entry 1 + mrs x1, esr_el1 + enable_dbg + mov x0, sp + bl do_serror + kernel_exit 1 +ENDPROC(el1_error) + +el0_error: + kernel_entry 0 +el0_error_naked: + mrs x1, esr_el1 + enable_dbg + mov x0, sp + bl do_serror + enable_daif + ct_user_exit + b ret_to_user +ENDPROC(el0_error) + + /* * This is the fast syscall return path. We do as little as possible here, * and this includes saving x0 back into the kernel stack.
arch/arm64/kernel/traps.c +13 -0
@@ -709,6 +709,19 @@ asmlinkage void handle_bad_stack(struct pt_regs *regs) }#endif +asmlinkage void do_serror(struct pt_regs *regs, unsigned int esr) +{ +nmi_enter (); + +console_verbose (); + +pr_crit ("SError Interrupt on CPU%d, code 0x%08x -- %s\n" , +smp_processor_id (), esr,esr_get_class_string (esr)); +__show_regs (regs); + +panic ("Asynchronous SError Interrupt" ); +} +void __pte_error (const char *file,int line,unsigned long val) {pr_err ("%s:%d: bad pte %016lx.\n" , file, line, val);
Signature · 1 line
2.15.0.rc2