cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From b8aa71df9dc7135c4894732449745f1e8a130798 Mon Sep 17 00:00:00 2001
0a122b
From: Vadim Rozenfeld <vrozenfe@redhat.com>
0a122b
Date: Mon, 3 Mar 2014 12:09:18 +0100
0a122b
Subject: [PATCH 06/12] kvm: make hyperv vapic assist page migratable
0a122b
0a122b
RH-Author: Vadim Rozenfeld <vrozenfe@redhat.com>
0a122b
Message-id: <1393848564-10511-7-git-send-email-vrozenfe@redhat.com>
0a122b
Patchwork-id: 57962
0a122b
O-Subject: [RHEL-7.0 qemu-kvm v4 PATCH 06/12] kvm: make hyperv vapic assist page migratable
0a122b
Bugzilla: 1004773
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Juan Quintela <quintela@redhat.com>
0a122b
0a122b
Signed-off-by: Vadim Rozenfeld <vrozenfe@redhat.com>
0a122b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
(cherry picked from commit 5ef68987e5671edf5f51f845d1bbf3e5759a8526)
0a122b
---
0a122b
 target-i386/cpu.h     |  1 +
0a122b
 target-i386/kvm.c     | 10 +++++++++-
0a122b
 target-i386/machine.c | 22 ++++++++++++++++++++++
0a122b
 3 files changed, 32 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 target-i386/cpu.h     |    1 +
0a122b
 target-i386/kvm.c     |   10 +++++++++-
0a122b
 target-i386/machine.c |   22 ++++++++++++++++++++++
0a122b
 3 files changed, 32 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
0a122b
index 4835a64..0773499 100644
0a122b
--- a/target-i386/cpu.h
0a122b
+++ b/target-i386/cpu.h
0a122b
@@ -846,6 +846,7 @@ typedef struct CPUX86State {
0a122b
     uint64_t msr_gp_evtsel[MAX_GP_COUNTERS];
0a122b
     uint64_t msr_hv_hypercall;
0a122b
     uint64_t msr_hv_guest_os_id;
0a122b
+    uint64_t msr_hv_vapic;
0a122b
 
0a122b
     /* exception/interrupt handling */
0a122b
     int error_code;
0a122b
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
0a122b
index 943abe1..a2946c4 100644
0a122b
--- a/target-i386/kvm.c
0a122b
+++ b/target-i386/kvm.c
0a122b
@@ -1204,7 +1204,8 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
0a122b
                               env->msr_hv_hypercall);
0a122b
         }
0a122b
         if (has_msr_hv_vapic) {
0a122b
-            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
0a122b
+            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE,
0a122b
+                              env->msr_hv_vapic);
0a122b
         }
0a122b
     }
0a122b
     if (env->mcg_cap) {
0a122b
@@ -1481,6 +1482,10 @@ static int kvm_get_msrs(X86CPU *cpu)
0a122b
         msrs[n++].index = HV_X64_MSR_HYPERCALL;
0a122b
         msrs[n++].index = HV_X64_MSR_GUEST_OS_ID;
0a122b
     }
0a122b
+    if (has_msr_hv_vapic) {
0a122b
+        msrs[n++].index = HV_X64_MSR_APIC_ASSIST_PAGE;
0a122b
+    }
0a122b
+
0a122b
     msr_data.info.nmsrs = n;
0a122b
     ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data);
0a122b
     if (ret < 0) {
0a122b
@@ -1588,6 +1593,9 @@ static int kvm_get_msrs(X86CPU *cpu)
0a122b
         case HV_X64_MSR_GUEST_OS_ID:
0a122b
             env->msr_hv_guest_os_id = msrs[i].data;
0a122b
             break;
0a122b
+        case HV_X64_MSR_APIC_ASSIST_PAGE:
0a122b
+            env->msr_hv_vapic = msrs[i].data;
0a122b
+            break;
0a122b
         }
0a122b
     }
0a122b
 
0a122b
diff --git a/target-i386/machine.c b/target-i386/machine.c
0a122b
index 817f8e4..021390b 100644
0a122b
--- a/target-i386/machine.c
0a122b
+++ b/target-i386/machine.c
0a122b
@@ -526,6 +526,25 @@ static const VMStateDescription vmstate_msr_hypercall_hypercall = {
0a122b
     }
0a122b
 };
0a122b
 
0a122b
+static bool hyperv_vapic_enable_needed(void *opaque)
0a122b
+{
0a122b
+    X86CPU *cpu = opaque;
0a122b
+    CPUX86State *env = &cpu->env;
0a122b
+
0a122b
+    return env->msr_hv_vapic != 0;
0a122b
+}
0a122b
+
0a122b
+static const VMStateDescription vmstate_msr_hyperv_vapic = {
0a122b
+    .name = "cpu/msr_hyperv_vapic",
0a122b
+    .version_id = 1,
0a122b
+    .minimum_version_id = 1,
0a122b
+    .minimum_version_id_old = 1,
0a122b
+    .fields      = (VMStateField []) {
0a122b
+        VMSTATE_UINT64(env.msr_hv_vapic, X86CPU),
0a122b
+        VMSTATE_END_OF_LIST()
0a122b
+    }
0a122b
+};
0a122b
+
0a122b
 const VMStateDescription vmstate_x86_cpu = {
0a122b
     .name = "cpu",
0a122b
     .version_id = 12,
0a122b
@@ -660,6 +679,9 @@ const VMStateDescription vmstate_x86_cpu = {
0a122b
         }, {
0a122b
             .vmsd = &vmstate_msr_hypercall_hypercall,
0a122b
             .needed = hyperv_hypercall_enable_needed,
0a122b
+        }, {
0a122b
+            .vmsd = &vmstate_msr_hyperv_vapic,
0a122b
+            .needed = hyperv_vapic_enable_needed,
0a122b
         } , {
0a122b
             /* empty */
0a122b
         }
0a122b
-- 
0a122b
1.7.1
0a122b