bug.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASMARM_BUG_H
  3. #define _ASMARM_BUG_H
  4. #include <linux/linkage.h>
  5. #include <linux/types.h>
  6. #include <asm/opcodes.h>
  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,\"aw\"\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
  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. #include <asm-generic/bug.h>
  50. struct pt_regs;
  51. void die(const char *msg, struct pt_regs *regs, int err);
  52. void arm_notify_die(const char *str, struct pt_regs *regs,
  53. int signo, int si_code, void __user *addr,
  54. unsigned long err, unsigned long trap);
  55. #ifdef CONFIG_ARM_LPAE
  56. #define FAULT_CODE_ALIGNMENT 33
  57. #define FAULT_CODE_DEBUG 34
  58. #else
  59. #define FAULT_CODE_ALIGNMENT 1
  60. #define FAULT_CODE_DEBUG 2
  61. #endif
  62. void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
  63. struct pt_regs *),
  64. int sig, int code, const char *name);
  65. void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
  66. struct pt_regs *),
  67. int sig, int code, const char *name);
  68. extern asmlinkage void c_backtrace(unsigned long fp, int pmode,
  69. const char *loglvl);
  70. struct mm_struct;
  71. void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr);
  72. extern void __show_regs(struct pt_regs *);
  73. extern void __show_regs_alloc_free(struct pt_regs *regs);
  74. #endif