Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: VMX: Re-pend KVM_REQ_APIC_PAGE_RELOAD if getting backing pfn fails
Date: Thu, 05 Nov 2026 18:31:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-199772@kernel.org> (raw)
In-Reply-To: <20261105181742.3718448-1-seanjc@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] KVM: VMX: stale no-retry comment in vmx_set_apic_access_page_addr()
--

commit 635b83243ce9cf39c9f2bbd0198d7730dbb21505
Author: Sean Christopherson <seanjc@google.com>

KVM: VMX: Re-pend KVM_REQ_APIC_PAGE_RELOAD if getting backing pfn fails

This commit re-pends KVM_REQ_APIC_PAGE_RELOAD in
vmx_set_apic_access_page_addr() when looking up the APIC-access page memslot
or faulting in its backing pfn fails, preventing the vCPU from running with a
stale vmcs.APIC_ACCESS_ADDR. It also adds a WARN_ON_ONCE() if the private
memslot is missing or invalid.

> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index b341af4c6057a..13dcf9c12c83a 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6923,8 +6923,10 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu)
>  	 * APICv is enabled, but paranoia won't hurt in this case.
>  	 */
>  	slot = id_to_memslot(slots, APIC_ACCESS_PAGE_PRIVATE_MEMSLOT);
> -	if (!slot || slot->flags & KVM_MEMSLOT_INVALID)
> +	if (WARN_ON_ONCE(!slot || slot->flags & KVM_MEMSLOT_INVALID)) {
> +		kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
>  		return;
> +	}
>  
>  	/*
>  	 * Ensure that the mmu_notifier sequence count is read before KVM
> @@ -6941,8 +6943,10 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu)
>  	 * if APICv is permanently inhibited, i.e. the memslot won't reappear.
>  	 */
>  	pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, &refcounted_page);
> -	if (is_error_noslot_pfn(pfn))
> +	if (is_error_noslot_pfn(pfn)) {
> +		kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
>  		return;
> +	}

[Severity: Low]
This isn't a bug, but in vmx_set_apic_access_page_addr() in
arch/x86/kvm/vmx/vmx.c, the full comment immediately above
__kvm_faultin_pfn() still states:

	/*
	 * No need to retry if the memslot does not exist or is invalid.  KVM
	 * controls the APIC-access page memslot, and only deletes the memslot
	 * if APICv is permanently inhibited, i.e. the memslot won't reappear.
	 */

Since both the invalid-memslot check and the is_error_noslot_pfn(pfn) check
now retry by calling kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu), and
VMX does not delete or inhibit the APIC-access page memslot while the VM is
alive, should this comment be updated or removed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105181742.3718448-1-seanjc@google.com?part=1

  reply	other threads:[~2026-11-05 18:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 18:17 [PATCH] KVM: VMX: Re-pend KVM_REQ_APIC_PAGE_RELOAD if getting backing pfn fails Sean Christopherson
2026-11-05 18:31 ` sashiko-bot [this message]
2026-11-05 18:39   ` Sean Christopherson

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=sashiko-outbox-199772@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seanjc@google.com \
    /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