]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: SEV: Ignore MMIO requests of length '0'
authorSean Christopherson <seanjc@google.com>
Fri, 1 May 2026 20:22:27 +0000 (13:22 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 29 May 2026 18:25:28 +0000 (20:25 +0200)
Explicitly ignore MMIO requests of length '0', so that setting up the
software scratch area (and other code) doesn't have to worry about
underflowing the length, and to allow for special casing '0' in the
future.

Fixes: 8f423a80d299 ("KVM: SVM: Support MMIO for an SEV-ES guest")
Cc: stable@vger.kernel.org
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20260501202250.2115252-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/sev.c

index 23170b64f4a33dbe3dd9925650e811f70ab67484..fb2174b6d1ba43aac9ad9feb88b9a6bb51046877 100644 (file)
@@ -4497,13 +4497,17 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
        case SVM_VMGEXIT_MMIO_READ:
        case SVM_VMGEXIT_MMIO_WRITE: {
                bool is_write = control->exit_code == SVM_VMGEXIT_MMIO_WRITE;
+               u64 len = control->exit_info_2;
 
-               ret = setup_vmgexit_scratch(svm, !is_write, control->exit_info_2);
+               if (!len)
+                       return 1;
+
+               ret = setup_vmgexit_scratch(svm, !is_write, len);
                if (ret)
                        break;
 
-               ret = kvm_sev_es_mmio(vcpu, is_write, control->exit_info_1,
-                                     control->exit_info_2, svm->sev_es.ghcb_sa);
+               ret = kvm_sev_es_mmio(vcpu, is_write, control->exit_info_1, len,
+                                     svm->sev_es.ghcb_sa);
                break;
        }
        case SVM_VMGEXIT_NMI_COMPLETE: