* [Qemu-devel] [PATCH v5 01/17] target-i386: Allow tsc-frequency to be larger then 2.147G
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 15:23 ` Stefan Hajnoczi
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 02/17] target-i386: Add missing kvm bits Don Slutz
` (16 subsequent siblings)
17 siblings, 1 reply; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz, Fred Oliveira
The check using INT_MAX (2147483647) is wrong in this case.
Signed-off-by: Fred Oliveira <foliveira@cloudswitch.com>
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index af50a8f..0313cf5 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1146,7 +1146,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
{
X86CPU *cpu = X86_CPU(obj);
const int64_t min = 0;
- const int64_t max = INT_MAX;
+ const int64_t max = INT64_MAX;
int64_t value;
visit_type_freq(v, &value, name, errp);
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 01/17] target-i386: Allow tsc-frequency to be larger then 2.147G
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 01/17] target-i386: Allow tsc-frequency to be larger then 2.147G Don Slutz
@ 2012-09-22 15:23 ` Stefan Hajnoczi
0 siblings, 0 replies; 21+ messages in thread
From: Stefan Hajnoczi @ 2012-09-22 15:23 UTC (permalink / raw)
To: Don Slutz
Cc: peter.maydell, ehabkost, kvm, mtosatti, qemu-devel, avi, anthony,
imammedo, Fred Oliveira, afaerber
On Fri, Sep 21, 2012 at 08:13:13PM -0400, Don Slutz wrote:
> The check using INT_MAX (2147483647) is wrong in this case.
>
> Signed-off-by: Fred Oliveira <foliveira@cloudswitch.com>
> Signed-off-by: Don Slutz <Don@CloudSwitch.com>
> ---
> target-i386/cpu.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches
Stefan
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 02/17] target-i386: Add missing kvm bits.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 01/17] target-i386: Allow tsc-frequency to be larger then 2.147G Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 03/17] target-i386: Add Hypervisor level Don Slutz
` (15 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Fix duplicate name (kvmclock => kvm_clock2) also.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0313cf5..25ca986 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -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[] = {
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 03/17] target-i386: Add Hypervisor level.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 01/17] target-i386: Allow tsc-frequency to be larger then 2.147G Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 02/17] target-i386: Add missing kvm bits Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 04/17] target-i386: Add cpu object access routines for " Don Slutz
` (14 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Also 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.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 5265c5a..1899f69 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -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];
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 04/17] target-i386: Add cpu object access routines for Hypervisor level.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (2 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 03/17] target-i386: Add Hypervisor level Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 05/17] " Don Slutz
` (13 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
These are modeled after x86_cpuid_get_xlevel and x86_cpuid_set_xlevel.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 25ca986..7b31de9 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -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,
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 05/17] target-i386: Add cpu object access routines for Hypervisor level.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (3 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 04/17] target-i386: Add cpu object access routines for " Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 06/17] target-i386: Use Hypervisor level in -machine pc, accel=kvm Don Slutz
` (12 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
These are modeled after x86_cpuid_get_xlevel and x86_cpuid_set_xlevel.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 8 ++++++++
target-i386/cpu.h | 2 ++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7b31de9..e5deca2 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1193,6 +1193,11 @@ 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 +1220,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 +1241,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 +1262,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
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 1899f69..3152a4e 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -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 */
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 06/17] target-i386: Use Hypervisor level in -machine pc, accel=kvm.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (4 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 05/17] " Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 07/17] target-i386: Use Hypervisor level in -machine pc, accel=tcg Don Slutz
` (11 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: 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.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).
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/kvm.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 895d848..8462c75 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -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];
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 07/17] target-i386: Use Hypervisor level in -machine pc, accel=tcg.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (5 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 06/17] target-i386: Use Hypervisor level in -machine pc, accel=kvm Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 08/17] target-i386: Add Hypervisor vendor Don Slutz
` (10 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: 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.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.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e5deca2..bf6faed 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1650,6 +1650,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;
@@ -1788,6 +1803,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;
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 08/17] target-i386: Add Hypervisor vendor.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (6 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 07/17] target-i386: Use Hypervisor level in -machine pc, accel=tcg Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 09/17] target-i386: Add cpu object access routines for " Don Slutz
` (9 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Also 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
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 3152a4e..11730b2 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -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];
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 09/17] target-i386: Add cpu object access routines for Hypervisor vendor.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (7 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 08/17] target-i386: Add Hypervisor vendor Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 10/17] target-i386: Use Hypervisor vendor in -machine pc, accel=kvm Don Slutz
` (8 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
These 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
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
target-i386/cpu.h | 2 ++
2 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index bf6faed..ab65594 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1192,10 +1192,52 @@ 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,
@@ -2125,6 +2167,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,
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 11730b2..eb6aa4a 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -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 */
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 10/17] target-i386: Use Hypervisor vendor in -machine pc, accel=kvm.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (8 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 09/17] target-i386: Add cpu object access routines for " Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 11/17] target-i386: Use Hypervisor vendor in -machine pc, accel=tcg Don Slutz
` (7 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Also 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
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/kvm.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 8462c75..f8a5177 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -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));
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 11/17] target-i386: Use Hypervisor vendor in -machine pc, accel=tcg.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (9 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 10/17] target-i386: Use Hypervisor vendor in -machine pc, accel=kvm Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 12/17] target-i386: Add some known names to Hypervisor vendor Don Slutz
` (6 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Also 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
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index ab65594..bfe7b27 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1693,7 +1693,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 */
@@ -1847,9 +1847,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;
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 12/17] target-i386: Add some known names to Hypervisor vendor.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (10 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 11/17] target-i386: Use Hypervisor vendor in -machine pc, accel=tcg Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 13/17] target-i386: Add optional Hypervisor leaf extra Don Slutz
` (5 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++-
target-i386/cpu.h | 19 +++++++++++++++++
2 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index bfe7b27..478b671 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -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;
@@ -1698,7 +1744,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;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index eb6aa4a..ebb3498 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -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 */
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 13/17] target-i386: Add optional Hypervisor leaf extra.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (11 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 12/17] target-i386: Add some known names to Hypervisor vendor Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 14/17] target-i386: Add cpu object access routines for " Don Slutz
` (4 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index ebb3498..254ddef 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -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];
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 14/17] target-i386: Add cpu object access routines for Hypervisor leaf extra.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (12 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 13/17] target-i386: Add optional Hypervisor leaf extra Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 15/17] target-i386: Add setting of Hypervisor leaf extra for known vmare4 Don Slutz
` (3 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 478b671..2423090 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -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)
{
@@ -2223,6 +2280,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,
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 15/17] target-i386: Add setting of Hypervisor leaf extra for known vmare4.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (13 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 14/17] target-i386: Add cpu object access routines for " Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 16/17] target-i386: Use Hypervisor leaf extra in -machine pc, accel=kvm Don Slutz
` (2 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
This was taken from:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/22643
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2423090..e8a21b5 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -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,
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 16/17] target-i386: Use Hypervisor leaf extra in -machine pc, accel=kvm.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (14 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 15/17] target-i386: Add setting of Hypervisor leaf extra for known vmare4 Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 17/17] target-i386: Use Hypervisor leaf extra in -machine pc, accel=tcg Don Slutz
2012-09-22 13:18 ` [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Blue Swirl
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/kvm.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index f8a5177..ff82034 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -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);
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 17/17] target-i386: Use Hypervisor leaf extra in -machine pc, accel=tcg.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (15 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 16/17] target-i386: Use Hypervisor leaf extra in -machine pc, accel=kvm Don Slutz
@ 2012-09-22 0:13 ` Don Slutz
2012-09-22 13:18 ` [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Blue Swirl
17 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-22 0:13 UTC (permalink / raw)
To: qemu-devel, mtosatti, ehabkost, imammedo, avi, afaerber,
peter.maydell, kvm, anthony
Cc: Don Slutz
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
target-i386/cpu.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e8a21b5..12bd5d4 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1999,6 +1999,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;
--
1.7.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs.
2012-09-22 0:13 [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Don Slutz
` (16 preceding siblings ...)
2012-09-22 0:13 ` [Qemu-devel] [PATCH v5 17/17] target-i386: Use Hypervisor leaf extra in -machine pc, accel=tcg Don Slutz
@ 2012-09-22 13:18 ` Blue Swirl
2012-09-24 13:15 ` Don Slutz
17 siblings, 1 reply; 21+ messages in thread
From: Blue Swirl @ 2012-09-22 13:18 UTC (permalink / raw)
To: Don Slutz
Cc: peter.maydell, ehabkost, kvm, mtosatti, qemu-devel, avi, anthony,
imammedo, afaerber
On Sat, Sep 22, 2012 at 12:13 AM, Don Slutz <Don@cloudswitch.com> wrote:
> 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.
Please use checkpatch.pl to check for missing braces etc.
>
>
> 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 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 (17):
> target-i386: Allow tsc-frequency to be larger then 2.147G
> target-i386: Add missing kvm bits.
> target-i386: Add Hypervisor level.
> target-i386: Add cpu object access routines for Hypervisor level.
> target-i386: Add cpu object access routines for Hypervisor level.
> 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, 341 insertions(+), 11 deletions(-)
>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs.
2012-09-22 13:18 ` [Qemu-devel] [PATCH v5 00/17] Allow changing of Hypervisor CPUIDs Blue Swirl
@ 2012-09-24 13:15 ` Don Slutz
0 siblings, 0 replies; 21+ messages in thread
From: Don Slutz @ 2012-09-24 13:15 UTC (permalink / raw)
To: Blue Swirl
Cc: peter.maydell, ehabkost, kvm, mtosatti, qemu-devel, avi, anthony,
imammedo, afaerber
On 09/22/12 09:18, Blue Swirl wrote:
> On Sat, Sep 22, 2012 at 12:13 AM, Don Slutz <Don@cloudswitch.com> wrote:
>> 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.
> Please use checkpatch.pl to check for missing braces etc.
I have been. Somehow missed the warnings on the posted patches. v6 in
the works.
>>
>> 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 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 (17):
>> target-i386: Allow tsc-frequency to be larger then 2.147G
>> target-i386: Add missing kvm bits.
>> target-i386: Add Hypervisor level.
>> target-i386: Add cpu object access routines for Hypervisor level.
>> target-i386: Add cpu object access routines for Hypervisor level.
>> 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, 341 insertions(+), 11 deletions(-)
>>
>>
-Don
^ permalink raw reply [flat|nested] 21+ messages in thread