Skip to content

Commit 51c821d

Browse files
committed
KVM: nVMX: Switch to vmcs01 to update APIC page on-demand if L2 is active
If the KVM-owned APIC-access page is migrated while L2 is running, temporarily load vmcs01 and immediately update APIC_ACCESS_ADDR instead of deferring the update until the next nested VM-Exit. Once changing the virtual APIC mode is converted to always do on-demand updates, all of the "defer until vmcs01 is active" logic will be gone. Reviewed-by: Chao Gao <chao.gao@intel.com> Link: https://patch.msgid.link/20260109034532.1012993-7-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 2bf889a commit 51c821d

3 files changed

Lines changed: 2 additions & 11 deletions

File tree

arch/x86/kvm/vmx/nested.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5129,11 +5129,6 @@ void __nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
51295129

51305130
nested_put_vmcs12_pages(vcpu);
51315131

5132-
if (vmx->nested.reload_vmcs01_apic_access_page) {
5133-
vmx->nested.reload_vmcs01_apic_access_page = false;
5134-
kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
5135-
}
5136-
51375132
if ((vm_exit_reason != -1) &&
51385133
(enable_shadow_vmcs || nested_vmx_is_evmptr12_valid(vmx)))
51395134
vmx->nested.need_vmcs12_to_shadow_sync = true;

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6904,11 +6904,8 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu)
69046904
kvm_pfn_t pfn;
69056905
bool writable;
69066906

6907-
/* Defer reload until vmcs01 is the current VMCS. */
6908-
if (is_guest_mode(vcpu)) {
6909-
to_vmx(vcpu)->nested.reload_vmcs01_apic_access_page = true;
6910-
return;
6911-
}
6907+
/* Note, the VIRTUALIZE_APIC_ACCESSES check needs to query vmcs01. */
6908+
guard(vmx_vmcs01)(vcpu);
69126909

69136910
if (!(secondary_exec_controls_get(to_vmx(vcpu)) &
69146911
SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES))

arch/x86/kvm/vmx/vmx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ struct nested_vmx {
132132
bool vmcs02_initialized;
133133

134134
bool change_vmcs01_virtual_apic_mode;
135-
bool reload_vmcs01_apic_access_page;
136135

137136
/*
138137
* Enlightened VMCS has been enabled. It does not mean that L1 has to

0 commit comments

Comments
 (0)