Re: [PATCH v6 7/7] KVM: SVM: Add Page modification logging support

Yosry Ahmed
2026-04-21T23:04:14Z

> @@ -3253,6 +3278,54 @@ static int bus_lock_exit(struct kvm_vcpu *vcpu)
> return 0;
> }
>
> +void svm_update_cpu_dirty_logging(struct kvm_vcpu *vcpu)
> +{
> + struct vcpu_svm *svm = to_svm(vcpu);
> +
> + if (WARN_ON_ONCE(!vcpu->kvm->arch.cpu_dirty_log_size))
> + return;
> +
> + guard(svm_vmcb01)(vcpu);

Why do we need this? Why not update vmcb01 directly below?

IIUC VMX needs this because it updates the loaded VMCS, but the VMCB is
just memory.

> +
> + /*
> + * Note, nr_memslots_dirty_logging can be changed concurrent with this
> + * code, but in that case another update request will be made and so
> + * the guest will never run with a stale PML value.
> + */
> + if (atomic_read(&vcpu->kvm->nr_memslots_dirty_logging))
> + svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_PML_ENABLE;
> + else
> + svm->vmcb->control.nested_ctl &= ~SVM_NESTED_CTL_PML_ENABLE;
> +
> + vmcb_mark_dirty(svm->vmcb, VMCB_NPT);
> +}
> +