Module Name: src Committed By: ryo Date: Sat May 23 18:08:59 UTC 2020
Modified Files: src/sys/arch/aarch64/aarch64: cpufunc.c cpuswitch.S exec_machdep.c genassym.cf netbsd32_machdep.c vectors.S vm_machdep.c src/sys/arch/aarch64/include: armreg.h machdep.h proc.h Log Message: Not only the kernel thread, but also the userland PAC keys (APIA,APIB,APDA,APDB,APGA) are now randomly initialized at exec, and switched when context switch. userland programs are able to perform pointer authentication on ARMv8.3+PAC cpu. reviewd by maxv@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/aarch64/aarch64/cpufunc.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/aarch64/cpuswitch.S cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/exec_machdep.c cvs rdiff -u -r1.24 -r1.25 src/sys/arch/aarch64/aarch64/genassym.cf cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/aarch64/aarch64/vectors.S cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/vm_machdep.c cvs rdiff -u -r1.44 -r1.45 src/sys/arch/aarch64/include/armreg.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/include/machdep.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/include/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/aarch64/aarch64/cpufunc.c diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.18 src/sys/arch/aarch64/aarch64/cpufunc.c:1.19 --- src/sys/arch/aarch64/aarch64/cpufunc.c:1.18 Fri May 15 04:55:40 2020 +++ src/sys/arch/aarch64/aarch64/cpufunc.c Sat May 23 18:08:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.c,v 1.18 2020/05/15 04:55:40 ryo Exp $ */ +/* $NetBSD: cpufunc.c,v 1.19 2020/05/23 18:08:58 ryo Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org> @@ -30,7 +30,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.18 2020/05/15 04:55:40 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.19 2020/05/23 18:08:58 ryo Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -474,8 +474,8 @@ aarch64_pac_init(int primary) return -1; /* Set the key. Curlwp here is the CPU's idlelwp. */ - reg_APIAKeyLo_EL1_write(curlwp->l_md.md_ia_kern_lo); - reg_APIAKeyHi_EL1_write(curlwp->l_md.md_ia_kern_hi); + reg_APIAKeyLo_EL1_write(curlwp->l_md.md_ia_kern[0]); + reg_APIAKeyHi_EL1_write(curlwp->l_md.md_ia_kern[1]); return 0; #else Index: src/sys/arch/aarch64/aarch64/cpuswitch.S diff -u src/sys/arch/aarch64/aarch64/cpuswitch.S:1.20 src/sys/arch/aarch64/aarch64/cpuswitch.S:1.21 --- src/sys/arch/aarch64/aarch64/cpuswitch.S:1.20 Fri May 22 19:29:26 2020 +++ src/sys/arch/aarch64/aarch64/cpuswitch.S Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuswitch.S,v 1.20 2020/05/22 19:29:26 ryo Exp $ */ +/* $NetBSD: cpuswitch.S,v 1.21 2020/05/23 18:08:59 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include "opt_ddb.h" #include "opt_kasan.h" -RCSID("$NetBSD: cpuswitch.S,v 1.20 2020/05/22 19:29:26 ryo Exp $") +RCSID("$NetBSD: cpuswitch.S,v 1.21 2020/05/23 18:08:59 ryo Exp $") ARMV8_DEFINE_OPTIONS @@ -92,14 +92,27 @@ ENTRY_NP(cpu_switchto) adrl x4, _C_LABEL(aarch64_pac_enabled) ldr w4, [x4] cbz w4, 1f -#if L_MD_IA_KERN_LO + 8 == L_MD_IA_KERN_HI - ldp x5, x6, [x1, #L_MD_IA_KERN_LO] -#else - ldr x5, [x1, #L_MD_IA_KERN_LO] - ldr x6, [x1, #L_MD_IA_KERN_HI] -#endif + ldp x5, x6, [x1, #L_MD_IA_KERN] msr APIAKeyLo_EL1, x5 msr APIAKeyHi_EL1, x6 + + /* Other keys only need to be updated when switching to user process */ + ldr w5, [x1, #L_FLAG] + and w5, w5, #LW_SYSTEM /* (lwp->l_flag & LW_SYSTEM) ? */ + cbnz w5, 1f + + ldp x5, x6, [x1, #L_MD_IB_USER] + msr APIBKeyLo_EL1, x5 + msr APIBKeyHi_EL1, x6 + ldp x5, x6, [x1, #L_MD_DA_USER] + msr APDAKeyLo_EL1, x5 + msr APDAKeyHi_EL1, x6 + ldp x5, x6, [x1, #L_MD_DB_USER] + msr APDBKeyLo_EL1, x5 + msr APDBKeyHi_EL1, x6 + ldp x5, x6, [x1, #L_MD_GA_USER] + msr APGAKeyLo_EL1, x5 + msr APGAKeyHi_EL1, x6 1: #endif @@ -163,12 +176,7 @@ ENTRY_NP(cpu_switchto_softint) adrl x4, _C_LABEL(aarch64_pac_enabled) ldr w4, [x4] cbz w4, 1f -#if L_MD_IA_KERN_LO + 8 == L_MD_IA_KERN_HI - ldp x5, x6, [x0, #L_MD_IA_KERN_LO] -#else - ldr x5, [x0, #L_MD_IA_KERN_LO] - ldr x6, [x0, #L_MD_IA_KERN_HI] -#endif + ldp x5, x6, [x0, #L_MD_IA_KERN] msr APIAKeyLo_EL1, x5 msr APIAKeyHi_EL1, x6 1: @@ -209,12 +217,7 @@ ENTRY_NP(cpu_switchto_softint) adrl x4, _C_LABEL(aarch64_pac_enabled) ldr w4, [x4] cbz w4, 1f -#if L_MD_IA_KERN_LO + 8 == L_MD_IA_KERN_HI - ldp x5, x6, [x19, #L_MD_IA_KERN_LO] -#else - ldr x5, [x19, #L_MD_IA_KERN_LO] - ldr x6, [x19, #L_MD_IA_KERN_HI] -#endif + ldp x5, x6, [x19, #L_MD_IA_KERN] msr APIAKeyLo_EL1, x5 msr APIAKeyHi_EL1, x6 1: @@ -271,10 +274,10 @@ ENTRY_NP(lwp_trampoline) cbz w4, 1f mov x26, x1 bl _C_LABEL(cprng_strong64) - str x0, [x26, #L_MD_IA_KERN_LO] + str x0, [x26, #L_MD_IA_KERN] msr APIAKeyLo_EL1, x0 bl _C_LABEL(cprng_strong64) - str x0, [x26, #L_MD_IA_KERN_HI] + str x0, [x26, #(L_MD_IA_KERN + 8)] msr APIAKeyHi_EL1, x0 1: #endif @@ -395,12 +398,7 @@ ENTRY_NP(el0_trap_exit) adrl x4, _C_LABEL(aarch64_pac_enabled) ldr w4, [x4] cbz w4, 1f -#if L_MD_IA_USER_LO + 8 == L_MD_IA_USER_HI - ldp x5, x6, [x9, #L_MD_IA_USER_LO] -#else - ldr x5, [x9, #L_MD_IA_USER_LO] - ldr x6, [x9, #L_MD_IA_USER_HI] -#endif + ldp x5, x6, [x9, #L_MD_IA_USER] msr APIAKeyLo_EL1, x5 msr APIAKeyHi_EL1, x6 1: Index: src/sys/arch/aarch64/aarch64/exec_machdep.c diff -u src/sys/arch/aarch64/aarch64/exec_machdep.c:1.6 src/sys/arch/aarch64/aarch64/exec_machdep.c:1.7 --- src/sys/arch/aarch64/aarch64/exec_machdep.c:1.6 Sun Nov 24 11:45:00 2019 +++ src/sys/arch/aarch64/aarch64/exec_machdep.c Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: exec_machdep.c,v 1.6 2019/11/24 11:45:00 rin Exp $ */ +/* $NetBSD: exec_machdep.c,v 1.7 2020/05/23 18:08:59 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: exec_machdep.c,v 1.6 2019/11/24 11:45:00 rin Exp $"); +__KERNEL_RCSID(1, "$NetBSD: exec_machdep.c,v 1.7 2020/05/23 18:08:59 ryo Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_netbsd32.h" @@ -40,6 +40,7 @@ __KERNEL_RCSID(1, "$NetBSD: exec_machdep #include <sys/systm.h> #include <sys/proc.h> #include <sys/exec.h> +#include <sys/cprng.h> #include <uvm/uvm_extern.h> @@ -51,7 +52,9 @@ __KERNEL_RCSID(1, "$NetBSD: exec_machdep #endif #include <aarch64/armreg.h> +#include <aarch64/cpufunc.h> #include <aarch64/frame.h> +#include <aarch64/machdep.h> #if EXEC_ELF64 int @@ -97,11 +100,46 @@ aarch64_netbsd_elf32_probe(struct lwp *l #endif void +aarch64_setregs_ptrauth(struct lwp *l, bool randomize) +{ +#ifdef ARMV83_PAC + if (!aarch64_pac_enabled) + return; + + if (randomize) { + cprng_strong(kern_cprng, l->l_md.md_ia_user, + sizeof(l->l_md.md_ia_user), 0); + cprng_strong(kern_cprng, l->l_md.md_ib_user, + sizeof(l->l_md.md_ib_user), 0); + cprng_strong(kern_cprng, l->l_md.md_da_user, + sizeof(l->l_md.md_da_user), 0); + cprng_strong(kern_cprng, l->l_md.md_db_user, + sizeof(l->l_md.md_db_user), 0); + cprng_strong(kern_cprng, l->l_md.md_ga_user, + sizeof(l->l_md.md_ga_user), 0); + } else { + memset(l->l_md.md_ia_user, 0, + sizeof(l->l_md.md_ia_user)); + memset(l->l_md.md_ib_user, 0, + sizeof(l->l_md.md_ib_user)); + memset(l->l_md.md_da_user, 0, + sizeof(l->l_md.md_da_user)); + memset(l->l_md.md_db_user, 0, + sizeof(l->l_md.md_db_user)); + memset(l->l_md.md_ga_user, 0, + sizeof(l->l_md.md_ga_user)); + } +#endif +} + +void setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack) { struct proc * const p = l->l_proc; struct trapframe * const tf = l->l_md.md_utf; + aarch64_setregs_ptrauth(l, true); + p->p_flag &= ~PK_32; /* Index: src/sys/arch/aarch64/aarch64/genassym.cf diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.24 src/sys/arch/aarch64/aarch64/genassym.cf:1.25 --- src/sys/arch/aarch64/aarch64/genassym.cf:1.24 Fri May 15 04:55:40 2020 +++ src/sys/arch/aarch64/aarch64/genassym.cf Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.24 2020/05/15 04:55:40 ryo Exp $ +# $NetBSD: genassym.cf,v 1.25 2020/05/23 18:08:59 ryo Exp $ #- # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -144,16 +144,20 @@ define PGSHIFT PGSHIFT # Important offsets into the lwp and proc structs & associated constants define L_PCB offsetof(struct lwp, l_addr) define L_CPU offsetof(struct lwp, l_cpu) +define L_FLAG offsetof(struct lwp, l_flag) define L_PROC offsetof(struct lwp, l_proc) define L_PRIVATE offsetof(struct lwp, l_private) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_UTF offsetof(struct lwp, l_md.md_utf) define L_MD_CPACR offsetof(struct lwp, l_md.md_cpacr) define L_MD_ONFAULT offsetof(struct lwp, l_md.md_onfault) -define L_MD_IA_KERN_LO offsetof(struct lwp, l_md.md_ia_kern_lo) -define L_MD_IA_KERN_HI offsetof(struct lwp, l_md.md_ia_kern_hi) -define L_MD_IA_USER_LO offsetof(struct lwp, l_md.md_ia_user_lo) -define L_MD_IA_USER_HI offsetof(struct lwp, l_md.md_ia_user_hi) +define L_MD_IA_KERN offsetof(struct lwp, l_md.md_ia_kern) +define L_MD_IA_USER offsetof(struct lwp, l_md.md_ia_user) +define L_MD_IB_USER offsetof(struct lwp, l_md.md_ib_user) +define L_MD_DA_USER offsetof(struct lwp, l_md.md_da_user) +define L_MD_DB_USER offsetof(struct lwp, l_md.md_db_user) +define L_MD_GA_USER offsetof(struct lwp, l_md.md_ga_user) +define LW_SYSTEM LW_SYSTEM define FB_X19 FB_X19 define FB_X20 FB_X20 Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep.c diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.12 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.13 --- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.12 Thu Apr 23 17:21:53 2020 +++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.12 2020/04/23 17:21:53 skrll Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.13 2020/05/23 18:08:59 ryo Exp $ */ /* * Copyright (c) 2018 Ryo Shimizu <r...@nerv.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.12 2020/04/23 17:21:53 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.13 2020/05/23 18:08:59 ryo Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -63,6 +63,8 @@ netbsd32_setregs(struct lwp *l, struct e struct proc * const p = l->l_proc; struct trapframe * const tf = l->l_md.md_utf; + aarch64_setregs_ptrauth(l, false); + p->p_flag |= PK_32; /* Index: src/sys/arch/aarch64/aarch64/vectors.S diff -u src/sys/arch/aarch64/aarch64/vectors.S:1.16 src/sys/arch/aarch64/aarch64/vectors.S:1.17 --- src/sys/arch/aarch64/aarch64/vectors.S:1.16 Fri May 15 09:08:10 2020 +++ src/sys/arch/aarch64/aarch64/vectors.S Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vectors.S,v 1.16 2020/05/15 09:08:10 ryo Exp $ */ +/* $NetBSD: vectors.S,v 1.17 2020/05/23 18:08:59 ryo Exp $ */ #include <aarch64/asm.h> #include "assym.h" @@ -91,12 +91,7 @@ ENTRY_NBTI(\func) adrl x4, _C_LABEL(aarch64_pac_enabled) ldr w4, [x4] cbz w4, 1f -#if L_MD_IA_KERN_LO + 8 == L_MD_IA_KERN_HI - ldp x5, x6, [x1, #L_MD_IA_KERN_LO] -#else - ldr x5, [x1, #L_MD_IA_KERN_LO] - ldr x6, [x1, #L_MD_IA_KERN_HI] -#endif + ldp x5, x6, [x1, #L_MD_IA_KERN] msr APIAKeyLo_EL1, x5 msr APIAKeyHi_EL1, x6 1: Index: src/sys/arch/aarch64/aarch64/vm_machdep.c diff -u src/sys/arch/aarch64/aarch64/vm_machdep.c:1.7 src/sys/arch/aarch64/aarch64/vm_machdep.c:1.8 --- src/sys/arch/aarch64/aarch64/vm_machdep.c:1.7 Fri May 22 19:29:26 2020 +++ src/sys/arch/aarch64/aarch64/vm_machdep.c Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.7 2020/05/22 19:29:26 ryo Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.8 2020/05/23 18:08:59 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_ddb.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.7 2020/05/22 19:29:26 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.8 2020/05/23 18:08:59 ryo Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -97,6 +97,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp */ l2->l_md.md_cpacr = CPACR_FPEN_NONE; +#ifdef ARMV83_PAC /* * Temporary kern PAC key, not really strong, but better than zero. * The real key gets generated by the new thread in lwp_trampoline(). @@ -105,8 +106,21 @@ cpu_lwp_fork(struct lwp *l1, struct lwp * be called early at boot time, when the CPRNG subsystem hasn't yet * been initialized. */ - l2->l_md.md_ia_kern_lo = (uintptr_t)l2; - l2->l_md.md_ia_kern_hi = (uintptr_t)stack; + l2->l_md.md_ia_kern[0] = (uintptr_t)l2; + l2->l_md.md_ia_kern[1] = (uintptr_t)stack; + + /* inherit user PAC key */ + memcpy(l2->l_md.md_ia_user, l1->l_md.md_ia_user, + sizeof(l2->l_md.md_ia_user)); + memcpy(l2->l_md.md_ib_user, l1->l_md.md_ib_user, + sizeof(l2->l_md.md_ib_user)); + memcpy(l2->l_md.md_da_user, l1->l_md.md_da_user, + sizeof(l2->l_md.md_da_user)); + memcpy(l2->l_md.md_db_user, l1->l_md.md_db_user, + sizeof(l2->l_md.md_db_user)); + memcpy(l2->l_md.md_ga_user, l1->l_md.md_ga_user, + sizeof(l2->l_md.md_ga_user)); +#endif /* * Set up the kernel stack for the process. Index: src/sys/arch/aarch64/include/armreg.h diff -u src/sys/arch/aarch64/include/armreg.h:1.44 src/sys/arch/aarch64/include/armreg.h:1.45 --- src/sys/arch/aarch64/include/armreg.h:1.44 Thu May 21 05:04:13 2020 +++ src/sys/arch/aarch64/include/armreg.h Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: armreg.h,v 1.44 2020/05/21 05:04:13 ryo Exp $ */ +/* $NetBSD: armreg.h,v 1.45 2020/05/23 18:08:59 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -569,6 +569,26 @@ AARCH64REG_WRITE_INLINE3(APIAKeyLo_EL1, AARCH64REG_READ_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a")) AARCH64REG_WRITE_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a")) + AARCH64REG_READ_INLINE(cpacr_el1) // Coprocessor Access Control Regiser AARCH64REG_WRITE_INLINE(cpacr_el1) Index: src/sys/arch/aarch64/include/machdep.h diff -u src/sys/arch/aarch64/include/machdep.h:1.10 src/sys/arch/aarch64/include/machdep.h:1.11 --- src/sys/arch/aarch64/include/machdep.h:1.10 Sat Feb 15 08:16:10 2020 +++ src/sys/arch/aarch64/include/machdep.h Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.h,v 1.10 2020/02/15 08:16:10 skrll Exp $ */ +/* $NetBSD: machdep.h,v 1.11 2020/05/23 18:08:59 ryo Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org> @@ -136,6 +136,9 @@ cpu_disable_onfault(void) } #endif +/* exec_machdep.c */ +void aarch64_setregs_ptrauth(struct lwp *, bool); + /* fpu.c */ void fpu_attach(struct cpu_info *); struct fpreg; Index: src/sys/arch/aarch64/include/proc.h diff -u src/sys/arch/aarch64/include/proc.h:1.6 src/sys/arch/aarch64/include/proc.h:1.7 --- src/sys/arch/aarch64/include/proc.h:1.6 Sun Apr 12 07:49:58 2020 +++ src/sys/arch/aarch64/include/proc.h Sat May 23 18:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.6 2020/04/12 07:49:58 maxv Exp $ */ +/* $NetBSD: proc.h,v 1.7 2020/05/23 18:08:59 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -44,11 +44,12 @@ struct mdlwp { uint64_t md_cpacr; uint32_t md_flags; - uint64_t md_ia_kern_lo; /* APIAKeyLo_EL1 */ - uint64_t md_ia_kern_hi; /* APIAKeyHi_EL1 */ - - uint64_t md_ia_user_lo; /* APIAKeyLo_EL1 */ - uint64_t md_ia_user_hi; /* APIAKeyHi_EL1 */ + uint64_t md_ia_kern[2]; /* APIAKey{Lo,Hi}_EL1 used in the kernel */ + uint64_t md_ia_user[2]; /* APIAKey{Lo,Hi}_EL1 used in user-process */ + uint64_t md_ib_user[2]; /* APIBKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_da_user[2]; /* APDAKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_db_user[2]; /* APDBKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_ga_user[2]; /* APGAKey{Lo,Hi}_EL1 only used in user-proc. */ }; struct mdproc {