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
39alternative_else_nop_endif39alternative_else_nop_endif
40 .endm40 .endm
41 41
42 .macro ptrauth_keys_install_kernel tsk, tmp1, tmp2, tmp342 .macro ptrauth_keys_install_kernel tsk, sync, tmp1, tmp2, tmp3
43alternative_if ARM64_HAS_ADDRESS_AUTH43alternative_if ARM64_HAS_ADDRESS_AUTH
44 mov \tmp1, #THREAD_KEYS_KERNEL44 mov \tmp1, #THREAD_KEYS_KERNEL
45 add \tmp1, \tsk, \tmp145 add \tmp1, \tsk, \tmp1
46 ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA]46 ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA]
47 msr_s SYS_APIAKEYLO_EL1, \tmp247 msr_s SYS_APIAKEYLO_EL1, \tmp2
48 msr_s SYS_APIAKEYHI_EL1, \tmp348 msr_s SYS_APIAKEYHI_EL1, \tmp3
49 .if \sync == 1
49 isb50 isb
51 .endif
50alternative_else_nop_endif52alternative_else_nop_endif
51 .endm53 .endm
52 54
@@ -55,7 +57,7 @@ alternative_else_nop_endif · 2 unmodified lines
55 .macro ptrauth_keys_install_user tsk, tmp1, tmp2, tmp357 .macro ptrauth_keys_install_user tsk, tmp1, tmp2, tmp3
56 .endm58 .endm
57 59
58 .macro ptrauth_keys_install_kernel tsk, tmp1, tmp2, tmp360 .macro ptrauth_keys_install_kernel tsk, sync, tmp1, tmp2, tmp3
59 .endm61 .endm
60 62
61#endif /* CONFIG_ARM64_PTR_AUTH */63#endif /* CONFIG_ARM64_PTR_AUTH */
arch/arm64/kernel/entry.S+2−2
@@ -178,7 +178,7 @@ alternative_cb_end · 177 unmodified lines
178 178
179 apply_ssbd 1, x22, x23179 apply_ssbd 1, x22, x23
180 180
181 ptrauth_keys_install_kernel tsk, x20, x22, x23181 ptrauth_keys_install_kernel tsk, 1, x20, x22, x23
182 .else182 .else
183 add x21, sp, #S_FRAME_SIZE183 add x21, sp, #S_FRAME_SIZE
184 get_current_task tsk184 get_current_task tsk
@@ -900,7 +900,7 @@ ENTRY(cpu_switch_to) · 715 unmodified lines
900 ldr lr, [x8]900 ldr lr, [x8]
901 mov sp, x9901 mov sp, x9
902 msr sp_el0, x1902 msr sp_el0, x1
903 ptrauth_keys_install_kernel x1, x8, x9, x10903 ptrauth_keys_install_kernel x1, 1, x8, x9, x10
904 ret904 ret
905ENDPROC(cpu_switch_to)905ENDPROC(cpu_switch_to)
906NOKPROBE(cpu_switch_to)906NOKPROBE(cpu_switch_to)
arch/arm64/mm/proc.S+2−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
11#include <linux/linkage.h>11#include <linux/linkage.h>
12#include <asm/assembler.h>12#include <asm/assembler.h>
13#include <asm/asm-offsets.h>13#include <asm/asm-offsets.h>
14#include <asm/asm_pointer_auth.h>
14#include <asm/hwcap.h>15#include <asm/hwcap.h>
15#include <asm/pgtable.h>16#include <asm/pgtable.h>
16#include <asm/pgtable-hwdef.h>17#include <asm/pgtable-hwdef.h>
@@ -137,6 +138,7 @@ alternative_if ARM64_HAS_RAS_EXTN · 120 unmodified lines
137 msr_s SYS_DISR_EL1, xzr138 msr_s SYS_DISR_EL1, xzr
138alternative_else_nop_endif139alternative_else_nop_endif
139 140
141 ptrauth_keys_install_kernel x14, 0, x1, x2, x3
140 isb142 isb
141 ret143 ret
142SYM_FUNC_END(cpu_do_resume)144SYM_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