This patch restores the kernel keys from current task during cpu resume after the mmu is turned on and ptrauth is enabled. A flag is added in macro ptrauth_keys_install_kernel to check if isb instruction needs to be executed.
Unified · Split
| @@ -39,14 +39,16 @@ alternative_if ARM64_HAS_GENERIC_AUTH · 38 unmodified lines | ||
| 39 | 39 | alternative_else_nop_endif |
| 40 | 40 | .endm |
| 41 | 41 | |
| 42 | − .macro ptrauth_keys_install_kernel tsk, tmp1, tmp2, tmp3 | |
| 42 | + .macro ptrauth_keys_install_kernel tsk, sync, tmp1, tmp2, tmp3 | |
| 43 | 43 | alternative_if ARM64_HAS_ADDRESS_AUTH |
| 44 | 44 | mov \tmp1, #THREAD_KEYS_KERNEL |
| 45 | 45 | add \tmp1, \tsk, \tmp1 |
| 46 | 46 | ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA] |
| 47 | 47 | msr_s SYS_APIAKEYLO_EL1, \tmp2 |
| 48 | 48 | msr_s SYS_APIAKEYHI_EL1, \tmp3 |
| 49 | + .if \sync == 1 | |
| 49 | 50 | isb |
| 51 | + .endif | |
| 50 | 52 | alternative_else_nop_endif |
| 51 | 53 | .endm |
| 52 | 54 | |
| @@ -55,7 +57,7 @@ alternative_else_nop_endif · 2 unmodified lines | ||
| 55 | 57 | .macro ptrauth_keys_install_user tsk, tmp1, tmp2, tmp3 |
| 56 | 58 | .endm |
| 57 | 59 | |
| 58 | − .macro ptrauth_keys_install_kernel tsk, tmp1, tmp2, tmp3 | |
| 60 | + .macro ptrauth_keys_install_kernel tsk, sync, tmp1, tmp2, tmp3 | |
| 59 | 61 | .endm |
| 60 | 62 | |
| 61 | 63 | #endif /* CONFIG_ARM64_PTR_AUTH */ |
| @@ -178,7 +178,7 @@ alternative_cb_end · 177 unmodified lines | ||
| 178 | 178 | |
| 179 | 179 | apply_ssbd 1, x22, x23 |
| 180 | 180 | |
| 181 | − ptrauth_keys_install_kernel tsk, x20, x22, x23 | |
| 181 | + ptrauth_keys_install_kernel tsk, 1, x20, x22, x23 | |
| 182 | 182 | .else |
| 183 | 183 | add x21, sp, #S_FRAME_SIZE |
| 184 | 184 | get_current_task tsk |
| @@ -900,7 +900,7 @@ ENTRY(cpu_switch_to) · 715 unmodified lines | ||
| 900 | 900 | ldr lr, [x8] |
| 901 | 901 | mov sp, x9 |
| 902 | 902 | msr sp_el0, x1 |
| 903 | − ptrauth_keys_install_kernel x1, x8, x9, x10 | |
| 903 | + ptrauth_keys_install_kernel x1, 1, x8, x9, x10 | |
| 904 | 904 | ret |
| 905 | 905 | ENDPROC(cpu_switch_to) |
| 906 | 906 | NOKPROBE(cpu_switch_to) |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <linux/linkage.h> |
| 12 | 12 | #include <asm/assembler.h> |
| 13 | 13 | #include <asm/asm-offsets.h> |
| 14 | +#include <asm/asm_pointer_auth.h> | |
| 14 | 15 | #include <asm/hwcap.h> |
| 15 | 16 | #include <asm/pgtable.h> |
| 16 | 17 | #include <asm/pgtable-hwdef.h> |
| @@ -137,6 +138,7 @@ alternative_if ARM64_HAS_RAS_EXTN · 120 unmodified lines | ||
| 137 | 138 | msr_s SYS_DISR_EL1, xzr |
| 138 | 139 | alternative_else_nop_endif |
| 139 | 140 | |
| 141 | + ptrauth_keys_install_kernel x14, 0, x1, x2, x3 | |
| 140 | 142 | isb |
| 141 | 143 | ret |
| 142 | 144 | SYM_FUNC_END(cpu_do_resume) |