printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / cfi.h
blobf0df518e11dd15a63aa3561355f71afe66c45e9f
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Clang Control Flow Integrity (CFI) support.
5 * Copyright (C) 2022 Google LLC
6 */
7 #ifndef _LINUX_CFI_H
8 #define _LINUX_CFI_H
10 #include <linux/bug.h>
11 #include <linux/module.h>
12 #include <asm/cfi.h>
14 #ifndef cfi_get_offset
15 static inline int cfi_get_offset(void)
17 return 0;
19 #endif
21 #ifdef CONFIG_CFI_CLANG
22 enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr,
23 unsigned long *target, u32 type);
25 static inline enum bug_trap_type report_cfi_failure_noaddr(struct pt_regs *regs,
26 unsigned long addr)
28 return report_cfi_failure(regs, addr, NULL, 0);
30 #endif /* CONFIG_CFI_CLANG */
32 #ifdef CONFIG_ARCH_USES_CFI_TRAPS
33 bool is_cfi_trap(unsigned long addr);
34 #else
35 static inline bool is_cfi_trap(unsigned long addr) { return false; }
36 #endif
38 #ifdef CONFIG_MODULES
39 #ifdef CONFIG_ARCH_USES_CFI_TRAPS
40 void module_cfi_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
41 struct module *mod);
42 #else
43 static inline void module_cfi_finalize(const Elf_Ehdr *hdr,
44 const Elf_Shdr *sechdrs,
45 struct module *mod) {}
46 #endif /* CONFIG_ARCH_USES_CFI_TRAPS */
47 #endif /* CONFIG_MODULES */
49 #ifndef CFI_NOSEAL
50 #define CFI_NOSEAL(x)
51 #endif
53 #endif /* _LINUX_CFI_H */