Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ackerley Tng" <ackerleytng@google.com>
Cc: "Marc Zyngier" <maz@kernel.org>,
	kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 1/4] KVM: SEV: Treat unassigned RMP entry as benign race on PSMASH failure
Date: Tue, 18 Aug 2026 08:23:31 +0000	[thread overview]
Message-ID: <20260818082332.5F9761F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818-gmem-no-return-page-v1-1-4f8d939efdbc@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Medium] Unaligned GFN range in RMP fault handler causes erroneous invalidation of adjacent memory
--

--- Patch [1]: [PATCH 1/4] KVM: SEV: Treat unassigned RMP entry as benign race on PSMASH failure ---
commit de1b2dc6f988d4cc54c9ff854b0263fe60c82d44
Author: Ackerley Tng <ackerleytng@google.com>
KVM: SEV: Treat unassigned RMP entry as benign race on PSMASH failure

This commit modifies KVM's handling of RMP faults during a PSMASH operation.
It updates the RMP entry lookup condition to treat an unassigned entry as an
expected race when re-checking after a failed PSMASH, preventing unnecessary
warning logs if another process transitions the page to shared.

> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index fcb41dfde4c02..b2738362a928b 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -5074,10 +5074,11 @@ void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code)

[ ... ]

>  		/*
>  		 * Look it up again. If it's 4K now then the PSMASH may have
>  		 * raced with another process and the issue has already resolved
> -		 * itself.
> +		 * itself. If it's not assigned, then this must have raced with
> +		 * another process that made this page shared.
>  		 */
>  		if (!snp_lookup_rmpentry(pfn, &assigned, &rmp_level) &&
> -		    assigned && rmp_level == PG_LEVEL_4K)
> +		    ((assigned && rmp_level == PG_LEVEL_4K) || !assigned))
>  			goto out;
>  
>  		pr_warn_ratelimited("SEV: Unable to split RMP entry for GPA 0x%llx PFN 0x%llx ret %d\n",
> 				    gpa, pfn, ret);
>  	}
>  
>  	kvm_zap_gfn_range(kvm, gfn, gfn + PTRS_PER_PMD);

[Severity: Medium]
This is a pre-existing issue, but does this correctly align the guest frame
number before zapping the range?

Looking at sev_handle_rmp_fault(), the gfn is calculated from the unaligned
faulting guest physical address. Since gfn isn't masked to a 2MB boundary,
does adding PTRS_PER_PMD cause the zap range to cross into and erroneously
invalidate up to 511 pages of the adjacent 2MB region?

Additionally, if the NPT mappings were already 4K, would this unaligned gfn
cause the function to miss zapping the start of the intended 2MB region?

> out:
>  	trace_kvm_rmp_fault(vcpu, gpa, pfn, error_code, rmp_level, ret);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818-gmem-no-return-page-v1-0-4f8d939efdbc@google.com?part=1

  reply	other threads:[~2026-08-18  8:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18  8:12 [PATCH 0/4] Stop returning struct page from guest_memfd PFN lookup Ackerley Tng
2026-08-18  8:12 ` [PATCH 1/4] KVM: SEV: Treat unassigned RMP entry as benign race on PSMASH failure Ackerley Tng
2026-08-18  8:23   ` sashiko-bot [this message]
2026-08-18  8:12 ` [PATCH 2/4] KVM: SEV: Drop page refcount early during RMP fault handling Ackerley Tng
2026-08-18  8:12   ` Yan Zhao
2026-08-18  9:04     ` Ackerley Tng
2026-08-18  8:26   ` sashiko-bot
2026-08-18  8:12 ` [PATCH 3/4] KVM: SEV: Drop page refcount early in VMSA reload Ackerley Tng
2026-08-18  8:12 ` [PATCH 4/4] KVM: guest_memfd: Stop returning struct page from PFN lookup Ackerley Tng
2026-08-18  8:34   ` Yan Zhao
2026-08-18  9:44     ` Ackerley Tng

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=20260818082332.5F9761F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox