diff options
Diffstat (limited to 'arch/arm64/include/asm/uaccess.h')
| -rw-r--r-- | arch/arm64/include/asm/uaccess.h | 72 | 
1 files changed, 12 insertions, 60 deletions
| diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 5c7b2f9d5913..05f4fc265428 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -136,55 +136,9 @@ static inline void __uaccess_enable_hw_pan(void)  			CONFIG_ARM64_PAN));  } -/* - * The Tag Check Flag (TCF) mode for MTE is per EL, hence TCF0 - * affects EL0 and TCF affects EL1 irrespective of which TTBR is - * used. - * The kernel accesses TTBR0 usually with LDTR/STTR instructions - * when UAO is available, so these would act as EL0 accesses using - * TCF0. - * However futex.h code uses exclusives which would be executed as - * EL1, this can potentially cause a tag check fault even if the - * user disables TCF0. - * - * To address the problem we set the PSTATE.TCO bit in uaccess_enable() - * and reset it in uaccess_disable(). - * - * The Tag check override (TCO) bit disables temporarily the tag checking - * preventing the issue. - */ -static inline void __uaccess_disable_tco(void) -{ -	asm volatile(ALTERNATIVE("nop", SET_PSTATE_TCO(0), -				 ARM64_MTE, CONFIG_KASAN_HW_TAGS)); -} - -static inline void __uaccess_enable_tco(void) -{ -	asm volatile(ALTERNATIVE("nop", SET_PSTATE_TCO(1), -				 ARM64_MTE, CONFIG_KASAN_HW_TAGS)); -} - -/* - * These functions disable tag checking only if in MTE async mode - * since the sync mode generates exceptions synchronously and the - * nofault or load_unaligned_zeropad can handle them. - */ -static inline void __uaccess_disable_tco_async(void) -{ -	if (system_uses_mte_async_or_asymm_mode()) -		 __uaccess_disable_tco(); -} - -static inline void __uaccess_enable_tco_async(void) -{ -	if (system_uses_mte_async_or_asymm_mode()) -		__uaccess_enable_tco(); -} -  static inline void uaccess_disable_privileged(void)  { -	__uaccess_disable_tco(); +	mte_disable_tco();  	if (uaccess_ttbr0_disable())  		return; @@ -194,7 +148,7 @@ static inline void uaccess_disable_privileged(void)  static inline void uaccess_enable_privileged(void)  { -	__uaccess_enable_tco(); +	mte_enable_tco();  	if (uaccess_ttbr0_enable())  		return; @@ -237,7 +191,7 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr)  	"1:	" load "	" reg "1, [%2]\n"			\  	"2:\n"								\  	_ASM_EXTABLE_##type##ACCESS_ERR_ZERO(1b, 2b, %w0, %w1)		\ -	: "+r" (err), "=&r" (x)						\ +	: "+r" (err), "=r" (x)						\  	: "r" (addr))  #define __raw_get_mem(ldr, x, ptr, err, type)					\ @@ -302,8 +256,8 @@ do {									\  #define get_user	__get_user  /* - * We must not call into the scheduler between __uaccess_enable_tco_async() and - * __uaccess_disable_tco_async(). As `dst` and `src` may contain blocking + * We must not call into the scheduler between __mte_enable_tco_async() and + * __mte_disable_tco_async(). As `dst` and `src` may contain blocking   * functions, we must evaluate these outside of the critical section.   */  #define __get_kernel_nofault(dst, src, type, err_label)			\ @@ -312,10 +266,10 @@ do {									\  	__typeof__(src) __gkn_src = (src);				\  	int __gkn_err = 0;						\  									\ -	__uaccess_enable_tco_async();					\ +	__mte_enable_tco_async();					\  	__raw_get_mem("ldr", *((type *)(__gkn_dst)),			\  		      (__force type *)(__gkn_src), __gkn_err, K);	\ -	__uaccess_disable_tco_async();					\ +	__mte_disable_tco_async();					\  									\  	if (unlikely(__gkn_err))					\  		goto err_label;						\ @@ -327,7 +281,7 @@ do {									\  	"2:\n"								\  	_ASM_EXTABLE_##type##ACCESS_ERR(1b, 2b, %w0)			\  	: "+r" (err)							\ -	: "r" (x), "r" (addr)) +	: "rZ" (x), "r" (addr))  #define __raw_put_mem(str, x, ptr, err, type)					\  do {										\ @@ -388,8 +342,8 @@ do {									\  #define put_user	__put_user  /* - * We must not call into the scheduler between __uaccess_enable_tco_async() and - * __uaccess_disable_tco_async(). As `dst` and `src` may contain blocking + * We must not call into the scheduler between __mte_enable_tco_async() and + * __mte_disable_tco_async(). As `dst` and `src` may contain blocking   * functions, we must evaluate these outside of the critical section.   */  #define __put_kernel_nofault(dst, src, type, err_label)			\ @@ -398,10 +352,10 @@ do {									\  	__typeof__(src) __pkn_src = (src);				\  	int __pkn_err = 0;						\  									\ -	__uaccess_enable_tco_async();					\ +	__mte_enable_tco_async();					\  	__raw_put_mem("str", *((type *)(__pkn_src)),			\  		      (__force type *)(__pkn_dst), __pkn_err, K);	\ -	__uaccess_disable_tco_async();					\ +	__mte_disable_tco_async();					\  									\  	if (unlikely(__pkn_err))					\  		goto err_label;						\ @@ -449,8 +403,6 @@ extern long strncpy_from_user(char *dest, const char __user *src, long count);  extern __must_check long strnlen_user(const char __user *str, long n);  #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE -struct page; -void memcpy_page_flushcache(char *to, struct page *page, size_t offset, size_t len);  extern unsigned long __must_check __copy_user_flushcache(void *to, const void __user *from, unsigned long n);  static inline int __copy_from_user_flushcache(void *dst, const void __user *src, unsigned size) | 
