2018-01-13 01:55:03 +08: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-13 01:55:33 +08:00
|
|
|
enum {
|
|
|
|
EI_ETYPE_NONE, /* Dummy value for undefined case */
|
|
|
|
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 16:39:23 +08:00
|
|
|
EI_ETYPE_TRUE, /* Return true if failure */
|
2018-01-13 01:55:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct error_injection_entry {
|
|
|
|
unsigned long addr;
|
|
|
|
int etype;
|
|
|
|
};
|
|
|
|
|
2019-08-06 18:00:13 +08:00
|
|
|
struct pt_regs;
|
|
|
|
|
2018-01-13 01:55:03 +08:00
|
|
|
#ifdef CONFIG_FUNCTION_ERROR_INJECTION
|
|
|
|
/*
|
2021-11-04 03:42:08 +08:00
|
|
|
* Whitelist generating macro. Specify functions which can be
|
2018-01-13 01:55:03 +08:00
|
|
|
* error-injectable using this macro.
|
|
|
|
*/
|
2018-01-13 01:55:33 +08:00
|
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype) \
|
|
|
|
static struct error_injection_entry __used \
|
2020-10-22 10:36:07 +08:00
|
|
|
__section("_error_injection_whitelist") \
|
2018-01-13 01:55:33 +08:00
|
|
|
_eil_addr_##fname = { \
|
|
|
|
.addr = (unsigned long)fname, \
|
|
|
|
.etype = EI_ETYPE_##_etype, \
|
2021-11-04 03:42:08 +08:00
|
|
|
}
|
2019-08-06 18:00:13 +08:00
|
|
|
|
|
|
|
void override_function_with_return(struct pt_regs *regs);
|
2018-01-13 01:55:03 +08:00
|
|
|
#else
|
2018-01-13 01:55:33 +08:00
|
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype)
|
2019-08-06 18:00:13 +08:00
|
|
|
|
|
|
|
static inline void override_function_with_return(struct pt_regs *regs) { }
|
2018-01-13 01:55:03 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _ASM_GENERIC_ERROR_INJECTION_H */
|