libxc, x86: Fix CPUID inline asm for x86/64.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 21 May 2008 15:55:11 +0000 (16:55 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 21 May 2008 15:55:11 +0000 (16:55 +0100)
Must save all 64 bits of RBX, not just the EBX sub-part.

Based on bug diagnosis and patch by Juergen Keil <jk@tools.de>

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/libxc/xc_cpuid_x86.c

index 2317b4d38d321f89ea61560f04208b72d4c34aa2..febf97c607c91986797330b36792ddd6b7603752 100644 (file)
@@ -105,11 +105,14 @@ static void intel_xc_cpuid_policy(
 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. */