asm-bug.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __ASM_ASM_BUG_H
  3. /*
  4. * Copyright (C) 2017 ARM Limited
  5. */
  6. #define __ASM_ASM_BUG_H
  7. #include <asm/brk-imm.h>
  8. #ifdef CONFIG_DEBUG_BUGVERBOSE
  9. #define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
  10. #define __BUGVERBOSE_LOCATION(file, line) \
  11. .pushsection .rodata.str,"aMS",@progbits,1; \
  12. 14472: .string file; \
  13. .popsection; \
  14. \
  15. .long 14472b - .; \
  16. .short line;
  17. #else
  18. #define _BUGVERBOSE_LOCATION(file, line)
  19. #endif
  20. #ifdef CONFIG_GENERIC_BUG
  21. #define __BUG_ENTRY_START \
  22. .pushsection __bug_table,"aw"; \
  23. .align 2; \
  24. 14470: .long 14471f - .; \
  25. #define __BUG_ENTRY_END \
  26. .align 2; \
  27. .popsection; \
  28. 14471:
  29. #define __BUG_ENTRY(flags) \
  30. __BUG_ENTRY_START \
  31. _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
  32. .short flags; \
  33. __BUG_ENTRY_END
  34. #else
  35. #define __BUG_ENTRY(flags)
  36. #endif
  37. #define ASM_BUG_FLAGS(flags) \
  38. __BUG_ENTRY(flags) \
  39. brk BUG_BRK_IMM
  40. #define ASM_BUG() ASM_BUG_FLAGS(0)
  41. #ifdef CONFIG_DEBUG_BUGVERBOSE
  42. #define __BUG_LOCATION_STRING(file, line) \
  43. ".long " file "- .;" \
  44. ".short " line ";"
  45. #else
  46. #define __BUG_LOCATION_STRING(file, line)
  47. #endif
  48. #define __BUG_ENTRY_STRING(file, line, flags) \
  49. __stringify(__BUG_ENTRY_START) \
  50. __BUG_LOCATION_STRING(file, line) \
  51. ".short " flags ";" \
  52. __stringify(__BUG_ENTRY_END)
  53. #define ARCH_WARN_ASM(file, line, flags, size) \
  54. __BUG_ENTRY_STRING(file, line, flags) \
  55. __stringify(brk BUG_BRK_IMM)
  56. #define ARCH_WARN_REACHABLE
  57. #endif /* __ASM_ASM_BUG_H */