0001
0002 #ifndef __ASM_ASM_UACCESS_H
0003 #define __ASM_ASM_UACCESS_H
0004
0005 #include <asm/alternative-macros.h>
0006 #include <asm/asm-extable.h>
0007 #include <asm/assembler.h>
0008 #include <asm/kernel-pgtable.h>
0009 #include <asm/mmu.h>
0010 #include <asm/sysreg.h>
0011
0012
0013
0014
0015 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
0016 .macro __uaccess_ttbr0_disable, tmp1
0017 mrs \tmp1, ttbr1_el1
0018 bic \tmp1, \tmp1, #TTBR_ASID_MASK
0019 sub \tmp1, \tmp1, #RESERVED_SWAPPER_OFFSET
0020 msr ttbr0_el1, \tmp1
0021 isb
0022 add \tmp1, \tmp1, #RESERVED_SWAPPER_OFFSET
0023 msr ttbr1_el1, \tmp1
0024 isb
0025 .endm
0026
0027 .macro __uaccess_ttbr0_enable, tmp1, tmp2
0028 get_current_task \tmp1
0029 ldr \tmp1, [\tmp1, #TSK_TI_TTBR0]
0030 mrs \tmp2, ttbr1_el1
0031 extr \tmp2, \tmp2, \tmp1, #48
0032 ror \tmp2, \tmp2, #16
0033 msr ttbr1_el1, \tmp2
0034 isb
0035 msr ttbr0_el1, \tmp1
0036 isb
0037 .endm
0038
0039 .macro uaccess_ttbr0_disable, tmp1, tmp2
0040 alternative_if_not ARM64_HAS_PAN
0041 save_and_disable_irq \tmp2
0042 __uaccess_ttbr0_disable \tmp1
0043 restore_irq \tmp2
0044 alternative_else_nop_endif
0045 .endm
0046
0047 .macro uaccess_ttbr0_enable, tmp1, tmp2, tmp3
0048 alternative_if_not ARM64_HAS_PAN
0049 save_and_disable_irq \tmp3
0050 __uaccess_ttbr0_enable \tmp1, \tmp2
0051 restore_irq \tmp3
0052 alternative_else_nop_endif
0053 .endm
0054 #else
0055 .macro uaccess_ttbr0_disable, tmp1, tmp2
0056 .endm
0057
0058 .macro uaccess_ttbr0_enable, tmp1, tmp2, tmp3
0059 .endm
0060 #endif
0061
0062 #define USER(l, x...) \
0063 9999: x; \
0064 _asm_extable_uaccess 9999b, l
0065
0066
0067
0068
0069
0070
0071 .macro user_ldp l, reg1, reg2, addr, post_inc
0072 8888: ldtr \reg1, [\addr];
0073 8889: ldtr \reg2, [\addr, #8];
0074 add \addr, \addr, \post_inc;
0075
0076 _asm_extable_uaccess 8888b, \l;
0077 _asm_extable_uaccess 8889b, \l;
0078 .endm
0079
0080 .macro user_stp l, reg1, reg2, addr, post_inc
0081 8888: sttr \reg1, [\addr];
0082 8889: sttr \reg2, [\addr, #8];
0083 add \addr, \addr, \post_inc;
0084
0085 _asm_extable_uaccess 8888b,\l;
0086 _asm_extable_uaccess 8889b,\l;
0087 .endm
0088
0089 .macro user_ldst l, inst, reg, addr, post_inc
0090 8888: \inst \reg, [\addr];
0091 add \addr, \addr, \post_inc;
0092
0093 _asm_extable_uaccess 8888b, \l;
0094 .endm
0095 #endif