From: Paolo Bonzini <pbonzini@redhat.com>
To: Vadim Rozenfeld <vrozenfe@redhat.com>, qemu-devel@nongnu.org
Cc: KY Srinivasan <kys@microsoft.com>, mtosatti@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 0/7] Hyper-V parameters update
Date: Thu, 23 Jan 2014 18:55:25 +0100 [thread overview]
Message-ID: <52E1578D.4090104@redhat.com> (raw)
In-Reply-To: <1390484449-20974-1-git-send-email-vrozenfe@redhat.com>
Il 23/01/2014 14:40, Vadim Rozenfeld ha scritto:
> This series consists of several clean-ups, hyper-v MSRs migration
> fixes, and adding support for new "hv-time" parameter, which designed
> for activating hyper-v timers feature.
Hi Vadim!
I think patches 1-4 have some problems:
(1) patches 1 and 4: the "KVMKVMKVM" and "Microsoft Hv" signatures are
used by Linux to understand the format of the leaves starting at
0x40000001. These are of course different between KVM and Hyper-V.
Microsoft suggests that guests detect Hyper-V by checking if
eax=0x31237648 at CPUID[0x40000001]. Linux should be corrected to do
this check (and KVM probably should reserve some bit, e.g. bit 16, to
avoid that its own feature mask ever is 0x31237648), but anyway we
cannot change the vendor signature as that conflicts with the detection
scheme for KVM's own leaves.
(2) patches 2 and 3 should not be applied without some command-line
option or versioning scheme, because they would cause CPUID to change
across migration.
(3) patches 4, in addition, misses the point of
KVM_CPUID_SIGNATURE_NEXT, which is to signal that the KVM_CPUID_FEATURES
leaf is not at 0x40000001 but rather at 0x40000101 (KVM_CPUID_FEATURES +
KVM_CPUID_SIGNATURE_NEXT - KVM_CPUID_SIGNATURE, if you want). This way,
Linux can use the KVM features even if Hyper-V enlightenments enabled.
Unfortunately, the logic is broken because KVM_CPUID_FEATURES is not to
0x40000101 if hyperv_enabled(). I include an untested patch to fix this
at the end of the message.
Luckily they are unnecessary, I'll review patches 5-7 tomorrow but at a
first glance they seem good.
Paolo
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 7522e98..d5cff89 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -454,6 +454,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
uint32_t unused;
struct kvm_cpuid_entry2 *c;
uint32_t signature[3];
+ int kvm_base = KVM_CPUID_SIGNATURE;
int r;
memset(&cpuid_data, 0, sizeof(cpuid_data));
@@ -461,26 +462,22 @@ int kvm_arch_init_vcpu(CPUState *cs)
cpuid_i = 0;
/* 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 {
+ if (hyperv_enabled(cpu)) {
+ c = &cpuid_data.entries[cpuid_i++];
+ c->function = HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
memcpy(signature, "Microsoft Hv", 12);
c->eax = HYPERV_CPUID_MIN;
- }
- c->ebx = signature[0];
- c->ecx = signature[1];
- c->edx = signature[2];
+ c->ebx = signature[0];
+ c->ecx = signature[1];
+ c->edx = signature[2];
- c = &cpuid_data.entries[cpuid_i++];
- c->function = KVM_CPUID_FEATURES;
- c->eax = env->features[FEAT_KVM];
-
- if (hyperv_enabled(cpu)) {
+ c = &cpuid_data.entries[cpuid_i++];
+ c->function = HYPERV_CPUID_INTERFACE;
memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
c->eax = signature[0];
+ c->ebx = 0;
+ c->ecx = 0;
+ c->edx = 0;
c = &cpuid_data.entries[cpuid_i++];
c->function = HYPERV_CPUID_VERSION;
@@ -512,15 +509,21 @@ int kvm_arch_init_vcpu(CPUState *cs)
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];
+ kvm_base = KVM_CPUID_SIGNATURE_NEXT;
}
+ memcpy(signature, "KVMKVMKVM\0\0\0", 12);
+ c = &cpuid_data.entries[cpuid_i++];
+ c->function = KVM_CPUID_SIGNATURE | kvm_base;
+ c->eax = 0;
+ c->ebx = signature[0];
+ c->ecx = signature[1];
+ c->edx = signature[2];
+
+ c = &cpuid_data.entries[cpuid_i++];
+ c->function = KVM_CPUID_FEATURES | kvm_base;
+ c->eax = env->features[FEAT_KVM];
+
has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
has_msr_pv_eoi_en = c->eax & (1 << KVM_FEATURE_PV_EOI);
prev parent reply other threads:[~2014-01-23 17:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-23 13:40 [Qemu-devel] [PATCH v2 0/7] Hyper-V parameters update Vadim Rozenfeld
2014-01-23 13:40 ` [Qemu-devel] [PATCH v2 1/7] Don't report "Microsoft" as the vendor ID signature Vadim Rozenfeld
2014-01-23 13:40 ` [Qemu-devel] [PATCH v2 2/7] Don't specify hypervisor system identity Vadim Rozenfeld
2014-01-23 13:40 ` [Qemu-devel] [PATCH v2 3/7] Don't specify implementation limits Vadim Rozenfeld
2014-01-23 13:40 ` [Qemu-devel] [PATCH v2 4/7] Don't report the KVM signature twice, since it's already reported in KVM_CPUID_SIGNATURE CPUID leaf Vadim Rozenfeld
2014-01-23 13:40 ` [Qemu-devel] [PATCH v2 5/7] make hyperv hypercall and guest os id MSRs migratable Vadim Rozenfeld
2014-01-23 18:19 ` Paolo Bonzini
2014-01-23 13:40 ` [Qemu-devel] [PATCH v2 6/7] make hyperv vapic assist page migratable Vadim Rozenfeld
2014-01-23 13:40 ` [Qemu-devel] [PATCH v2 7/7] add support for hyper-v timers http://msdn.microsoft.com/en-us/library/windows/hardware/ff541625%28v=vs.85%29.aspx This code is generic for activating reference time counter or virtual reference time stamp counter Vadim Rozenfeld
2014-01-23 17:31 ` Marcelo Tosatti
2014-01-23 17:55 ` Paolo Bonzini [this message]
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=52E1578D.4090104@redhat.com \
--to=pbonzini@redhat.com \
--cc=kys@microsoft.com \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vrozenfe@redhat.com \
/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).