summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-06-03 12:37:26 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2024-06-03 12:38:14 -0400
commit73137f59246da530c29674a506f83a18fe327946 (patch)
tree5052e8a9534ce7ee5ada77cca5977e70b9640390 /arch/x86
parentfebff040b1a6781c46b3670e73fbcb707e731e7e (diff)
downloadlinux-stable-73137f59246da530c29674a506f83a18fe327946.tar.gz
linux-stable-73137f59246da530c29674a506f83a18fe327946.tar.bz2
linux-stable-73137f59246da530c29674a506f83a18fe327946.zip
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 <seanjc@google.com> Closes: https://lore.kernel.org/kvm/ZkU3_y0UoPk5yAeK@google.com/ Fixes: 8eb01900b018 ("KVM: SEV: Implement gmem hook for invalidating private pages") Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/svm/sev.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 39f8eeea5659..526b9bfb7234 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -4682,6 +4682,9 @@ void sev_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end)
{
kvm_pfn_t pfn;
+ if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
+ return;
+
pr_debug("%s: PFN start 0x%llx PFN end 0x%llx\n", __func__, start, end);
for (pfn = start; pfn < end;) {
@@ -4690,11 +4693,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))
- goto next_pfn;
-
- if (!assigned)
+ if (rc || !assigned)
goto next_pfn;
use_2m_update = IS_ALIGNED(pfn, PTRS_PER_PMD) &&