diff mbox

Don't try to mess with CPUID when running nested SVM

Message ID 1242378078-1908-2-git-send-email-agraf@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Graf May 15, 2009, 9:01 a.m. UTC
When using nested SVM we usually want the guest to see the exact CPUID values
we gave it and not some mangled ones.

Hyper-V for example doesn't even start when the "hypervisor present" bit is set.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-i386/helper.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Avi Kivity May 15, 2009, 11:09 a.m. UTC | #1
Alexander Graf wrote:
> When using nested SVM we usually want the guest to see the exact CPUID values
> we gave it and not some mangled ones.
>   

That would triggered by -cpu host, not nesting.

> @@ -1506,7 +1506,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
>          *edx = env->cpuid_features;
>  
>          /* "Hypervisor present" bit required for Microsoft SVVP */
> -        if (kvm_enabled())
> +        if (kvm_enabled() && !kvm_nested)
>              *ecx |= (1 << 31);
>          break;
>   

-cpu host,-hypervisor
Alexander Graf May 15, 2009, 11:15 a.m. UTC | #2
On 15.05.2009, at 13:09, Avi Kivity wrote:

> Alexander Graf wrote:
>> When using nested SVM we usually want the guest to see the exact  
>> CPUID values
>> we gave it and not some mangled ones.
>>
>
> That would triggered by -cpu host, not nesting.

Oh we have -cpu host already? If so, we don't need that hackery of  
course :-)

>> @@ -1506,7 +1506,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t  
>> index, uint32_t count,
>>         *edx = env->cpuid_features;
>>          /* "Hypervisor present" bit required for Microsoft SVVP */
>> -        if (kvm_enabled())
>> +        if (kvm_enabled() && !kvm_nested)
>>             *ecx |= (1 << 31);
>>         break;
>>
>
> -cpu host,-hypervisor

hm - treating the hypervisor bit like any other cpuid bit sounds like  
a good idea. I'm wondering though which way should be preferred. I  
usually don't want to have the hypervisor bit set - but maybe I'm the  
minority.

Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity May 15, 2009, 11:19 a.m. UTC | #3
Alexander Graf wrote:
>>> When using nested SVM we usually want the guest to see the exact 
>>> CPUID values
>>> we gave it and not some mangled ones.
>>>
>>
>> That would triggered by -cpu host, not nesting.
>
> Oh we have -cpu host already?

No, we don't :)

> hm - treating the hypervisor bit like any other cpuid bit sounds like 
> a good idea. I'm wondering though which way should be preferred. I 
> usually don't want to have the hypervisor bit set - but maybe I'm the 
> minority.
>

Windows requires the hypervisor bit to set in order to pass some testing 
program.
diff mbox

Patch

diff --git a/target-i386/helper.c b/target-i386/helper.c
index 24fcea8..5f56698 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1496,7 +1496,7 @@  void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
          * isn't supported in compatibility mode on Intel.  so advertise the
          * actuall cpu, and say goodbye to migration between different vendors
          * is you use compatibility mode. */
-        if (kvm_enabled())
+        if (kvm_enabled() && !kvm_nested)
             host_cpuid(0, 0, NULL, ebx, ecx, edx);
         break;
     case 1:
@@ -1506,7 +1506,7 @@  void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *edx = env->cpuid_features;
 
         /* "Hypervisor present" bit required for Microsoft SVVP */
-        if (kvm_enabled())
+        if (kvm_enabled() && !kvm_nested)
             *ecx |= (1 << 31);
         break;
     case 2: