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

Nikunj A. Dadhania
2026-04-22T06:26:58Z

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:

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);
}

>
> Yeah, I don't see the point of patch 6. guard(svm_vmcb01) doesn't exist in the
> current code base because it's not needed.

Sure, I can drop patch6. I wanted to keep the code similar.

>
>> IIUC VMX needs this because it updates the loaded VMCS, but the VMCB is
>> just memory.
>
> Yep. If VMWRITE could target an arbitrary VMCS pointer, VMX wouldn't need the
> helper either.

Regards
Nikunj