Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_GENERIC_ERROR_INJECTION_H
0003 #define _ASM_GENERIC_ERROR_INJECTION_H
0004 
0005 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
0006 enum {
0007     EI_ETYPE_NONE,      /* Dummy value for undefined case */
0008     EI_ETYPE_NULL,      /* Return NULL if failure */
0009     EI_ETYPE_ERRNO,     /* Return -ERRNO if failure */
0010     EI_ETYPE_ERRNO_NULL,    /* Return -ERRNO or NULL if failure */
0011     EI_ETYPE_TRUE,      /* Return true if failure */
0012 };
0013 
0014 struct error_injection_entry {
0015     unsigned long   addr;
0016     int     etype;
0017 };
0018 
0019 struct pt_regs;
0020 
0021 #ifdef CONFIG_FUNCTION_ERROR_INJECTION
0022 /*
0023  * Whitelist generating macro. Specify functions which can be
0024  * error-injectable using this macro.
0025  */
0026 #define ALLOW_ERROR_INJECTION(fname, _etype)                \
0027 static struct error_injection_entry __used              \
0028     __section("_error_injection_whitelist")             \
0029     _eil_addr_##fname = {                       \
0030         .addr = (unsigned long)fname,               \
0031         .etype = EI_ETYPE_##_etype,             \
0032     }
0033 
0034 void override_function_with_return(struct pt_regs *regs);
0035 #else
0036 #define ALLOW_ERROR_INJECTION(fname, _etype)
0037 
0038 static inline void override_function_with_return(struct pt_regs *regs) { }
0039 #endif
0040 #endif
0041 
0042 #endif /* _ASM_GENERIC_ERROR_INJECTION_H */