From: Vadim Rozenfeld <vrozenfe@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mtosatti@redhat.com,
Vadim Rozenfeld <vrozenfe@redhat.com>
Subject: [Qemu-devel] [PATCH v2 6/7] make hyperv vapic assist page migratable
Date: Fri, 24 Jan 2014 00:40:48 +1100 [thread overview]
Message-ID: <1390484449-20974-7-git-send-email-vrozenfe@redhat.com> (raw)
In-Reply-To: <1390484449-20974-1-git-send-email-vrozenfe@redhat.com>
Signed-off-by: Vadim Rozenfeld <vrozenfe@redhat.com>
---
target-i386/cpu.h | 1 +
target-i386/kvm.c | 16 +++++++++++++---
target-i386/machine.c | 22 ++++++++++++++++++++++
3 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 3bfaf87..d75a793 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -848,6 +848,7 @@ typedef struct CPUX86State {
uint64_t msr_gp_evtsel[MAX_GP_COUNTERS];
uint64_t msr_hv_hypercall;
uint64_t msr_hv_guest_os_id;
+ uint64_t msr_hv_vapic;
/* exception/interrupt handling */
int error_code;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 48a747e..6563dcb 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -72,6 +72,7 @@ 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;
@@ -490,6 +491,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
if (cpu->hyperv_vapic) {
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++];
@@ -497,7 +499,7 @@ 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;
@@ -1185,8 +1187,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_HYPERCALL,
env->msr_hv_hypercall);
}
- if (cpu->hyperv_vapic) {
- kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
+ if (has_msr_hv_vapic) {
+ kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE,
+ env->msr_hv_vapic);
}
if (has_msr_feature_control) {
kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
@@ -1470,6 +1473,10 @@ static int kvm_get_msrs(X86CPU *cpu)
msrs[n++].index = HV_X64_MSR_HYPERCALL;
msrs[n++].index = HV_X64_MSR_GUEST_OS_ID;
}
+ if (has_msr_hv_vapic) {
+ msrs[n++].index = HV_X64_MSR_APIC_ASSIST_PAGE;
+ }
+
msr_data.info.nmsrs = n;
ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data);
if (ret < 0) {
@@ -1580,6 +1587,9 @@ static int kvm_get_msrs(X86CPU *cpu)
case HV_X64_MSR_GUEST_OS_ID:
env->msr_hv_guest_os_id = msrs[i].data;
break;
+ case HV_X64_MSR_APIC_ASSIST_PAGE:
+ env->msr_hv_vapic = msrs[i].data;
+ break;
}
}
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 3809d06..8fc81bc 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -526,6 +526,25 @@ static const VMStateDescription vmstate_msr_hypercall_hypercall = {
}
};
+static bool hyperv_vapic_enable_needed(void *opaque)
+{
+ X86CPU *cpu = opaque;
+ CPUX86State *env = &cpu->env;
+
+ return env->msr_hv_vapic != 0;
+}
+
+static const VMStateDescription vmstate_msr_hyperv_vapic = {
+ .name = "cpu/msr_hyperv_vapic",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT64(env.msr_hv_vapic, X86CPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
const VMStateDescription vmstate_x86_cpu = {
.name = "cpu",
.version_id = 12,
@@ -660,6 +679,9 @@ const VMStateDescription vmstate_x86_cpu = {
}, {
.vmsd = &vmstate_msr_hypercall_hypercall,
.needed = hyperv_hypercall_enable_needed,
+ }, {
+ .vmsd = &vmstate_msr_hyperv_vapic,
+ .needed = hyperv_vapic_enable_needed,
} , {
/* empty */
}
--
1.8.1.4
next prev parent reply other threads:[~2014-01-23 13:42 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 ` Vadim Rozenfeld [this message]
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 ` [Qemu-devel] [PATCH v2 0/7] Hyper-V parameters update 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=1390484449-20974-7-git-send-email-vrozenfe@redhat.com \
--to=vrozenfe@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 NNTP newsgroup(s).