]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: Treat mapping failures equally in VMLOAD/VMSAVE emulation
authorYosry Ahmed <yosry@kernel.org>
Mon, 16 Mar 2026 20:27:29 +0000 (20:27 +0000)
committerSean Christopherson <seanjc@google.com>
Fri, 3 Apr 2026 23:08:03 +0000 (16:08 -0700)
Currently, a #GP is only injected if kvm_vcpu_map() fails with -EINVAL.
But it could also fail with -EFAULT if creating a host mapping failed.
Inject a #GP in all cases, no reason to treat failure modes differently.

Similar to commit 01ddcdc55e09 ("KVM: nSVM: Always inject a #GP if
mapping VMCB12 fails on nested VMRUN"), treat all failures equally.

Fixes: 8c5fbf1a7231 ("KVM/nSVM: Use the new mapping API for mapping guest memory")
Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260316202732.3164936-7-yosry@kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c

index 7d0d95f40cd25952e754cf5da353535845ee6c37..b83d524a6e781fdb1b8ac1e8f371d3f1f0ee5f68 100644 (file)
@@ -2204,10 +2204,8 @@ static int vmload_vmsave_interception(struct kvm_vcpu *vcpu, bool vmload)
                return 1;
        }
 
-       ret = kvm_vcpu_map(vcpu, gpa_to_gfn(vmcb12_gpa), &map);
-       if (ret) {
-               if (ret == -EINVAL)
-                       kvm_inject_gp(vcpu, 0);
+       if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmcb12_gpa), &map)) {
+               kvm_inject_gp(vcpu, 0);
                return 1;
        }