• James Morse's avatar
    arm64: entry: SP Alignment Fault doesn't write to FAR_EL1 · 40ca0ce5
    James Morse authored
    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: 60ffc30d ("arm64: Exception handling")
    Signed-off-by: default avatarJames Morse <james.morse@arm.com>
    [will: change label name and fleshed out comment]
    Signed-off-by: default avatarWill Deacon <will@kernel.org>
    40ca0ce5
entry.S 30 KB