Commit 3e393417 authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon

arm64: entry: cleanup sp_el0 manipulation

The kernel stashes the current task struct in sp_el0 so that this can be
acquired consistently/cheaply when required. When we take an exception
from EL0 we have to:

1) stash the original sp_el0 value
2) find the current task
3) update sp_el0 with the current task pointer

Currently steps #1 and #2 occur in one place, and step #3 a while later.
As the value of sp_el0 is immaterial between these points, let's move
them together to make the code clearer and minimize ifdeffery. This
necessitates moving the comment for MDSCR_EL1.SS.

There should be no functional change as a result of this patch.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 7a2c0944
...@@ -167,9 +167,13 @@ alternative_cb_end ...@@ -167,9 +167,13 @@ alternative_cb_end
.if \el == 0 .if \el == 0
clear_gp_regs clear_gp_regs
mrs x21, sp_el0 mrs x21, sp_el0
ldr_this_cpu tsk, __entry_task, x20 // Ensure MDSCR_EL1.SS is clear, ldr_this_cpu tsk, __entry_task, x20
ldr x19, [tsk, #TSK_TI_FLAGS] // since we can unmask debug msr sp_el0, tsk
disable_step_tsk x19, x20 // exceptions when scheduling.
// Ensure MDSCR_EL1.SS is clear, since we can unmask debug exceptions
// when scheduling.
ldr x19, [tsk, #TSK_TI_FLAGS]
disable_step_tsk x19, x20
apply_ssbd 1, x22, x23 apply_ssbd 1, x22, x23
...@@ -232,13 +236,6 @@ alternative_else_nop_endif ...@@ -232,13 +236,6 @@ alternative_else_nop_endif
str w21, [sp, #S_SYSCALLNO] str w21, [sp, #S_SYSCALLNO]
.endif .endif
/*
* Set sp_el0 to current thread_info.
*/
.if \el == 0
msr sp_el0, tsk
.endif
/* Save pmr */ /* Save pmr */
alternative_if ARM64_HAS_IRQ_PRIO_MASKING alternative_if ARM64_HAS_IRQ_PRIO_MASKING
mrs_s x20, SYS_ICC_PMR_EL1 mrs_s x20, SYS_ICC_PMR_EL1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment