Skip to content

Commit e51f5f5

Browse files
amitdanielkachhapctmarinas
authored andcommitted
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. Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com> Reviewed-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent cdcb61a commit e51f5f5

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

arch/arm64/include/asm/asm_pointer_auth.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ alternative_if ARM64_HAS_GENERIC_AUTH
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
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ alternative_cb_end
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)
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
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
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)

0 commit comments

Comments
 (0)