1540adea3SMasami Hiramatsu /* SPDX-License-Identifier: GPL-2.0 */ 2540adea3SMasami Hiramatsu #ifndef _ASM_GENERIC_ERROR_INJECTION_H 3540adea3SMasami Hiramatsu #define _ASM_GENERIC_ERROR_INJECTION_H 4540adea3SMasami Hiramatsu 5540adea3SMasami Hiramatsu #if defined(__KERNEL__) && !defined(__ASSEMBLY__) 6663faf9fSMasami Hiramatsu enum { 7663faf9fSMasami Hiramatsu EI_ETYPE_NULL, /* Return NULL if failure */ 8663faf9fSMasami Hiramatsu EI_ETYPE_ERRNO, /* Return -ERRNO if failure */ 9663faf9fSMasami Hiramatsu EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */ 10af3b8544SBenjamin Poirier EI_ETYPE_TRUE, /* Return true if failure */ 11663faf9fSMasami Hiramatsu }; 12663faf9fSMasami Hiramatsu 13663faf9fSMasami Hiramatsu struct error_injection_entry { 14663faf9fSMasami Hiramatsu unsigned long addr; 15663faf9fSMasami Hiramatsu int etype; 16663faf9fSMasami Hiramatsu }; 17663faf9fSMasami Hiramatsu 1845880f7bSLeo Yan struct pt_regs; 1945880f7bSLeo Yan 20540adea3SMasami Hiramatsu #ifdef CONFIG_FUNCTION_ERROR_INJECTION 21540adea3SMasami Hiramatsu /* 22*bef7ec4eSMasami Hiramatsu (Google) * Whitelist generating macro. Specify functions which can be error-injectable 23*bef7ec4eSMasami Hiramatsu (Google) * using this macro. If you unsure what is required for the error-injectable 24*bef7ec4eSMasami Hiramatsu (Google) * functions, please read Documentation/fault-injection/fault-injection.rst 25*bef7ec4eSMasami Hiramatsu (Google) * 'Error Injectable Functions' section. 26540adea3SMasami Hiramatsu */ 27663faf9fSMasami Hiramatsu #define ALLOW_ERROR_INJECTION(fname, _etype) \ 28663faf9fSMasami Hiramatsu static struct error_injection_entry __used \ 2933def849SJoe Perches __section("_error_injection_whitelist") \ 30663faf9fSMasami Hiramatsu _eil_addr_##fname = { \ 31663faf9fSMasami Hiramatsu .addr = (unsigned long)fname, \ 32663faf9fSMasami Hiramatsu .etype = EI_ETYPE_##_etype, \ 33733e4175SWasin Thonkaew } 3445880f7bSLeo Yan 3545880f7bSLeo Yan void override_function_with_return(struct pt_regs *regs); 36540adea3SMasami Hiramatsu #else 37663faf9fSMasami Hiramatsu #define ALLOW_ERROR_INJECTION(fname, _etype) 3845880f7bSLeo Yan override_function_with_return(struct pt_regs * regs)3945880f7bSLeo Yanstatic inline void override_function_with_return(struct pt_regs *regs) { } 40540adea3SMasami Hiramatsu #endif 41540adea3SMasami Hiramatsu #endif 42540adea3SMasami Hiramatsu 43540adea3SMasami Hiramatsu #endif /* _ASM_GENERIC_ERROR_INJECTION_H */ 44