|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC 03/10] xen/arm: Implement assembly version of WARN/BUG/ASSERT_FAILED...
... to produce clear error message in assembly code.
Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx>
---
TODO:
- Implement the arm32 bits
---
xen/arch/arm/arm64/entry.S | 1 +
xen/include/asm-arm/arm64/bug.h | 4 ++++
xen/include/asm-arm/bug.h | 37 +++++++++++++++++++++++++++++++++----
3 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S
index 2b9d4cd..93c80ff 100644
--- a/xen/arch/arm/arm64/entry.S
+++ b/xen/arch/arm/arm64/entry.S
@@ -1,5 +1,6 @@
#include <xen/config.h>
#include <asm/asm_defns.h>
+#include <asm/bug.h>
#include <asm/regs.h>
#include <public/xen.h>
diff --git a/xen/include/asm-arm/arm64/bug.h b/xen/include/asm-arm/arm64/bug.h
index 42b0e4f..9670505 100644
--- a/xen/include/asm-arm/arm64/bug.h
+++ b/xen/include/asm-arm/arm64/bug.h
@@ -5,6 +5,10 @@
#define BRK_BUG_FRAME 1
+#ifndef __ASSEMBLY__
#define BUG_INSTR "brk " __stringify(BRK_BUG_FRAME)
+#else
+#define BUG_INSTR brk BRK_BUG_FRAME
+#endif
#endif /* __ARM_ARM64_BUG_H__ */
diff --git a/xen/include/asm-arm/bug.h b/xen/include/asm-arm/bug.h
index fd3e95e..ffd7f6c 100644
--- a/xen/include/asm-arm/bug.h
+++ b/xen/include/asm-arm/bug.h
@@ -11,6 +11,12 @@
# error "unknown ARM variant"
#endif
+#define BUGFRAME_warn 0
+#define BUGFRAME_bug 1
+#define BUGFRAME_assert 2
+
+#ifndef __ASSEMBLY__
+
struct bug_frame {
signed int loc_disp; /* Relative address to the bug address */
signed int file_disp; /* Relative address to the filename */
@@ -24,10 +30,6 @@ struct bug_frame {
#define bug_line(b) ((b)->line)
#define bug_msg(b) ((const char *)(b) + (b)->msg_disp)
-#define BUGFRAME_warn 0
-#define BUGFRAME_bug 1
-#define BUGFRAME_assert 2
-
/* Many versions of GCC doesn't support the asm %c parameter which would
* be preferable to this unpleasantness. We use mergeable string
* sections to avoid multiple copies of the string appearing in the
@@ -71,6 +73,33 @@ extern const struct bug_frame __start_bug_frames[],
int do_bug_frame(struct cpu_user_regs *regs, vaddr_t pc);
+#else /* !__ASSEMBLY__ */
+
+.macro BUG_FRAME type, line , file, has_msg, msg
+.L\@bug:BUG_INSTR
+.pushsection .rodata.str, "aMS", %progbits, 1
+ .L\@s1:.asciz "\file"
+ .L\@s2:
+ .if \has_msg
+ .asciz "\msg"
+ .endif
+.popsection
+.pushsection .bug_frames.\type, "a", %progbits
+ .L\@bf:
+ .long (.L\@bug - .L\@bf)
+ .long (.L\@s1 - .L\@bf)
+ .long (.L\@s2 - .L\@bf)
+ .hword \line, 0
+.popsection
+.endm
+
+#define WARN BUG_FRAME BUGFRAME_warn, __LINE__, __FILE__, 0, 0
+#define BUG BUG_FRAME BUGFRAME_bug, __LINE__, __FILE__, 0, 0
+#define ASSERT_FAILED(msg) \
+ BUG_FRAME BUGFRAME_assert, __LINE__, __FILE__, 1, msg
+
+#endif
+
#endif /* __ARM_BUG_H__ */
/*
* Local variables:
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |