sysctl: add and use base directory declarer and registration helper
[linux-block.git] / include / linux / cfi.h
CommitLineData
cf68fffb
ST
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Clang Control Flow Integrity (CFI) support.
4 *
5 * Copyright (C) 2021 Google LLC
6 */
7#ifndef _LINUX_CFI_H
8#define _LINUX_CFI_H
9
10#ifdef CONFIG_CFI_CLANG
11typedef void (*cfi_check_fn)(uint64_t id, void *ptr, void *diag);
12
13/* Compiler-generated function in each module, and the kernel */
14extern void __cfi_check(uint64_t id, void *ptr, void *diag);
15
16/*
17 * Force the compiler to generate a CFI jump table entry for a function
18 * and store the jump table address to __cfi_jt_<function>.
19 */
20#define __CFI_ADDRESSABLE(fn, __attr) \
21 const void *__cfi_jt_ ## fn __visible __attr = (void *)&fn
22
23#ifdef CONFIG_CFI_CLANG_SHADOW
24
25extern void cfi_module_add(struct module *mod, unsigned long base_addr);
26extern void cfi_module_remove(struct module *mod, unsigned long base_addr);
27
28#else
29
30static inline void cfi_module_add(struct module *mod, unsigned long base_addr) {}
31static inline void cfi_module_remove(struct module *mod, unsigned long base_addr) {}
32
33#endif /* CONFIG_CFI_CLANG_SHADOW */
34
35#else /* !CONFIG_CFI_CLANG */
36
37#define __CFI_ADDRESSABLE(fn, __attr)
38
39#endif /* CONFIG_CFI_CLANG */
40
41#endif /* _LINUX_CFI_H */