bug.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _ASMARM_BUG_H
  2. #define _ASMARM_BUG_H
  3. #include <linux/linkage.h>
  4. #ifdef CONFIG_BUG
  5. /*
  6. * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
  7. * We need to be careful not to conflict with those used by other modules and
  8. * the register_undef_hook() system.
  9. */
  10. #ifdef CONFIG_THUMB2_KERNEL
  11. #define BUG_INSTR_VALUE 0xde02
  12. #define BUG_INSTR_TYPE ".hword "
  13. #else
  14. #define BUG_INSTR_VALUE 0xe7f001f2
  15. #define BUG_INSTR_TYPE ".word "
  16. #endif
  17. #define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
  18. #define _BUG(file, line, value) __BUG(file, line, value)
  19. #ifdef CONFIG_DEBUG_BUGVERBOSE
  20. /*
  21. * The extra indirection is to ensure that the __FILE__ string comes through
  22. * OK. Many version of gcc do not support the asm %c parameter which would be
  23. * preferable to this unpleasantness. We use mergeable string sections to
  24. * avoid multiple copies of the string appearing in the kernel image.
  25. */
  26. #define __BUG(__file, __line, __value) \
  27. do { \
  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. struct pt_regs;
  49. void die(const char *msg, struct pt_regs *regs, int err);
  50. struct siginfo;
  51. void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info,
  52. unsigned long err, unsigned long trap);
  53. #ifdef CONFIG_ARM_LPAE
  54. #define FAULT_CODE_ALIGNMENT 33
  55. #define FAULT_CODE_DEBUG 34
  56. #else
  57. #define FAULT_CODE_ALIGNMENT 1
  58. #define FAULT_CODE_DEBUG 2
  59. #endif
  60. void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
  61. struct pt_regs *),
  62. int sig, int code, const char *name);
  63. void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
  64. struct pt_regs *),
  65. int sig, int code, const char *name);
  66. extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
  67. struct mm_struct;
  68. extern void show_pte(struct mm_struct *mm, unsigned long addr);
  69. extern void __show_regs(struct pt_regs *);
  70. #endif