KVM: x86: Introducing kvm_x86_ops.apicv_post_state_restore
authorSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Wed, 4 May 2016 19:09:49 +0000 (14:09 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 18 May 2016 16:04:30 +0000 (18:04 +0200)
Adding kvm_x86_ops hooks to allow APICv to do post state restore.
This is required to support VM save and restore feature.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/lapic.c
arch/x86/kvm/svm.c

index 7aaa10891e2ccde3053ae2bf9d57239ff5c1fba2..43e74384c60662dc1b0d8e152c457a8a3d9711b2 100644 (file)
@@ -1004,6 +1004,7 @@ struct kvm_x86_ops {
 
        int (*update_pi_irte)(struct kvm *kvm, unsigned int host_irq,
                              uint32_t guest_irq, bool set);
+       void (*apicv_post_state_restore)(struct kvm_vcpu *vcpu);
 };
 
 struct kvm_arch_async_pf {
index 34c28c0ffe6ae89306b9ca988d67d902acc1cfc0..539675c6daa2c939588d54b7ec9810c361b1e334 100644 (file)
@@ -1961,6 +1961,8 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu,
                                1 : count_vectors(apic->regs + APIC_ISR);
        apic->highest_isr_cache = -1;
        if (vcpu->arch.apicv_active) {
+               if (kvm_x86_ops->apicv_post_state_restore)
+                       kvm_x86_ops->apicv_post_state_restore(vcpu);
                kvm_x86_ops->hwapic_irr_update(vcpu,
                                apic_find_highest_irr(apic));
                kvm_x86_ops->hwapic_isr_update(vcpu->kvm,
index db2c140ed079dda2188c3f023087f5682955c61d..8c85b8ee68b630a113002f26f6610b749c5ca949 100644 (file)
@@ -4834,6 +4834,15 @@ static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
 {
 }
 
+static inline void avic_post_state_restore(struct kvm_vcpu *vcpu)
+{
+       if (avic_handle_apic_id_update(vcpu) != 0)
+               return;
+       if (avic_handle_dfr_update(vcpu) != 0)
+               return;
+       avic_handle_ldr_update(vcpu);
+}
+
 static struct kvm_x86_ops svm_x86_ops = {
        .cpu_has_kvm_support = has_svm,
        .disabled_by_bios = is_disabled,
@@ -4914,6 +4923,7 @@ static struct kvm_x86_ops svm_x86_ops = {
        .sync_pir_to_irr = svm_sync_pir_to_irr,
        .hwapic_irr_update = svm_hwapic_irr_update,
        .hwapic_isr_update = svm_hwapic_isr_update,
+       .apicv_post_state_restore = avic_post_state_restore,
 
        .set_tss_addr = svm_set_tss_addr,
        .get_tdp_level = get_npt_level,