From: Isaku Yamahata VMX APIC timer virtualization requires the virtual-interrupt delivery. It's part of KVM apicv, and when apicv state is changed, the refresh_apicv_exec_ctrl() callback is invoked. Export a lapic function to update which timer to use for APIC timer emulation and make the VMX backend call it. Signed-off-by: Isaku Yamahata -- Changes v1 -> v2: - Use EXPORT_SYMBOL_FOR_KVM_INTERNAL() instead of EXPORT_SYMBOL_GPL(). - Add in-kernel apic check. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/lapic.c | 9 +++++++++ arch/x86/kvm/lapic.h | 1 + arch/x86/kvm/vmx/vmx.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index abbd51c4da7f..a3c1a81e63e2 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1946,6 +1946,15 @@ static void apic_update_apic_virt_timer(struct kvm_lapic *apic) apic_cancel_apic_virt_timer(apic); } +void kvm_update_apic_virt_timer(struct kvm_vcpu *vcpu) +{ + if (!lapic_in_kernel(vcpu)) + return; + + apic_update_apic_virt_timer(vcpu->arch.apic); +} +EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_update_apic_virt_timer); + static void apic_update_lvtt(struct kvm_lapic *apic) { u32 timer_mode = kvm_lapic_get_reg(apic, APIC_LVTT) & diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 2f510503f5b3..0571b7438328 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -259,6 +259,7 @@ void kvm_lapic_switch_to_apic_virt_timer(struct kvm_vcpu *vcpu); void kvm_lapic_expired_hv_timer(struct kvm_vcpu *vcpu); bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu); void kvm_lapic_restart_hv_timer(struct kvm_vcpu *vcpu); +void kvm_update_apic_virt_timer(struct kvm_vcpu *vcpu); static inline bool kvm_lapic_apic_virt_timer_in_use(struct kvm_vcpu *vcpu) { diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index b70641bfecab..5d36f2b632e9 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4591,6 +4591,8 @@ void vmx_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) kvm_vcpu_apicv_active(vcpu)); vmx_update_msr_bitmap_x2apic(vcpu); + + kvm_update_apic_virt_timer(vcpu); } static u32 vmx_exec_control(struct vcpu_vmx *vmx) -- 2.45.2