bug.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef _ASMARM_BUG_H
  2. #define _ASMARM_BUG_H
  3. #include <linux/linkage.h>
  4. #include <linux/types.h>
  5. #include <asm/opcodes.h>
  6. #ifdef CONFIG_BUG
  7. /*
  8. * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
  9. * We need to be careful not to conflict with those used by other modules and
  10. * the register_undef_hook() system.
  11. */
  12. #ifdef CONFIG_THUMB2_KERNEL
  13. #define BUG_INSTR_VALUE 0xde02
  14. #define BUG_INSTR(__value) __inst_thumb16(__value)
  15. #else
  16. #define BUG_INSTR_VALUE 0xe7f001f2
  17. #define BUG_INSTR(__value) __inst_arm(__value)
  18. #endif
  19. #define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
  20. #define _BUG(file, line, value) __BUG(file, line, value)
  21. #ifdef CONFIG_DEBUG_BUGVERBOSE
  22. /*
  23. * The extra indirection is to ensure that the __FILE__ string comes through
  24. * OK. Many version of gcc do not support the asm %c parameter which would be
  25. * preferable to this unpleasantness. We use mergeable string sections to
  26. * avoid multiple copies of the string appearing in the kernel image.
  27. */
  28. #define __BUG(__file, __line, __value) \
  29. do { \
  30. asm volatile("1:\t" BUG_INSTR(__value) "\n" \
  31. ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
  32. "2:\t.asciz " #__file "\n" \
  33. ".popsection\n" \
  34. ".pushsection __bug_table,\"a\"\n" \
  35. ".align 2\n" \
  36. "3:\t.word 1b, 2b\n" \
  37. "\t.hword " #__line ", 0\n" \
  38. ".popsection"); \
  39. unreachable(); \
  40. } while (0)
  41. #else /* not CONFIG_DEBUG_BUGVERBOSE */
  42. #define __BUG(__file, __line, __value) \
  43. do { \
  44. asm volatile(BUG_INSTR(__value) "\n"); \
  45. unreachable(); \
  46. } while (0)
  47. #endif /* CONFIG_DEBUG_BUGVERBOSE */
  48. #define HAVE_ARCH_BUG
  49. #endif /* CONFIG_BUG */
  50. #include <asm-generic/bug.h>
  51. struct pt_regs;
  52. void die(const char *msg, struct pt_regs *regs, int err);
  53. struct siginfo;
  54. void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info,
  55. unsigned long err, unsigned long trap);
  56. #ifdef CONFIG_ARM_LPAE
  57. #define FAULT_CODE_ALIGNMENT 33
  58. #define FAULT_CODE_DEBUG 34
  59. #else
  60. #define FAULT_CODE_ALIGNMENT 1
  61. #define FAULT_CODE_DEBUG 2
  62. #endif
  63. void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
  64. struct pt_regs *),
  65. int sig, int code, const char *name);
  66. void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
  67. struct pt_regs *),
  68. int sig, int code, const char *name);
  69. extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
  70. struct mm_struct;
  71. extern void show_pte(struct mm_struct *mm, unsigned long addr);
  72. extern void __show_regs(struct pt_regs *);
  73. #endif