2018-01-13 00:55:03 +07: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 00:55:33 +07: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 15:39:23 +07:00
|
|
|
EI_ETYPE_TRUE, /* Return true if failure */
|
2018-01-13 00:55:33 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct error_injection_entry {
|
|
|
|
unsigned long addr;
|
|
|
|
int etype;
|
|
|
|
};
|
|
|
|
|
2019-08-06 17:00:13 +07:00
|
|
|
struct pt_regs;
|
|
|
|
|
2018-01-13 00:55:03 +07:00
|
|
|
#ifdef CONFIG_FUNCTION_ERROR_INJECTION
|
|
|
|
/*
|
|
|
|
* Whitelist ganerating macro. Specify functions which can be
|
|
|
|
* error-injectable using this macro.
|
|
|
|
*/
|
2018-01-13 00:55:33 +07:00
|
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype) \
|
|
|
|
static struct error_injection_entry __used \
|
2018-01-13 00:55:03 +07:00
|
|
|
__attribute__((__section__("_error_injection_whitelist"))) \
|
2018-01-13 00:55:33 +07:00
|
|
|
_eil_addr_##fname = { \
|
|
|
|
.addr = (unsigned long)fname, \
|
|
|
|
.etype = EI_ETYPE_##_etype, \
|
|
|
|
};
|
2019-08-06 17:00:13 +07:00
|
|
|
|
|
|
|
void override_function_with_return(struct pt_regs *regs);
|
2018-01-13 00:55:03 +07:00
|
|
|
#else
|
2018-01-13 00:55:33 +07:00
|
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype)
|
2019-08-06 17:00:13 +07:00
|
|
|
|
|
|
|
static inline void override_function_with_return(struct pt_regs *regs) { }
|
2018-01-13 00:55:03 +07:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _ASM_GENERIC_ERROR_INJECTION_H */
|