Re: [PATCH v2] KVM: nSVM: Use vcpu->arch.cr2 when updating vmcb12 on nested #VMEXIT
From: Sean Christopherson
Date: Thu Mar 05 2026 - 12:19:59 EST
On Tue, 03 Feb 2026 20:10:10 +0000, Yosry Ahmed wrote:
> KVM currently uses the value of CR2 from vmcb02 to update vmcb12 on
> nested #VMEXIT. This value is incorrect in some cases, causing L1 to run
> L2 with a corrupted CR2. This could lead to segfaults or data corruption
> if L2 is in the middle of handling a #PF and reads a corrupted CR2. Use
> the correct value in vcpu->arch.cr2 instead.
>
> The value in vcpu->arch.cr2 is sync'd to vmcb02 shortly before a VMRUN
> of L2, and sync'd back to vcpu->arch.cr2 shortly after. The value are
> only out-of-sync in two cases: after save+restore, and after a #PF is
> injected into L2. In either case, if a #VMEXIT to L1 is synthesized
> before L2 runs, using the value in vmcb02 would be incorrect.
>
> [...]
Applied to kvm-x86 nested, thanks!
[1/1] KVM: nSVM: Use vcpu->arch.cr2 when updating vmcb12 on nested #VMEXIT
https://github.com/kvm-x86/linux/commit/5c247d08bc81
--
https://github.com/kvm-x86/linux/tree/next