morello_capcpy() was introduced by "arm64: morello: Context-switch capability GPRs and CSP" in order to copy the capability registers (preserving their tags). Nowadays, the kernel is compiled as a hybrid binary, allowing capabilities to be directly manipulated. This implies in in particular that memcpy() preserves capability tags if possible. As a result, we no longer need a dedicated function like morello_capcpy() - we can simply let the compiler copy capabilities itself, or call memcpy().
This commit partially reverts "arm64: morello: Context-switch capability GPRs and CSP".
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com ---
Note: I checked in the generated code for copy_thread() that the branch to morello_capcpy is replaced by one to memcpy, with absolutely no other difference.
arch/arm64/include/asm/morello.h | 6 ------ arch/arm64/kernel/process.c | 9 +-------- arch/arm64/lib/morello.S | 18 ------------------ 3 files changed, 1 insertion(+), 32 deletions(-)
diff --git a/arch/arm64/include/asm/morello.h b/arch/arm64/include/asm/morello.h index 9f35d710cbfe..68ec2d4767a2 100644 --- a/arch/arm64/include/asm/morello.h +++ b/arch/arm64/include/asm/morello.h @@ -62,12 +62,6 @@ void morello_thread_set_csp(struct pt_regs *regs, user_uintptr_t sp); * Any invalid usage will result in an error at link time. */
-/* - * Copies src to dst preserving capability tags. - * All of dst, src and len must be 16-byte aligned. - */ -void *morello_capcpy(void *dst, const void *src, size_t len); - void morello_thread_start(struct pt_regs *regs, unsigned long pc); void morello_thread_init_user(void); void morello_thread_save_user_state(struct task_struct *tsk); diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index cab68cebf1fa..cff890a14d41 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -396,14 +396,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) ptrauth_thread_init_kernel(p);
if (likely(!args->fn)) { - if (!system_supports_morello()) { - *childregs = *current_pt_regs(); - } else { - BUILD_BUG_ON(__alignof__(struct pt_regs) < - __alignof__(__uint128_t)); - morello_capcpy(childregs, current_pt_regs(), - sizeof(*current_pt_regs())); - } + *childregs = *current_pt_regs(); childregs->regs[0] = 0;
/* diff --git a/arch/arm64/lib/morello.S b/arch/arm64/lib/morello.S index 5bc1540c829f..04ef653380d2 100644 --- a/arch/arm64/lib/morello.S +++ b/arch/arm64/lib/morello.S @@ -46,24 +46,6 @@ SYM_FUNC_START(morello_build_any_user_cap) ret SYM_FUNC_END(morello_build_any_user_cap)
-SYM_FUNC_START(morello_capcpy) - mov x3, x0 - and x4, x2, #0x10 // Bytes to reach 32-byte alignment (0 or 16) - subs x5, x2, x4 // 32-byte aligned length - b.eq 2f -1: - ldp c6, c7, [x1], #32 // 32-byte loop - stp c6, c7, [x3], #32 - subs x5, x5, #32 - b.ne 1b -2: - cbz x4, 3f // 16-byte leftover (if any) - ldr c6, [x1], #16 - str c6, [x3], #16 -3: - ret -SYM_FUNC_END(morello_capcpy) - SYM_FUNC_START(__morello_thread_init_user) mov x9, #THREAD_MORELLO_USER_STATE add x0, x0, x9 // x0 = tsk->thread.morello_user_state