History

arm64: suspend: restore the kernel ptrauth keys

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.

Amit Daniel Kachhap committed 6 years ago

Commit e51f5f51 parent cdcb61a3 files · +8 −4Browse files

Unified · Split

3 files
  1. arch/arm64/include/asm/asm_pointer_auth.h +4 −2
  2. arch/arm64/kernel/entry.S +2 −2
  3. arch/arm64/mm/proc.S +2 −0
arch/arm64/include/asm/asm_pointer_auth.h+4−2
@@ -39,14 +39,16 @@ alternative_if ARM64_HAS_GENERIC_AUTH · 38 unmodified lines
3939 alternative_else_nop_endif
4040 .endm
4141
42− .macro ptrauth_keys_install_kernel tsk, tmp1, tmp2, tmp3
42+ .macro ptrauth_keys_install_kernel tsk, sync, tmp1, tmp2, tmp3
4343 alternative_if ARM64_HAS_ADDRESS_AUTH
4444 mov \tmp1, #THREAD_KEYS_KERNEL
4545 add \tmp1, \tsk, \tmp1
4646 ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA]
4747 msr_s SYS_APIAKEYLO_EL1, \tmp2
4848 msr_s SYS_APIAKEYHI_EL1, \tmp3
49+ .if \sync == 1
4950 isb
51+ .endif
5052 alternative_else_nop_endif
5153 .endm
5254
@@ -55,7 +57,7 @@ alternative_else_nop_endif · 2 unmodified lines
5557 .macro ptrauth_keys_install_user tsk, tmp1, tmp2, tmp3
5658 .endm
5759
58− .macro ptrauth_keys_install_kernel tsk, tmp1, tmp2, tmp3
60+ .macro ptrauth_keys_install_kernel tsk, sync, tmp1, tmp2, tmp3
5961 .endm
6062
6163 #endif /* CONFIG_ARM64_PTR_AUTH */
arch/arm64/kernel/entry.S+2−2
@@ -178,7 +178,7 @@ alternative_cb_end · 177 unmodified lines
178178
179179 apply_ssbd 1, x22, x23
180180
181− ptrauth_keys_install_kernel tsk, x20, x22, x23
181+ ptrauth_keys_install_kernel tsk, 1, x20, x22, x23
182182 .else
183183 add x21, sp, #S_FRAME_SIZE
184184 get_current_task tsk
@@ -900,7 +900,7 @@ ENTRY(cpu_switch_to) · 715 unmodified lines
900900 ldr lr, [x8]
901901 mov sp, x9
902902 msr sp_el0, x1
903− ptrauth_keys_install_kernel x1, x8, x9, x10
903+ ptrauth_keys_install_kernel x1, 1, x8, x9, x10
904904 ret
905905 ENDPROC(cpu_switch_to)
906906 NOKPROBE(cpu_switch_to)
arch/arm64/mm/proc.S+2−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <linux/linkage.h>
1212 #include <asm/assembler.h>
1313 #include <asm/asm-offsets.h>
14+#include <asm/asm_pointer_auth.h>
1415 #include <asm/hwcap.h>
1516 #include <asm/pgtable.h>
1617 #include <asm/pgtable-hwdef.h>
@@ -137,6 +138,7 @@ alternative_if ARM64_HAS_RAS_EXTN · 120 unmodified lines
137138 msr_s SYS_DISR_EL1, xzr
138139 alternative_else_nop_endif
139140
141+ ptrauth_keys_install_kernel x14, 0, x1, x2, x3
140142 isb
141143 ret
142144 SYM_FUNC_END(cpu_do_resume)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t