Skip to content

Commit 3ce8f58

Browse files
willdeaconctmarinas
authored andcommitted
arm64: scs: Remove redundant save/restore of SCS SP on entry to/from EL0
When returning to userspace, the SCS is empty and so the SCS SP just points to the base address of the SCS page. Rather than saving and restoring this address in the current task, we can simply restore the SCS SP to point at the base of the stack on entry to EL1 from EL0. Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Will Deacon <will@kernel.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 6712fcd commit 3ce8f58

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

arch/arm64/include/asm/scs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#ifdef CONFIG_SHADOW_CALL_STACK
1111
scs_sp .req x18
1212

13+
.macro scs_load_current_base
14+
get_current_task scs_sp
15+
ldr scs_sp, [scs_sp, #TSK_TI_SCS_BASE]
16+
.endm
17+
1318
.macro scs_load_current
1419
get_current_task scs_sp
1520
ldr scs_sp, [scs_sp, #TSK_TI_SCS_SP]
@@ -19,6 +24,9 @@
1924
str scs_sp, [\tsk, #TSK_TI_SCS_SP]
2025
.endm
2126
#else
27+
.macro scs_load_current_base
28+
.endm
29+
2230
.macro scs_load_current
2331
.endm
2432

arch/arm64/kernel/entry.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ alternative_if ARM64_HAS_ADDRESS_AUTH
273273
alternative_else_nop_endif
274274
1:
275275

276-
scs_load_current
276+
scs_load_current_base
277277
.else
278278
add x21, sp, #PT_REGS_SIZE
279279
get_current_task tsk
@@ -378,8 +378,6 @@ alternative_if ARM64_WORKAROUND_845719
378378
alternative_else_nop_endif
379379
#endif
380380
3:
381-
scs_save tsk
382-
383381
/* Ignore asynchronous tag check faults in the uaccess routines */
384382
ldr x0, [tsk, THREAD_SCTLR_USER]
385383
clear_mte_async_tcf x0

0 commit comments

Comments
 (0)