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

Yosry Ahmed
2026-04-22T19:48:34Z

On Wed, Apr 22, 2026 at 11:56:43AM +0530, Nikunj A. Dadhania wrote:
>
>
> On 4/22/2026 4:45 AM, Sean Christopherson wrote:
> > On Tue, Apr 21, 2026, Yosry Ahmed wrote:
> >>> @@ -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?
>
> Are you suggesting something like below:

Yes.

>
> void svm_update_cpu_dirty_logging(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
> struct vmcb *vmcb01 = svm->vmcb01.ptr;
>
> if (WARN_ON_ONCE(!vcpu->kvm->arch.cpu_dirty_log_size))
> return;
>
> /*
> * 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))
> vmcb01->control.nested_ctl |= SVM_NESTED_CTL_PML_ENABLE;
> else
> vmcb01->control.nested_ctl &= ~SVM_NESTED_CTL_PML_ENABLE;
>
> vmcb_mark_dirty(vmcb01, VMCB_NPT);
> }