To implement the context tracker properly on arm64,
a function call needs to be made after debugging and
interrupts are turned on, but before the lr is changed
to point to ret_to_user(). If the function call
is made after the lr is changed the function will not
return to the correct place.
For similar reasons, defer the setting of x0 so that
it doesn't need to be saved around the function call
(save far_el1 in x26 temporarily instead).
Acked-by: Will Deacon <will.deacon@arm.com>
Reviewed-by: Kevin Hilman <khilman@linaro.org>
Tested-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Larry Bassel <larry.bassel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class
cmp x24, #ESR_EL1_EC_SVC64 // SVC in 64-bit state
b.eq el0_svc
lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class
cmp x24, #ESR_EL1_EC_SVC64 // SVC in 64-bit state
b.eq el0_svc
cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0
b.eq el0_da
cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0
cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0
b.eq el0_da
cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0
lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class
cmp x24, #ESR_EL1_EC_SVC32 // SVC in 32-bit state
b.eq el0_svc_compat
lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class
cmp x24, #ESR_EL1_EC_SVC32 // SVC in 32-bit state
b.eq el0_svc_compat
cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0
b.eq el0_da
cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0
cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0
b.eq el0_da
cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0
/*
* Data abort handling
*/
/*
* Data abort handling
*/
- mrs x0, far_el1
- bic x0, x0, #(0xff << 56)
// enable interrupts before calling the main handler
enable_dbg_and_irq
// enable interrupts before calling the main handler
enable_dbg_and_irq
+ bic x0, x26, #(0xff << 56)
b do_mem_abort
el0_ia:
/*
* Instruction abort handling
*/
b do_mem_abort
el0_ia:
/*
* Instruction abort handling
*/
// enable interrupts before calling the main handler
enable_dbg_and_irq
// enable interrupts before calling the main handler
enable_dbg_and_irq
orr x1, x25, #1 << 24 // use reserved ISS bit for instruction aborts
mov x2, sp
orr x1, x25, #1 << 24 // use reserved ISS bit for instruction aborts
mov x2, sp
b do_mem_abort
el0_fpsimd_acc:
/*
b do_mem_abort
el0_fpsimd_acc:
/*
enable_dbg
mov x0, x25
mov x1, sp
enable_dbg
mov x0, x25
mov x1, sp
b do_fpsimd_acc
el0_fpsimd_exc:
/*
b do_fpsimd_acc
el0_fpsimd_exc:
/*
enable_dbg
mov x0, x25
mov x1, sp
enable_dbg
mov x0, x25
mov x1, sp
b do_fpsimd_exc
el0_sp_pc:
/*
* Stack or PC alignment exception handling
*/
b do_fpsimd_exc
el0_sp_pc:
/*
* Stack or PC alignment exception handling
*/
// enable interrupts before calling the main handler
enable_dbg_and_irq
// enable interrupts before calling the main handler
enable_dbg_and_irq
b do_sp_pc_abort
el0_undef:
/*
b do_sp_pc_abort
el0_undef:
/*
// enable interrupts before calling the main handler
enable_dbg_and_irq
mov x0, sp
// enable interrupts before calling the main handler
enable_dbg_and_irq
mov x0, sp
b do_undefinstr
el0_dbg:
/*
b do_undefinstr
el0_dbg:
/*
mov x0, sp
mov x1, #BAD_SYNC
mrs x2, esr_el1
mov x0, sp
mov x1, #BAD_SYNC
mrs x2, esr_el1
b bad_mode
ENDPROC(el0_sync)
b bad_mode
ENDPROC(el0_sync)