qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Rozenfeld <vrozenfe@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mtosatti@redhat.com, pl@dlhnet.de,
	Vadim Rozenfeld <vrozenfe@redhat.com>,
	aliguori@amazon.com
Subject: [Qemu-devel] [PATCH 1/3] cleanup hyper-v interface initialization
Date: Tue, 21 Jan 2014 19:02:45 +1100	[thread overview]
Message-ID: <1390291367-21958-2-git-send-email-vrozenfe@redhat.com> (raw)
In-Reply-To: <1390291367-21958-1-git-send-email-vrozenfe@redhat.com>

Signed-off-by: Vadim Rozenfeld <vrozenfe@redhat.com>
---
 target-i386/kvm.c | 46 +++++++++++++++++-----------------------------
 1 file changed, 17 insertions(+), 29 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 7522e98..768ca1d 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -71,6 +71,8 @@ static bool has_msr_pv_eoi_en;
 static bool has_msr_misc_enable;
 static bool has_msr_kvm_steal_time;
 static int lm_capable_kernel;
+static bool has_msr_hv_hypercall;
+static bool has_msr_hv_vapic;
 
 static bool has_msr_architectural_pmu;
 static uint32_t num_architectural_pmu_counters;
@@ -463,13 +465,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
     /* Paravirtualization CPUIDs */
     c = &cpuid_data.entries[cpuid_i++];
     c->function = KVM_CPUID_SIGNATURE;
-    if (!hyperv_enabled(cpu)) {
-        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
-        c->eax = 0;
-    } else {
-        memcpy(signature, "Microsoft Hv", 12);
-        c->eax = HYPERV_CPUID_MIN;
-    }
+    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
     c->ebx = signature[0];
     c->ecx = signature[1];
     c->edx = signature[2];
@@ -478,23 +474,23 @@ int kvm_arch_init_vcpu(CPUState *cs)
     c->function = KVM_CPUID_FEATURES;
     c->eax = env->features[FEAT_KVM];
 
-    if (hyperv_enabled(cpu)) {
+    if (hyperv_enabled(cpu) &&
+        kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0) {
+        has_msr_hv_hypercall = true;
+
         memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
         c->eax = signature[0];
 
         c = &cpuid_data.entries[cpuid_i++];
-        c->function = HYPERV_CPUID_VERSION;
-        c->eax = 0x00001bbc;
-        c->ebx = 0x00060001;
-
-        c = &cpuid_data.entries[cpuid_i++];
         c->function = HYPERV_CPUID_FEATURES;
         if (cpu->hyperv_relaxed_timing) {
             c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
         }
-        if (cpu->hyperv_vapic) {
+        if (cpu->hyperv_vapic &&
+            kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_VAPIC) > 0) {
             c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
             c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
+            has_msr_hv_vapic = true;
         }
 
         c = &cpuid_data.entries[cpuid_i++];
@@ -502,23 +498,15 @@ int kvm_arch_init_vcpu(CPUState *cs)
         if (cpu->hyperv_relaxed_timing) {
             c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
         }
-        if (cpu->hyperv_vapic) {
+        if (has_msr_hv_vapic) {
             c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
         }
-        c->ebx = cpu->hyperv_spinlock_attempts;
-
-        c = &cpuid_data.entries[cpuid_i++];
-        c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
-        c->eax = 0x40;
-        c->ebx = 0x40;
-
-        c = &cpuid_data.entries[cpuid_i++];
-        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];
+        if (cpu->hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY &&
+            kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_SPIN) > 0) {
+            c->ebx = cpu->hyperv_spinlock_attempts;
+        } else {
+            c->ebx = HYPERV_SPINLOCK_NEVER_RETRY;
+        }
     }
 
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
-- 
1.8.3.1

  reply	other threads:[~2014-01-21  8:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21  8:02 [Qemu-devel] [PATCH 0/3] Hyper-V parameters Vadim Rozenfeld
2014-01-21  8:02 ` Vadim Rozenfeld [this message]
2014-01-21 10:14   ` [Qemu-devel] [PATCH 1/3] cleanup hyper-v interface initialization Paolo Bonzini
2014-01-21  8:02 ` [Qemu-devel] [PATCH 2/3] make hyperv hypercall, vapic, and os id MSRs migratable Vadim Rozenfeld
2014-01-21 10:17   ` Paolo Bonzini
2014-01-21  8:02 ` [Qemu-devel] [PATCH 3/3] add support for hyperv time parameter Vadim Rozenfeld
2014-01-21 10:21   ` Paolo Bonzini
2014-01-21 21:12     ` Vadim Rozenfeld
2014-01-22 10:02       ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390291367-21958-2-git-send-email-vrozenfe@redhat.com \
    --to=vrozenfe@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pl@dlhnet.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).