public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: Dongli Zhang <dongli.zhang@oracle.com>
Cc: <kvm@vger.kernel.org>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>, <seanjc@google.com>,
	<pbonzini@redhat.com>, <tglx@linutronix.de>, <mingo@redhat.com>,
	<bp@alien8.de>, <dave.hansen@linux.intel.com>, <hpa@zytor.com>,
	<joe.jin@oracle.com>
Subject: Re: [PATCH 1/1] KVM: VMX: configure SVI during runtime APICv activation
Date: Fri, 7 Nov 2025 15:45:30 +0800	[thread overview]
Message-ID: <aQ2jmnN8wUYVEawF@intel.com> (raw)
In-Reply-To: <9a54bd8d-ea42-4c9b-afdc-a9ae3c31b034@oracle.com>

>> Why is the nested case exempted here? IIUC, kvm_apic_update_hwapic_isr()
>> guarantees an update to VMCS01's SVI even if the vCPU is in guest mode.
>> 
>> And there is already a check against apicv_active right below. So, to be
>> concise, how about:
>> 
>> 	if (!apic->apicv_active)
>> 		kvm_make_request(KVM_REQ_EVENT, vcpu);
>> 	else
>> 		kvm_apic_update_hwapic_isr(vcpu);
>
>Thank you very much for reminder.
>
>I missed the scenario when vCPU is in L2. The __nested_vmx_vmexit() will not
>call kvm_apic_update_hwapic_isr() unless 'update_vmcs01_hwapic_isr' is set to true.
>
>However, can I remove the below WARN_ON_ONCE introduced by the commit
>04bc93cf49d1 ("KVM: nVMX: Defer SVI update to vmcs01 on EOI when L2 is active
>w/o VID")?
>
>Now we need to call vmx_hwapic_isr_update() when the vCPU is running with vmcs12
>VID configured.
>
>diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>index f87c216d976d..d263dbf0b917 100644
>--- a/arch/x86/kvm/vmx/vmx.c
>+++ b/arch/x86/kvm/vmx/vmx.c
>@@ -6878,15 +6878,6 @@ void vmx_hwapic_isr_update(struct kvm_vcpu *vcpu, int
>max_isr)
>         * VM-Exit, otherwise L1 with run with a stale SVI.
>         */
>        if (is_guest_mode(vcpu)) {
>-               /*
>-                * KVM is supposed to forward intercepted L2 EOIs to L1 if VID
>-                * is enabled in vmcs12; as above, the EOIs affect L2's vAPIC.
>-                * Note, userspace can stuff state while L2 is active; assert
>-                * that VID is disabled if and only if the vCPU is in KVM_RUN
>-                * to avoid false positives if userspace is setting APIC state.
>-                */
>-               WARN_ON_ONCE(vcpu->wants_to_run &&
>-                            nested_cpu_has_vid(get_vmcs12(vcpu)));

Thanks for testing this.

I think it is fine to remove it. The warning produced some false positives when
added. That's why we have the vcpu->wants_to_run check here. Now that we have
new false positives; the check is less useful than expected. But let's see what
Sean thinks about this.


A side topic:

I am not quite sure how vmx_refresh_apicv_exec_ctrl() works for the nested case.

If a KVM_REQ_APICV_UPDATE event is pending, __kvm_vcpu_update_apicv() is called
to update VMCS controls. If the vCPU is in a nested case, vmcs01 isn't updated
immediately. Instead, the update is delayed by setting the
update_vmcs01_apicv_status flag and another KVM_REQ_APICV_UPDATE request is
queued to do the update after the nested VM exits.

So, __kvm_vcpu_update_apicv() gets called again. My theory is that the second
call doesn't update vmcs01 either because the "if (apic->apicv_active ==
activate)" condition becomes true and so vmx_refresh_apicv_exec_ctrl() isn't
called again.

>                to_vmx(vcpu)->nested.update_vmcs01_hwapic_isr = true;
>                return;
>        }
>

  reply	other threads:[~2025-11-07  7:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03 21:41 [PATCH 1/1] KVM: VMX: configure SVI during runtime APICv activation Dongli Zhang
2025-11-04  7:37 ` Chao Gao
2025-11-06 23:41   ` Dongli Zhang
2025-11-07  7:45     ` Chao Gao [this message]
2025-11-08  2:04       ` Dongli Zhang

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=aQ2jmnN8wUYVEawF@intel.com \
    --to=chao.gao@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dongli.zhang@oracle.com \
    --cc=hpa@zytor.com \
    --cc=joe.jin@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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