We no longer need to have standalone __morello_{get,put}_user_cap_asm() helpers; we can implement the access to user capabilities inline, on the model of __{get,put}_mem_asm(). We cannot directly use the latter though, as a different constraint is required for the capability to load/store.
There is currently no way to get Clang to output the X register corresponding to a capability argument, so we also need to add .L__gpr_num_* aliases for C registers, in order to keep the EX_DATA_REG() macro happy.
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com --- arch/arm64/include/asm/gpr-num.h | 6 +++++- arch/arm64/include/asm/morello.h | 4 ---- arch/arm64/include/asm/uaccess.h | 16 ++++++++++++++-- arch/arm64/lib/morello.S | 23 ----------------------- 4 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/arch/arm64/include/asm/gpr-num.h b/arch/arm64/include/asm/gpr-num.h index 05da4a7c5788..bac15df6242f 100644 --- a/arch/arm64/include/asm/gpr-num.h +++ b/arch/arm64/include/asm/gpr-num.h @@ -7,9 +7,11 @@ .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 .equ .L__gpr_num_x\num, \num .equ .L__gpr_num_w\num, \num + .equ .L__gpr_num_c\num, \num .endr .equ .L__gpr_num_xzr, 31 .equ .L__gpr_num_wzr, 31 + .equ .L__gpr_num_czr, 31
#else /* __ASSEMBLY__ */
@@ -17,9 +19,11 @@ " .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n" \ " .equ .L__gpr_num_x\num, \num\n" \ " .equ .L__gpr_num_w\num, \num\n" \ +" .equ .L__gpr_num_c\num, \num\n" \ " .endr\n" \ " .equ .L__gpr_num_xzr, 31\n" \ -" .equ .L__gpr_num_wzr, 31\n" +" .equ .L__gpr_num_wzr, 31\n" \ +" .equ .L__gpr_num_czr, 31\n"
#endif /* __ASSEMBLY__ */
diff --git a/arch/arm64/include/asm/morello.h b/arch/arm64/include/asm/morello.h index 68ec2d4767a2..357f403d073d 100644 --- a/arch/arm64/include/asm/morello.h +++ b/arch/arm64/include/asm/morello.h @@ -47,10 +47,6 @@ int morello_ptrace_access_remote_cap(struct task_struct *tsk, struct user_cap *user_cap, unsigned int gup_flags);
-/* Low-level uacces helpers, must not be called directly */ -void __morello_get_user_cap_asm(uintcap_t *x, const uintcap_t __user *ptr, int *err); -void __morello_put_user_cap_asm(const uintcap_t *x, uintcap_t __user *ptr, int *err); - #ifdef CONFIG_CHERI_PURECAP_UABI void morello_thread_set_csp(struct pt_regs *regs, user_uintptr_t sp); #endif diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 6a7a323cd36b..cf12e70baa98 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -436,7 +436,13 @@ do { \ do { \ __chk_user_ptr(ptr); \ uaccess_ttbr0_enable(); \ - __morello_get_user_cap_asm(&(x), (ptr), &(err)); \ + asm volatile( \ + "1: ldtr %1, [%2]\n" \ + "2:\n" \ + _ASM_EXTABLE_UACCESS_ERR_ZERO(1b, 2b, %w0, %w1) \ + : "+r" (err), "=C" (x) \ + /* TODO [PCuABI] - perform the access via the user capability */\ + : "r" ((ptraddr_t)(user_uintptr_t)(ptr))); \ uaccess_ttbr0_disable(); \ } while (0)
@@ -466,7 +472,13 @@ do { \ do { \ __chk_user_ptr(ptr); \ uaccess_ttbr0_enable(); \ - __morello_put_user_cap_asm(&(x), (ptr), &(err)); \ + asm volatile( \ + "1: sttr %1, [%2]\n" \ + "2:\n" \ + _ASM_EXTABLE_UACCESS_ERR(1b, 2b, %w0) \ + : "+r" (err) \ + /* TODO [PCuABI] - perform the access via the user capability */\ + : "CZ" (x), "r" ((ptraddr_t)(user_uintptr_t)(ptr))); \ uaccess_ttbr0_disable(); \ } while (0)
diff --git a/arch/arm64/lib/morello.S b/arch/arm64/lib/morello.S index 04ef653380d2..0800375ef33d 100644 --- a/arch/arm64/lib/morello.S +++ b/arch/arm64/lib/morello.S @@ -177,29 +177,6 @@ SYM_FUNC_START(morello_task_restore_user_tls) ret SYM_FUNC_END(morello_task_restore_user_tls)
-SYM_FUNC_START(__morello_get_user_cap_asm) - user_ldst 1f, ldtr, c3, x1, 0 - str c3, [x0] - ret - - // Exception fixups -1: mov w3, #-EFAULT - str w3, [x2] - str czr, [x0] - ret -SYM_FUNC_END(__morello_get_user_cap_asm) - -SYM_FUNC_START(__morello_put_user_cap_asm) - ldr c3, [x0] - user_ldst 1f, sttr, c3, x1, 0 - ret - - // Exception fixups -1: mov w3, #-EFAULT - str w3, [x2] - ret -SYM_FUNC_END(__morello_put_user_cap_asm) -
SYM_FUNC_START(__morello_cap_lo_hi_tag) str x0, [x1]