Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs

2011-10-11 Thread Paolo Bonzini

On 10/09/2011 08:52 PM, Vadim Rozenfeld wrote:

---
  target-i386/kvm.c |   53 -
  1 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 3840255..74fcc9a 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -29,6 +29,7 @@
  #include hw/pc.h
  #include hw/apic.h
  #include ioport.h
+#include hyperv.h

  //#define DEBUG_KVM

@@ -379,11 +380,21 @@ int kvm_arch_init_vcpu(CPUState *env)
  cpuid_i = 0;

  /* Paravirtualization CPUIDs */
-memcpy(signature, KVMKVMKVM\0\0\0, 12);


These should not be KVM-specific.  You should be able to add 
enlightenments to a TCG VM.  At the same time, the KVM leaves could be 
moved to 0x4100 when enlightenments are active, similar to what Xen 
does.


Paolo


  c =cpuid_data.entries[cpuid_i++];
  memset(c, 0, sizeof(*c));
  c-function = KVM_CPUID_SIGNATURE;
+#ifndef CONFIG_HYPERV
+memcpy(signature, KVMKVMKVM\0\0\0, 12);
  c-eax = 0;
+#else
+if (!hyperv_enabled()) {
+memcpy(signature, KVMKVMKVM\0\0\0, 12);
+c-eax = 0;
+} else {
+memcpy(signature, Microsoft Hv, 12);
+c-eax = HYPERV_CPUID_MIN;
+}
+#endif
  c-ebx = signature[0];
  c-ecx = signature[1];
  c-edx = signature[2];
@@ -393,6 +404,46 @@ int kvm_arch_init_vcpu(CPUState *env)
  c-function = KVM_CPUID_FEATURES;
  c-eax = env-cpuid_kvm_features
  kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
+#ifdef CONFIG_HYPERV
+if (hyperv_enabled()) {
+memcpy(signature, Hv#1\0\0\0\0\0\0\0\0, 12);
+c-eax = signature[0];
+
+c =cpuid_data.entries[cpuid_i++];
+memset(c, 0, sizeof(*c));
+c-function = HYPERV_CPUID_VERSION;
+c-eax = 0x1bbc;
+c-ebx = 0x00060001;
+
+c =cpuid_data.entries[cpuid_i++];
+memset(c, 0, sizeof(*c));
+c-function = HYPERV_CPUID_FEATURES;
+if (hyperv_relaxed_timing()) {
+c-eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
+}
+if (hyperv_apic_recommended()) {
+c-eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
+c-eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
+}
+
+c =cpuid_data.entries[cpuid_i++];
+memset(c, 0, sizeof(*c));
+c-function = HYPERV_CPUID_ENLIGHTMENT_INFO;
+if (hyperv_relaxed_timing()) {
+c-eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
+}
+if (hyperv_apic_recommended()) {
+c-eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
+}
+c-ebx = hyperv_spinlock_retries();
+
+c =cpuid_data.entries[cpuid_i++];
+memset(c, 0, sizeof(*c));
+c-function = HYPERV_CPUID_IMPLEMENT_LIMITS;
+c-eax = 0x40;
+c-ebx = 0x40;
+}
+#endif

  has_msr_async_pf_en = c-eax  (1  KVM_FEATURE_ASYNC_PF);



--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs

2011-10-11 Thread Vadim Rozenfeld
On Tue, 2011-10-11 at 09:38 +0200, Paolo Bonzini wrote:
 On 10/09/2011 08:52 PM, Vadim Rozenfeld wrote:
  ---
target-i386/kvm.c |   53 
  -
1 files changed, 52 insertions(+), 1 deletions(-)
 
  diff --git a/target-i386/kvm.c b/target-i386/kvm.c
  index 3840255..74fcc9a 100644
  --- a/target-i386/kvm.c
  +++ b/target-i386/kvm.c
  @@ -29,6 +29,7 @@
#include hw/pc.h
#include hw/apic.h
#include ioport.h
  +#include hyperv.h
 
//#define DEBUG_KVM
 
  @@ -379,11 +380,21 @@ int kvm_arch_init_vcpu(CPUState *env)
cpuid_i = 0;
 
/* Paravirtualization CPUIDs */
  -memcpy(signature, KVMKVMKVM\0\0\0, 12);
 
 These should not be KVM-specific.  You should be able to add 
 enlightenments to a TCG VM.  At the same time, the KVM leaves could be 
 moved to 0x4100 when enlightenments are active, similar to what Xen 
 does.
 

IMO, adding Hyper-V features without KVM support has little, if any,
meaning. Relaxed timing is the only one thing, which can be activated
without help from hypervisor.

 Paolo
 
c =cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c-function = KVM_CPUID_SIGNATURE;
  +#ifndef CONFIG_HYPERV
  +memcpy(signature, KVMKVMKVM\0\0\0, 12);
c-eax = 0;
  +#else
  +if (!hyperv_enabled()) {
  +memcpy(signature, KVMKVMKVM\0\0\0, 12);
  +c-eax = 0;
  +} else {
  +memcpy(signature, Microsoft Hv, 12);
  +c-eax = HYPERV_CPUID_MIN;
  +}
  +#endif
c-ebx = signature[0];
c-ecx = signature[1];
c-edx = signature[2];
  @@ -393,6 +404,46 @@ int kvm_arch_init_vcpu(CPUState *env)
c-function = KVM_CPUID_FEATURES;
c-eax = env-cpuid_kvm_features
kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
  +#ifdef CONFIG_HYPERV
  +if (hyperv_enabled()) {
  +memcpy(signature, Hv#1\0\0\0\0\0\0\0\0, 12);
  +c-eax = signature[0];
  +
  +c =cpuid_data.entries[cpuid_i++];
  +memset(c, 0, sizeof(*c));
  +c-function = HYPERV_CPUID_VERSION;
  +c-eax = 0x1bbc;
  +c-ebx = 0x00060001;
  +
  +c =cpuid_data.entries[cpuid_i++];
  +memset(c, 0, sizeof(*c));
  +c-function = HYPERV_CPUID_FEATURES;
  +if (hyperv_relaxed_timing()) {
  +c-eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
  +}
  +if (hyperv_apic_recommended()) {
  +c-eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
  +c-eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
  +}
  +
  +c =cpuid_data.entries[cpuid_i++];
  +memset(c, 0, sizeof(*c));
  +c-function = HYPERV_CPUID_ENLIGHTMENT_INFO;
  +if (hyperv_relaxed_timing()) {
  +c-eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
  +}
  +if (hyperv_apic_recommended()) {
  +c-eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
  +}
  +c-ebx = hyperv_spinlock_retries();
  +
  +c =cpuid_data.entries[cpuid_i++];
  +memset(c, 0, sizeof(*c));
  +c-function = HYPERV_CPUID_IMPLEMENT_LIMITS;
  +c-eax = 0x40;
  +c-ebx = 0x40;
  +}
  +#endif
 
has_msr_async_pf_en = c-eax  (1  KVM_FEATURE_ASYNC_PF);
 
 
 --
 To unsubscribe from this list: send the line unsubscribe kvm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs

2011-10-11 Thread Paolo Bonzini

On 10/11/2011 03:46 PM, Vadim Rozenfeld wrote:

  These should not be KVM-specific.  You should be able to add
  enlightenments to a TCG VM.  At the same time, the KVM leaves could be
  moved to 0x4100 when enlightenments are active, similar to what Xen
  does.


IMO, adding Hyper-V features without KVM support has little, if any,
meaning. Relaxed timing is the only one thing, which can be activated
without help from hypervisor.


Spinlocks too.  TCG does its own round-robin scheduling, so having zero 
retries could be the best setting.  But even if it is not useful for 
TCG, there's nothing KVM-specific, and that's the important point.


Paolo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs

2011-10-11 Thread Vadim Rozenfeld
On Tue, 2011-10-11 at 17:52 +0200, Paolo Bonzini wrote:
 On 10/11/2011 03:46 PM, Vadim Rozenfeld wrote:
These should not be KVM-specific.  You should be able to add
enlightenments to a TCG VM.  At the same time, the KVM leaves could be
moved to 0x4100 when enlightenments are active, similar to what Xen
does.
  
 
  IMO, adding Hyper-V features without KVM support has little, if any,
  meaning. Relaxed timing is the only one thing, which can be activated
  without help from hypervisor.
 
 Spinlocks too.  TCG does its own round-robin scheduling, so having zero 
How? You need hypercall page for it.
Best,
Vadim.
 retries could be the best setting.  But even if it is not useful for 
 TCG, there's nothing KVM-specific, and that's the important point.
 
 Paolo


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs

2011-10-11 Thread Paolo Bonzini

On 10/11/2011 06:09 PM, Vadim Rozenfeld wrote:

  Spinlocks too.  TCG does its own round-robin scheduling, so having zero
How? You need hypercall page for it.


I'm not saying you should implement it, :) in principle TCG could have a 
hypercall page.


Paolo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html