From: sashiko-bot@kernel.org
To: "Ackerley Tng" <ackerleytng@google.com>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>,
kvm@vger.kernel.org
Subject: Re: [PATCH v2 2/4] KVM: SEV: Drop page refcount early during RMP fault handling
Date: Tue, 18 Aug 2026 09:29:09 +0000 [thread overview]
Message-ID: <20260818092909.DBA151F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260818-gmem-no-return-page-v2-2-5298f42d49bb@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Dropping the page refcount early introduces a race condition where a concurrent `guest_memfd` invalidation can trigger a false-positive 'Unexpected RMP fault' kernel warning.
--
--- Patch [2]: [PATCH v2 2/4] KVM: SEV: Drop page refcount early during RMP fault handling ---
commit 7d0f356d8592ce1804052b0fdb61fccf3a11ecaa
Author: Sean Christopherson <seanjc@google.com>
KVM: SEV: Drop page refcount early during RMP fault handling
When handling an RMP fault, KVM retrieves the PFN for a private GPA from
guest_memfd. This patch drops the page reference immediately after retrieving
the PFN instead of holding it across the entire handler, and adopts the MMU
invalidation protocol to guard committing anything based on the PFN.
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index b2738362a928b..b34b11d7f8fad 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
[ ... ]
> @@ -5030,18 +5031,22 @@ void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code)
> return;
> }
>
> + mmu_seq = kvm->mmu_invalidate_seq;
> + smp_rmb();
> +
> ret = kvm_gmem_get_pfn(kvm, slot, gfn, &pfn, &page, &order);
> if (ret) {
> pr_warn_ratelimited("SEV: Unexpected RMP fault, no backing page for private GPA 0x%llx\n",
> gpa);
> return;
> }
> + kvm_release_page_unused(page);
>
> ret = snp_lookup_rmpentry(pfn, &assigned, &rmp_level);
> if (ret || !assigned) {
> pr_warn_ratelimited("SEV: Unexpected RMP fault, no assigned RMP entry found for GPA 0x%llx PFN 0x%llx error %d\n",
> gpa, pfn, ret);
> - goto out_no_trace;
> + return;
> }
[Severity: Medium]
Since the page reference is dropped before this lookup in
sev_handle_rmp_fault(), could a concurrent guest_memfd hole-punch drop
the file's reference to the page and free it?
If the page is freed, the RMP entry would transition to shared/unassigned.
Could this then cause snp_lookup_rmpentry() to see the page as unassigned
and incorrectly emit this warning before the mmu_invalidate_retry_gfn()
check happens?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818-gmem-no-return-page-v2-0-5298f42d49bb@google.com?part=2
next prev parent reply other threads:[~2026-08-18 9:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 9:15 [PATCH v2 0/4] Stop returning struct page from guest_memfd PFN lookup Ackerley Tng
2026-08-18 9:15 ` [PATCH v2 1/4] KVM: SEV: Treat unassigned RMP entry as benign race on PSMASH failure Ackerley Tng
2026-08-18 9:15 ` [PATCH v2 2/4] KVM: SEV: Drop page refcount early during RMP fault handling Ackerley Tng
2026-08-18 9:29 ` sashiko-bot [this message]
2026-08-18 9:15 ` [PATCH v2 3/4] KVM: SEV: Drop page refcount early in VMSA reload Ackerley Tng
2026-08-18 9:27 ` sashiko-bot
2026-08-18 9:15 ` [PATCH v2 4/4] KVM: guest_memfd: Stop returning struct page from PFN lookup Ackerley Tng
2026-08-18 9:31 ` sashiko-bot
2026-08-18 13:58 ` Suzuki K Poulose
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=20260818092909.DBA151F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ackerleytng@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.