bug.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2015 ARM Limited
  3. * Author: Dave Martin <Dave.Martin@arm.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _ARCH_ARM64_ASM_BUG_H
  18. #define _ARCH_ARM64_ASM_BUG_H
  19. #include <asm/debug-monitors.h>
  20. #ifdef CONFIG_DEBUG_BUGVERBOSE
  21. #define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
  22. #define __BUGVERBOSE_LOCATION(file, line) \
  23. ".pushsection .rodata.str,\"aMS\",@progbits,1\n" \
  24. "2: .string \"" file "\"\n\t" \
  25. ".popsection\n\t" \
  26. \
  27. ".long 2b - 0b\n\t" \
  28. ".short " #line "\n\t"
  29. #else
  30. #define _BUGVERBOSE_LOCATION(file, line)
  31. #endif
  32. #ifdef CONFIG_GENERIC_BUG
  33. #define __BUG_ENTRY(flags) \
  34. ".pushsection __bug_table,\"a\"\n\t" \
  35. ".align 2\n\t" \
  36. "0: .long 1f - 0b\n\t" \
  37. _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
  38. ".short " #flags "\n\t" \
  39. ".popsection\n" \
  40. "1: "
  41. #else
  42. #define __BUG_ENTRY(flags) ""
  43. #endif
  44. #define __BUG_FLAGS(flags) \
  45. asm volatile ( \
  46. __BUG_ENTRY(flags) \
  47. "brk %[imm]" :: [imm] "i" (BUG_BRK_IMM) \
  48. );
  49. #define BUG() do { \
  50. __BUG_FLAGS(0); \
  51. unreachable(); \
  52. } while (0)
  53. #define __WARN_TAINT(taint) \
  54. __BUG_FLAGS(BUGFLAG_TAINT(taint))
  55. #define HAVE_ARCH_BUG
  56. #include <asm-generic/bug.h>
  57. #endif /* ! _ARCH_ARM64_ASM_BUG_H */