bug.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_BUG_H
  3. #define __ASM_BUG_H
  4. #include <asm/break.h>
  5. #include <linux/stringify.h>
  6. #include <linux/objtool.h>
  7. #ifndef CONFIG_DEBUG_BUGVERBOSE
  8. #define _BUGVERBOSE_LOCATION(file, line)
  9. #else
  10. #define __BUGVERBOSE_LOCATION(file, line) \
  11. .pushsection .rodata.str, "aMS", @progbits, 1; \
  12. 10002: .string file; \
  13. .popsection; \
  14. \
  15. .long 10002b - .; \
  16. .short line;
  17. #define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
  18. #endif
  19. #ifndef CONFIG_GENERIC_BUG
  20. #define __BUG_ENTRY(flags)
  21. #else
  22. #define __BUG_ENTRY(flags) \
  23. .pushsection __bug_table, "aw"; \
  24. .align 2; \
  25. 10000: .long 10001f - .; \
  26. _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
  27. .short flags; \
  28. .popsection; \
  29. 10001:
  30. #endif
  31. #define ASM_BUG_FLAGS(flags) \
  32. __BUG_ENTRY(flags) \
  33. break BRK_BUG;
  34. #define ASM_BUG() ASM_BUG_FLAGS(0)
  35. #define __BUG_FLAGS(flags, extra) \
  36. asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)) \
  37. extra);
  38. #define __WARN_FLAGS(flags) \
  39. do { \
  40. instrumentation_begin(); \
  41. __BUG_FLAGS(BUGFLAG_WARNING|(flags), ASM_REACHABLE); \
  42. instrumentation_end(); \
  43. } while (0)
  44. #define BUG() \
  45. do { \
  46. instrumentation_begin(); \
  47. __BUG_FLAGS(0, ""); \
  48. unreachable(); \
  49. } while (0)
  50. #define HAVE_ARCH_BUG
  51. #include <asm-generic/bug.h>
  52. #endif /* __ASM_BUG_H */