Merge tag 'perf-tools-for-v6.4-3-2023-05-06' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / include / asm-generic / error-injection.h
CommitLineData
540adea3
MH
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_GENERIC_ERROR_INJECTION_H
3#define _ASM_GENERIC_ERROR_INJECTION_H
4
5#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
663faf9f 6enum {
663faf9f
MH
7 EI_ETYPE_NULL, /* Return NULL if failure */
8 EI_ETYPE_ERRNO, /* Return -ERRNO if failure */
9 EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */
af3b8544 10 EI_ETYPE_TRUE, /* Return true if failure */
663faf9f
MH
11};
12
13struct error_injection_entry {
14 unsigned long addr;
15 int etype;
16};
17
45880f7b
LY
18struct pt_regs;
19
540adea3
MH
20#ifdef CONFIG_FUNCTION_ERROR_INJECTION
21/*
bef7ec4e
MHG
22 * Whitelist generating macro. Specify functions which can be error-injectable
23 * using this macro. If you unsure what is required for the error-injectable
24 * functions, please read Documentation/fault-injection/fault-injection.rst
25 * 'Error Injectable Functions' section.
540adea3 26 */
663faf9f
MH
27#define ALLOW_ERROR_INJECTION(fname, _etype) \
28static struct error_injection_entry __used \
33def849 29 __section("_error_injection_whitelist") \
663faf9f
MH
30 _eil_addr_##fname = { \
31 .addr = (unsigned long)fname, \
32 .etype = EI_ETYPE_##_etype, \
733e4175 33 }
45880f7b
LY
34
35void override_function_with_return(struct pt_regs *regs);
540adea3 36#else
663faf9f 37#define ALLOW_ERROR_INJECTION(fname, _etype)
45880f7b
LY
38
39static inline void override_function_with_return(struct pt_regs *regs) { }
540adea3
MH
40#endif
41#endif
42
43#endif /* _ASM_GENERIC_ERROR_INJECTION_H */