* [PATCH v2 0/2] KVM: x86: Drop deferred updates of EOI bitmaps
@ 2026-10-22 2:28 Sean Christopherson
2026-10-22 2:28 ` [PATCH v2 1/2] KVM: x86: Switch to vmcs01 to update EOI exiting bitmap on-demand if L2 is active Sean Christopherson
2026-10-22 2:28 ` [PATCH v2 2/2] KVM: x86: Consolidate invocations of kvm_x86_ops.load_eoi_exitmap() Sean Christopherson
0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2026-10-22 2:28 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Amirmohammad Eftekhar
Stop deferring EOI bitmap updates. As pointed out by Amirmohammad, I missed
this one when removing all the other cases where KVM defers an update until
vmcs01 is active.
v1: https://lore.kernel.org/all/20261017093016.32348-2-amirmohammad.eftekhar@cispa.de
Sean Christopherson (2):
KVM: x86: Switch to vmcs01 to update EOI exiting bitmap on-demand if
L2 is active
KVM: x86: Consolidate invocations of kvm_x86_ops.load_eoi_exitmap()
arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/regs.h | 6 ------
arch/x86/kvm/vmx/vmx.c | 2 ++
arch/x86/kvm/x86.c | 27 +++++++--------------------
4 files changed, 10 insertions(+), 27 deletions(-)
base-commit: 164405e8e9a0378c7e1aff2254625a6553a291f1
--
2.56.0.218.g1ec904b173-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] KVM: x86: Switch to vmcs01 to update EOI exiting bitmap on-demand if L2 is active
2026-10-22 2:28 [PATCH v2 0/2] KVM: x86: Drop deferred updates of EOI bitmaps Sean Christopherson
@ 2026-10-22 2:28 ` Sean Christopherson
2026-10-22 2:28 ` [PATCH v2 2/2] KVM: x86: Consolidate invocations of kvm_x86_ops.load_eoi_exitmap() Sean Christopherson
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2026-10-22 2:28 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Amirmohammad Eftekhar
If KVM needs to update the EOI bitmap while L2 is running, temporarily load
vmcs01 and immediately refresh the bitmap in vmcs01 instead of deferring
the update until the next nested VM-Exit. I.e. give the EOI bitmap the
same treatment as the many other updates that were previously deferred.
Reported-by: Amirmohammad Eftekhar <amirmohammad.eftekhar@cispa.de>
Closes: https://lore.kernel.org/all/20261017093016.32348-2-amirmohammad.eftekhar@cispa.de
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/regs.h | 6 ------
arch/x86/kvm/vmx/vmx.c | 2 ++
arch/x86/kvm/x86.c | 13 -------------
4 files changed, 3 insertions(+), 20 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 0378577d9d8b..f2c53a5f40e3 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -113,7 +113,7 @@
#define KVM_REQ_HV_RESET KVM_ARCH_REQ(20)
#define KVM_REQ_HV_EXIT KVM_ARCH_REQ(21)
#define KVM_REQ_HV_STIMER KVM_ARCH_REQ(22)
-#define KVM_REQ_LOAD_EOI_EXITMAP KVM_ARCH_REQ(23)
+/*#define FREE!!! USE ME!!! KVM_ARCH_REQ(23) */
#define KVM_REQ_GET_NESTED_STATE_PAGES KVM_ARCH_REQ(24)
#define KVM_REQ_APICV_UPDATE \
KVM_ARCH_REQ_FLAGS(25, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
diff --git a/arch/x86/kvm/regs.h b/arch/x86/kvm/regs.h
index 97c17b120a57..04d047f46753 100644
--- a/arch/x86/kvm/regs.h
+++ b/arch/x86/kvm/regs.h
@@ -463,12 +463,6 @@ static inline void enter_guest_mode(struct kvm_vcpu *vcpu)
static inline void leave_guest_mode(struct kvm_vcpu *vcpu)
{
vcpu->arch.hflags &= ~HF_GUEST_MASK;
-
- if (vcpu->arch.load_eoi_exitmap_pending) {
- vcpu->arch.load_eoi_exitmap_pending = false;
- kvm_make_request(KVM_REQ_LOAD_EOI_EXITMAP, vcpu);
- }
-
vcpu->stat.guest_mode = 0;
}
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index b341af4c6057..59b48d959ee0 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -7082,6 +7082,8 @@ void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)
if (!kvm_vcpu_apicv_active(vcpu))
return;
+ guard(vmx_vmcs01)(vcpu);
+
vmcs_write64(EOI_EXIT_BITMAP0, eoi_exit_bitmap[0]);
vmcs_write64(EOI_EXIT_BITMAP1, eoi_exit_bitmap[1]);
vmcs_write64(EOI_EXIT_BITMAP2, eoi_exit_bitmap[2]);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 32563a91fba9..0028d57e964a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8062,17 +8062,6 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)
kvm_ioapic_scan_entry(vcpu, vcpu->arch.ioapic_handled_vectors);
#endif
- if (is_guest_mode(vcpu))
- vcpu->arch.load_eoi_exitmap_pending = true;
- else
- kvm_make_request(KVM_REQ_LOAD_EOI_EXITMAP, vcpu);
-}
-
-static void vcpu_load_eoi_exitmap(struct kvm_vcpu *vcpu)
-{
- if (!kvm_apic_hw_enabled(vcpu->arch.apic))
- return;
-
#ifdef CONFIG_KVM_HYPERV
if (to_hv_vcpu(vcpu)) {
u64 eoi_exit_bitmap[4];
@@ -8240,8 +8229,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
}
if (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu))
vcpu_scan_ioapic(vcpu);
- if (kvm_check_request(KVM_REQ_LOAD_EOI_EXITMAP, vcpu))
- vcpu_load_eoi_exitmap(vcpu);
if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu))
kvm_vcpu_reload_apic_access_page(vcpu);
#ifdef CONFIG_KVM_HYPERV
--
2.56.0.218.g1ec904b173-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] KVM: x86: Consolidate invocations of kvm_x86_ops.load_eoi_exitmap()
2026-10-22 2:28 [PATCH v2 0/2] KVM: x86: Drop deferred updates of EOI bitmaps Sean Christopherson
2026-10-22 2:28 ` [PATCH v2 1/2] KVM: x86: Switch to vmcs01 to update EOI exiting bitmap on-demand if L2 is active Sean Christopherson
@ 2026-10-22 2:28 ` Sean Christopherson
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2026-10-22 2:28 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Amirmohammad Eftekhar
Rework KVM's handling of EOI exit bitmap updates to consolidate the calls
to vendor code so that it's easier to see that the Hyper-V path is doing
the exact same thing, just with extra input to account for the SynIC
vectors.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/x86.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0028d57e964a..483dac323c8e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8047,6 +8047,9 @@ EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_inc_or_dec_irq_window_inhibit);
static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)
{
+ unsigned long *eoi_exit_bitmap = vcpu->arch.ioapic_handled_vectors;
+ DECLARE_BITMAP(__eoi_exit_bitmap, 256) __maybe_unused;
+
if (!kvm_apic_present(vcpu))
return;
@@ -8064,17 +8067,14 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)
#ifdef CONFIG_KVM_HYPERV
if (to_hv_vcpu(vcpu)) {
- u64 eoi_exit_bitmap[4];
-
- bitmap_or((ulong *)eoi_exit_bitmap,
+ bitmap_or(__eoi_exit_bitmap,
vcpu->arch.ioapic_handled_vectors,
to_hv_synic(vcpu)->vec_bitmap, 256);
- kvm_x86_call(load_eoi_exitmap)(vcpu, eoi_exit_bitmap);
- return;
+
+ eoi_exit_bitmap = __eoi_exit_bitmap;
}
#endif
- kvm_x86_call(load_eoi_exitmap)(
- vcpu, (u64 *)vcpu->arch.ioapic_handled_vectors);
+ kvm_x86_call(load_eoi_exitmap)(vcpu, (u64 *)eoi_exit_bitmap);
}
void kvm_arch_guest_memory_reclaimed(struct kvm *kvm)
--
2.56.0.218.g1ec904b173-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-22 2:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 2:28 [PATCH v2 0/2] KVM: x86: Drop deferred updates of EOI bitmaps Sean Christopherson
2026-10-22 2:28 ` [PATCH v2 1/2] KVM: x86: Switch to vmcs01 to update EOI exiting bitmap on-demand if L2 is active Sean Christopherson
2026-10-22 2:28 ` [PATCH v2 2/2] KVM: x86: Consolidate invocations of kvm_x86_ops.load_eoi_exitmap() Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®