2018-01-12 17:55:03 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _ASM_GENERIC_ERROR_INJECTION_H
|
|
|
|
#define _ASM_GENERIC_ERROR_INJECTION_H
|
|
|
|
|
|
|
|
#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
|
2018-01-12 17:55:33 +00:00
|
|
|
enum {
|
|
|
|
EI_ETYPE_NULL, /* Return NULL if failure */
|
|
|
|
EI_ETYPE_ERRNO, /* Return -ERRNO if failure */
|
|
|
|
EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */
|
2018-12-28 08:39:23 +00:00
|
|
|
EI_ETYPE_TRUE, /* Return true if failure */
|
2018-01-12 17:55:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct error_injection_entry {
|
|
|
|
unsigned long addr;
|
|
|
|
int etype;
|
|
|
|
};
|
|
|
|
|
2019-08-06 10:00:13 +00:00
|
|
|
struct pt_regs;
|
|
|
|
|
2018-01-12 17:55:03 +00:00
|
|
|
#ifdef CONFIG_FUNCTION_ERROR_INJECTION
|
|
|
|
/*
|
2022-12-12 02:46:54 +00:00
|
|
|
* Whitelist generating macro. Specify functions which can be error-injectable
|
|
|
|
* using this macro. If you unsure what is required for the error-injectable
|
|
|
|
* functions, please read Documentation/fault-injection/fault-injection.rst
|
|
|
|
* 'Error Injectable Functions' section.
|
2018-01-12 17:55:03 +00:00
|
|
|
*/
|
2018-01-12 17:55:33 +00:00
|
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype) \
|
|
|
|
static struct error_injection_entry __used \
|
2020-10-22 02:36:07 +00:00
|
|
|
__section("_error_injection_whitelist") \
|
2018-01-12 17:55:33 +00:00
|
|
|
_eil_addr_##fname = { \
|
|
|
|
.addr = (unsigned long)fname, \
|
|
|
|
.etype = EI_ETYPE_##_etype, \
|
2021-11-03 19:42:08 +00:00
|
|
|
}
|
2019-08-06 10:00:13 +00:00
|
|
|
|
|
|
|
void override_function_with_return(struct pt_regs *regs);
|
2018-01-12 17:55:03 +00:00
|
|
|
#else
|
2018-01-12 17:55:33 +00:00
|
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype)
|
2019-08-06 10:00:13 +00:00
|
|
|
|
|
|
|
static inline void override_function_with_return(struct pt_regs *regs) { }
|
2018-01-12 17:55:03 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _ASM_GENERIC_ERROR_INJECTION_H */
|