arm64: entry: SP Alignment Fault doesn't write to FAR_EL1
authorJames Morse <james.morse@arm.com>
Mon, 22 Jul 2019 15:11:48 +0000 (16:11 +0100)
committerWill Deacon <will@kernel.org>
Mon, 22 Jul 2019 15:22:34 +0000 (16:22 +0100)
commit40ca0ce56d4bb889dc43b455c55398468115569a
tree7a9676958df8994374788b5f1fa92502e0e6192e
parentcbdf8a189a66001c36007bf0f5c975d0376c5c3a
arm64: entry: SP Alignment Fault doesn't write to FAR_EL1

Comparing the arm-arm's  pseudocode for AArch64.PCAlignmentFault() with
AArch64.SPAlignmentFault() shows that SP faults don't copy the faulty-SP
to FAR_EL1, but this is where we read from, and the address we provide
to user-space with the BUS_ADRALN signal.

For user-space this value will be UNKNOWN due to the previous ERET to
user-space. If the last value is preserved, on systems with KASLR or KPTI
this will be the user-space link-register left in FAR_EL1 by tramp_exit().
Fix this to retrieve the original sp_el0 value, and pass this to
do_sp_pc_fault().

SP alignment faults from EL1 will cause us to take the fault again when
trying to store the pt_regs. This eventually takes us to the overflow
stack. Remove the ESR_ELx_EC_SP_ALIGN check as we will never make it
this far.

Fixes: 60ffc30d5652 ("arm64: Exception handling")
Signed-off-by: James Morse <james.morse@arm.com>
[will: change label name and fleshed out comment]
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/entry.S