Skip to content

Commit 3e39341

Browse files
mrutland-armwilldeacon
authored andcommitted
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: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: James Morse <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 7a2c094 commit 3e39341

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

arch/arm64/kernel/entry.S

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,13 @@ alternative_cb_end
167167
.if \el == 0
168168
clear_gp_regs
169169
mrs x21, sp_el0
170-
ldr_this_cpu tsk, __entry_task, x20 // Ensure MDSCR_EL1.SS is clear,
171-
ldr x19, [tsk, #TSK_TI_FLAGS] // since we can unmask debug
172-
disable_step_tsk x19, x20 // exceptions when scheduling.
170+
ldr_this_cpu tsk, __entry_task, x20
171+
msr sp_el0, tsk
172+
173+
// Ensure MDSCR_EL1.SS is clear, since we can unmask debug exceptions
174+
// when scheduling.
175+
ldr x19, [tsk, #TSK_TI_FLAGS]
176+
disable_step_tsk x19, x20
173177

174178
apply_ssbd 1, x22, x23
175179

@@ -232,13 +236,6 @@ alternative_else_nop_endif
232236
str w21, [sp, #S_SYSCALLNO]
233237
.endif
234238

235-
/*
236-
* Set sp_el0 to current thread_info.
237-
*/
238-
.if \el == 0
239-
msr sp_el0, tsk
240-
.endif
241-
242239
/* Save pmr */
243240
alternative_if ARM64_HAS_IRQ_PRIO_MASKING
244241
mrs_s x20, SYS_ICC_PMR_EL1

0 commit comments

Comments
 (0)