bug.h 2.6 KB

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