Re: [PATCH v2 2/6] KVM: nSVM: Simplify error handling of nested_svm_copy_vmcb12_to_cache()
From: Yosry Ahmed
Date: Thu Mar 12 2026 - 17:02:16 EST
> I strongly dislike the if-elif approach, because it makes unnecessarily hard to
> see that *all* ret !=0 cases are handled, i.e. that overwriting ret below is ok.
>
> The comment is also super confusing, because there's no #UD in sight, but there
> is a #GP.
>
> This is what I have locally and am planning on pushing to kvm-x86/next.
>
> ret = nested_svm_copy_vmcb12_to_cache(vcpu, vmcb12_gpa);
> if (ret) {
> if (ret == -EFAULT) {
> kvm_inject_gp(vcpu, 0);
> return 1;
> }
>
> /* Advance RIP past VMRUN as part of the nested #VMEXIT. */
> return kvm_skip_emulated_instruction(vcpu);
> }
>
> /* At this point, VMRUN is guaranteed to not fault; advance RIP. */
> ret = kvm_skip_emulated_instruction(vcpu);
Looks good. I will rebase on top of this and drop the patch before
sending the next version.