bug.h 1.3 KB

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