arm64: sdei: Handle exceptions taken inside the event handler
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | arm64: sdei: Run the event handler on the kernel vectorsarch/ | +20 | 2 replies | |
| 2/2 | arm64: sdei: Preserve the interrupted context's exception registersarch/ | +54 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] arm64: sdei: Handle exceptions taken inside the event handler
An SDEI event can land anywhere, and a synchronous exception taken by its handler breaks the context it interrupted:
- With KPTI, an event that lands in user space runs the handler on the trampoline vectors, whose current-EL half is empty. The exception loops there and the CPU is lost.
- The exception overwrites ELR, SPSR, ESR and FAR. If the event landed in exception entry or return, the interrupted context runs on the handler's values: a task gets SIGILL, or the kernel oopses on a fault it never took.
Patch 1 runs the handler on the kernel vectors. Patch 2 saves and restores the exception registers around it.
Handlers take such exceptions in normal operation now that SDEI delivers NMI backtraces: show_regs() reads through _nofault() accessors that fault, and a kprobe or WARN anywhere in the path takes a BRK.
Tested under QEMU TCG with TF-A, 4 CPUs, 20 x sysrq-l under load, with a test-only copy_from_kernel_nofault() of address 0x10 in sdei_nmi_handler():
- v7.4-rc1, KPTI on: CPUs stuck in the trampoline vectors, RCU stalls.
- v7.4-rc1, KPTI off: 60 "unsafe: exception during handler" warnings, SIGILL and SIGSEGV in user tasks, and an oops in execve().
- With the series, KPTI on and off: no warnings, no stalls.
Patch 2 was also run on arm64 hardware with firmware SDEI, where a plain sysrq-l was enough to trigger the warning without it.
Kiryl Shutsemau (Meta) (2):
arm64: sdei: Run the event handler on the kernel vectors
arm64: sdei: Preserve the interrupted context's exception registers
arch/arm64/kernel/sdei.c | 83 +++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 9 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.54.0