public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Christian Hesse <mail-8oMOrB1mGocUSW6y5lq3GQ@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [ANNOUNCE] kvm-20 release
Date: Tue, 24 Apr 2007 12:22:46 +0300	[thread overview]
Message-ID: <462DCC66.3000902@qumranet.com> (raw)
In-Reply-To: <200704241114.11921.mail-8oMOrB1mGocUSW6y5lq3GQ@public.gmane.org>

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

Christian Hesse wrote:
> On Tuesday 24 April 2007, Avi Kivity wrote:
>   
>> Jeff Chua wrote:
>>     
>>> On 4/22/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>>>       
>>>> Significant cpu performance improvements (esp. for 32-bit guests on
>>>> 64-bit hosts), as well as Windows 2000 support (without acpi).
>>>>         
>>> Avi,
>>>
>>> Ecountered the following error with kvm-20 (external modules) on
>>> Linux-2.6.21-rc7.
>>>
>>> kvm_run: failed entry, reason 7
>>> kvm_run returned -8
>>>
>>> Runs fine with kvm-19 (external modules).
>>>
>>> Am I missing something?
>>>       
>> I'm missing something:
>>
>> - what host cpu?
>>
>> - what host bitness?
>>
>> - what guest OS?
>>     
>
> Hi Avi,
>
> same here, so I will answer in place:
>
> Samsung X11 with Intel Core Duo T2300 with Gentoo Linux and Kernel 2.6.21-rc7 
> + kvm-20. Guest OS is Win XP.
>
> Additionally I've patched my kernel with cfs v5 now. I thought that could be 
> the problem... Jeff, are you running cfs or any non mainline scheduler as 
> well?
>   

It may be the cpuid strangeness that Rusty saw.  Can you try the
attached patch?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


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

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index e00b0f3..46b0b99 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -682,6 +682,49 @@ void kvm_qemu_destroy(void)
     kvm_finalize(kvm_context);
 }
 
+static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
+		       uint32_t *ecx, uint32_t *edx)
+{
+    uint32_t vec[4];
+
+    vec[0] = function;
+    asm volatile (
+#ifdef __x86_64__
+         "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"
+#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"
+#endif
+	 : : "rm"(vec) : "memory");
+    if (eax)
+	*eax = vec[0];
+    if (ebx)
+	*ebx = vec[1];
+    if (ecx)
+	*ecx = vec[2];
+    if (edx)
+	*edx = vec[3];
+}
+
 static void do_cpuid_ent(struct kvm_cpuid_entry *e, uint32_t function)
 {
     EAX = function;
@@ -694,17 +737,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry *e, uint32_t function)
     if (function == 1)
 	e->edx &= ~(1 << 12); /* disable mtrr support */
     if (function == 0x80000001) {
-	unsigned long h_eax = function, h_edx;
+	uint32_t h_eax, h_edx;
 
-
-	// push/pop hack to workaround gcc 3 register pressure trouble
-	asm (
-#ifdef __x86_64__
-	     "push %%rbx; push %%rcx; cpuid; pop %%rcx; pop %%rbx"
-#else
-	     "push %%ebx; push %%ecx; cpuid; pop %%ecx; pop %%ebx"
-#endif
-	     : "+a"(h_eax), "=d"(h_edx));
+	host_cpuid(function, &h_eax, NULL, NULL, &h_edx);
 
 	// long mode
 	if ((h_edx & 0x20000000) == 0)
@@ -722,27 +757,8 @@ static void do_cpuid_ent(struct kvm_cpuid_entry *e, uint32_t function)
     // is you use compatibility mode.
     if (function == 0) {
 	uint32_t bcd[3];
-	asm (
-#ifdef __x86_64__
-	     "push %%rax; push %%rbx; push %%rcx; push %%rdx \n\t"
-	     "mov $0, %%eax \n\t"
-	     "cpuid \n\t"
-	     "mov (%%rsp), %%rax \n\t"
-	     "mov %%ebx, (%%rax) \n\t"
-	     "mov %%ecx, 4(%%rax) \n\t"
-	     "mov %%edx, 8(%%rax) \n\t"
-	     "pop %%rdx; pop %%rcx; pop %%rbx; pop %%rax"
-#else
-	     "push %%eax; push %%ebx; push %%ecx; push %%edx \n\t"
-	     "mov $0, %%eax \n\t"
-	     "cpuid \n\t"
-	     "mov (%%esp), %%eax \n\t"
-	     "mov %%ebx, (%%eax) \n\t"
-	     "mov %%ecx, 4(%%eax) \n\t"
-	     "mov %%edx, 8(%%eax) \n\t"
-	     "pop %%edx; pop %%ecx; pop %%ebx; pop %%eax"
-#endif
-	     : : "d"(bcd) : "memory");
+
+	host_cpuid(0, NULL, &bcd[0], &bcd[1], &bcd[2]);
 	e->ebx = bcd[0];
 	e->ecx = bcd[1];
 	e->edx = bcd[2];

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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

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

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

  parent reply	other threads:[~2007-04-24  9:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-22 10:21 [ANNOUNCE] kvm-20 release Avi Kivity
     [not found] ` <462B372C.4050207-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-23 13:52   ` Jeff Chua
     [not found]     ` <b6a2187b0704230652q27bf8178q2c8b0b55807085ad-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-04-24  8:48       ` Avi Kivity
     [not found]         ` <462DC453.7000608-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-24  9:14           ` Christian Hesse
     [not found]             ` <200704241114.11921.mail-8oMOrB1mGocUSW6y5lq3GQ@public.gmane.org>
2007-04-24  9:22               ` Avi Kivity [this message]
     [not found]                 ` <462DCC66.3000902-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-24  9:49                   ` Christian Hesse
     [not found]                     ` <200704241149.39214.mail-8oMOrB1mGocUSW6y5lq3GQ@public.gmane.org>
2007-04-24 10:18                       ` Avi Kivity
     [not found]                         ` <462DD964.8060204-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-24 10:44                           ` Christian Hesse
     [not found]                             ` <200704241244.13115.mail-8oMOrB1mGocUSW6y5lq3GQ@public.gmane.org>
2007-04-24 14:46                               ` Jeff Chua

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=462DCC66.3000902@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=mail-8oMOrB1mGocUSW6y5lq3GQ@public.gmane.org \
    /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