summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAckerley Tng <ackerleytng@google.com>2026-08-26 09:01:48 +0000
committerSean Christopherson <seanjc@google.com>2026-09-22 07:28:17 -0700
commitacafcf32c83ec16631463eeed9e87e44177c2e49 (patch)
treebe10e04cb493c6d415eb005d324103b064e8a237
parent375b32931b5da6a86ccb017e7e12a67a2def03f0 (diff)
KVM: SEV: Check for invalidation before warning on unassigned RMP entry
When handling an RMP fault, KVM looks up the RMP entry for the backing PFN to determine if a 2MB page needs to be split via PSMASH. If the RMP entry is not assigned (or lookup fails), KVM logs a rate-limited warning under the assumption that private memory should always have an assigned RMP entry. However, a concurrent invalidation (such as guest_memfd hole punching) can race with RMP fault handling and transition the page to shared, unassigning the RMP entry after KVM fetched the PFN. In such cases, not finding an assigned RMP entry is benign. Check mmu_invalidate_retry_gfn() under mmu_lock before warning about a missing or unassigned RMP entry, and suppress the spurious warning if an invalidation occurred for the faulting GFN. Fixes: c63cf135cc99 ("KVM: SEV: Add support to handle RMP nested page faults") Signed-off-by: Ackerley Tng <ackerleytng@google.com> Link: https://patch.msgid.link/20260826-gmem-no-return-page-v4-3-3bb9c1ddb4e3@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
-rw-r--r--arch/x86/kvm/svm/sev.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 0d027cff734c..f9dce8acac8e 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -5060,8 +5060,12 @@ void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code)
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);
+ guard(read_lock)(&kvm->mmu_lock);
+
+ if (!mmu_invalidate_retry_gfn(kvm, mmu_seq, gfn))
+ 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);
+
return;
}