error-injection.h 980 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_GENERIC_ERROR_INJECTION_H
  3. #define _ASM_GENERIC_ERROR_INJECTION_H
  4. #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
  5. enum {
  6. EI_ETYPE_NONE, /* Dummy value for undefined case */
  7. EI_ETYPE_NULL, /* Return NULL if failure */
  8. EI_ETYPE_ERRNO, /* Return -ERRNO if failure */
  9. EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */
  10. };
  11. struct error_injection_entry {
  12. unsigned long addr;
  13. int etype;
  14. };
  15. #ifdef CONFIG_FUNCTION_ERROR_INJECTION
  16. /*
  17. * Whitelist ganerating macro. Specify functions which can be
  18. * error-injectable using this macro.
  19. */
  20. #define ALLOW_ERROR_INJECTION(fname, _etype) \
  21. static struct error_injection_entry __used \
  22. __attribute__((__section__("_error_injection_whitelist"))) \
  23. _eil_addr_##fname = { \
  24. .addr = (unsigned long)fname, \
  25. .etype = EI_ETYPE_##_etype, \
  26. };
  27. #else
  28. #define ALLOW_ERROR_INJECTION(fname, _etype)
  29. #endif
  30. #endif
  31. #endif /* _ASM_GENERIC_ERROR_INJECTION_H */