KVM: x86: Update APICv on APIC reset
authorJan H. Schönherr <jschoenh@amazon.de>
Wed, 25 Oct 2017 14:43:27 +0000 (16:43 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 2 Nov 2017 17:28:13 +0000 (18:28 +0100)
In kvm_apic_set_state() we update the hardware virtualized APIC after
the full APIC state has been overwritten. Do the same, when the full
APIC state has been reset in kvm_lapic_reset().

This updates some hardware state that was previously forgotten, as
far as I can tell. Also, this allows removing some APIC-related reset
code from vmx_vcpu_reset().

Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/lapic.c
arch/x86/kvm/vmx.c

index 69c5612be786fbc7909b6f81a8d0a29f2cd324a6..36c90d631096d8c4eea10291d2958d6fb1393b4b 100644 (file)
@@ -1992,6 +1992,11 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
                                vcpu->arch.apic_base | MSR_IA32_APICBASE_BSP);
        vcpu->arch.pv_eoi.msr_val = 0;
        apic_update_ppr(apic);
+       if (vcpu->arch.apicv_active) {
+               kvm_x86_ops->apicv_post_state_restore(vcpu);
+               kvm_x86_ops->hwapic_irr_update(vcpu, -1);
+               kvm_x86_ops->hwapic_isr_update(vcpu, -1);
+       }
 
        vcpu->arch.apic_arb_prio = 0;
        vcpu->arch.apic_attention = 0;
index e0b4b64f211adbcb587f61248cdca010373acc59..a6f4f095f8f4eb4aa5b4bae2a21dd66cccd824e7 100644 (file)
@@ -5619,11 +5619,6 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
 
        kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
 
-       if (kvm_vcpu_apicv_active(vcpu)) {
-               pi_clear_on(&vmx->pi_desc);
-               memset(vmx->pi_desc.pir, 0, sizeof(vmx->pi_desc.pir));
-       }
-
        if (vmx->vpid != 0)
                vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);