Commit 878b8efa authored by Yosry Ahmed's avatar Yosry Ahmed Committed by Sean Christopherson
Browse files

KVM: SVM: Treat mapping failures equally in VMLOAD/VMSAVE emulation



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 01ddcdc5 ("KVM: nSVM: Always inject a #GP if
mapping VMCB12 fails on nested VMRUN"), treat all failures equally.

Fixes: 8c5fbf1a ("KVM/nSVM: Use the new mapping API for mapping guest memory")
Signed-off-by: default avatarYosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260316202732.3164936-7-yosry@kernel.org


Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent 783cf7d0
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -2204,9 +2204,7 @@ 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)
	if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmcb12_gpa), &map)) {
		kvm_inject_gp(vcpu, 0);
		return 1;
	}