Re: [PATCH v2 3/5] KVM: nSVM: Mark CR3 as dirty when loading CR3 on nested transitions

From: Yosry Ahmed

Date: Wed Nov 25 2026 - 16:36:56 EST


On Tue, Nov 17, 2026 at 1:09 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> Mark CR3 as dirty when loading CR3 on nested VMRUN and nested #VMEXIT, even
> though svm_load_mmu_pgd() unconditionally updates vmcb.save.CR3, i.e. never
> consumes the dirty bit. This will allow deduplicating nearly-identical
> code between nVMX and nSVM with respect to loading CR3.
>
> Note, VMX consumes the dirty flag in kvm_mmu_new_pgd(), i.e. having nVMX
> mark CR3 after the fact isn't a viable option. Marking CR3 dirty in nVMX
> code before invoking the to-be-common helper also isn't safe in general, as
> it's theoretically possible KVM could observe+consume the dirty flag before
> vcpu->arch.cr3 is updated (even though that's extremely unlikely to ever be
> the case).
>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>

Reviewed-by: Yosry Ahmed <yosry@xxxxxxxxxx>