mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	linux-kernel@vger.kernel.org,
	"Roman Kagan" <rkagan@virtuozzo.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Stephen Hemminger" <sthemmin@microsoft.com>,
	x86@kernel.org,
	"Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com>
Subject: [QEMU PATCH] i386/kvm: add support for Direct Mode for Hyper-V synthetic timers
Date: Tue, 13 Nov 2018 16:22:17 +0100	[thread overview]
Message-ID: <20181113152218.22049-5-vkuznets@redhat.com> (raw)
In-Reply-To: <20181113152218.22049-1-vkuznets@redhat.com>

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 linux-headers/linux/kvm.h  |  1 +
 target/i386/cpu.c          |  1 +
 target/i386/cpu.h          |  1 +
 target/i386/hyperv-proto.h |  1 +
 target/i386/kvm.c          | 11 +++++++++++
 5 files changed, 15 insertions(+)

diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index f11a7eb49c..43fb240b60 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -965,6 +965,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_COALESCED_PIO 162
 #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
 #define KVM_CAP_EXCEPTION_PAYLOAD 164
+#define KVM_CAP_HYPERV_STIMER_DIRECT 166
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index af7e9f09cc..cd42fb81dd 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -5733,6 +5733,7 @@ static Property x86_cpu_properties[] = {
     DEFINE_PROP_BOOL("hv-reenlightenment", X86CPU, hyperv_reenlightenment, false),
     DEFINE_PROP_BOOL("hv-tlbflush", X86CPU, hyperv_tlbflush, false),
     DEFINE_PROP_BOOL("hv-ipi", X86CPU, hyperv_ipi, false),
+    DEFINE_PROP_BOOL("hv-stimer-direct", X86CPU, hyperv_stimer_direct, false),
     DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true),
     DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
     DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true),
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index ad0e0b4534..a3d7cac8be 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1392,6 +1392,7 @@ struct X86CPU {
     bool hyperv_reenlightenment;
     bool hyperv_tlbflush;
     bool hyperv_ipi;
+    bool hyperv_stimer_direct;
     bool check_cpuid;
     bool enforce_cpuid;
     bool expose_kvm;
diff --git a/target/i386/hyperv-proto.h b/target/i386/hyperv-proto.h
index 8c572cd7c2..4543112cf5 100644
--- a/target/i386/hyperv-proto.h
+++ b/target/i386/hyperv-proto.h
@@ -48,6 +48,7 @@
 #define HV_GUEST_IDLE_STATE_AVAILABLE           (1u << 5)
 #define HV_FREQUENCY_MSRS_AVAILABLE             (1u << 8)
 #define HV_GUEST_CRASH_MSR_AVAILABLE            (1u << 10)
+#define HV_STIMER_DIRECT_MODE_AVAILABLE		(1u << 19)
 
 /*
  * HV_CPUID_ENLIGHTMENT_INFO.EAX bits
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 796a049a0d..f12321e0f7 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -797,6 +797,17 @@ static int hyperv_handle_properties(CPUState *cs)
         }
         env->features[FEAT_HYPERV_EAX] |= HV_SYNTIMERS_AVAILABLE;
     }
+    if (cpu->hyperv_stimer_direct) {
+        if (kvm_check_extension(cs->kvm_state,
+                                KVM_CAP_HYPERV_STIMER_DIRECT) <= 0) {
+            fprintf(stderr, "Hyper-V timers direct mode "
+                        "(requested by 'hv-stimer-direct' cpu flag) "
+                        " is not supported by kernel\n");
+                return -ENOSYS;
+        }
+        env->features[FEAT_HYPERV_EDX] |= HV_STIMER_DIRECT_MODE_AVAILABLE;
+    }
+
     return 0;
 }
 
-- 
2.17.2


  parent reply	other threads:[~2018-11-13 15:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-13 15:22 [PATCH 0/3] x86/kvm/hyper-v: Implement Direct Mode for " Vitaly Kuznetsov
2018-11-13 15:22 ` [PATCH 1/3] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h Vitaly Kuznetsov
2018-11-13 15:22 ` [PATCH 2/3] x86/kvm/hyper-v: use stimer config definition from hyperv-tlfs.h Vitaly Kuznetsov
2018-11-13 15:22 ` [PATCH 3/3] x86/kvm/hyper-v: direct mode for synthetic timers Vitaly Kuznetsov
2018-11-26 10:14   ` Paolo Bonzini
2018-11-13 15:22 ` Vitaly Kuznetsov [this message]
2018-11-13 15:22 ` [kvm-unit-tests PATCH] x86/hyper-v: stimer_direct test Vitaly Kuznetsov

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=20181113152218.22049-5-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=Michael.H.Kelley@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkagan@virtuozzo.com \
    --cc=rkrcmar@redhat.com \
    --cc=sthemmin@microsoft.com \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®