|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/3] xen/x86: Infrastructure to create BUG_FRAMES in asm code
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
xen/include/asm-x86/bug.h | 48 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 43 insertions(+), 5 deletions(-)
diff --git a/xen/include/asm-x86/bug.h b/xen/include/asm-x86/bug.h
index cd862e3..365c6b8 100644
--- a/xen/include/asm-x86/bug.h
+++ b/xen/include/asm-x86/bug.h
@@ -5,6 +5,13 @@
#define BUG_LINE_LO_WIDTH (31 - BUG_DISP_WIDTH)
#define BUG_LINE_HI_WIDTH (31 - BUG_DISP_WIDTH)
+#define BUGFRAME_run_fn 0
+#define BUGFRAME_warn 1
+#define BUGFRAME_bug 2
+#define BUGFRAME_assert 3
+
+#ifndef __ASSEMBLY__
+
struct bug_frame {
signed int loc_disp:BUG_DISP_WIDTH;
unsigned int line_hi:BUG_LINE_HI_WIDTH;
@@ -22,11 +29,6 @@ struct bug_frame {
((1 << BUG_LINE_LO_WIDTH) - 1)))
#define bug_msg(b) ((const char *)(b) + (b)->msg_disp[1])
-#define BUGFRAME_run_fn 0
-#define BUGFRAME_warn 1
-#define BUGFRAME_bug 2
-#define BUGFRAME_assert 3
-
#define BUG_FRAME(type, line, ptr, second_frame, msg) do { \
BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH)); \
asm volatile ( ".Lbug%=: ud2\n" \
@@ -66,4 +68,40 @@ struct bug_frame {
__stop_bug_frames_2[],
__stop_bug_frames_3[];
+#else /* !__ASSEMBLY__ */
+
+/*
+ * Construct a bugframe, suitable for using in assembly code. Should always
+ * match the C version above. One complication is having to stash the strings
+ * in .rodata (TODO - figure out how to get GAS to elide duplicate file_str's)
+ */
+.macro BUG_FRAME type, line, file_str, second_frame, msg
+92: ud2a
+
+.pushsection .rodata
+94: .asciz "\file_str"
+.popsection
+
+.pushsection .bug_frames.\type, "a", @progbits
+93:
+.long (92b - 93b) + ((\line >> BUG_LINE_LO_WIDTH) << BUG_DISP_WIDTH)
+.long (94b - 93b) + ((\line & ((1 << BUG_LINE_LO_WIDTH) - 1)) <<
BUG_DISP_WIDTH)
+
+.if \second_frame
+ .pushsection .rodata
+ 95: .asciz "\msg"
+ .popsection
+.long 0, (95b - 93b)
+.endif
+.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 /* !__ASSEMBLY__ */
+
#endif /* __X86_BUG_H__ */
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |