bug.h 2.4 KB

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