bug.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PARISC_BUG_H
  3. #define _PARISC_BUG_H
  4. /*
  5. * Tell the user there is some problem.
  6. * The offending file and line are encoded in the __bug_table section.
  7. */
  8. #ifdef CONFIG_BUG
  9. #define HAVE_ARCH_BUG
  10. #define HAVE_ARCH_WARN_ON
  11. /* the break instruction is used as BUG() marker. */
  12. #define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
  13. #define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */
  14. #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
  15. # define __BUG_REL(val) ".word " __stringify(val) " - ."
  16. #else
  17. # define __BUG_REL(val) ".word " __stringify(val)
  18. #endif
  19. #ifdef CONFIG_DEBUG_BUGVERBOSE
  20. #define BUG() \
  21. do { \
  22. asm volatile("\n" \
  23. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  24. "\t.pushsection __bug_table,\"a\"\n" \
  25. "\t.align 4\n" \
  26. "2:\t" __BUG_REL(1b) "\n" \
  27. "\t" __BUG_REL(%c0) "\n" \
  28. "\t.short %1, %2\n" \
  29. "\t.blockz %3-2*4-2*2\n" \
  30. "\t.popsection" \
  31. : : "i" (__FILE__), "i" (__LINE__), \
  32. "i" (0), "i" (sizeof(struct bug_entry)) ); \
  33. unreachable(); \
  34. } while(0)
  35. #else
  36. #define BUG() \
  37. do { \
  38. asm volatile(PARISC_BUG_BREAK_ASM : : ); \
  39. unreachable(); \
  40. } while(0)
  41. #endif
  42. #ifdef CONFIG_DEBUG_BUGVERBOSE
  43. #define __WARN_FLAGS(cond_str, flags) \
  44. do { \
  45. asm volatile("\n" \
  46. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  47. "\t.pushsection __bug_table,\"a\"\n" \
  48. "\t.align 4\n" \
  49. "2:\t" __BUG_REL(1b) "\n" \
  50. "\t" __BUG_REL(%c0) "\n" \
  51. "\t.short %1, %2\n" \
  52. "\t.blockz %3-2*4-2*2\n" \
  53. "\t.popsection" \
  54. : : "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__), \
  55. "i" (BUGFLAG_WARNING|(flags)), \
  56. "i" (sizeof(struct bug_entry)) ); \
  57. } while(0)
  58. #else
  59. #define __WARN_FLAGS(cond_str, flags) \
  60. do { \
  61. asm volatile("\n" \
  62. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  63. "\t.pushsection __bug_table,\"a\"\n" \
  64. "\t.align 4\n" \
  65. "2:\t" __BUG_REL(1b) "\n" \
  66. "\t.short %0\n" \
  67. "\t.blockz %1-4-2\n" \
  68. "\t.popsection" \
  69. : : "i" (BUGFLAG_WARNING|(flags)), \
  70. "i" (sizeof(struct bug_entry)) ); \
  71. } while(0)
  72. #endif
  73. #define WARN_ON(x) ({ \
  74. int __ret_warn_on = !!(x); \
  75. if (__builtin_constant_p(__ret_warn_on)) { \
  76. if (__ret_warn_on) \
  77. __WARN(); \
  78. } else { \
  79. if (unlikely(__ret_warn_on)) \
  80. __WARN(); \
  81. } \
  82. unlikely(__ret_warn_on); \
  83. })
  84. #endif
  85. #include <asm-generic/bug.h>
  86. #endif