mirror of
https://github.com/openharmony/kernel_linux_common_modules.git
synced 2026-08-27 09:41:18 -04:00
4aecc74281
Signed-off-by: Haryslee <lihao189@huawei.com>
65 lines
1.7 KiB
C
65 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
|
*
|
|
* Pointer authentication keys initialisation.
|
|
*/
|
|
|
|
#ifndef __ASM_POINTER_AUTH_KEY_H
|
|
#define __ASM_POINTER_AUTH_KEY_H
|
|
|
|
#include <asm/alternative.h>
|
|
#include <asm/asm-offsets.h>
|
|
#include <asm/cpucaps.h>
|
|
#include <asm/sysreg.h>
|
|
|
|
.macro __ptrauth_address_keys_install_kernel tmp1, tmp2, tmp3
|
|
ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIB]
|
|
msr_s SYS_APIBKEYLO_EL1, \tmp2
|
|
msr_s SYS_APIBKEYHI_EL1, \tmp3
|
|
|
|
adr_l \tmp1, kernel_common_keys
|
|
ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA]
|
|
msr_s SYS_APIAKEYLO_EL1, \tmp2
|
|
msr_s SYS_APIAKEYHI_EL1, \tmp3
|
|
|
|
ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APDA]
|
|
msr_s SYS_APDAKEYLO_EL1, \tmp2
|
|
msr_s SYS_APDAKEYHI_EL1, \tmp3
|
|
|
|
ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APDB]
|
|
msr_s SYS_APDBKEYLO_EL1, \tmp2
|
|
msr_s SYS_APDBKEYHI_EL1, \tmp3
|
|
.endm
|
|
|
|
.macro __ptrauth_generic_key_install_kernel tmp1, tmp2, tmp3
|
|
ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APGA]
|
|
msr_s SYS_APGAKEYLO_EL1, \tmp2
|
|
msr_s SYS_APGAKEYHI_EL1, \tmp3
|
|
.endm
|
|
|
|
.macro ptrauth_keys_install_kernel_all tsk, tmp1, tmp2, tmp3
|
|
mov \tmp1, #THREAD_KEYS_KERNEL
|
|
add \tmp1, \tsk, \tmp1
|
|
|
|
alternative_if_not ARM64_HAS_ADDRESS_AUTH
|
|
b .Lno_addr_auth\@
|
|
alternative_else_nop_endif
|
|
__ptrauth_address_keys_install_kernel \tmp1, \tmp2, \tmp3
|
|
|
|
.Lno_addr_auth\@:
|
|
alternative_if ARM64_HAS_GENERIC_AUTH
|
|
__ptrauth_generic_key_install_kernel \tmp1, \tmp2, \tmp3
|
|
alternative_else_nop_endif
|
|
isb
|
|
.endm
|
|
|
|
.macro __ptrauth_keys_install_kernel_all tsk, tmp1, tmp2, tmp3
|
|
mov \tmp1, #THREAD_KEYS_KERNEL
|
|
add \tmp1, \tsk, \tmp1
|
|
__ptrauth_address_keys_install_kernel \tmp1, \tmp2, \tmp3
|
|
__ptrauth_generic_key_install_kernel \tmp1, \tmp2, \tmp3
|
|
.endm
|
|
|
|
#endif
|