bug.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef _ASMARM_BUG_H
  2. #define _ASMARM_BUG_H
  3. #ifdef CONFIG_BUG
  4. /*
  5. * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
  6. * We need to be careful not to conflict with those used by other modules and
  7. * the register_undef_hook() system.
  8. */
  9. #ifdef CONFIG_THUMB2_KERNEL
  10. #define BUG_INSTR_VALUE 0xde02
  11. #define BUG_INSTR_TYPE ".hword "
  12. #else
  13. #define BUG_INSTR_VALUE 0xe7f001f2
  14. #define BUG_INSTR_TYPE ".word "
  15. #endif
  16. #define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
  17. #define _BUG(file, line, value) __BUG(file, line, value)
  18. #ifdef CONFIG_DEBUG_BUGVERBOSE
  19. /*
  20. * The extra indirection is to ensure that the __FILE__ string comes through
  21. * OK. Many version of gcc do not support the asm %c parameter which would be
  22. * preferable to this unpleasantness. We use mergeable string sections to
  23. * avoid multiple copies of the string appearing in the kernel image.
  24. */
  25. #define __BUG(__file, __line, __value) \
  26. do { \
  27. BUILD_BUG_ON(sizeof(struct bug_entry) != 12); \
  28. asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" \
  29. ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
  30. "2:\t.asciz " #__file "\n" \
  31. ".popsection\n" \
  32. ".pushsection __bug_table,\"a\"\n" \
  33. "3:\t.word 1b, 2b\n" \
  34. "\t.hword " #__line ", 0\n" \
  35. ".popsection"); \
  36. unreachable(); \
  37. } while (0)
  38. #else /* not CONFIG_DEBUG_BUGVERBOSE */
  39. #define __BUG(__file, __line, __value) \
  40. do { \
  41. asm volatile(BUG_INSTR_TYPE #__value); \
  42. unreachable(); \
  43. } while (0)
  44. #endif /* CONFIG_DEBUG_BUGVERBOSE */
  45. #define HAVE_ARCH_BUG
  46. #endif /* CONFIG_BUG */
  47. #include <asm-generic/bug.h>
  48. #endif