public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <alex@csgraf.de>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel@lists.sourceforge.net
Subject: [PATCH] fix CPUID handling
Date: Mon, 25 Feb 2008 18:37:19 +0100	[thread overview]
Message-ID: <47C2FCCF.8030109@csgraf.de> (raw)
In-Reply-To: <47C29C2F.4070907@qumranet.com>

[-- Attachment #1: Type: text/plain, Size: 156 bytes --]

So this is a new version of the same patch. It should be rather safe
now, as most cases are handled by gcc.

Signed-off-by: Alexander Graf <alex@csgraf.de>

[-- Attachment #2: cpuid.patch --]
[-- Type: text/x-patch, Size: 1793 bytes --]

diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
index 37354fb..3062d1b 100644
--- a/qemu/qemu-kvm-x86.c
+++ b/qemu/qemu-kvm-x86.c
@@ -427,36 +427,22 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
 {
     uint32_t vec[4];
 
-    vec[0] = function;
-    asm volatile (
-#ifdef __x86_64__
-	 "sub $128, %%rsp \n\t"  /* skip red zone */
-         "push %0;  push %%rsi \n\t"
-	 "push %%rax; push %%rbx; push %%rcx; push %%rdx \n\t"
-	 "mov 8*5(%%rsp), %%rsi \n\t"
-	 "mov (%%rsi), %%eax \n\t"
-	 "cpuid \n\t"
-	 "mov %%eax, (%%rsi) \n\t"
-	 "mov %%ebx, 4(%%rsi) \n\t"
-	 "mov %%ecx, 8(%%rsi) \n\t"
-	 "mov %%edx, 12(%%rsi) \n\t"
-	 "pop %%rdx; pop %%rcx; pop %%rbx; pop %%rax \n\t"
-	 "pop %%rsi; pop %0 \n\t"
-	 "add $128, %%rsp"
+#if defined(__i386__) && defined(__PIC__)
+    /* We need to handle ebx manually, as PIC code requires it */
+    asm volatile("movl %%ebx, %%esi \n\t"
+                "cpuid \n\t"
+                "movl %%ebx, %1 \n\t"
+                "movl %%esi, %%ebx"
+                : "=a" (vec[0]), "=r" (vec[1]), "=c" (vec[2]), "=d" (vec[3])
+                : "0"(function)
+                : "esi", "cc");
 #else
-         "push %0;  push %%esi \n\t"
-	 "push %%eax; push %%ebx; push %%ecx; push %%edx \n\t"
-	 "mov 4*5(%%esp), %%esi \n\t"
-	 "mov (%%esi), %%eax \n\t"
-	 "cpuid \n\t"
-	 "mov %%eax, (%%esi) \n\t"
-	 "mov %%ebx, 4(%%esi) \n\t"
-	 "mov %%ecx, 8(%%esi) \n\t"
-	 "mov %%edx, 12(%%esi) \n\t"
-	 "pop %%edx; pop %%ecx; pop %%ebx; pop %%eax \n\t"
-	 "pop %%esi; pop %0 \n\t"
+    asm volatile("cpuid"
+                : "=a" (vec[0]), "=b" (vec[1]),"=c" (vec[2]), "=d" (vec[3]) 
+                : "0"(function)
+                : "cc");
 #endif
-	 : : "rm"(vec) : "memory");
+
     if (eax)
 	*eax = vec[0];
     if (ebx)

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

      parent reply	other threads:[~2008-02-25 17:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-25  8:41 KVM Test result, kernel 81e4400.., userspace 08385e4.. , One new issue Zhao, Yunfeng
2008-02-25  9:31 ` Yang, Sheng
2008-02-25  9:34   ` Avi Kivity
2008-02-25 10:28     ` Alexander Graf
2008-02-25 10:45       ` Avi Kivity
2008-02-25 12:55         ` Alexander Graf
2008-02-25 17:40           ` Avi Kivity
2008-02-25 18:35             ` Alexander Graf
2008-02-25 19:26               ` Avi Kivity
2008-02-25 17:37         ` Alexander Graf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47C2FCCF.8030109@csgraf.de \
    --to=alex@csgraf.de \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox