OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>,
	devel@openvz.org, Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: [Devel] [PATCH hci-8.1 v2 2/2] ms/KVM: nVMX: Immediately refresh APICv controls as needed on nested VM-Exit
Date: Thu, 24 Sep 2026 19:15:38 +0200	[thread overview]
Message-ID: <20260924-b4-prep-kvm-v2-2-ad742e43266c@virtuozzo.com> (raw)
In-Reply-To: <20260924-b4-prep-kvm-v2-0-ad742e43266c@virtuozzo.com>

From: Maxim Levitsky <mlevitsk@redhat.com>

JIRA: https://issues.redhat.com/browse/RHEL-151869

commit 29763138830916f46daaa50e83e7f4f907a3236b
Author: Dongli Zhang <dongli.zhang@oracle.com>
Date:   Fri Dec 5 15:19:05 2025 -0800

    KVM: nVMX: Immediately refresh APICv controls as needed on nested VM-Exit

    If an APICv status updated was pended while L2 was active, immediately
    refresh vmcs01's controls instead of pending KVM_REQ_APICV_UPDATE as
    kvm_vcpu_update_apicv() only calls into vendor code if a change is
    necessary.

    E.g. if APICv is inhibited, and then activated while L2 is running:

      kvm_vcpu_update_apicv()
      |
      -> __kvm_vcpu_update_apicv()
         |
         -> apic->apicv_active = true
          |
          -> vmx_refresh_apicv_exec_ctrl()
             |
             -> vmx->nested.update_vmcs01_apicv_status = true
              |
              -> return

    Then L2 exits to L1:

      __nested_vmx_vmexit()
      |
      -> kvm_make_request(KVM_REQ_APICV_UPDATE)

      vcpu_enter_guest(): KVM_REQ_APICV_UPDATE
      -> kvm_vcpu_update_apicv()
         |
         -> __kvm_vcpu_update_apicv()
            |
            -> return // because if (apic->apicv_active == activate)

    Reported-by: Chao Gao <chao.gao@intel.com>
    Closes: https://lore.kernel.org/all/aQ2jmnN8wUYVEawF@intel.com
    Fixes: 7c69661e225c ("KVM: nVMX: Defer APICv updates while L2 is active until L1 is active")
    Cc: stable@vger.kernel.org
    Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
    [sean: write changelog]
    Link: https://patch.msgid.link/20251205231913.441872-3-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

(cherry picked from commit e299e09009929a5b4a5f209617ab25bcd08e41bb)

https://virtuozzo.atlassian.net/browse/VSTOR-147087
Feature: fix ms/kvm

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 arch/x86/kvm/vmx/nested.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 7ff9a8d2c2c93..8c771d8c35e35 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -18,6 +18,7 @@
 #include "trace.h"
 #include "vmx.h"
 #include "smm.h"
+#include "x86_ops.h"
 
 static bool __read_mostly enable_shadow_vmcs = 1;
 module_param_named(enable_shadow_vmcs, enable_shadow_vmcs, bool, S_IRUGO);
@@ -5087,7 +5088,7 @@ void __nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
 
 	if (vmx->nested.update_vmcs01_apicv_status) {
 		vmx->nested.update_vmcs01_apicv_status = false;
-		kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu);
+		vmx_refresh_apicv_exec_ctrl(vcpu);
 	}
 
 	if (vmx->nested.update_vmcs01_hwapic_isr) {

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-09-24 17:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 17:15 [Devel] [PATCH hci-8.1 v2 0/2] KVM: VMX: fix stale SVI after APICv is re-activated at runtime Konstantin Khorenko
2026-09-24 17:15 ` [Devel] [PATCH hci-8.1 v2 1/2] ms/KVM: VMX: Update SVI during runtime APICv activation Konstantin Khorenko
2026-09-24 17:15 ` Konstantin Khorenko [this message]
2026-09-24 17:24 ` [Devel] [PATCH hci-8.1 v2 0/2] KVM: VMX: fix stale SVI after APICv is re-activated at runtime Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260924-b4-prep-kvm-v2-2-ad742e43266c@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=devel@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox