diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2023-03-27 19:02:49 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2023-03-27 19:02:49 +0000 |
commit | 81e1880d57e75d2d4d803dda990dd9e084e65300 (patch) | |
tree | d302049075963290b7dad7c7cf46c81d65c8a960 /sys/arch/arm64/include | |
parent | a1b672c48d95478927971e1174699803be45de92 (diff) |
Implement branch target protection using the branch target identification
feature introduced in Armv8.5. This provides "head-CFI" to complement
the "tail-CFI" provided by retguard. Unfortunately most arm64 machines
don't support this feature yet. But Apple M2 does support it and it
seems to work there.
ok deraadt@
Diffstat (limited to 'sys/arch/arm64/include')
-rw-r--r-- | sys/arch/arm64/include/armreg.h | 3 | ||||
-rw-r--r-- | sys/arch/arm64/include/asm.h | 12 | ||||
-rw-r--r-- | sys/arch/arm64/include/pte.h | 3 |
3 files changed, 10 insertions, 8 deletions
diff --git a/sys/arch/arm64/include/armreg.h b/sys/arch/arm64/include/armreg.h index c1799668508..bffe8cccacf 100644 --- a/sys/arch/arm64/include/armreg.h +++ b/sys/arch/arm64/include/armreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armreg.h,v 1.26 2022/12/23 17:46:49 kettenis Exp $ */ +/* $OpenBSD: armreg.h,v 1.27 2023/03/27 19:02:48 kettenis Exp $ */ /*- * Copyright (c) 2013, 2014 Andrew Turner * Copyright (c) 2015 The FreeBSD Foundation @@ -165,6 +165,7 @@ #define ESR_ELx_EXCEPTION(esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) #define EXCP_UNKNOWN 0x00 /* Unkwn exception */ #define EXCP_FP_SIMD 0x07 /* FP/SIMD trap */ +#define EXCP_BRANCH_TGT 0x0d /* Branch target exception */ #define EXCP_ILL_STATE 0x0e /* Illegal execution state */ #define EXCP_SVC 0x15 /* SVC trap */ #define EXCP_MSR 0x18 /* MSR/MRS trap */ diff --git a/sys/arch/arm64/include/asm.h b/sys/arch/arm64/include/asm.h index 59687fc2149..c85ea5c2c9c 100644 --- a/sys/arch/arm64/include/asm.h +++ b/sys/arch/arm64/include/asm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asm.h,v 1.11 2022/12/08 01:25:44 guenther Exp $ */ +/* $OpenBSD: asm.h,v 1.12 2023/03/27 19:02:48 kettenis Exp $ */ /* $NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $ */ /* @@ -125,11 +125,11 @@ # define RETGUARD_SYMBOL(x) #endif -#define ENTRY(y) _ENTRY(y); _PROF_PROLOGUE -#define ENTRY_NP(y) _ENTRY(y) -#define ENTRY_NB(y) _ENTRY_NB(y); _PROF_PROLOGUE -#define ASENTRY(y) _ENTRY(y); _PROF_PROLOGUE -#define ASENTRY_NP(y) _ENTRY(y) +#define ENTRY(y) _ENTRY(y); bti c; _PROF_PROLOGUE +#define ENTRY_NP(y) _ENTRY(y); bti c +#define ENTRY_NB(y) _ENTRY_NB(y); bti c; _PROF_PROLOGUE +#define ASENTRY(y) _ENTRY(y); bti c; _PROF_PROLOGUE +#define ASENTRY_NP(y) _ENTRY(y); bti c #define END(y) .size y, . - y #define EENTRY(sym) .globl sym; sym: #define EEND(sym) diff --git a/sys/arch/arm64/include/pte.h b/sys/arch/arm64/include/pte.h index c6fa32124c1..8306b2b7e69 100644 --- a/sys/arch/arm64/include/pte.h +++ b/sys/arch/arm64/include/pte.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pte.h,v 1.7 2021/02/28 21:28:33 patrick Exp $ */ +/* $OpenBSD: pte.h,v 1.8 2023/03/27 19:02:48 kettenis Exp $ */ /* * Copyright (c) 2014 Dale Rahn <drahn@dalerahn.com> * @@ -43,6 +43,7 @@ #define ATTR_SW_WIRED (1UL << 55) #define ATTR_UXN (1UL << 54) #define ATTR_PXN (1UL << 53) +#define ATTR_GP (1UL << 50) #define ATTR_nG (1 << 11) #define ATTR_AF (1 << 10) #define ATTR_SH(x) ((x) << 8) |