.. | .. |
---|
2 | 2 | #ifndef __ASM_ASM_UACCESS_H |
---|
3 | 3 | #define __ASM_ASM_UACCESS_H |
---|
4 | 4 | |
---|
5 | | -#include <asm/alternative.h> |
---|
| 5 | +#include <asm/alternative-macros.h> |
---|
6 | 6 | #include <asm/kernel-pgtable.h> |
---|
7 | 7 | #include <asm/mmu.h> |
---|
8 | 8 | #include <asm/sysreg.h> |
---|
.. | .. |
---|
15 | 15 | .macro __uaccess_ttbr0_disable, tmp1 |
---|
16 | 16 | mrs \tmp1, ttbr1_el1 // swapper_pg_dir |
---|
17 | 17 | bic \tmp1, \tmp1, #TTBR_ASID_MASK |
---|
18 | | - sub \tmp1, \tmp1, #RESERVED_TTBR0_SIZE // reserved_ttbr0 just before swapper_pg_dir |
---|
| 18 | + sub \tmp1, \tmp1, #PAGE_SIZE // reserved_pg_dir just before swapper_pg_dir |
---|
19 | 19 | msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1 |
---|
20 | 20 | isb |
---|
21 | | - add \tmp1, \tmp1, #RESERVED_TTBR0_SIZE |
---|
| 21 | + add \tmp1, \tmp1, #PAGE_SIZE |
---|
22 | 22 | msr ttbr1_el1, \tmp1 // set reserved ASID |
---|
23 | 23 | isb |
---|
24 | 24 | .endm |
---|
25 | 25 | |
---|
26 | 26 | .macro __uaccess_ttbr0_enable, tmp1, tmp2 |
---|
27 | | - get_thread_info \tmp1 |
---|
| 27 | + get_current_task \tmp1 |
---|
28 | 28 | ldr \tmp1, [\tmp1, #TSK_TI_TTBR0] // load saved TTBR0_EL1 |
---|
29 | 29 | mrs \tmp2, ttbr1_el1 |
---|
30 | 30 | extr \tmp2, \tmp2, \tmp1, #48 |
---|
.. | .. |
---|
59 | 59 | #endif |
---|
60 | 60 | |
---|
61 | 61 | /* |
---|
62 | | - * These macros are no-ops when UAO is present. |
---|
| 62 | + * Generate the assembly for LDTR/STTR with exception table entries. |
---|
| 63 | + * This is complicated as there is no post-increment or pair versions of the |
---|
| 64 | + * unprivileged instructions, and USER() only works for single instructions. |
---|
63 | 65 | */ |
---|
64 | | - .macro uaccess_disable_not_uao, tmp1, tmp2 |
---|
65 | | - uaccess_ttbr0_disable \tmp1, \tmp2 |
---|
66 | | -alternative_if ARM64_ALT_PAN_NOT_UAO |
---|
67 | | - SET_PSTATE_PAN(1) |
---|
68 | | -alternative_else_nop_endif |
---|
| 66 | + .macro uao_ldp l, reg1, reg2, addr, post_inc |
---|
| 67 | +8888: ldtr \reg1, [\addr]; |
---|
| 68 | +8889: ldtr \reg2, [\addr, #8]; |
---|
| 69 | + add \addr, \addr, \post_inc; |
---|
| 70 | + |
---|
| 71 | + _asm_extable 8888b,\l; |
---|
| 72 | + _asm_extable 8889b,\l; |
---|
69 | 73 | .endm |
---|
70 | 74 | |
---|
71 | | - .macro uaccess_enable_not_uao, tmp1, tmp2, tmp3 |
---|
72 | | - uaccess_ttbr0_enable \tmp1, \tmp2, \tmp3 |
---|
73 | | -alternative_if ARM64_ALT_PAN_NOT_UAO |
---|
74 | | - SET_PSTATE_PAN(0) |
---|
75 | | -alternative_else_nop_endif |
---|
| 75 | + .macro uao_stp l, reg1, reg2, addr, post_inc |
---|
| 76 | +8888: sttr \reg1, [\addr]; |
---|
| 77 | +8889: sttr \reg2, [\addr, #8]; |
---|
| 78 | + add \addr, \addr, \post_inc; |
---|
| 79 | + |
---|
| 80 | + _asm_extable 8888b,\l; |
---|
| 81 | + _asm_extable 8889b,\l; |
---|
76 | 82 | .endm |
---|
77 | 83 | |
---|
78 | | -/* |
---|
79 | | - * Remove the address tag from a virtual address, if present. |
---|
80 | | - */ |
---|
81 | | - .macro untagged_addr, dst, addr |
---|
82 | | - sbfx \dst, \addr, #0, #56 |
---|
83 | | - and \dst, \dst, \addr |
---|
84 | | - .endm |
---|
| 84 | + .macro uao_user_alternative l, inst, alt_inst, reg, addr, post_inc |
---|
| 85 | +8888: \alt_inst \reg, [\addr]; |
---|
| 86 | + add \addr, \addr, \post_inc; |
---|
85 | 87 | |
---|
| 88 | + _asm_extable 8888b,\l; |
---|
| 89 | + .endm |
---|
86 | 90 | #endif |
---|