Skip to content

Commit ca0245d

Browse files
gaochaointelsean-jc
authored andcommitted
KVM: x86: Remove hwapic_irr_update() from kvm_x86_ops
Remove the redundant .hwapic_irr_update() ops. If a vCPU has APICv enabled, KVM updates its RVI before VM-enter to L1 in vmx_sync_pir_to_irr(). This guarantees RVI is up-to-date and aligned with the vIRR in the virtual APIC. So, no need to update RVI every time the vIRR changes. Note that KVM never updates vmcs02 RVI in .hwapic_irr_update() or vmx_sync_pir_to_irr(). So, removing .hwapic_irr_update() has no impact to the nested case. Signed-off-by: Chao Gao <chao.gao@intel.com> Link: https://lore.kernel.org/r/20241111085947.432645-1-chao.gao@intel.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 3d91521 commit ca0245d

File tree

6 files changed

+0
-23
lines changed

6 files changed

+0
-23
lines changed

arch/x86/include/asm/kvm-x86-ops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ KVM_X86_OP(enable_nmi_window)
8383
KVM_X86_OP(enable_irq_window)
8484
KVM_X86_OP_OPTIONAL(update_cr8_intercept)
8585
KVM_X86_OP(refresh_apicv_exec_ctrl)
86-
KVM_X86_OP_OPTIONAL(hwapic_irr_update)
8786
KVM_X86_OP_OPTIONAL(hwapic_isr_update)
8887
KVM_X86_OP_OPTIONAL(load_eoi_exitmap)
8988
KVM_X86_OP_OPTIONAL(set_virtual_apic_mode)

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,6 @@ struct kvm_x86_ops {
17341734
const unsigned long required_apicv_inhibits;
17351735
bool allow_apicv_in_x2apic_without_x2apic_virtualization;
17361736
void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu);
1737-
void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
17381737
void (*hwapic_isr_update)(struct kvm_vcpu *vcpu, int isr);
17391738
void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
17401739
void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu);

arch/x86/kvm/lapic.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,7 @@ static inline int apic_find_highest_irr(struct kvm_lapic *apic)
734734
static inline void apic_clear_irr(int vec, struct kvm_lapic *apic)
735735
{
736736
if (unlikely(apic->apicv_active)) {
737-
/* need to update RVI */
738737
kvm_lapic_clear_vector(vec, apic->regs + APIC_IRR);
739-
kvm_x86_call(hwapic_irr_update)(apic->vcpu,
740-
apic_find_highest_irr(apic));
741738
} else {
742739
apic->irr_pending = false;
743740
kvm_lapic_clear_vector(vec, apic->regs + APIC_IRR);
@@ -2816,7 +2813,6 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
28162813
apic_update_ppr(apic);
28172814
if (apic->apicv_active) {
28182815
kvm_x86_call(apicv_post_state_restore)(vcpu);
2819-
kvm_x86_call(hwapic_irr_update)(vcpu, -1);
28202816
kvm_x86_call(hwapic_isr_update)(vcpu, -1);
28212817
}
28222818

@@ -3132,7 +3128,6 @@ int kvm_apic_set_state(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s)
31323128
kvm_apic_update_apicv(vcpu);
31333129
if (apic->apicv_active) {
31343130
kvm_x86_call(apicv_post_state_restore)(vcpu);
3135-
kvm_x86_call(hwapic_irr_update)(vcpu, apic_find_highest_irr(apic));
31363131
kvm_x86_call(hwapic_isr_update)(vcpu, apic_find_highest_isr(apic));
31373132
}
31383133
kvm_make_request(KVM_REQ_EVENT, vcpu);

arch/x86/kvm/vmx/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
100100
.load_eoi_exitmap = vmx_load_eoi_exitmap,
101101
.apicv_pre_state_restore = vmx_apicv_pre_state_restore,
102102
.required_apicv_inhibits = VMX_REQUIRED_APICV_INHIBITS,
103-
.hwapic_irr_update = vmx_hwapic_irr_update,
104103
.hwapic_isr_update = vmx_hwapic_isr_update,
105104
.sync_pir_to_irr = vmx_sync_pir_to_irr,
106105
.deliver_interrupt = vmx_deliver_interrupt,

arch/x86/kvm/vmx/vmx.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6918,20 +6918,6 @@ static void vmx_set_rvi(int vector)
69186918
}
69196919
}
69206920

6921-
void vmx_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr)
6922-
{
6923-
/*
6924-
* When running L2, updating RVI is only relevant when
6925-
* vmcs12 virtual-interrupt-delivery enabled.
6926-
* However, it can be enabled only when L1 also
6927-
* intercepts external-interrupts and in that case
6928-
* we should not update vmcs02 RVI but instead intercept
6929-
* interrupt. Therefore, do nothing when running L2.
6930-
*/
6931-
if (!is_guest_mode(vcpu))
6932-
vmx_set_rvi(max_irr);
6933-
}
6934-
69356921
int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu)
69366922
{
69376923
struct vcpu_vmx *vmx = to_vmx(vcpu);

arch/x86/kvm/vmx/x86_ops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ bool vmx_apic_init_signal_blocked(struct kvm_vcpu *vcpu);
4747
void vmx_migrate_timers(struct kvm_vcpu *vcpu);
4848
void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu);
4949
void vmx_apicv_pre_state_restore(struct kvm_vcpu *vcpu);
50-
void vmx_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr);
5150
void vmx_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr);
5251
int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu);
5352
void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode,

0 commit comments

Comments
 (0)