QEMU-Devel Archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: qemu-devel@nongnu.org, Eduardo Habkost <ehabkost@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: [PATCH v8 7/9] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed
Date: Tue,  8 Jun 2021 14:08:15 +0200	[thread overview]
Message-ID: <20210608120817.1325125-8-vkuznets@redhat.com> (raw)
In-Reply-To: <20210608120817.1325125-1-vkuznets@redhat.com>

According to TLFS, Hyper-V guest is supposed to check
HV_HYPERCALL_AVAILABLE privilege bit before accessing
HV_X64_MSR_GUEST_OS_ID/HV_X64_MSR_HYPERCALL MSRs but at least some
Windows versions ignore that. As KVM is very permissive and allows
accessing these MSRs unconditionally, no issue is observed. We may,
however, want to tighten the checks eventually. Conforming to the
spec is probably also a good idea.

Enable HV_HYPERCALL_AVAILABLE bit unconditionally.

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 target/i386/kvm/kvm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 1cce0969067e..33830117fa31 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -810,8 +810,6 @@ static struct {
     [HYPERV_FEAT_RELAXED] = {
         .desc = "relaxed timing (hv-relaxed)",
         .flags = {
-            {.func = HV_CPUID_FEATURES, .reg = R_EAX,
-             .bits = HV_HYPERCALL_AVAILABLE},
             {.func = HV_CPUID_ENLIGHTMENT_INFO, .reg = R_EAX,
              .bits = HV_RELAXED_TIMING_RECOMMENDED}
         }
@@ -820,7 +818,7 @@ static struct {
         .desc = "virtual APIC (hv-vapic)",
         .flags = {
             {.func = HV_CPUID_FEATURES, .reg = R_EAX,
-             .bits = HV_HYPERCALL_AVAILABLE | HV_APIC_ACCESS_AVAILABLE},
+             .bits = HV_APIC_ACCESS_AVAILABLE},
             {.func = HV_CPUID_ENLIGHTMENT_INFO, .reg = R_EAX,
              .bits = HV_APIC_ACCESS_RECOMMENDED}
         }
@@ -829,8 +827,7 @@ static struct {
         .desc = "clocksources (hv-time)",
         .flags = {
             {.func = HV_CPUID_FEATURES, .reg = R_EAX,
-             .bits = HV_HYPERCALL_AVAILABLE | HV_TIME_REF_COUNT_AVAILABLE |
-             HV_REFERENCE_TSC_AVAILABLE}
+             .bits = HV_TIME_REF_COUNT_AVAILABLE | HV_REFERENCE_TSC_AVAILABLE}
         }
     },
     [HYPERV_FEAT_CRASH] = {
@@ -1343,6 +1340,9 @@ static int hyperv_fill_cpuids(CPUState *cs,
     c->ebx = hv_build_cpuid_leaf(cs, HV_CPUID_FEATURES, R_EBX);
     c->edx = hv_build_cpuid_leaf(cs, HV_CPUID_FEATURES, R_EDX);
 
+    /* Unconditionally required with any Hyper-V enlightenment */
+    c->eax |= HV_HYPERCALL_AVAILABLE;
+
     /* Not exposed by KVM but needed to make CPU hotplug in Windows work */
     c->edx |= HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE;
 
-- 
2.31.1



  parent reply	other threads:[~2021-06-08 12:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 12:08 [PATCH v8 0/9] i386: KVM: expand Hyper-V features early Vitaly Kuznetsov
2021-06-08 12:08 ` [PATCH v8 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length Vitaly Kuznetsov
2021-06-08 12:12   ` Philippe Mathieu-Daudé
2021-06-08 12:08 ` [PATCH v8 2/9] i386: clarify 'hv-passthrough' behavior Vitaly Kuznetsov
2021-06-08 12:08 ` [PATCH v8 3/9] i386: hardcode supported eVMCS version to '1' Vitaly Kuznetsov
2021-06-08 12:52   ` Eduardo Habkost
2021-06-16  8:12     ` Vitaly Kuznetsov
2021-06-08 12:08 ` [PATCH v8 4/9] i386: make hyperv_expand_features() return bool Vitaly Kuznetsov
2021-06-08 12:08 ` [PATCH v8 5/9] i386: expand Hyper-V features during CPU feature expansion time Vitaly Kuznetsov
2021-06-08 12:08 ` [PATCH v8 6/9] i386: kill off hv_cpuid_check_and_set() Vitaly Kuznetsov
2021-06-08 12:08 ` Vitaly Kuznetsov [this message]
2021-06-08 12:08 ` [PATCH v8 8/9] i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS privileges Vitaly Kuznetsov
2021-06-08 12:08 ` [PATCH v8 9/9] qtest/hyperv: Introduce a simple hyper-v test Vitaly Kuznetsov
2021-06-08 12:52   ` Eduardo Habkost
2021-07-08 21:02   ` Eduardo Habkost
2021-07-09  8:22     ` Igor Mammedov
2021-07-16 12:12       ` Vitaly Kuznetsov
2021-07-19 13:56         ` Igor Mammedov
2021-07-07 14:00 ` [PATCH v8 0/9] i386: KVM: expand Hyper-V features early Eduardo Habkost

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=20210608120817.1325125-8-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --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 read-only IMAP folder(s) and NNTP newsgroup(s).