Allow changing of Hypervisor CPUIDs.
v6 cover Allow changing of Hypervisor CPUIDs.
Also known as Paravirtualization CPUIDs.
This is primarily done so that the guest will think it is running under vmware when hypervisor-vendor=vmware is specified as a property of a cpu.
This depends on:
http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg01400.html
As far as I know it is #4. It depends on (1) and (2) and (3).
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
Changes from v5 to v6:
Split out 01/17: target-i386: Allow tsc-frequency to be larger then 2.147G
It has been accepted as a trivial patch:
http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg03959.html
Blue Swirl:
Fix 2 checkpatch.pl "WARNING: line over 80 characters".
Changes from v4 to v5:
Undo kvm_clock2 change.
Add cpuid_hv_level_set; cpuid_hv_level == 0 is now valid.
Add cpuid_hv_vendor_set; the null string is now valid.
Handle kvm and cpuid_hv_level == 0. hypervisor-vendor=kvm,hypervisor-level=0 and hypervisor-level=0,hypervisor-vendor=kvm
now do the same thing.
Changes from v3 to v4:
Added CPUID_HV_LEVEL_HYPERV, CPUID_HV_LEVEL_KVM. Added CPUID_HV_VENDOR_HYPERV.
Added hyperv as known hypservisor-vendor. Allow hypervisor-level to be 0.
Changes from v2 to v3:
Clean post to qemu-devel.
Changes from v1 to v2:
1) Added 1/4 from http://lists.gnu.org/archive/html/qemu-devel/2012-08/msg05153.html
Because Fred is changing jobs and so will not be pushing to get this in. It needed to be rebased, And I needed it to complete the testing of this change.
2) Added 2/4 because of the re-work I needed a way to clear all KVM bits,
3) The rework of v1. Make it fit into the object model re-work of cpu.c for x86.
4) Added 3/4 -- The split out of the code that is not needed for accel=kvm.
Changes from v2 to v3:
Marcelo Tosatti:
Its one big patch, better split in logically correlated patches (with better changelog). This would help reviewers.
So split 3 and 4 into 3 to 17. More info in change log. No code change.
Don Slutz (16):
target-i386: Add missing kvm bits.
target-i386: Add Hypervisor level.
target-i386: Add cpu object access routines for Hypervisor level.
target-i386: Add x86_set_hyperv.
target-i386: Use Hypervisor level in -machine pc,accel=kvm.
target-i386: Use Hypervisor level in -machine pc,accel=tcg.
target-i386: Add Hypervisor vendor.
target-i386: Add cpu object access routines for Hypervisor vendor.
target-i386: Use Hypervisor vendor in -machine pc,accel=kvm.
target-i386: Use Hypervisor vendor in -machine pc,accel=tcg.
target-i386: Add some known names to Hypervisor vendor.
target-i386: Add optional Hypervisor leaf extra.
target-i386: Add cpu object access routines for Hypervisor leaf
extra.
target-i386: Add setting of Hypervisor leaf extra for known vmare4.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=kvm.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=tcg.
target-i386/cpu.c | 285 ++++++++++++++++++++++++++++++++++++++++++++++++++++- target-i386/cpu.h | 34 +++++++ target-i386/kvm.c | 33 +++++- 3 files changed, 342 insertions(+), 10 deletions(-)
PATCH v6 1/16 target-i386: Add missing kvm bits.
--- target-i386/cpu.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
target-i386/cpu.c +8 -4
@@ -87,10 +87,14 @@ static const char *ext3_feature_name[] = { };static const char *kvm_feature_name[] = { -"kvmclock" ,"kvm_nopiodelay" ,"kvm_mmu" ,"kvmclock" ,"kvm_asyncpf" ,NULL ,"kvm_pv_eoi" ,NULL , -NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , +"kvmclock" ,"kvm_nopiodelay" ,"kvm_mmu" ,"kvmclock" , +"kvm_asyncpf" ,"kvm_steal_time" ,"kvm_pv_eoi" ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +"kvm_clock_stable" ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , };static const char *svm_feature_name[] = {
Signature · 1 line
1.7.1
PATCH v6 2/16 target-i386: Add Hypervisor level.
In reply to Don SlutzAlso known as Paravirtualization level or maximim cpuid function present in this leaf. This is just the EAX value for 0x40000000.
QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).
This is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
QEMU has the value HYPERV_CPUID_MIN defined.
--- target-i386/cpu.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
target-i386/cpu.h +3 -0
@@ -777,11 +777,14 @@ typedef struct CPUX86State {uint32_t cpuid_ext3_features;uint32_t cpuid_apic_id;bool cpuid_vendor_override; +bool cpuid_hv_level_set;/* Store the results of Centaur's CPUID instructions */ uint32_t cpuid_xlevel2;uint32_t cpuid_ext4_features;/* Flags from CPUID[EAX=7,ECX=0].EBX */ uint32_t cpuid_7_0_ebx; +/* Hypervisor CPUIDs */ +uint32_t cpuid_hv_level;/* MTRRs */ uint64_t mtrr_fixed[11 ];
Signature · 1 line
1.7.1
PATCH v6 3/16 target-i386: Add cpu object access routines for Hypervisor level.
In reply to Don SlutzThese are modeled after x86_cpuid_get_xlevel and x86_cpuid_set_xlevel.
--- target-i386/cpu.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
target-i386/cpu.c +29 -0
@@ -1166,6 +1166,32 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static void x86_cpuid_get_hv_level (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_level, name, errp); +} + +static void x86_cpuid_set_hv_level (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +uint32_t value; + +visit_type_uint32 (v, &value, name, errp); +if (error_is_set (errp)) { +return ; + } + +if (value !=0 && value <0x40000000 ) { + value +=0x40000000 ; + } + cpu->env.cpuid_hv_level = value; + cpu->env.cpuid_hv_level_set = true; +} +#if !defined(CONFIG_USER_ONLY )static void x86_get_hv_spinlocks (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp)
@@ -2061,6 +2087,9 @@ static void x86_cpu_initfn(Object *obj)object_property_add (obj,"enforce" ,"bool" , x86_cpuid_get_enforce, x86_cpuid_set_enforce,NULL ,NULL ,NULL ); +object_property_add (obj,"hypervisor-level" ,"int" , + x86_cpuid_get_hv_level, + x86_cpuid_set_hv_level,NULL ,NULL ,NULL );#if !defined(CONFIG_USER_ONLY ) object_property_add(obj, "hv_spinlocks", "int", x86_get_hv_spinlocks,
Signature · 1 line
1.7.1
Re: [PATCH v6 03/16] target-i386: Add cpu object access routines for Hypervisor level.
Quoted 27 lines · Don Slutz
These are modeled after
x86_cpuid_get_xlevelandx86_cpuid_set_xlevel.Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)target-i386/cpu.c +12
-0@@ -1166,6 +1166,32 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static void x86_cpuid_get_hv_level (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_level, name, errp); +} + +static void x86_cpuid_set_hv_level (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj);
target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1190
Quoted 10 lines
target-i386/cpu.c +10
-0+uint32_t value; + +visit_type_uint32 (v, &value, name, errp); +if (error_is_set (errp)) { +return ; + } + +if (value !=0 && value <0x40000000 ) { + value +=0x40000000 ; + }
Whats the purpose of this? Adds ambiguity.
Re: [PATCH v6 03/16] target-i386: Add cpu object access routines for Hypervisor level.
Quoted 31 lines · Marcelo Tosatti
Quoted 30 lines · Don Slutz
These are modeled after
x86_cpuid_get_xlevelandx86_cpuid_set_xlevel.Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)target-i386/cpu.c +15
-0@@ -1166,6 +1166,32 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static void x86_cpuid_get_hv_level (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_level, name, errp); +} + +static void x86_cpuid_set_hv_level (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +uint32_t value; + +visit_type_uint32 (v, &value, name, errp);
Quoted 8 lines
target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1190
Quoted 7 lines
target-i386/cpu.c +7
-0+if (error_is_set (errp)) { +return ; + } + +if (value !=0 && value <0x40000000 ) { + value +=0x40000000 ; + }Whats the purpose of this? Adds ambiguity.
Will add more info in this commit message.
-Don
Re: [PATCH v6 03/16] target-i386: Add cpu object access routines for Hypervisor level.
Quoted 42 lines · Don Slutz
Quoted 33 lines · Marcelo Tosatti
Quoted 32 lines · Don Slutz
These are modeled after
x86_cpuid_get_xlevelandx86_cpuid_set_xlevel.Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)target-i386/cpu.c +14
-0@@ -1166,6 +1166,32 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static void x86_cpuid_get_hv_level(Object *obj, Visitor *v, void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_level, name, errp); +} + +static void x86_cpuid_set_hv_level (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +uint32_t value; + +visit_type_uint32 (v, &value, name, errp);Quoted 8 lines
target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1190
Quoted 7 lines
target-i386/cpu.c +7
-0+if (error_is_set (errp)) { +return ; + } + +if (value !=0 && value <0x40000000 ) { + value +=0x40000000 ; + }Whats the purpose of this? Adds ambiguity.
Quoted 6 lines
Will add more info in this commit message.
-DonSignature · 3 lines
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Not clear on how to add info in the commit message.
This is direct copy with adjustment from x86_cpuid_set_xlevel():
if (value < 0x80000000) {
value += 0x80000000;
}(Pending patch: http://comments.gmane.org/gmane.comp.emulators.qemu/172703 adds this)
The adjustment is that 0 is a legal value. See http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
This does mean that just like xlevel=1 and xlevel=0x80000001 are the same; hypervisor-level=1 and hypervisor-level=0x4000001 are the same. If this is not wanted, I have no issue with removing it.
-Don Slutz
Re: [PATCH v6 03/16] target-i386: Add cpu object access routines for Hypervisor level.
Am 10.10.2012 17:22, schrieb Don Slutz:
Quoted 19 lines · Don Slutz
Quoted 18 lines · Marcelo Tosatti
Quoted 17 lines · Don Slutz
Quoted 5 lines
+static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque,
target-i386/cpu.c +3
-0+ const char *name, Error **errp) +{ + X86CPU *cpu = X86_CPU(obj);target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1190
Quoted 10 lines
target-i386/cpu.c +10
-0+uint32_t value; + +visit_type_uint32 (v, &value, name, errp); +if (error_is_set (errp)) { +return ; + } + +if (value !=0 && value <0x40000000 ) { + value +=0x40000000 ; + }Whats the purpose of this? Adds ambiguity.
[...]
Quoted 8 lines
This is direct copy with adjustment from
x86_cpuid_set_xlevel():if (value < 0x80000000) { value += 0x80000000; }(Pending patch:
http://comments.gmane.org/gmane.comp.emulators.qemu/172703 adds this)
(Any pending patch can be changed ;))
Quoted 6 lines
The adjustment is that 0 is a legal value. See
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlThis does mean that just like xlevel=1 and xlevel=0x80000001 are the same; hypervisor-level=1 and hypervisor-level=0x4000001 are the same. If this is not wanted, I have no issue with removing it.
I have no strong opinion either way, but if there's only one call site, I'd prefer to apply these fixups to user input before setting the property and to have the property setter error out on invalid values. I consider that cleaner than silently fixing up values inside the setter.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [PATCH v6 03/16] target-i386: Add cpu object access routines for Hypervisor level.
Quoted 37 lines · Andreas Färber
Am 10.10.2012 17:22, schrieb Don Slutz:
Quoted 19 lines · Don Slutz
Quoted 18 lines · Marcelo Tosatti
Quoted 17 lines · Don Slutz
Quoted 5 lines
+static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque,
target-i386/cpu.c +3
-0+ const char *name, Error **errp) +{ + X86CPU *cpu = X86_CPU(obj);target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1190
Quoted 10 lines
target-i386/cpu.c +10
-0+uint32_t value; + +visit_type_uint32 (v, &value, name, errp); +if (error_is_set (errp)) { +return ; + } + +if (value !=0 && value <0x40000000 ) { + value +=0x40000000 ; + }Whats the purpose of this? Adds ambiguity.
[...]
Quoted 8 lines
This is direct copy with adjustment from
x86_cpuid_set_xlevel():if (value < 0x80000000) { value += 0x80000000; }(Pending patch:
http://comments.gmane.org/gmane.comp.emulators.qemu/172703 adds this)(Any pending patch can be changed ;))
Quoted 6 lines
The adjustment is that 0 is a legal value. See
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlThis does mean that just like xlevel=1 and xlevel=0x80000001 are the same; hypervisor-level=1 and hypervisor-level=0x4000001 are the same. If this is not wanted, I have no issue with removing it.
Quoted 8 lines
I have no strong opinion either way, but if there's only one call site, I'd prefer to apply these fixups to user input before setting the property and to have the property setter error out on invalid values. I consider that cleaner than silently fixing up values inside the setter.
Regards,
Andreas
I find more then one call site. And one of them is converting the predefined x86 cpus (like 486). So I am not planning on a change.
I have finished up the v7 changes except for this. I will wait until some time tomorrow to send it in case there is more on this topic.
-Don Slutz
PATCH v6 4/16 target-i386: Add x86_set_hyperv.
In reply to Don SlutzThis is used to set the cpu object's hypervisor level to the default for Microsoft's Hypervisor.
--- target-i386/cpu.c | 9 +++++++++ target-i386/cpu.h | 2 ++ 2 files changed, 11 insertions(+), 0 deletions(-)
target-i386/cpu.c +9 -0
@@ -1193,6 +1193,12 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, }#if !defined(CONFIG_USER_ONLY ) +static void x86_set_hyperv (Object *obj,Error **errp) +{ +object_property_set_int (obj,CPUID_HV_LEVEL_HYPERV , +"hypervisor-level" , errp); +} +static void x86_get_hv_spinlocks (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {
@@ -1215,6 +1221,7 @@ static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,return ; }hyperv_set_spinlock_retries (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_relaxed(Object *obj, Visitor *v, void *opaque,
@@ -1235,6 +1242,7 @@ static void x86_set_hv_relaxed(Object *obj, Visitor *v, void *opaque,return ; }hyperv_enable_relaxed_timing (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_vapic(Object *obj, Visitor *v, void *opaque,
@@ -1255,6 +1263,7 @@ static void x86_set_hv_vapic(Object *obj, Visitor *v, void *opaque, return; }hyperv_enable_vapic_recommended (value); +x86_set_hyperv (obj, errp); }#endif
target-i386/cpu.h +2 -0
@@ -488,6 +488,8 @@#define CPUID_VENDOR_VIA "CentaurHauls" +#define CPUID_HV_LEVEL_HYPERV 0x40000005 +#define CPUID_MWAIT_IBE (1 << 1)/* Interrupts can exit capability */ #define CPUID_MWAIT_EMX (1 << 0)/* enumeration supported */
Signature · 1 line
1.7.1
Re: [PATCH v6 04/16] target-i386: Add x86_set_hyperv.
Quoted 54 lines · Don Slutz
This is used to set the cpu object's hypervisor level to the default for Microsoft's Hypervisor.
Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 9 +++++++++ target-i386/cpu.h | 2 ++ 2 files changed, 11 insertions(+), 0 deletions(-)target-i386/cpu.c +9
-0@@ -1193,6 +1193,12 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, }#if !defined(CONFIG_USER_ONLY ) +static void x86_set_hyperv (Object *obj,Error **errp) +{ +object_property_set_int (obj,CPUID_HV_LEVEL_HYPERV , +"hypervisor-level" , errp); +} +static void x86_get_hv_spinlocks (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {@@ -1215,6 +1221,7 @@ static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,return ; }hyperv_set_spinlock_retries (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_relaxed(Object *obj, Visitor *v, void *opaque,@@ -1235,6 +1242,7 @@ static void x86_set_hv_relaxed(Object *obj, Visitor *v, void *opaque,return ; }hyperv_enable_relaxed_timing (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_vapic(Object *obj, Visitor *v, void *opaque,@@ -1255,6 +1263,7 @@ static void x86_set_hv_vapic(Object *obj, Visitor *v, void *opaque, return; }hyperv_enable_vapic_recommended (value); +x86_set_hyperv (obj, errp); }#endif target-i386/cpu.h +0
-0
target-i386/cpu.h line 492
Quoted 5 lines
target-i386/cpu.h +2
-0@@ -488,6 +488,8 @@#define CPUID_VENDOR_VIA "CentaurHauls" +#define CPUID_HV_LEVEL_HYPERV 0x40000005 +
Where this comes from?
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
has under "Leaf 0x40000000" (at very top of table):
EAX
The maximum input value for hypervisor CPUID information. For Microsoft hypervisors, this value will be at least 0x40000005. The vendor ID signature should be used only for reporting and diagnostic purposes.
Is that the same 0x40000005 as in this patch?
Re: [PATCH v6 04/16] target-i386: Add x86_set_hyperv.
Quoted 67 lines · Marcelo Tosatti
Quoted 54 lines · Don Slutz
This is used to set the cpu object's hypervisor level to the default for Microsoft's Hypervisor.
Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 9 +++++++++ target-i386/cpu.h | 2 ++ 2 files changed, 11 insertions(+), 0 deletions(-)target-i386/cpu.c +9
-0@@ -1193,6 +1193,12 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, }#if !defined(CONFIG_USER_ONLY ) +static void x86_set_hyperv (Object *obj,Error **errp) +{ +object_property_set_int (obj,CPUID_HV_LEVEL_HYPERV , +"hypervisor-level" , errp); +} +static void x86_get_hv_spinlocks (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {@@ -1215,6 +1221,7 @@ static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,return ; }hyperv_set_spinlock_retries (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_relaxed(Object *obj, Visitor *v, void *opaque,@@ -1235,6 +1242,7 @@ static void x86_set_hv_relaxed(Object *obj, Visitor *v, void *opaque,return ; }hyperv_enable_relaxed_timing (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_vapic(Object *obj, Visitor *v, void *opaque,@@ -1255,6 +1263,7 @@ static void x86_set_hv_vapic(Object *obj, Visitor *v, void *opaque, return; }hyperv_enable_vapic_recommended (value); +x86_set_hyperv (obj, errp); }#endif target-i386/cpu.h +0
-0target-i386/cpu.h line 492
Quoted 5 lines
target-i386/cpu.h +2
-0@@ -488,6 +488,8 @@#define CPUID_VENDOR_VIA "CentaurHauls" +#define CPUID_HV_LEVEL_HYPERV 0x40000005 +Where this comes from?
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
has under "Leaf
0x40000000" (at very top of table):
Quoted 7 lines
EAX
The maximum input value for hypervisor CPUID information. For Microsoft hypervisors, this value will be at least
0x40000005. The vendor ID signature should be used only for reporting and diagnostic purposes.Is that the same
0x40000005as in this patch?
Yes, the #define can be reused:
#define HYPERV_CPUID_MIN 0x40000005
Re: [PATCH v6 04/16] target-i386: Add x86_set_hyperv.
Quoted 69 lines · Marcelo Tosatti
Quoted 68 lines · Marcelo Tosatti
Quoted 54 lines · Don Slutz
This is used to set the cpu object's hypervisor level to the default for Microsoft's Hypervisor.
Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 9 +++++++++ target-i386/cpu.h | 2 ++ 2 files changed, 11 insertions(+), 0 deletions(-)target-i386/cpu.c +9
-0@@ -1193,6 +1193,12 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, }#if !defined(CONFIG_USER_ONLY ) +static void x86_set_hyperv (Object *obj,Error **errp) +{ +object_property_set_int (obj,CPUID_HV_LEVEL_HYPERV , +"hypervisor-level" , errp); +} +static void x86_get_hv_spinlocks (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {@@ -1215,6 +1221,7 @@ static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,return ; }hyperv_set_spinlock_retries (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_relaxed(Object *obj, Visitor *v, void *opaque,@@ -1235,6 +1242,7 @@ static void x86_set_hv_relaxed(Object *obj, Visitor *v, void *opaque,return ; }hyperv_enable_relaxed_timing (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_vapic(Object *obj, Visitor *v, void *opaque,@@ -1255,6 +1263,7 @@ static void x86_set_hv_vapic(Object *obj, Visitor *v, void *opaque, return; }hyperv_enable_vapic_recommended (value); +x86_set_hyperv (obj, errp); }#endif target-i386/cpu.h +0
-0target-i386/cpu.h line 492
Quoted 5 lines
target-i386/cpu.h +2
-0@@ -488,6 +488,8 @@#define CPUID_VENDOR_VIA "CentaurHauls" +#define CPUID_HV_LEVEL_HYPERV 0x40000005 +Where this comes from?
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
has under "Leaf
0x40000000" (at very top of table):EAX
Quoted 9 lines
Quoted 5 lines
The maximum input value for hypervisor CPUID information. For Microsoft hypervisors, this value will be at least
0x40000005. The vendor ID signature should be used only for reporting and diagnostic purposes.Is that the same
0x40000005as in this patch?Yes, the #define can be reused:
#define
HYPERV_CPUID_MIN0x40000005
Not as simple as it seems.
http://lists.nongnu.org/archive/html/qemu-devel/2012-09/msg03359.html
I can make sure this info is part of the commit message.
-Don Slutz
Re: [PATCH v6 04/16] target-i386: Add x86_set_hyperv.
Quoted 72 lines · Don Slutz
Quoted 71 lines · Marcelo Tosatti
Quoted 61 lines · Marcelo Tosatti
Quoted 51 lines · Don Slutz
This is used to set the cpu object's hypervisor level to the default for Microsoft's Hypervisor.
Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 9 +++++++++ target-i386/cpu.h | 2 ++ 2 files changed, 11 insertions(+), 0 deletions(-)target-i386/cpu.c +9
-0@@ -1193,6 +1193,12 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, }#if !defined(CONFIG_USER_ONLY ) +static void x86_set_hyperv (Object *obj,Error **errp) +{ +object_property_set_int (obj,CPUID_HV_LEVEL_HYPERV , +"hypervisor-level" , errp); +} +static void x86_get_hv_spinlocks (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {@@ -1215,6 +1221,7 @@ static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,return ; }hyperv_set_spinlock_retries (value); +x86_set_hyperv (obj, errp); } static void x86_get_hv_relaxed(Object *obj, Visitor *v, void *opaque,@@ -1235,6 +1242,7 @@ static void x86_set_hv_relaxed(Object *obj, Visitor *v, void *opaque,return ; }hyperv_enable_relaxed_timing (value); +x86_set_hyperv (obj, errp); } } static void x86_get_hv_vapic(Object *obj, Visitor *v, void *opaque,@@ -1255,6 +1263,7 @@ static void x86_set_hv_vapic(Object *obj, Visitor *v, void *opaque, return; }hyperv_enable_vapic_recommended (value); +x86_set_hyperv (obj, errp); }#endif target-i386/cpu.h +0
-0target-i386/cpu.h line 490
Quoted 3 lines
target-i386/cpu.h +2
-0@@ -488,6 +488,8 @@#define CPUID_VENDOR_VIA "CentaurHauls" +#define CPUID_HV_LEVEL_HYPERV 0x40000005 +Where this comes from?
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
has under "Leaf
0x40000000" (at very top of table):Quoted 7 lines
EAX
The maximum input value for hypervisor CPUID information. For Microsoft hypervisors, this value will be at least
0x40000005. The vendor ID signature should be used only for reporting and diagnostic purposes.Is that the same
0x40000005as in this patch?Yes, the #define can be reused:
Quoted 8 lines
Quoted 2 lines
#define
HYPERV_CPUID_MIN0x40000005Not as simple as it seems.
http://lists.nongnu.org/archive/html/qemu-devel/2012-09/msg03359.html
I can make sure this info is part of the commit message.
-Don Slutz
Ok add a copy but have CPUID_MIN in the name (because CPUID_HV_LEVEL_HYPERV is very confusing). Add a comment
/* maximum input value for h...
PATCH v6 5/16 target-i386: Use Hypervisor level in -machine pc,accel=kvm.
In reply to Don SlutzAlso known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).
--- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
target-i386/kvm.c +2 -2
@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];memset (c,0 ,sizeof (*c)); c->function =KVM_CPUID_SIGNATURE ; -if (!hyperv_enabled ()) { +if (!env->cpuid_hv_level_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; }else {memcpy (signature,"Microsoft Hv" ,12 ); - c->eax =HYPERV_CPUID_MIN ; + c->eax = env->cpuid_hv_level; } c->ebx = signature[0 ]; c->ecx = signature[1 ];
Signature · 1 line
1.7.1
Re: [PATCH v6 05/16] target-i386: Use Hypervisor level in -machine pc,accel=kvm.
Quoted 29 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this is
KVM_CPUID_SIGNATURE(0x40000000).Signed-off-by Don Slutz <[email protected]>--- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)target-i386/kvm.c +0
-0@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];
target-i386/kvm.c int kvm_arch_init_vcpu(CPUX86State *env) · line 397
Quoted 10 lines
target-i386/kvm.c +2
-2memset (c,0 ,sizeof (*c)); c->function = KVM_CPUID_SIGNATURE -if (!hyperv_enabled ()) { +if (!env->cpuid_hv_level_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; }else {memcpy (signature,"Microsoft Hv" ,12 ); - c->eax =HYPERV_CPUID_MIN ; + c->eax = env->cpuid_hv_level;
This breaks hyperv_enabled() checks.
Don, are you certain it is worthwhile to make this configurable? Can you explain why, under your scenario, it is worthwhile?
Because these are separate problems:
- "Fake" VMWare hypervisor (which seems to be your main goal).
- Make CPUID HV leafs configurable via command line.
My point is that the CPUIDs must be carefully constructed, that i miss the point why making them configurable is desired.
Re: [PATCH v6 05/16] target-i386: Use Hypervisor level in -machine pc, accel=kvm.
Quoted 43 lines · Marcelo Tosatti
Quoted 29 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this is
KVM_CPUID_SIGNATURE(0x40000000).Signed-off-by Don Slutz <[email protected]>--- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)target-i386/kvm.c +0
-0@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];target-i386/kvm.c int kvm_arch_init_vcpu(CPUX86State *env) · line 397
Quoted 10 lines
target-i386/kvm.c +2
-2memset (c,0 ,sizeof (*c)); c->function = KVM_CPUID_SIGNATURE -if (!hyperv_enabled ()) { +if (!env->cpuid_hv_level_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; }else {memcpy (signature,"Microsoft Hv" ,12 ); - c->eax =HYPERV_CPUID_MIN ; + c->eax = env->cpuid_hv_level;This breaks
hyperv_enabled()checks.
Quoted 7 lines
Don, are you certain it is worthwhile to make this configurable? Can you explain why, under your scenario, it is worthwhile?
Because these are separate problems:
- "Fake" VMWare hypervisor (which seems to be your main goal).
- Make CPUID HV leafs configurable via command line.
Err, meant via properties. Point is, why have VMWare CPUID configuration as data, if there are reasons to believe code is a better fit (code as in current Hyper-V implementation).
Quoted 8 lines
My point is that the CPUIDs must be carefully constructed, that i miss the point why making them configurable is desired.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 05/16] target-i386: Use Hypervisor level in -machine pc, accel=kvm.
Quoted 47 lines · Marcelo Tosatti
Quoted 46 lines · Marcelo Tosatti
Quoted 29 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this is
KVM_CPUID_SIGNATURE(0x40000000).Signed-off-by Don Slutz <[email protected]>--- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)target-i386/kvm.c +0
-0@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];target-i386/kvm.c int kvm_arch_init_vcpu(CPUX86State *env) · line 397
Quoted 10 lines
target-i386/kvm.c +2
-2memset (c,0 ,sizeof (*c)); c->function = KVM_CPUID_SIGNATURE -if (!hyperv_enabled ()) { +if (!env->cpuid_hv_level_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; }else {memcpy (signature,"Microsoft Hv" ,12 ); - c->eax =HYPERV_CPUID_MIN ; + c->eax = env->cpuid_hv_level;This breaks
hyperv_enabled()checks.Don, are you certain it is worthwhile to make this configurable? Can you explain why, under your scenario, it is worthwhile?
Quoted 8 lines
Quoted 4 lines
Because these are separate problems:
- "Fake" VMWare hypervisor (which seems to be your main goal).
- Make CPUID HV leafs configurable via command line.Err, meant via properties. Point is, why have VMWare CPUID configuration as data, if there are reasons to believe code is a better fit (code as in current Hyper-V implementation).
Nevermind, its the right thing to do. Just separate the patchset please:
1) Create object properties.
2) Export VMWare CPUID via properties.
3) Convert Hyper-V.
Be careful to make sure Hyper-V's current options are functional in 3).
Re: [PATCH v6 05/16] target-i386: Use Hypervisor level in -machine pc,accel=kvm.
Quoted 57 lines · Marcelo Tosatti
Quoted 46 lines · Marcelo Tosatti
Quoted 45 lines · Marcelo Tosatti
Quoted 29 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this is
KVM_CPUID_SIGNATURE(0x40000000).Signed-off-by Don Slutz <[email protected]>--- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)target-i386/kvm.c +0
-0@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];target-i386/kvm.c int kvm_arch_init_vcpu(CPUX86State *env) · line 397
Quoted 10 lines
target-i386/kvm.c +2
-2memset (c,0 ,sizeof (*c)); c->function = KVM_CPUID_SIGNATURE -if (!hyperv_enabled ()) { +if (!env->cpuid_hv_level_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; }else {memcpy (signature,"Microsoft Hv" ,12 ); - c->eax =HYPERV_CPUID_MIN ; + c->eax = env->cpuid_hv_level;This breaks
hyperv_enabled()checks.Don, are you certain it is worthwhile to make this configurable? Can you explain why, under your scenario, it is worthwhile?
Quoted 7 lines
Quoted 4 lines
Because these are separate problems:
- "Fake" VMWare hypervisor (which seems to be your main goal).
- Make CPUID HV leafs configurable via command line.Err, meant via properties. Point is, why have VMWare CPUID configuration as data, if there are reasons to believe code is a better fit (code as in current Hyper-V implementation).
Nevermind, its the right thing to do. Just separate the patchset please:
Quoted 7 lines
1) Create object properties.
2) Export VMWare CPUID via properties.
3) Convert Hyper-V.Be careful to make sure Hyper-V's current options are functional in 3).
Did you mean 3 patch sets (or more)? Or just a different order?
-Don Slutz
Re: [PATCH v6 05/16] target-i386: Use Hypervisor level in -machine pc,accel=kvm.
Quoted 62 lines · Don Slutz
Quoted 61 lines · Marcelo Tosatti
Quoted 46 lines · Marcelo Tosatti
Quoted 45 lines · Marcelo Tosatti
Quoted 29 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this is
KVM_CPUID_SIGNATURE(0x40000000).Signed-off-by Don Slutz <[email protected]>--- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)target-i386/kvm.c +0
-0@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];target-i386/kvm.c int kvm_arch_init_vcpu(CPUX86State *env) · line 397
Quoted 10 lines
target-i386/kvm.c +2
-2memset (c,0 ,sizeof (*c)); c->function = KVM_CPUID_SIGNATURE -if (!hyperv_enabled ()) { +if (!env->cpuid_hv_level_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; }else {memcpy (signature,"Microsoft Hv" ,12 ); - c->eax =HYPERV_CPUID_MIN ; + c->eax = env->cpuid_hv_level;This breaks
hyperv_enabled()checks.Don, are you certain it is worthwhile to make this configurable? Can you explain why, under your scenario, it is worthwhile?
Quoted 7 lines
Quoted 4 lines
Because these are separate problems:
- "Fake" VMWare hypervisor (which seems to be your main goal).
- Make CPUID HV leafs configurable via command line.Err, meant via properties. Point is, why have VMWare CPUID configuration as data, if there are reasons to believe code is a better fit (code as in current Hyper-V implementation).
Nevermind, its the right thing to do. Just separate the patchset please:
1) Create object properties.
2) Export VMWare CPUID via properties.
3) Convert Hyper-V.
Quoted 5 lines
Quoted 3 lines
Be careful to make sure Hyper-V's current options are functional in 3).
Did you mean 3 patch sets (or more)? Or just a different order?
-Don Slutz
Different order. Patches should be logically related (think of what information the reviewer needs). Please write changelogs for every patch.
Re: [PATCH v6 05/16] target-i386: Use Hypervisor level in -machine pc,accel=kvm.
Quoted 63 lines · Marcelo Tosatti
Quoted 62 lines · Don Slutz
Quoted 61 lines · Marcelo Tosatti
Quoted 46 lines · Marcelo Tosatti
Quoted 45 lines · Marcelo Tosatti
Quoted 29 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this is
KVM_CPUID_SIGNATURE(0x40000000).Signed-off-by Don Slutz <[email protected]>--- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)target-i386/kvm.c +0
-0@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];target-i386/kvm.c int kvm_arch_init_vcpu(CPUX86State *env) · line 397
Quoted 10 lines
target-i386/kvm.c +2
-2memset (c,0 ,sizeof (*c)); c->function = KVM_CPUID_SIGNATURE -if (!hyperv_enabled ()) { +if (!env->cpuid_hv_level_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; }else {memcpy (signature,"Microsoft Hv" ,12 ); - c->eax =HYPERV_CPUID_MIN ; + c->eax = env->cpuid_hv_level;This breaks
hyperv_enabled()checks.Don, are you certain it is worthwhile to make this configurable? Can you explain why, under your scenario, it is worthwhile?
Quoted 7 lines
Quoted 4 lines
Because these are separate problems:
- "Fake" VMWare hypervisor (which seems to be your main goal).
- Make CPUID HV leafs configurable via command line.Err, meant via properties. Point is, why have VMWare CPUID configuration as data, if there are reasons to believe code is a better fit (code as in current Hyper-V implementation).
Nevermind, its the right thing to do. Just separate the patchset please:
1) Create object properties.
2) Export VMWare CPUID via properties.
3) Convert Hyper-V.
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
Be careful to make sure Hyper-V's current options are functional in 3).
Did you mean 3 patch sets (or more)? Or just a different order?
-Don SlutzDifferent order. Patches should be logically related (think of what information the reviewer needs). Please write changelogs for every patch.
Using this order causes support for Hyper-V to stop working in the middle of the patch set. How about this order:
1) Create object properties.
2) Convert Hyper-V to set the new properties.
3) Change kvm.c to use the new properties.
4) Export VMWare CPUID via properties.
5) Change accel=tcg to use the new properties.
-Don Slutz
Re: [PATCH v6 05/16] target-i386: Use Hypervisor level in -machine pc,accel=kvm.
Quoted 14 lines · Don Slutz
Quoted 7 lines
Quoted 2 lines
Did you mean 3 patch sets (or more)? Or just a different order?
-Don SlutzDifferent order. Patches should be logically related (think of what information the reviewer needs). Please write changelogs for every patch.
Using this order causes support for Hyper-V to stop working in the middle of the patch set. How about this order:
1) Create object properties.
2) Convert Hyper-V to set the new properties.
3) Changekvm.cto use the new properties.
4) Export VMWare CPUID via properties.
Quoted 3 lines
5) Change accel=tcg to use the new properties.
-Don Slutz
Fine, as long as change from item A) does not leak to item B).
PATCH v6 6/16 target-i386: Use Hypervisor level in -machine pc,accel=tcg.
In reply to Don SlutzAlso known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
QEMU knows this as KVM_CPUID_SIGNATURE (0x40000000) in kvm on linux.
This does not provide vendor support in tcg yet.
--- target-i386/cpu.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
target-i386/cpu.c +27 -0
@@ -1651,6 +1651,21 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, index = env->cpuid_xlevel; } } + }else if (index &0x40000000 ) { +if (env->cpuid_hv_level_set) { +uint32_t real_level = env->cpuid_hv_level; + +/* Handle Hypervisor CPUIDs */ +if (real_level <0x40000000 ) { + real_level =0x40000000 ; + } +if (index > real_level) { + index = real_level; + } + }else { +if (index > env->cpuid_level) + index = env->cpuid_level; + } }else {if (index > env->cpuid_level) index = env->cpuid_level;
@@ -1789,6 +1804,18 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx =0 ; }break ; +case 0x40000000 : + *eax = env->cpuid_hv_level; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +break ; +case 0x40000001 : + *eax = env->cpuid_kvm_features; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +break ;case 0x80000000 : *eax = env->cpuid_xlevel; *ebx = env->cpuid_vendor1;
Signature · 1 line
1.7.1
Re: [PATCH v6 06/16] target-i386: Use Hypervisor level in -machine pc,accel=tcg.
Quoted 38 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this as
KVM_CPUID_SIGNATURE(0x40000000) in kvm on linux.This does not provide vendor support in tcg yet.
Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)target-i386/cpu.c +5
-0@@ -1651,6 +1651,21 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, index = env->cpuid_xlevel; } } + }else if (index &0x40000000 ) { +if (env->cpuid_hv_level_set) { +uint32_t real_level = env->cpuid_hv_level; + +/* Handle Hypervisor CPUIDs */
target-i386/cpu.c void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, · line 1668
Quoted 10 lines
target-i386/cpu.c +10
-0+if (real_level <0x40000000 ) { + real_level =0x40000000 ; + } +if (index > real_level) { + index = real_level; + } + }else { +if (index > env->cpuid_level) + index = env->cpuid_level; + }
Whats the purpose of this checks?
Please provide changelogs for each patch.
Quoted 29 lines
target-i386/cpu.c +12
-0}else {if (index > env->cpuid_level) index = env->cpuid_level;@@ -1789,6 +1804,18 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx =0 ; }break ; +case 0x40000000 : + *eax = env->cpuid_hv_level; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +break ; +case 0x40000001 : + *eax = env->cpuid_kvm_features; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +break ;case 0x80000000 : *eax = env->cpuid_xlevel; *ebx = env->cpuid_vendor1;Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 06/16] target-i386: Use Hypervisor level in -machine pc,accel=tcg.
Quoted 42 lines · Marcelo Tosatti
Quoted 41 lines · Don Slutz
Also known as Paravirtualization level.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspxLinux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.htmlVMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458QEMU knows this as
KVM_CPUID_SIGNATURE(0x40000000) in kvm on linux.This does not provide vendor support in tcg yet.
Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)target-i386/cpu.c +8
-0@@ -1651,6 +1651,21 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, index = env->cpuid_xlevel; } } + }else if (index &0x40000000 ) { +if (env->cpuid_hv_level_set) { +uint32_t real_level = env->cpuid_hv_level; + +/* Handle Hypervisor CPUIDs */ +if (real_level <0x40000000 ) { + real_level =0x40000000 ; + }
Quoted 8 lines
target-i386/cpu.c void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, · line 1668
Quoted 7 lines
target-i386/cpu.c +7
-0+if (index > real_level) { + index = real_level; + } + }else { +if (index > env->cpuid_level) + index = env->cpuid_level; + }Whats the purpose of this checks?
They control what happens for CPUID requests outside the defined ranges. Very similar to code just above this.
Quoted 2 lines
Please provide changelogs for each patch.
In progress.
Quoted 25 lines
Quoted 25 lines
target-i386/cpu.c +12
-0}else {if (index > env->cpuid_level) index = env->cpuid_level;@@ -1789,6 +1804,18 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx =0 ; }break ; +case 0x40000000 : + *eax = env->cpuid_hv_level; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +break ; +case 0x40000001 : + *eax = env->cpuid_kvm_features; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +break ;case 0x80000000 : *eax = env->cpuid_xlevel; *ebx = env->cpuid_vendor1;Signature · 1 line
1.7.1
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-Don Slutz
PATCH v6 7/16 target-i386: Add Hypervisor vendor.
In reply to Don SlutzAlso known as Paravirtualization vendor.
This is EBX, ECX, EDX data for 0x40000000.
QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).
This is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
--- target-i386/cpu.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
target-i386/cpu.h +4 -0
@@ -780,6 +780,7 @@ typedef struct CPUX86State {uint32_t cpuid_apic_id;bool cpuid_vendor_override;bool cpuid_hv_level_set; +bool cpuid_hv_vendor_set;/* Store the results of Centaur's CPUID instructions */ uint32_t cpuid_xlevel2;uint32_t cpuid_ext4_features;
@@ -787,6 +788,9 @@ typedef struct CPUX86State {uint32_t cpuid_7_0_ebx;/* Hypervisor CPUIDs */ uint32_t cpuid_hv_level; +uint32_t cpuid_hv_vendor1; +uint32_t cpuid_hv_vendor2; +uint32_t cpuid_hv_vendor3;/* MTRRs */ uint64_t mtrr_fixed[11 ];
Signature · 1 line
1.7.1
PATCH v6 8/16 target-i386: Add cpu object access routines for Hypervisor vendor.
In reply to Don SlutzThese are modeled after x86_cpuid_set_vendor and x86_cpuid_get_vendor.
Since kvm's vendor is shorter, the test for correct size is removed and zero padding is added.
Set Microsoft's Vendor now that we can. Value defined in:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
And matches want is in target-i386/kvm.c
--- target-i386/cpu.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ target-i386/cpu.h | 2 ++ 2 files changed, 48 insertions(+), 0 deletions(-)
target-i386/cpu.c +46 -0
@@ -1192,11 +1192,54 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, cpu->env.cpuid_hv_level_set = true; } +static char *x86_cpuid_get_hv_vendor (Object *obj,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +CPUX86State *env = &cpu->env; +char *value; +int i; + + value = (char *)g_malloc (CPUID_VENDOR_SZ +1 ); +for (i =0 ; i <4 ; i++) { + value[i +0 ] = env->cpuid_hv_vendor1 >> (8 * i); + value[i +4 ] = env->cpuid_hv_vendor2 >> (8 * i); + value[i +8 ] = env->cpuid_hv_vendor3 >> (8 * i); + } + value[CPUID_VENDOR_SZ ] ='\0' ; + +return value; +} + +static void x86_cpuid_set_hv_vendor (Object *obj,const char *value, +Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +CPUX86State *env = &cpu->env; +int i; +char adj_value[CPUID_VENDOR_SZ +1 ]; + +memset (adj_value,0 ,sizeof (adj_value)); + +pstrcpy (adj_value,sizeof (adj_value), value); + + env->cpuid_hv_vendor1 =0 ; + env->cpuid_hv_vendor2 =0 ; + env->cpuid_hv_vendor3 =0 ; +for (i =0 ; i <4 ; i++) { + env->cpuid_hv_vendor1 |= ((uint8_t )adj_value[i +0 ]) << (8 * i); + env->cpuid_hv_vendor2 |= ((uint8_t )adj_value[i +4 ]) << (8 * i); + env->cpuid_hv_vendor3 |= ((uint8_t )adj_value[i +8 ]) << (8 * i); + } + env->cpuid_hv_vendor_set = true; +} +#if !defined(CONFIG_USER_ONLY )static void x86_set_hyperv (Object *obj,Error **errp) {object_property_set_int (obj,CPUID_HV_LEVEL_HYPERV ,"hypervisor-level" , errp); +object_property_set_str (obj,CPUID_HV_VENDOR_HYPERV , +"hypervisor-vendor" , errp); } static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
@@ -2126,6 +2169,9 @@ static void x86_cpu_initfn(Object *obj)object_property_add (obj,"hypervisor-level" ,"int" , x86_cpuid_get_hv_level, x86_cpuid_set_hv_level,NULL ,NULL ,NULL ); +object_property_add_str (obj,"hypervisor-vendor" , + x86_cpuid_get_hv_vendor, + x86_cpuid_set_hv_vendor,NULL );#if !defined(CONFIG_USER_ONLY ) object_property_add(obj, "hv_spinlocks", "int", x86_get_hv_spinlocks,
target-i386/cpu.h +2 -0
@@ -488,6 +488,8 @@#define CPUID_VENDOR_VIA "CentaurHauls" +#define CPUID_HV_VENDOR_HYPERV "Microsoft Hv" +#define CPUID_HV_LEVEL_HYPERV 0x40000005#define CPUID_MWAIT_IBE (1 << 1)/* Interrupts can exit capability */
Signature · 1 line
1.7.1
Re: [PATCH v6 08/16] target-i386: Add cpu object access routines for Hypervisor vendor.
Quoted 87 lines · Don Slutz
These are modeled after
x86_cpuid_set_vendorandx86_cpuid_get_vendor.
Since kvm's vendor is shorter, the test for correct size is removed and zero padding is added.Set Microsoft's Vendor now that we can. Value defined in:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
And matches want is intarget-i386/kvm.cSigned-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ target-i386/cpu.h | 2 ++ 2 files changed, 48 insertions(+), 0 deletions(-)target-i386/cpu.c +46
-0@@ -1192,11 +1192,54 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, cpu->env.cpuid_hv_level_set = true; } +static char *x86_cpuid_get_hv_vendor (Object *obj,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +CPUX86State *env = &cpu->env; +char *value; +int i; + + value = (char *)g_malloc (CPUID_VENDOR_SZ +1 ); +for (i =0 ; i <4 ; i++) { + value[i +0 ] = env->cpuid_hv_vendor1 >> (8 * i); + value[i +4 ] = env->cpuid_hv_vendor2 >> (8 * i); + value[i +8 ] = env->cpuid_hv_vendor3 >> (8 * i); + } + value[CPUID_VENDOR_SZ ] ='\0' ; + +return value; +} + +static void x86_cpuid_set_hv_vendor (Object *obj,const char *value, +Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +CPUX86State *env = &cpu->env; +int i; +char adj_value[CPUID_VENDOR_SZ +1 ]; + +memset (adj_value,0 ,sizeof (adj_value)); + +pstrcpy (adj_value,sizeof (adj_value), value); + + env->cpuid_hv_vendor1 =0 ; + env->cpuid_hv_vendor2 =0 ; + env->cpuid_hv_vendor3 =0 ; +for (i =0 ; i <4 ; i++) { + env->cpuid_hv_vendor1 |= ((uint8_t )adj_value[i +0 ]) << (8 * i); + env->cpuid_hv_vendor2 |= ((uint8_t )adj_value[i +4 ]) << (8 * i); + env->cpuid_hv_vendor3 |= ((uint8_t )adj_value[i +8 ]) << (8 * i); + } + env->cpuid_hv_vendor_set = true; +} +#if !defined(CONFIG_USER_ONLY )static void x86_set_hyperv (Object *obj,Error **errp) {object_property_set_int (obj,CPUID_HV_LEVEL_HYPERV ,"hypervisor-level" , errp); +object_property_set_str (obj,CPUID_HV_VENDOR_HYPERV , +"hypervisor-vendor" , errp); } static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,@@ -2126,6 +2169,9 @@ static void x86_cpu_initfn(Object *obj)object_property_add (obj,"hypervisor-level" ,"int" , x86_cpuid_get_hv_level, x86_cpuid_set_hv_level,NULL ,NULL ,NULL ); +object_property_add_str (obj,"hypervisor-vendor" , + x86_cpuid_get_hv_vendor, + x86_cpuid_set_hv_vendor,NULL );#if !defined(CONFIG_USER_ONLY ) object_property_add(obj, "hv_spinlocks", "int", x86_get_hv_spinlocks,target-i386/cpu.h +0
-0
target-i386/cpu.h line 493
Quoted 6 lines
target-i386/cpu.h +2
-0@@ -488,6 +488,8 @@#define CPUID_VENDOR_VIA "CentaurHauls" +#define CPUID_HV_VENDOR_HYPERV "Microsoft Hv" +#define CPUID_HV_LEVEL_HYPERV 0x40000005
As requested, please separate patchset in groups.
PATCH v6 9/16 target-i386: Use Hypervisor vendor in -machine pc,accel=kvm.
In reply to Don SlutzAlso known as Paravirtualization vendor.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
--- target-i386/kvm.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
target-i386/kvm.c +7 -5
@@ -389,16 +389,18 @@ int kvm_arch_init_vcpu(CPUX86State *env) c = &cpuid_data.entries[cpuid_i++];memset (c,0 ,sizeof (*c)); c->function =KVM_CPUID_SIGNATURE ; -if (!env->cpuid_hv_level_set) { +if (!env->cpuid_hv_level_set && !env->cpuid_hv_vendor_set) {memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); c->eax =0 ; + c->ebx = signature[0 ]; + c->ecx = signature[1 ]; + c->edx = signature[2 ]; }else { -memcpy (signature,"Microsoft Hv" ,12 ); c->eax = env->cpuid_hv_level; + c->ebx = env->cpuid_hv_vendor1; + c->ecx = env->cpuid_hv_vendor2; + c->edx = env->cpuid_hv_vendor3; } - c->ebx = signature[0 ]; - c->ecx = signature[1 ]; - c->edx = signature[2 ]; c = &cpuid_data.entries[cpuid_i++];memset (c,0 ,sizeof (*c));
Signature · 1 line
1.7.1
PATCH v6 10/16 target-i386: Use Hypervisor vendor in -machine pc,accel=tcg.
In reply to Don SlutzAlso known as Paravirtualization vendor.
This change is based on:
Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
This is where the 0 is the same as 0x40000001 is defined.
VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
--- target-i386/cpu.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
target-i386/cpu.c +4 -4
@@ -1695,7 +1695,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } } }else if (index &0x40000000 ) { -if (env->cpuid_hv_level_set) { +if (env->cpuid_hv_level_set || env->cpuid_hv_vendor_set) {uint32_t real_level = env->cpuid_hv_level;/* Handle Hypervisor CPUIDs */
@@ -1849,9 +1849,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,break ;case 0x40000000 : *eax = env->cpuid_hv_level; - *ebx =0 ; - *ecx =0 ; - *edx =0 ; + *ebx = env->cpuid_hv_vendor1; + *ecx = env->cpuid_hv_vendor2; + *edx = env->cpuid_hv_vendor3;break ;case 0x40000001 : *eax = env->cpuid_kvm_features;
Signature · 1 line
1.7.1
PATCH v6 11/16 target-i386: Add some known names to Hypervisor vendor.
In reply to Don Slutz--- target-i386/cpu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++- target-i386/cpu.h | 19 +++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-)
target-i386/cpu.c +55 -2
@@ -1207,6 +1207,24 @@ static char *x86_cpuid_get_hv_vendor(Object *obj, Error **errp) } value[CPUID_VENDOR_SZ ] ='\0' ; +/* Convert known names */ +if (!strcmp (value,CPUID_HV_VENDOR_HYPERV ) && + env->cpuid_hv_level ==CPUID_HV_LEVEL_HYPERV ) { +pstrcpy (value,sizeof (value),"hyperv" ); + }else if (!strcmp (value,CPUID_HV_VENDOR_VMWARE )) { +if (env->cpuid_hv_level ==CPUID_HV_LEVEL_VMWARE_4 ) { +pstrcpy (value,sizeof (value),"vmware4" ); + }else if (env->cpuid_hv_level ==CPUID_HV_LEVEL_VMWARE_3 ) { +pstrcpy (value,sizeof (value),"vmware3" ); + } + }else if (!strcmp (value,CPUID_HV_VENDOR_XEN ) && + env->cpuid_hv_level ==CPUID_HV_LEVEL_XEN ) { +pstrcpy (value,sizeof (value),"xen" ); + }else if (!strcmp (value,CPUID_HV_VENDOR_KVM ) && + (env->cpuid_hv_level ==0 || + env->cpuid_hv_level ==CPUID_HV_LEVEL_KVM )) { +pstrcpy (value,sizeof (value),"kvm" ); + }return value; }
@@ -1220,7 +1238,35 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value,memset (adj_value,0 ,sizeof (adj_value)); -pstrcpy (adj_value,sizeof (adj_value), value); +/* Convert known names */ +if (!strcmp (value,"hyperv" )) { +if (!env->cpuid_hv_level_set) { + env->cpuid_hv_level =CPUID_HV_LEVEL_HYPERV ; + } +pstrcpy (adj_value,sizeof (adj_value),CPUID_HV_VENDOR_HYPERV ); + }else if (!strcmp (value,"vmware" ) || !strcmp (value,"vmware4" )) { +if (!env->cpuid_hv_level_set) { + env->cpuid_hv_level =CPUID_HV_LEVEL_VMWARE_4 ; + } +pstrcpy (adj_value,sizeof (adj_value),CPUID_HV_VENDOR_VMWARE ); + }else if (!strcmp (value,"vmware3" )) { +if (!env->cpuid_hv_level_set) { + env->cpuid_hv_level =CPUID_HV_LEVEL_VMWARE_3 ; + } +pstrcpy (adj_value,sizeof (adj_value),CPUID_HV_VENDOR_VMWARE ); + }else if (!strcmp (value,"xen" )) { +if (!env->cpuid_hv_level_set) { + env->cpuid_hv_level =CPUID_HV_LEVEL_XEN ; + } +pstrcpy (adj_value,sizeof (adj_value),CPUID_HV_VENDOR_XEN ); + }else if (!strcmp (value,"kvm" )) { +if (!env->cpuid_hv_level_set) { + env->cpuid_hv_level =CPUID_HV_LEVEL_KVM ; + } +pstrcpy (adj_value,sizeof (adj_value),CPUID_HV_VENDOR_KVM ); + }else { +pstrcpy (adj_value,sizeof (adj_value), value); + } env->cpuid_hv_vendor1 =0 ; env->cpuid_hv_vendor2 =0 ;
@@ -1700,7 +1746,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,/* Handle Hypervisor CPUIDs */ if (real_level <0x40000000 ) { - real_level =0x40000000 ; +if (env->cpuid_hv_vendor1 ==CPUID_HV_VENDOR_KVM_1 && + env->cpuid_hv_vendor2 ==CPUID_HV_VENDOR_KVM_2 && + env->cpuid_hv_vendor3 ==CPUID_HV_VENDOR_KVM_3 && + real_level ==0 ) { + real_level =CPUID_HV_LEVEL_KVM ; + }else { + real_level =0x40000000 ; + } }if (index > real_level) { index = real_level;
target-i386/cpu.h +19 -0
@@ -490,8 +490,27 @@#define CPUID_HV_VENDOR_HYPERV "Microsoft Hv" +#define CPUID_HV_VENDOR_VMWARE_1 0x61774d56/* "VMwa" */ +#define CPUID_HV_VENDOR_VMWARE_2 0x4d566572/* "reVM" */ +#define CPUID_HV_VENDOR_VMWARE_3 0x65726177/* "ware" */ +#define CPUID_HV_VENDOR_VMWARE "VMwareVMware" + +#define CPUID_HV_VENDOR_XEN "XenVMMXenVMM" + +#define CPUID_HV_VENDOR_KVM_1 0x4b4d564b/* "KVMK" */ +#define CPUID_HV_VENDOR_KVM_2 0x564b4d56/* "VMKV" */ +#define CPUID_HV_VENDOR_KVM_3 0x0000004d/* "M\0\0\0" */ +#define CPUID_HV_VENDOR_KVM "KVMKVMKVM" +#define CPUID_HV_LEVEL_HYPERV 0x40000005 +#define CPUID_HV_LEVEL_VMWARE_3 0x40000002 +#define CPUID_HV_LEVEL_VMWARE_4 0x40000010 + +#define CPUID_HV_LEVEL_XEN 0x40000002 + +#define CPUID_HV_LEVEL_KVM 0x40000001 +#define CPUID_MWAIT_IBE (1 << 1)/* Interrupts can exit capability */ #define CPUID_MWAIT_EMX (1 << 0)/* enumeration supported */
Signature · 1 line
1.7.1
PATCH v6 12/16 target-i386: Add optional Hypervisor leaf extra.
In reply to Don Slutz--- target-i386/cpu.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
target-i386/cpu.h +4 -0
@@ -812,6 +812,10 @@ typedef struct CPUX86State {uint32_t cpuid_hv_vendor1;uint32_t cpuid_hv_vendor2;uint32_t cpuid_hv_vendor3; +/* VMware extra data */ +uint32_t cpuid_hv_extra; +uint32_t cpuid_hv_extra_a; +uint32_t cpuid_hv_extra_b;/* MTRRs */ uint64_t mtrr_fixed[11 ];
Signature · 1 line
1.7.1
PATCH v6 13/16 target-i386: Add cpu object access routines for Hypervisor leaf extra.
In reply to Don Slutz--- target-i386/cpu.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 66 insertions(+), 0 deletions(-)
target-i386/cpu.c +66 -0
@@ -1279,6 +1279,63 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value, env->cpuid_hv_vendor_set = true; } +static void x86_cpuid_get_hv_extra (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_extra, name, errp); +} + +static void x86_cpuid_set_hv_extra (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); +uint32_t value; + +visit_type_uint32 (v, &value, name, errp); +if (error_is_set (errp)) { +return ; + } + +if ((value !=0 ) && (value <0x40000000 )) { + value +=0x40000000 ; + } + cpu->env.cpuid_hv_extra = value; +} + +static void x86_cpuid_get_hv_extra_a (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_extra_a, name, errp); +} + +static void x86_cpuid_set_hv_extra_a (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_extra_a, name, errp); +} + +static void x86_cpuid_get_hv_extra_b (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_extra_b, name, errp); +} + +static void x86_cpuid_set_hv_extra_b (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +visit_type_uint32 (v, &cpu->env.cpuid_hv_extra_b, name, errp); +} +#if !defined(CONFIG_USER_ONLY )static void x86_set_hyperv (Object *obj,Error **errp) {
@@ -2225,6 +2282,15 @@ static void x86_cpu_initfn(Object *obj)object_property_add_str (obj,"hypervisor-vendor" , x86_cpuid_get_hv_vendor, x86_cpuid_set_hv_vendor,NULL ); +object_property_add (obj,"hypervisor-extra" ,"int" , + x86_cpuid_get_hv_extra, + x86_cpuid_set_hv_extra,NULL ,NULL ,NULL ); +object_property_add (obj,"hypervisor-extra-a" ,"int" , + x86_cpuid_get_hv_extra_a, + x86_cpuid_set_hv_extra_a,NULL ,NULL ,NULL ); +object_property_add (obj,"hypervisor-extra-b" ,"int" , + x86_cpuid_get_hv_extra_b, + x86_cpuid_set_hv_extra_b,NULL ,NULL ,NULL );#if !defined(CONFIG_USER_ONLY ) object_property_add(obj, "hv_spinlocks", "int", x86_get_hv_spinlocks,
Signature · 1 line
1.7.1
PATCH v6 14/16 target-i386: Add setting of Hypervisor leaf extra for known vmare4.
In reply to Don SlutzThis was taken from:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/22643
--- target-i386/cpu.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
target-i386/cpu.c +32 -0
@@ -1135,6 +1135,36 @@ static void x86_cpuid_set_model_id(Object *obj, const char *model_id, } } +static void x86_cpuid_set_vmware_extra (Object *obj) +{ +X86CPU *cpu =X86_CPU (obj); + +if ((cpu->env.tsc_khz !=0 ) && + (cpu->env.cpuid_hv_level ==CPUID_HV_LEVEL_VMWARE_4 ) && + (cpu->env.cpuid_hv_vendor1 ==CPUID_HV_VENDOR_VMWARE_1 ) && + (cpu->env.cpuid_hv_vendor2 ==CPUID_HV_VENDOR_VMWARE_2 ) && + (cpu->env.cpuid_hv_vendor3 ==CPUID_HV_VENDOR_VMWARE_3 )) { +const uint32_t apic_khz =1000000L ; + +/* +* From article.gmane.org/gmane.comp.emulators.kvm.devel/22643 +* +* Leaf 0x40000010, Timing Information. +* +* VMware has defined the first generic leaf to provide timing +* information. This leaf returns the current TSC frequency and +* current Bus frequency in kHz. +* +* # EAX: (Virtual) TSC frequency in kHz. +* # EBX: (Virtual) Bus (local apic timer) frequency in kHz. +* # ECX, EDX: RESERVED (Per above, reserved fields are set to zero). +*/ + cpu->env.cpuid_hv_extra =0x40000010 ; + cpu->env.cpuid_hv_extra_a = (uint32_t )cpu->env.tsc_khz; + cpu->env.cpuid_hv_extra_b = apic_khz; + } +} +static void x86_cpuid_get_tsc_freq (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {
@@ -1164,6 +1194,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, } cpu->env.tsc_khz = value /1000 ; +x86_cpuid_set_vmware_extra (obj); } static void x86_cpuid_get_hv_level(Object *obj, Visitor *v, void *opaque,
@@ -1277,6 +1308,7 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value, env->cpuid_hv_vendor3 |= ((uint8_t )adj_value[i +8 ]) << (8 * i); } env->cpuid_hv_vendor_set = true; +x86_cpuid_set_vmware_extra (obj); } static void x86_cpuid_get_hv_extra(Object *obj, Visitor *v, void *opaque,
Signature · 1 line
1.7.1
Re: [PATCH v6 14/16] target-i386: Add setting of Hypervisor leaf extra for known vmare4.
Quoted 58 lines · Don Slutz
This was taken from:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/22643Signed-off-by Don Slutz <[email protected]>--- target-i386/cpu.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)target-i386/cpu.c +31
-0@@ -1135,6 +1135,36 @@ static void x86_cpuid_set_model_id(Object *obj, const char *model_id, } } +static void x86_cpuid_set_vmware_extra (Object *obj) +{ +X86CPU *cpu =X86_CPU (obj); + +if ((cpu->env.tsc_khz !=0 ) && + (cpu->env.cpuid_hv_level ==CPUID_HV_LEVEL_VMWARE_4 ) && + (cpu->env.cpuid_hv_vendor1 ==CPUID_HV_VENDOR_VMWARE_1 ) && + (cpu->env.cpuid_hv_vendor2 ==CPUID_HV_VENDOR_VMWARE_2 ) && + (cpu->env.cpuid_hv_vendor3 ==CPUID_HV_VENDOR_VMWARE_3 )) { +const uint32_t apic_khz =1000000L ; + +/* +* From article.gmane.org/gmane.comp.emulators.kvm.devel/22643 +* +* Leaf 0x40000010, Timing Information. +* +* VMware has defined the first generic leaf to provide timing +* information. This leaf returns the current TSC frequency and +* current Bus frequency in kHz. +* +* # EAX: (Virtual) TSC frequency in kHz. +* # EBX: (Virtual) Bus (local apic timer) frequency in kHz. +* # ECX, EDX: RESERVED (Per above, reserved fields are set to zero). +*/ + cpu->env.cpuid_hv_extra =0x40000010 ; + cpu->env.cpuid_hv_extra_a = (uint32_t )cpu->env.tsc_khz; + cpu->env.cpuid_hv_extra_b = apic_khz; + } +} +static void x86_cpuid_get_tsc_freq (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {@@ -1164,6 +1194,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, } cpu->env.tsc_khz = value /1000 ; +x86_cpuid_set_vmware_extra (obj); } static void x86_cpuid_get_hv_level(Object *obj, Visitor *v, void *opaque,
target-i386/cpu.c static void x86_cpuid_set_hv_vendor(Object *obj, const char *value, · line 1312
Quoted 5 lines
target-i386/cpu.c +1
-0@@ -1277,6 +1308,7 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value, env->cpuid_hv_vendor3 |= ((uint8_t )adj_value[i +8 ]) << (8 * i); } env->cpuid_hv_vendor_set = true; +x86_cpuid_set_vmware_extra (obj); }
This is strange. Please have this configuration, that depends on other properties being set, ordered in x86_cpu_initfn. Say:
object_property_add(obj, "tsc-frequency", "int",
x86_cpuid_get_tsc_freq,
x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
/* depends on tsc frequency */
object_property_add(obj, "vmware-extra", "int",
x86_cpuid_get_vmware_extra,
x86_cpuid_set_vmware_extra, NULL, NULL, NULL);Or something to that effect.
PATCH v6 15/16 target-i386: Use Hypervisor leaf extra in -machine pc,accel=kvm.
In reply to Don Slutz--- target-i386/kvm.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
target-i386/kvm.c +19 -0
@@ -454,6 +454,25 @@ int kvm_arch_init_vcpu(CPUX86State *env) c->ebx = signature[0 ]; c->ecx = signature[1 ]; c->edx = signature[2 ]; + }else if (env->cpuid_hv_extra !=0 ) { +for (i =KVM_CPUID_FEATURES +1 ; i <= env->cpuid_hv_level; i++) { + c = &cpuid_data.entries[cpuid_i++]; +memset (c,0 ,sizeof (*c)); + c->function = i; +if (i == env->cpuid_hv_extra) { + c->eax = env->cpuid_hv_extra_a; + c->ebx = env->cpuid_hv_extra_b; + } + } + + c = &cpuid_data.entries[cpuid_i++]; +memset (c,0 ,sizeof (*c)); + c->function =KVM_CPUID_SIGNATURE_NEXT ; +memcpy (signature,"KVMKVMKVM\0\0\0" ,12 ); + c->eax =0 ; + c->ebx = signature[0 ]; + c->ecx = signature[1 ]; + c->edx = signature[2 ]; } has_msr_async_pf_en = c->eax & (1 <<KVM_FEATURE_ASYNC_PF );
Signature · 1 line
1.7.1
PATCH v6 16/16 target-i386: Use Hypervisor leaf extra in -machine pc,accel=tcg.
In reply to Don Slutz--- target-i386/cpu.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
target-i386/cpu.c +11 -0
@@ -2001,6 +2001,17 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx =0 ; *edx =0 ;break ; + case 0x40000002 ... 0x400000FF: +if (index == env->cpuid_hv_extra) { + *eax = env->cpuid_hv_extra_a; + *ebx = env->cpuid_hv_extra_b; + }else { + *eax =0 ; + *ebx =0 ; + } + *ecx =0 ; + *edx =0 ; +break ;case 0x80000000 : *eax = env->cpuid_xlevel; *ebx = env->cpuid_vendor1;
Signature · 1 line
1.7.1