All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-22 21:47 ` Andre Przywara
  0 siblings, 0 replies; 18+ messages in thread
From: Andre Przywara @ 2009-06-22 21:47 UTC (permalink / raw)
  To: aliguori; +Cc: avi, qemu-devel, kvm, Andre Przywara

KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU clears
it. On some occasions one want to set or clear it the other way round (for
instance to get HyperV running inside a guest).
Allow the default to be overridden on the command line and fix some
whitespace damage on the way.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 target-i386/helper.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index 8a76abd..529f962 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -44,7 +44,7 @@ static const char *ext_feature_name[] = {
     "pni" /* Intel,AMD sse3 */, NULL, NULL, "monitor", "ds_cpl", "vmx", NULL /* Linux smx */, "est",
     "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
     NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, "hypervisor",
 };
 static const char *ext2_feature_name[] = {
     "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
@@ -59,30 +59,30 @@ static const char *ext3_feature_name[] = {
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
 
-static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, 
-                                    uint32_t *ext_features, 
-                                    uint32_t *ext2_features, 
+static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
+                                    uint32_t *ext_features,
+                                    uint32_t *ext2_features,
                                     uint32_t *ext3_features)
 {
     int i;
     int found = 0;
 
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
             *features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
             *ext_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
             *ext2_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {
             *ext3_features |= 1 << i;
             found = 1;
@@ -330,6 +330,11 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
         goto error;
     memcpy(x86_cpu_def, def, sizeof(*def));
 
+    if (kvm_enabled()) {
+        add_flagname_to_bitmaps("hypervisor", &plus_features,
+            &plus_ext_features, &plus_ext2_features, &plus_ext3_features);
+    }
+
     featurestr = strtok(NULL, ",");
 
     while (featurestr) {
@@ -1523,10 +1528,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
         *ecx = env->cpuid_ext_features;
         *edx = env->cpuid_features;
-
-        /* "Hypervisor present" bit required for Microsoft SVVP */
-        if (kvm_enabled())
-            *ecx |= (1 << 31);
         break;
     case 2:
         /* cache info: needed for Pentium Pro compatibility */
-- 
1.6.1.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-22 21:47 ` Andre Przywara
  0 siblings, 0 replies; 18+ messages in thread
From: Andre Przywara @ 2009-06-22 21:47 UTC (permalink / raw)
  To: aliguori; +Cc: Andre Przywara, avi, kvm, qemu-devel

KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU clears
it. On some occasions one want to set or clear it the other way round (for
instance to get HyperV running inside a guest).
Allow the default to be overridden on the command line and fix some
whitespace damage on the way.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 target-i386/helper.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index 8a76abd..529f962 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -44,7 +44,7 @@ static const char *ext_feature_name[] = {
     "pni" /* Intel,AMD sse3 */, NULL, NULL, "monitor", "ds_cpl", "vmx", NULL /* Linux smx */, "est",
     "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
     NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, "hypervisor",
 };
 static const char *ext2_feature_name[] = {
     "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
@@ -59,30 +59,30 @@ static const char *ext3_feature_name[] = {
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
 
-static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, 
-                                    uint32_t *ext_features, 
-                                    uint32_t *ext2_features, 
+static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
+                                    uint32_t *ext_features,
+                                    uint32_t *ext2_features,
                                     uint32_t *ext3_features)
 {
     int i;
     int found = 0;
 
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
             *features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
             *ext_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
             *ext2_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {
             *ext3_features |= 1 << i;
             found = 1;
@@ -330,6 +330,11 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
         goto error;
     memcpy(x86_cpu_def, def, sizeof(*def));
 
+    if (kvm_enabled()) {
+        add_flagname_to_bitmaps("hypervisor", &plus_features,
+            &plus_ext_features, &plus_ext2_features, &plus_ext3_features);
+    }
+
     featurestr = strtok(NULL, ",");
 
     while (featurestr) {
@@ -1523,10 +1528,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
         *ecx = env->cpuid_ext_features;
         *edx = env->cpuid_features;
-
-        /* "Hypervisor present" bit required for Microsoft SVVP */
-        if (kvm_enabled())
-            *ecx |= (1 << 31);
         break;
     case 2:
         /* cache info: needed for Pentium Pro compatibility */
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
  2009-06-22 21:47 ` [Qemu-devel] " Andre Przywara
@ 2009-06-23 10:01   ` Avi Kivity
  -1 siblings, 0 replies; 18+ messages in thread
From: Avi Kivity @ 2009-06-23 10:01 UTC (permalink / raw)
  To: Andre Przywara; +Cc: aliguori, qemu-devel, kvm

On 06/23/2009 12:47 AM, Andre Przywara wrote:
> KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU clears
> it. On some occasions one want to set or clear it the other way round (for
> instance to get HyperV running inside a guest).
> Allow the default to be overridden on the command line and fix some
> whitespace damage on the way.
>    

It makes sense for qemu to set the hypervisor bit unconditionally.  A 
guest running under qemu is not bare metal.

That's a separate change though.  Patch looks good.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-23 10:01   ` Avi Kivity
  0 siblings, 0 replies; 18+ messages in thread
From: Avi Kivity @ 2009-06-23 10:01 UTC (permalink / raw)
  To: Andre Przywara; +Cc: aliguori, qemu-devel, kvm

On 06/23/2009 12:47 AM, Andre Przywara wrote:
> KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU clears
> it. On some occasions one want to set or clear it the other way round (for
> instance to get HyperV running inside a guest).
> Allow the default to be overridden on the command line and fix some
> whitespace damage on the way.
>    

It makes sense for qemu to set the hypervisor bit unconditionally.  A 
guest running under qemu is not bare metal.

That's a separate change though.  Patch looks good.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
  2009-06-23 10:01   ` [Qemu-devel] " Avi Kivity
@ 2009-06-23 11:31     ` Paul Brook
  -1 siblings, 0 replies; 18+ messages in thread
From: Paul Brook @ 2009-06-23 11:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Avi Kivity, Andre Przywara, aliguori, kvm

On Tuesday 23 June 2009, Avi Kivity wrote:
> On 06/23/2009 12:47 AM, Andre Przywara wrote:
> > KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
> > clears it. On some occasions one want to set or clear it the other way
> > round (for instance to get HyperV running inside a guest).
> > Allow the default to be overridden on the command line and fix some
> > whitespace damage on the way.
>
> It makes sense for qemu to set the hypervisor bit unconditionally.  A
> guest running under qemu is not bare metal.

I see no reason why a guest has to be told that it's running inside a VM.
In principle an appropriately configured qemu should be indistinguishable from 
real hardware. In practice it's technically infeasible to cover absolutely 
everything, but if we set this bit we're not even trying.

I have no objection to the bit being set by default for the QEMU CPU types.

Paul

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-23 11:31     ` Paul Brook
  0 siblings, 0 replies; 18+ messages in thread
From: Paul Brook @ 2009-06-23 11:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andre Przywara, aliguori, Avi Kivity, kvm

On Tuesday 23 June 2009, Avi Kivity wrote:
> On 06/23/2009 12:47 AM, Andre Przywara wrote:
> > KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
> > clears it. On some occasions one want to set or clear it the other way
> > round (for instance to get HyperV running inside a guest).
> > Allow the default to be overridden on the command line and fix some
> > whitespace damage on the way.
>
> It makes sense for qemu to set the hypervisor bit unconditionally.  A
> guest running under qemu is not bare metal.

I see no reason why a guest has to be told that it's running inside a VM.
In principle an appropriately configured qemu should be indistinguishable from 
real hardware. In practice it's technically infeasible to cover absolutely 
everything, but if we set this bit we're not even trying.

I have no objection to the bit being set by default for the QEMU CPU types.

Paul

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
  2009-06-23 11:31     ` Paul Brook
@ 2009-06-23 11:35       ` Avi Kivity
  -1 siblings, 0 replies; 18+ messages in thread
From: Avi Kivity @ 2009-06-23 11:35 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel, Andre Przywara, aliguori, kvm

On 06/23/2009 02:31 PM, Paul Brook wrote:
> On Tuesday 23 June 2009, Avi Kivity wrote:
>    
>> On 06/23/2009 12:47 AM, Andre Przywara wrote:
>>      
>>> KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
>>> clears it. On some occasions one want to set or clear it the other way
>>> round (for instance to get HyperV running inside a guest).
>>> Allow the default to be overridden on the command line and fix some
>>> whitespace damage on the way.
>>>        
>> It makes sense for qemu to set the hypervisor bit unconditionally.  A
>> guest running under qemu is not bare metal.
>>      
>
> I see no reason why a guest has to be told that it's running inside a VM.
> In principle an appropriately configured qemu should be indistinguishable from
> real hardware. In practice it's technically infeasible to cover absolutely
> everything, but if we set this bit we're not even trying.
>
> I have no objection to the bit being set by default for the QEMU CPU types.
>    

I agree it's pointless, but it is a Microsoft requirement for passing 
their SVVP tests.  Enabling it by default makes life a little easier for 
users who wish to validate their hypervisor and has no drawbacks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-23 11:35       ` Avi Kivity
  0 siblings, 0 replies; 18+ messages in thread
From: Avi Kivity @ 2009-06-23 11:35 UTC (permalink / raw)
  To: Paul Brook; +Cc: Andre Przywara, aliguori, qemu-devel, kvm

On 06/23/2009 02:31 PM, Paul Brook wrote:
> On Tuesday 23 June 2009, Avi Kivity wrote:
>    
>> On 06/23/2009 12:47 AM, Andre Przywara wrote:
>>      
>>> KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
>>> clears it. On some occasions one want to set or clear it the other way
>>> round (for instance to get HyperV running inside a guest).
>>> Allow the default to be overridden on the command line and fix some
>>> whitespace damage on the way.
>>>        
>> It makes sense for qemu to set the hypervisor bit unconditionally.  A
>> guest running under qemu is not bare metal.
>>      
>
> I see no reason why a guest has to be told that it's running inside a VM.
> In principle an appropriately configured qemu should be indistinguishable from
> real hardware. In practice it's technically infeasible to cover absolutely
> everything, but if we set this bit we're not even trying.
>
> I have no objection to the bit being set by default for the QEMU CPU types.
>    

I agree it's pointless, but it is a Microsoft requirement for passing 
their SVVP tests.  Enabling it by default makes life a little easier for 
users who wish to validate their hypervisor and has no drawbacks.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
  2009-06-23 11:35       ` Avi Kivity
@ 2009-06-23 11:43         ` Paul Brook
  -1 siblings, 0 replies; 18+ messages in thread
From: Paul Brook @ 2009-06-23 11:43 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel, Andre Przywara, aliguori, kvm

> I agree it's pointless, but it is a Microsoft requirement for passing
> their SVVP tests.  Enabling it by default makes life a little easier for
> users who wish to validate their hypervisor and has no drawbacks.

I wasn't arguing against setting it by default (for QEMU CPU types), just 
against enabling it unconditionally.

Paul

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-23 11:43         ` Paul Brook
  0 siblings, 0 replies; 18+ messages in thread
From: Paul Brook @ 2009-06-23 11:43 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Andre Przywara, aliguori, qemu-devel, kvm

> I agree it's pointless, but it is a Microsoft requirement for passing
> their SVVP tests.  Enabling it by default makes life a little easier for
> users who wish to validate their hypervisor and has no drawbacks.

I wasn't arguing against setting it by default (for QEMU CPU types), just 
against enabling it unconditionally.

Paul

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/2 v2] allow hypervisor CPUID bit to be overriden
  2009-06-22 21:47 ` [Qemu-devel] " Andre Przywara
@ 2009-06-23 12:37   ` Andre Przywara
  -1 siblings, 0 replies; 18+ messages in thread
From: Andre Przywara @ 2009-06-23 12:37 UTC (permalink / raw)
  To: aliguori; +Cc: avi, kvm, qemu-devel, Andre Przywara

KVM defaults to the hypervisor CPUID bit to be set, whereas pure
QEMU clears it. On some occasions one wants to set or clear it the
other way round (for instance to get HyperV running inside a guest).

Move the bit-set to be done before the command line parsing and
enable it by default. One can disable it by using: -cpu qemu64,-hypervisor
Fix some whitespace damage on the way.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 target-i386/helper.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index 8a76abd..cb9113e 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -44,7 +44,7 @@ static const char *ext_feature_name[] = {
     "pni" /* Intel,AMD sse3 */, NULL, NULL, "monitor", "ds_cpl", "vmx", NULL /* Linux smx */, "est",
     "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
     NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, "hypervisor",
 };
 static const char *ext2_feature_name[] = {
     "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
@@ -59,30 +59,30 @@ static const char *ext3_feature_name[] = {
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
 
-static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, 
-                                    uint32_t *ext_features, 
-                                    uint32_t *ext2_features, 
+static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
+                                    uint32_t *ext_features,
+                                    uint32_t *ext2_features,
                                     uint32_t *ext3_features)
 {
     int i;
     int found = 0;
 
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
             *features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
             *ext_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
             *ext2_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {
             *ext3_features |= 1 << i;
             found = 1;
@@ -330,6 +330,9 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
         goto error;
     memcpy(x86_cpu_def, def, sizeof(*def));
 
+    add_flagname_to_bitmaps("hypervisor", &plus_features,
+        &plus_ext_features, &plus_ext2_features, &plus_ext3_features);
+
     featurestr = strtok(NULL, ",");
 
     while (featurestr) {
@@ -1523,10 +1526,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
         *ecx = env->cpuid_ext_features;
         *edx = env->cpuid_features;
-
-        /* "Hypervisor present" bit required for Microsoft SVVP */
-        if (kvm_enabled())
-            *ecx |= (1 << 31);
         break;
     case 2:
         /* cache info: needed for Pentium Pro compatibility */
-- 
1.6.1.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PATCH 1/2 v2] allow hypervisor CPUID bit to be overriden
@ 2009-06-23 12:37   ` Andre Przywara
  0 siblings, 0 replies; 18+ messages in thread
From: Andre Przywara @ 2009-06-23 12:37 UTC (permalink / raw)
  To: aliguori; +Cc: Andre Przywara, avi, kvm, qemu-devel

KVM defaults to the hypervisor CPUID bit to be set, whereas pure
QEMU clears it. On some occasions one wants to set or clear it the
other way round (for instance to get HyperV running inside a guest).

Move the bit-set to be done before the command line parsing and
enable it by default. One can disable it by using: -cpu qemu64,-hypervisor
Fix some whitespace damage on the way.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 target-i386/helper.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index 8a76abd..cb9113e 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -44,7 +44,7 @@ static const char *ext_feature_name[] = {
     "pni" /* Intel,AMD sse3 */, NULL, NULL, "monitor", "ds_cpl", "vmx", NULL /* Linux smx */, "est",
     "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
     NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, "hypervisor",
 };
 static const char *ext2_feature_name[] = {
     "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
@@ -59,30 +59,30 @@ static const char *ext3_feature_name[] = {
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
 
-static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, 
-                                    uint32_t *ext_features, 
-                                    uint32_t *ext2_features, 
+static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
+                                    uint32_t *ext_features,
+                                    uint32_t *ext2_features,
                                     uint32_t *ext3_features)
 {
     int i;
     int found = 0;
 
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
             *features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
             *ext_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
             *ext2_features |= 1 << i;
             found = 1;
         }
-    for ( i = 0 ; i < 32 ; i++ ) 
+    for ( i = 0 ; i < 32 ; i++ )
         if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {
             *ext3_features |= 1 << i;
             found = 1;
@@ -330,6 +330,9 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
         goto error;
     memcpy(x86_cpu_def, def, sizeof(*def));
 
+    add_flagname_to_bitmaps("hypervisor", &plus_features,
+        &plus_ext_features, &plus_ext2_features, &plus_ext3_features);
+
     featurestr = strtok(NULL, ",");
 
     while (featurestr) {
@@ -1523,10 +1526,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
         *ecx = env->cpuid_ext_features;
         *edx = env->cpuid_features;
-
-        /* "Hypervisor present" bit required for Microsoft SVVP */
-        if (kvm_enabled())
-            *ecx |= (1 << 31);
         break;
     case 2:
         /* cache info: needed for Pentium Pro compatibility */
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v2] allow hypervisor CPUID bit to be overriden
  2009-06-23 12:37   ` [Qemu-devel] " Andre Przywara
@ 2009-06-23 14:17     ` Anthony Liguori
  -1 siblings, 0 replies; 18+ messages in thread
From: Anthony Liguori @ 2009-06-23 14:17 UTC (permalink / raw)
  To: Andre Przywara; +Cc: avi, kvm, qemu-devel

Andre Przywara wrote:
> KVM defaults to the hypervisor CPUID bit to be set, whereas pure
> QEMU clears it. On some occasions one wants to set or clear it the
> other way round (for instance to get HyperV running inside a guest).
>
> Move the bit-set to be done before the command line parsing and
> enable it by default. One can disable it by using: -cpu qemu64,-hypervisor
> Fix some whitespace damage on the way.
>
> Signed-off-by: Andre Przywara <andre.przywara@amd.com>
>
>   
Please also resend 2/2.


-- 
Regards,

Anthony Liguori


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Qemu-devel] Re: [PATCH 1/2 v2] allow hypervisor CPUID bit to be overriden
@ 2009-06-23 14:17     ` Anthony Liguori
  0 siblings, 0 replies; 18+ messages in thread
From: Anthony Liguori @ 2009-06-23 14:17 UTC (permalink / raw)
  To: Andre Przywara; +Cc: avi, kvm, qemu-devel

Andre Przywara wrote:
> KVM defaults to the hypervisor CPUID bit to be set, whereas pure
> QEMU clears it. On some occasions one wants to set or clear it the
> other way round (for instance to get HyperV running inside a guest).
>
> Move the bit-set to be done before the command line parsing and
> enable it by default. One can disable it by using: -cpu qemu64,-hypervisor
> Fix some whitespace damage on the way.
>
> Signed-off-by: Andre Przywara <andre.przywara@amd.com>
>
>   
Please also resend 2/2.


-- 
Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
  2009-06-23 11:35       ` Avi Kivity
@ 2009-06-24 21:20         ` Jamie Lokier
  -1 siblings, 0 replies; 18+ messages in thread
From: Jamie Lokier @ 2009-06-24 21:20 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Paul Brook, Andre Przywara, aliguori, qemu-devel, kvm

Avi Kivity wrote:
> On 06/23/2009 02:31 PM, Paul Brook wrote:
> >On Tuesday 23 June 2009, Avi Kivity wrote:
> >   
> >>On 06/23/2009 12:47 AM, Andre Przywara wrote:
> >>     
> >>>KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
> >>>clears it. On some occasions one want to set or clear it the other way
> >>>round (for instance to get HyperV running inside a guest).
> >>>Allow the default to be overridden on the command line and fix some
> >>>whitespace damage on the way.
> >>>       
> >>It makes sense for qemu to set the hypervisor bit unconditionally.  A
> >>guest running under qemu is not bare metal.
> >>     
> >
> >I see no reason why a guest has to be told that it's running inside a VM.
> >In principle an appropriately configured qemu should be indistinguishable 
> >from
> >real hardware. In practice it's technically infeasible to cover absolutely
> >everything, but if we set this bit we're not even trying.
> >
> >I have no objection to the bit being set by default for the QEMU CPU types.
> >   
> 
> I agree it's pointless, but it is a Microsoft requirement for passing 
> their SVVP tests.  Enabling it by default makes life a little easier for 
> users who wish to validate their hypervisor and has no drawbacks.

Hold on.

Do the SVVP tests fail on a real (non-virtal) machine then?

Or is QEMU's machine emulation insufficiently accurate?

I see a drawback in setting the bit by default.

Something I expect from an emulator is that it behaves like a real
machine to the extent possible.  In particular, guest code which
attempts to check if it's running on a real machine should get the
answer "yes".  Unfriendly guest code which pops up a message like
"Sorry I refuse to work for you after 100 hours/ because you are
attempting to run me in a virtual machine, and don't even think of
trying to hide this from me now you know I look for it" should never
do so.

-- Jamie

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-24 21:20         ` Jamie Lokier
  0 siblings, 0 replies; 18+ messages in thread
From: Jamie Lokier @ 2009-06-24 21:20 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Andre Przywara, aliguori, Paul Brook, kvm, qemu-devel

Avi Kivity wrote:
> On 06/23/2009 02:31 PM, Paul Brook wrote:
> >On Tuesday 23 June 2009, Avi Kivity wrote:
> >   
> >>On 06/23/2009 12:47 AM, Andre Przywara wrote:
> >>     
> >>>KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
> >>>clears it. On some occasions one want to set or clear it the other way
> >>>round (for instance to get HyperV running inside a guest).
> >>>Allow the default to be overridden on the command line and fix some
> >>>whitespace damage on the way.
> >>>       
> >>It makes sense for qemu to set the hypervisor bit unconditionally.  A
> >>guest running under qemu is not bare metal.
> >>     
> >
> >I see no reason why a guest has to be told that it's running inside a VM.
> >In principle an appropriately configured qemu should be indistinguishable 
> >from
> >real hardware. In practice it's technically infeasible to cover absolutely
> >everything, but if we set this bit we're not even trying.
> >
> >I have no objection to the bit being set by default for the QEMU CPU types.
> >   
> 
> I agree it's pointless, but it is a Microsoft requirement for passing 
> their SVVP tests.  Enabling it by default makes life a little easier for 
> users who wish to validate their hypervisor and has no drawbacks.

Hold on.

Do the SVVP tests fail on a real (non-virtal) machine then?

Or is QEMU's machine emulation insufficiently accurate?

I see a drawback in setting the bit by default.

Something I expect from an emulator is that it behaves like a real
machine to the extent possible.  In particular, guest code which
attempts to check if it's running on a real machine should get the
answer "yes".  Unfriendly guest code which pops up a message like
"Sorry I refuse to work for you after 100 hours/ because you are
attempting to run me in a virtual machine, and don't even think of
trying to hide this from me now you know I look for it" should never
do so.

-- Jamie

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
  2009-06-24 21:20         ` Jamie Lokier
@ 2009-06-25  5:23           ` Gleb Natapov
  -1 siblings, 0 replies; 18+ messages in thread
From: Gleb Natapov @ 2009-06-25  5:23 UTC (permalink / raw)
  To: Jamie Lokier
  Cc: Avi Kivity, Paul Brook, Andre Przywara, aliguori, qemu-devel, kvm

On Wed, Jun 24, 2009 at 10:20:41PM +0100, Jamie Lokier wrote:
> Avi Kivity wrote:
> > On 06/23/2009 02:31 PM, Paul Brook wrote:
> > >On Tuesday 23 June 2009, Avi Kivity wrote:
> > >   
> > >>On 06/23/2009 12:47 AM, Andre Przywara wrote:
> > >>     
> > >>>KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
> > >>>clears it. On some occasions one want to set or clear it the other way
> > >>>round (for instance to get HyperV running inside a guest).
> > >>>Allow the default to be overridden on the command line and fix some
> > >>>whitespace damage on the way.
> > >>>       
> > >>It makes sense for qemu to set the hypervisor bit unconditionally.  A
> > >>guest running under qemu is not bare metal.
> > >>     
> > >
> > >I see no reason why a guest has to be told that it's running inside a VM.
> > >In principle an appropriately configured qemu should be indistinguishable 
> > >from
> > >real hardware. In practice it's technically infeasible to cover absolutely
> > >everything, but if we set this bit we're not even trying.
> > >
> > >I have no objection to the bit being set by default for the QEMU CPU types.
> > >   
> > 
> > I agree it's pointless, but it is a Microsoft requirement for passing 
> > their SVVP tests.  Enabling it by default makes life a little easier for 
> > users who wish to validate their hypervisor and has no drawbacks.
> 
> Hold on.
> 
> Do the SVVP tests fail on a real (non-virtal) machine then?
> 
SVVP -> Server Virtualization Validation Program

Definitely fails on a real machine :)

--
			Gleb.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 1/2] allow hypervisor CPUID bit to be overriden
@ 2009-06-25  5:23           ` Gleb Natapov
  0 siblings, 0 replies; 18+ messages in thread
From: Gleb Natapov @ 2009-06-25  5:23 UTC (permalink / raw)
  To: Jamie Lokier
  Cc: Andre Przywara, aliguori, kvm, qemu-devel, Avi Kivity, Paul Brook

On Wed, Jun 24, 2009 at 10:20:41PM +0100, Jamie Lokier wrote:
> Avi Kivity wrote:
> > On 06/23/2009 02:31 PM, Paul Brook wrote:
> > >On Tuesday 23 June 2009, Avi Kivity wrote:
> > >   
> > >>On 06/23/2009 12:47 AM, Andre Przywara wrote:
> > >>     
> > >>>KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU
> > >>>clears it. On some occasions one want to set or clear it the other way
> > >>>round (for instance to get HyperV running inside a guest).
> > >>>Allow the default to be overridden on the command line and fix some
> > >>>whitespace damage on the way.
> > >>>       
> > >>It makes sense for qemu to set the hypervisor bit unconditionally.  A
> > >>guest running under qemu is not bare metal.
> > >>     
> > >
> > >I see no reason why a guest has to be told that it's running inside a VM.
> > >In principle an appropriately configured qemu should be indistinguishable 
> > >from
> > >real hardware. In practice it's technically infeasible to cover absolutely
> > >everything, but if we set this bit we're not even trying.
> > >
> > >I have no objection to the bit being set by default for the QEMU CPU types.
> > >   
> > 
> > I agree it's pointless, but it is a Microsoft requirement for passing 
> > their SVVP tests.  Enabling it by default makes life a little easier for 
> > users who wish to validate their hypervisor and has no drawbacks.
> 
> Hold on.
> 
> Do the SVVP tests fail on a real (non-virtal) machine then?
> 
SVVP -> Server Virtualization Validation Program

Definitely fails on a real machine :)

--
			Gleb.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2009-06-25  5:25 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-22 21:47 [PATCH 1/2] allow hypervisor CPUID bit to be overriden Andre Przywara
2009-06-22 21:47 ` [Qemu-devel] " Andre Przywara
2009-06-23 10:01 ` Avi Kivity
2009-06-23 10:01   ` [Qemu-devel] " Avi Kivity
2009-06-23 11:31   ` Paul Brook
2009-06-23 11:31     ` Paul Brook
2009-06-23 11:35     ` Avi Kivity
2009-06-23 11:35       ` Avi Kivity
2009-06-23 11:43       ` Paul Brook
2009-06-23 11:43         ` Paul Brook
2009-06-24 21:20       ` Jamie Lokier
2009-06-24 21:20         ` Jamie Lokier
2009-06-25  5:23         ` Gleb Natapov
2009-06-25  5:23           ` Gleb Natapov
2009-06-23 12:37 ` [PATCH 1/2 v2] " Andre Przywara
2009-06-23 12:37   ` [Qemu-devel] " Andre Przywara
2009-06-23 14:17   ` Anthony Liguori
2009-06-23 14:17     ` [Qemu-devel] " Anthony Liguori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.