aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMike McTernan <mikemcternan@google.com>2022-11-25 14:26:15 +0000
committerMike McTernan <mikemcternan@google.com>2023-01-31 17:42:37 +0000
commitee23583e1053ea51aeee37b82e9b978a83a5225d (patch)
treecdd444e1fda0eacf2ff710a0516b727b70645ab8 /include
parent1279a44dc3c6c57c98b749f9ba3b694219f53f5d (diff)
downloadcommon-ee23583e1053ea51aeee37b82e9b978a83a5225d.tar.gz
lk: Add kernel BTI support.
Add support for ARM-A v8.5 Branch Target Identification. This is a mandatory Aarch64 feature that checks the BR and BLR instructions land on a BTI instruction. If this happens in a 'guarded' memory page (a new GP bit in the PTE is set), an exception is raised and execution can be halted (panic). This resists Jump Oriented Programming (JOP) attacks by reducing available code 'gadgets' Bug: 260397427 Test: build.py qemu-generic-arm64-test-debug Test: build.py qemu-generic-arm32-test-debug Test: build.py qemu-generic-arm64-test-debug, Qemu 7 with cpu=max (BTI supported) Change-Id: I682cb40be61b4819caa199e65338beeb452da766
Diffstat (limited to 'include')
-rw-r--r--include/arch/mmu.h3
-rw-r--r--include/arch/ops.h7
-rw-r--r--include/kernel/vm.h1
3 files changed, 11 insertions, 0 deletions
diff --git a/include/arch/mmu.h b/include/arch/mmu.h
index 616e6689..c761707f 100644
--- a/include/arch/mmu.h
+++ b/include/arch/mmu.h
@@ -47,6 +47,9 @@ __BEGIN_CDECLS
typedef struct arch_aspace arch_aspace_t;
#define ARCH_ASPACE_FLAG_KERNEL (1U<<0)
+#define ARCH_ASPACE_FLAG_BTI (1U<<1)
+
+#define ARCH_ASPACE_FLAG_ALL (ARCH_ASPACE_FLAG_KERNEL | ARCH_ASPACE_FLAG_BTI)
/* initialize per address space */
status_t arch_mmu_init_aspace(arch_aspace_t *aspace, vaddr_t base, size_t size, uint flags) __NONNULL((1));
diff --git a/include/arch/ops.h b/include/arch/ops.h
index 88503d18..99a11cd6 100644
--- a/include/arch/ops.h
+++ b/include/arch/ops.h
@@ -76,6 +76,13 @@ void arch_clear_pages_and_tags(vaddr_t addr, size_t size);
*/
bool arch_tagging_enabled(void);
+/**
+ * arch_bti_supported - indicates if branch target identification is supported.
+ *
+ * Return: true if BTI is supported, false if not
+ */
+bool arch_bti_supported(void);
+
__END_CDECLS
#endif // !ASSEMBLY
diff --git a/include/kernel/vm.h b/include/kernel/vm.h
index 316042bd..f869e436 100644
--- a/include/kernel/vm.h
+++ b/include/kernel/vm.h
@@ -297,6 +297,7 @@ typedef struct vmm_aspace {
} vmm_aspace_t;
#define VMM_ASPACE_FLAG_KERNEL 0x1
+#define VMM_ASPACE_FLAG_BTI 0x2
/**
* struct vmm_obj_slice - range of memory backed by a &struct vmm_obj