Skip to content

Commit cae64e1

Browse files
sean-jcgregkh
authored andcommitted
KVM: x86: Plumb in the vCPU to kvm_x86_ops.hwapic_isr_update()
commit 76bce9f upstream. Pass the target vCPU to the hwapic_isr_update() vendor hook so that VMX can defer the update until after nested VM-Exit if an EOI for L1's vAPIC occurs while L2 is active. Note, commit d39850f ("KVM: x86: Drop @vcpu parameter from kvm_x86_ops.hwapic_isr_update()") removed the parameter with the justification that doing so "allows for a decent amount of (future) cleanup in the APIC code", but it's not at all clear what cleanup was intended, or if it was ever realized. No functional change intended. Cc: stable@vger.kernel.org Reviewed-by: Chao Gao <chao.gao@intel.com> Tested-by: Chao Gao <chao.gao@intel.com> Link: https://lore.kernel.org/r/20241128000010.4051275-2-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 73ac634 commit cae64e1

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ struct kvm_x86_ops {
17351735
bool allow_apicv_in_x2apic_without_x2apic_virtualization;
17361736
void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu);
17371737
void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
1738-
void (*hwapic_isr_update)(int isr);
1738+
void (*hwapic_isr_update)(struct kvm_vcpu *vcpu, int isr);
17391739
void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
17401740
void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu);
17411741
void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu);

arch/x86/kvm/lapic.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ static inline void apic_set_isr(int vec, struct kvm_lapic *apic)
763763
* just set SVI.
764764
*/
765765
if (unlikely(apic->apicv_active))
766-
kvm_x86_call(hwapic_isr_update)(vec);
766+
kvm_x86_call(hwapic_isr_update)(apic->vcpu, vec);
767767
else {
768768
++apic->isr_count;
769769
BUG_ON(apic->isr_count > MAX_APIC_VECTOR);
@@ -808,7 +808,7 @@ static inline void apic_clear_isr(int vec, struct kvm_lapic *apic)
808808
* and must be left alone.
809809
*/
810810
if (unlikely(apic->apicv_active))
811-
kvm_x86_call(hwapic_isr_update)(apic_find_highest_isr(apic));
811+
kvm_x86_call(hwapic_isr_update)(apic->vcpu, apic_find_highest_isr(apic));
812812
else {
813813
--apic->isr_count;
814814
BUG_ON(apic->isr_count < 0);
@@ -2806,7 +2806,7 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
28062806
if (apic->apicv_active) {
28072807
kvm_x86_call(apicv_post_state_restore)(vcpu);
28082808
kvm_x86_call(hwapic_irr_update)(vcpu, -1);
2809-
kvm_x86_call(hwapic_isr_update)(-1);
2809+
kvm_x86_call(hwapic_isr_update)(vcpu, -1);
28102810
}
28112811

28122812
vcpu->arch.apic_arb_prio = 0;
@@ -3121,9 +3121,8 @@ int kvm_apic_set_state(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s)
31213121
kvm_apic_update_apicv(vcpu);
31223122
if (apic->apicv_active) {
31233123
kvm_x86_call(apicv_post_state_restore)(vcpu);
3124-
kvm_x86_call(hwapic_irr_update)(vcpu,
3125-
apic_find_highest_irr(apic));
3126-
kvm_x86_call(hwapic_isr_update)(apic_find_highest_isr(apic));
3124+
kvm_x86_call(hwapic_irr_update)(vcpu, apic_find_highest_irr(apic));
3125+
kvm_x86_call(hwapic_isr_update)(vcpu, apic_find_highest_isr(apic));
31273126
}
31283127
kvm_make_request(KVM_REQ_EVENT, vcpu);
31293128
if (ioapic_in_kernel(vcpu->kvm))

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6862,7 +6862,7 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu)
68626862
read_unlock(&vcpu->kvm->mmu_lock);
68636863
}
68646864

6865-
void vmx_hwapic_isr_update(int max_isr)
6865+
void vmx_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr)
68666866
{
68676867
u16 status;
68686868
u8 old;

arch/x86/kvm/vmx/x86_ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ 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);
5050
void vmx_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr);
51-
void vmx_hwapic_isr_update(int max_isr);
51+
void vmx_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr);
5252
int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu);
5353
void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode,
5454
int trig_mode, int vector);

0 commit comments

Comments
 (0)