1 #ifndef __ASM_ASM_UACCESS_H
2 #define __ASM_ASM_UACCESS_H
4 #include <asm/alternative.h>
5 #include <asm/kernel-pgtable.h>
6 #include <asm/sysreg.h>
7 #include <asm/assembler.h>
10 * User access enabling/disabling macros.
12 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
13 .macro __uaccess_ttbr0_disable, tmp1
14 mrs \tmp1, ttbr1_el1 // swapper_pg_dir
15 add \tmp1, \tmp1, #SWAPPER_DIR_SIZE // reserved_ttbr0 at the end of swapper_pg_dir
16 msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
20 .macro __uaccess_ttbr0_enable, tmp1
22 ldr \tmp1, [\tmp1, #TSK_TI_TTBR0] // load saved TTBR0_EL1
23 msr ttbr0_el1, \tmp1 // set the non-PAN TTBR0_EL1
27 .macro uaccess_ttbr0_disable, tmp1
28 alternative_if_not ARM64_HAS_PAN
29 __uaccess_ttbr0_disable \tmp1
30 alternative_else_nop_endif
33 .macro uaccess_ttbr0_enable, tmp1, tmp2
34 alternative_if_not ARM64_HAS_PAN
35 save_and_disable_irq \tmp2 // avoid preemption
36 __uaccess_ttbr0_enable \tmp1
38 alternative_else_nop_endif
41 .macro uaccess_ttbr0_disable, tmp1
44 .macro uaccess_ttbr0_enable, tmp1, tmp2
49 * These macros are no-ops when UAO is present.
51 .macro uaccess_disable_not_uao, tmp1
52 uaccess_ttbr0_disable \tmp1
53 alternative_if ARM64_ALT_PAN_NOT_UAO
55 alternative_else_nop_endif
58 .macro uaccess_enable_not_uao, tmp1, tmp2
59 uaccess_ttbr0_enable \tmp1, \tmp2
60 alternative_if ARM64_ALT_PAN_NOT_UAO
62 alternative_else_nop_endif