xref: /linux/arch/riscv/include/asm/cfi.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_RISCV_CFI_H
3 #define _ASM_RISCV_CFI_H
4 
5 /*
6  * Clang Control Flow Integrity (CFI) support.
7  *
8  * Copyright (C) 2023 Google LLC
9  */
10 #include <linux/bug.h>
11 
12 struct pt_regs;
13 
14 #ifdef CONFIG_CFI_CLANG
15 enum bug_trap_type handle_cfi_failure(struct pt_regs *regs);
16 #define __bpfcall
cfi_get_offset(void)17 static inline int cfi_get_offset(void)
18 {
19 	return 4;
20 }
21 
22 #define cfi_get_offset cfi_get_offset
23 extern u32 cfi_bpf_hash;
24 extern u32 cfi_bpf_subprog_hash;
25 extern u32 cfi_get_func_hash(void *func);
26 #else
handle_cfi_failure(struct pt_regs * regs)27 static inline enum bug_trap_type handle_cfi_failure(struct pt_regs *regs)
28 {
29 	return BUG_TRAP_TYPE_NONE;
30 }
31 
32 #define cfi_bpf_hash 0U
33 #define cfi_bpf_subprog_hash 0U
cfi_get_func_hash(void * func)34 static inline u32 cfi_get_func_hash(void *func)
35 {
36 	return 0;
37 }
38 #endif /* CONFIG_CFI_CLANG */
39 
40 #endif /* _ASM_RISCV_CFI_H */
41