Sami Tolvanen | 00a195e | 2017-05-11 15:03:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_CFI_H |
| 2 | #define _LINUX_CFI_H |
| 3 | |
| 4 | #include <linux/stringify.h> |
| 5 | |
| 6 | #ifdef CONFIG_CFI_CLANG |
| 7 | #ifdef CONFIG_MODULES |
| 8 | |
| 9 | typedef void (*cfi_check_fn)(uint64_t, void *, void *); |
| 10 | |
| 11 | /* Compiler-generated function in each module, and the kernel */ |
| 12 | #define CFI_CHECK_FN __cfi_check |
| 13 | #define CFI_CHECK_FN_NAME __stringify(CFI_CHECK_FN) |
| 14 | |
| 15 | extern void CFI_CHECK_FN(uint64_t, void *, void *); |
| 16 | |
| 17 | #ifdef CONFIG_CFI_CLANG_SHADOW |
| 18 | extern void cfi_module_add(struct module *mod, unsigned long min_addr, |
| 19 | unsigned long max_addr); |
| 20 | |
| 21 | extern void cfi_module_remove(struct module *mod, unsigned long min_addr, |
| 22 | unsigned long max_addr); |
| 23 | #else |
| 24 | static inline void cfi_module_add(struct module *mod, unsigned long min_addr, |
| 25 | unsigned long max_addr) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | static inline void cfi_module_remove(struct module *mod, unsigned long min_addr, |
| 30 | unsigned long max_addr) |
| 31 | { |
| 32 | } |
| 33 | #endif /* CONFIG_CFI_CLANG_SHADOW */ |
| 34 | |
| 35 | #endif /* CONFIG_MODULES */ |
| 36 | #endif /* CONFIG_CFI_CLANG */ |
| 37 | |
| 38 | #endif /* _LINUX_CFI_H */ |