WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86: unify BUG() & Co, reduce overhead on

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: unify BUG() & Co, reduce overhead on x86-64
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 07 Apr 2009 23:02:02 -0700
Delivery-date: Tue, 07 Apr 2009 23:05:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1238502191 -3600
# Node ID 69108560c7eb76299f59db491fd849c63e892e35
# Parent  2fa1d38097dadddb866a4a17ad68476e9e9a7081
x86: unify BUG() & Co, reduce overhead on x86-64

Since it's only the string pointer representations that differ between
i386 and x86-64, abstract out those and make everything else shared.

While touching this code, also use
- proper instructions rather than a mixture of such and raw .byte/
  .long/.quad data emissions,
- PC-relative pointers on x86-64 to cut the amount of storage (and
  in particular cache space) needed for string references by half.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/arch/x86/traps.c             |   14 +++++++++-----
 xen/include/asm-x86/bug.h        |   24 ++++++++++++++++++++++++
 xen/include/asm-x86/x86_32/bug.h |   29 +++--------------------------
 xen/include/asm-x86/x86_64/bug.h |   31 ++++---------------------------
 4 files changed, 40 insertions(+), 58 deletions(-)

diff -r 2fa1d38097da -r 69108560c7eb xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Tue Mar 31 13:22:12 2009 +0100
+++ b/xen/arch/x86/traps.c      Tue Mar 31 13:23:11 2009 +0100
@@ -841,7 +841,7 @@ asmlinkage void do_invalid_op(struct cpu
 {
     struct bug_frame bug;
     struct bug_frame_str bug_str;
-    char *filename, *predicate, *eip = (char *)regs->eip;
+    const char *filename, *predicate, *eip = (char *)regs->eip;
     unsigned long fixup;
     int id, lineno;
 
@@ -873,11 +873,13 @@ asmlinkage void do_invalid_op(struct cpu
     /* WARN, BUG or ASSERT: decode the filename pointer and line number. */
     if ( !is_kernel(eip) ||
          __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
-         memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
+         (bug_str.mov != 0xbc) )
         goto die;
+    filename = bug_str(bug_str, eip);
     eip += sizeof(bug_str);
 
-    filename = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
+    if ( !is_kernel(filename) )
+        filename = "<unknown>";
     lineno   = bug.id >> 2;
 
     if ( id == BUGFRAME_warn )
@@ -900,11 +902,13 @@ asmlinkage void do_invalid_op(struct cpu
     ASSERT(id == BUGFRAME_assert);
     if ( !is_kernel(eip) ||
          __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
-         memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
+         (bug_str.mov != 0xbc) )
         goto die;
+    predicate = bug_str(bug_str, eip);
     eip += sizeof(bug_str);
 
-    predicate = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
+    if ( !is_kernel(predicate) )
+        predicate = "<unknown>";
     printk("Assertion '%s' failed at %.50s:%d\n",
            predicate, filename, lineno);
     DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
diff -r 2fa1d38097da -r 69108560c7eb xen/include/asm-x86/bug.h
--- a/xen/include/asm-x86/bug.h Tue Mar 31 13:22:12 2009 +0100
+++ b/xen/include/asm-x86/bug.h Tue Mar 31 13:23:11 2009 +0100
@@ -18,4 +18,28 @@ struct bug_frame {
 #define BUGFRAME_bug    2
 #define BUGFRAME_assert 3
 
+#define dump_execution_state()                     \
+    asm volatile (                                 \
+        "ud2 ; ret $0"                             \
+        : : "i" (BUGFRAME_dump) )
+
+#define WARN()                                     \
+    asm volatile (                                 \
+        "ud2 ; ret %0" BUG_STR(1)                  \
+        : : "i" (BUGFRAME_warn | (__LINE__<<2)),   \
+            "i" (__FILE__) )
+
+#define BUG()                                      \
+    asm volatile (                                 \
+        "ud2 ; ret %0" BUG_STR(1)                  \
+        : : "i" (BUGFRAME_bug | (__LINE__<<2)),    \
+            "i" (__FILE__) )
+
+#define assert_failed(p)                           \
+    asm volatile (                                 \
+        "ud2 ; ret %0" BUG_STR(1) BUG_STR(2)       \
+        : : "i" (BUGFRAME_assert | (__LINE__<<2)), \
+            "i" (__FILE__), "i" (#p) )
+
+
 #endif /* __X86_BUG_H__ */
diff -r 2fa1d38097da -r 69108560c7eb xen/include/asm-x86/x86_32/bug.h
--- a/xen/include/asm-x86/x86_32/bug.h  Tue Mar 31 13:22:12 2009 +0100
+++ b/xen/include/asm-x86/x86_32/bug.h  Tue Mar 31 13:23:11 2009 +0100
@@ -2,33 +2,10 @@
 #define __X86_32_BUG_H__
 
 struct bug_frame_str {
-    unsigned char mov[1];
+    unsigned char mov;
     unsigned long str;
 } __attribute__((packed));
-#define BUG_MOV_STR "\xbc"
-
-#define dump_execution_state()                          \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0"                                \
-        : : "i" (BUGFRAME_dump) )
-
-#define WARN()                                          \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
-        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
-            "i" (__FILE__) )
-
-#define BUG()                                           \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
-        : : "i" (BUGFRAME_bug | (__LINE__<<2)),         \
-            "i" (__FILE__) )
-
-#define assert_failed(p)                                \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
-        " ; .byte 0xbc ; .long %c2"                     \
-        : : "i" (BUGFRAME_assert | (__LINE__<<2)),      \
-            "i" (__FILE__), "i" (#p) )
+#define bug_str(b, eip) ((const char *)(b).str)
+#define BUG_STR(n) "; movl %" #n ", %%esp"
 
 #endif /* __X86_32_BUG_H__ */
diff -r 2fa1d38097da -r 69108560c7eb xen/include/asm-x86/x86_64/bug.h
--- a/xen/include/asm-x86/x86_64/bug.h  Tue Mar 31 13:22:12 2009 +0100
+++ b/xen/include/asm-x86/x86_64/bug.h  Tue Mar 31 13:23:11 2009 +0100
@@ -2,33 +2,10 @@
 #define __X86_64_BUG_H__
 
 struct bug_frame_str {
-    unsigned char mov[2];
-    unsigned long str;
+    unsigned char mov;
+    signed int str_disp;
 } __attribute__((packed));
-#define BUG_MOV_STR "\x48\xbc"
-
-#define dump_execution_state()                          \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0"                                \
-        : : "i" (BUGFRAME_dump) )
-
-#define WARN()                                          \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
-        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
-            "i" (__FILE__) )
-
-#define BUG()                                           \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
-        : : "i" (BUGFRAME_bug | (__LINE__<<2)),         \
-            "i" (__FILE__) )
-
-#define assert_failed(p)                                \
-    asm volatile (                                      \
-        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
-        " ; .byte 0x48,0xbc ; .quad %c2"                \
-        : : "i" (BUGFRAME_assert | (__LINE__<<2)),      \
-            "i" (__FILE__), "i" (#p) )
+#define bug_str(b, rip) ((const char *)(rip) + (b).str_disp)
+#define BUG_STR(n) "; movl %" #n " - ., %%esp"
 
 #endif /* __X86_64_BUG_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: unify BUG() & Co, reduce overhead on x86-64, Xen patchbot-unstable <=