[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxc, x86: Fix CPUID inline asm for x86/64.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1211385311 -3600
# Node ID e64c3a8c60e17ccdf5290c9479dc7ad32c14ca78
# Parent  36d9c5943b466c1e02386366bab3f1996efca9cb
libxc, x86: Fix CPUID inline asm for x86/64.

Must save all 64 bits of RBX, not just the EBX sub-part.

Based on bug diagnosis and patch by Juergen Keil <jk@xxxxxxxx>

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/libxc/xc_cpuid_x86.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff -r 36d9c5943b46 -r e64c3a8c60e1 tools/libxc/xc_cpuid_x86.c
--- a/tools/libxc/xc_cpuid_x86.c        Wed May 21 11:23:03 2008 +0100
+++ b/tools/libxc/xc_cpuid_x86.c        Wed May 21 16:55:11 2008 +0100
@@ -105,11 +105,14 @@ static void cpuid(const unsigned int *in
 static void cpuid(const unsigned int *input, unsigned int *regs)
 {
     unsigned int count = (input[1] == XEN_CPUID_INPUT_UNUSED) ? 0 : input[1];
-    unsigned int bx_temp;
-    asm ( "mov %%ebx,%4; cpuid; mov %%ebx,%1; mov %4,%%ebx"
-          : "=a" (regs[0]), "=r" (regs[1]),
-          "=c" (regs[2]), "=d" (regs[3]), "=m" (bx_temp)
-          : "0" (input[0]), "2" (count) );
+    asm (
+#ifdef __i386__
+        "push %%ebx; cpuid; mov %%ebx,%1; pop %%ebx"
+#else
+        "push %%rbx; cpuid; mov %%ebx,%1; pop %%rbx"
+#endif
+        : "=a" (regs[0]), "=r" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
+        : "0" (input[0]), "2" (count) );
 }
 
 /* Get the manufacturer brand name of the host processor. */

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.