Skip to content

Commit 73137f5

Browse files
committed
KVM: SEV: Don't WARN() if RMP lookup fails when invalidating gmem pages
The hook only handles cleanup work specific to SNP, e.g. RMP table entries and flushing caches for encrypted guest memory. When run on a non-SNP-enabled host (currently only possible using KVM_X86_SW_PROTECTED_VM, e.g. via KVM selftests), the callback is a noop and will WARN due to the RMP table not being present. It's actually expected in this case that the RMP table wouldn't be present and that the hook should be a noop, so drop the WARN_ONCE(). Reported-by: Sean Christopherson <[email protected]> Closes: https://lore.kernel.org/kvm/[email protected]/ Fixes: 8eb0190 ("KVM: SEV: Implement gmem hook for invalidating private pages") Suggested-by: Paolo Bonzini <[email protected]> Signed-off-by: Michael Roth <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent febff04 commit 73137f5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4682,6 +4682,9 @@ void sev_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end)
46824682
{
46834683
kvm_pfn_t pfn;
46844684

4685+
if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
4686+
return;
4687+
46854688
pr_debug("%s: PFN start 0x%llx PFN end 0x%llx\n", __func__, start, end);
46864689

46874690
for (pfn = start; pfn < end;) {
@@ -4690,11 +4693,7 @@ void sev_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end)
46904693
bool assigned;
46914694

46924695
rc = snp_lookup_rmpentry(pfn, &assigned, &rmp_level);
4693-
if (WARN_ONCE(rc, "SEV: Failed to retrieve RMP entry for PFN 0x%llx error %d\n",
4694-
pfn, rc))
4695-
goto next_pfn;
4696-
4697-
if (!assigned)
4696+
if (rc || !assigned)
46984697
goto next_pfn;
46994698

47004699
use_2m_update = IS_ALIGNED(pfn, PTRS_PER_PMD) &&

0 commit comments

Comments
 (0)