bug.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #if defined(CONFIG_64BIT)
  16. #define ASM_WORD_INSN ".dword\t"
  17. #else
  18. #define ASM_WORD_INSN ".word\t"
  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,\"aw\"\n" \
  26. "2:\t" ASM_WORD_INSN "1b, %c0\n" \
  27. "\t.short %c1, %c2\n" \
  28. "\t.org 2b+%c3\n" \
  29. "\t.popsection" \
  30. : : "i" (__FILE__), "i" (__LINE__), \
  31. "i" (0), "i" (sizeof(struct bug_entry)) ); \
  32. unreachable(); \
  33. } while(0)
  34. #else
  35. #define BUG() \
  36. do { \
  37. asm volatile(PARISC_BUG_BREAK_ASM : : ); \
  38. unreachable(); \
  39. } while(0)
  40. #endif
  41. #ifdef CONFIG_DEBUG_BUGVERBOSE
  42. #define __WARN_FLAGS(flags) \
  43. do { \
  44. asm volatile("\n" \
  45. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  46. "\t.pushsection __bug_table,\"aw\"\n" \
  47. "2:\t" ASM_WORD_INSN "1b, %c0\n" \
  48. "\t.short %c1, %c2\n" \
  49. "\t.org 2b+%c3\n" \
  50. "\t.popsection" \
  51. : : "i" (__FILE__), "i" (__LINE__), \
  52. "i" (BUGFLAG_WARNING|(flags)), \
  53. "i" (sizeof(struct bug_entry)) ); \
  54. } while(0)
  55. #else
  56. #define __WARN_FLAGS(flags) \
  57. do { \
  58. asm volatile("\n" \
  59. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  60. "\t.pushsection __bug_table,\"aw\"\n" \
  61. "2:\t" ASM_WORD_INSN "1b\n" \
  62. "\t.short %c0\n" \
  63. "\t.org 2b+%c1\n" \
  64. "\t.popsection" \
  65. : : "i" (BUGFLAG_WARNING|(flags)), \
  66. "i" (sizeof(struct bug_entry)) ); \
  67. } while(0)
  68. #endif
  69. #define WARN_ON(x) ({ \
  70. int __ret_warn_on = !!(x); \
  71. if (__builtin_constant_p(__ret_warn_on)) { \
  72. if (__ret_warn_on) \
  73. __WARN(); \
  74. } else { \
  75. if (unlikely(__ret_warn_on)) \
  76. __WARN(); \
  77. } \
  78. unlikely(__ret_warn_on); \
  79. })
  80. #endif
  81. #include <asm-generic/bug.h>
  82. #endif