Re: [PULL 13/19] KVM: SEV: Implement gmem hook for invalidating private pages

From: Paolo Bonzini
Date: Tue May 21 2024 - 12:55:55 EST


On Thu, May 16, 2024 at 5:12 AM Michael Roth <michael.roth@xxxxxxx> wrote:
> Longer term if we need something more robust would be to modify the
> .free_folio callback path to pass along folio->mapping, or switch to
> something else that provides similar functionality. Another approach
> might be to set .free_folio dynamically based on the vm_type of the
> gmem user when creating the gmem instance.

You need to not warn. Testing CC_ATTR_HOST_SEV_SNP is just an optimization.

Paolo

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index dc00b89404a2..1c57b4535f15 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -4676,8 +4676,7 @@ void sev_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end)
bool assigned;

rc = snp_lookup_rmpentry(pfn, &assigned, &rmp_level);
- if (WARN_ONCE(rc, "SEV: Failed to retrieve RMP entry for PFN
0x%llx error %d\n",
- pfn, rc))
+ if (rc)
goto next_pfn;

if (!assigned)

Paolo