18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_GENERIC_ERROR_INJECTION_H 38c2ecf20Sopenharmony_ci#define _ASM_GENERIC_ERROR_INJECTION_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 68c2ecf20Sopenharmony_cienum { 78c2ecf20Sopenharmony_ci EI_ETYPE_NONE, /* Dummy value for undefined case */ 88c2ecf20Sopenharmony_ci EI_ETYPE_NULL, /* Return NULL if failure */ 98c2ecf20Sopenharmony_ci EI_ETYPE_ERRNO, /* Return -ERRNO if failure */ 108c2ecf20Sopenharmony_ci EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */ 118c2ecf20Sopenharmony_ci EI_ETYPE_TRUE, /* Return true if failure */ 128c2ecf20Sopenharmony_ci}; 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistruct error_injection_entry { 158c2ecf20Sopenharmony_ci unsigned long addr; 168c2ecf20Sopenharmony_ci int etype; 178c2ecf20Sopenharmony_ci}; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistruct pt_regs; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#ifdef CONFIG_FUNCTION_ERROR_INJECTION 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * Whitelist ganerating macro. Specify functions which can be 248c2ecf20Sopenharmony_ci * error-injectable using this macro. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci#define ALLOW_ERROR_INJECTION(fname, _etype) \ 278c2ecf20Sopenharmony_cistatic struct error_injection_entry __used \ 288c2ecf20Sopenharmony_ci __section("_error_injection_whitelist") \ 298c2ecf20Sopenharmony_ci _eil_addr_##fname = { \ 308c2ecf20Sopenharmony_ci .addr = (unsigned long)fname, \ 318c2ecf20Sopenharmony_ci .etype = EI_ETYPE_##_etype, \ 328c2ecf20Sopenharmony_ci }; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_civoid override_function_with_return(struct pt_regs *regs); 358c2ecf20Sopenharmony_ci#else 368c2ecf20Sopenharmony_ci#define ALLOW_ERROR_INJECTION(fname, _etype) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistatic inline void override_function_with_return(struct pt_regs *regs) { } 398c2ecf20Sopenharmony_ci#endif 408c2ecf20Sopenharmony_ci#endif 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#endif /* _ASM_GENERIC_ERROR_INJECTION_H */ 43