Re: [RESEND PATCH ] KVM: VMX: Enable/disable PML when dirty logging gets enabled/disabled

From: Paolo Bonzini
Date: Thu Feb 11 2021 - 04:16:21 EST


On 10/02/21 22:23, Makarand Sonare wrote:
+void vmx_update_pml_in_vmcs(struct kvm_vcpu *vcpu)
+{
+ if (cpu_has_secondary_exec_ctrls()) {
+ if (is_guest_mode(vcpu)) {
+ to_vmx(vcpu)->nested.deferred_update_pml_vmcs = true;
+ return;
+ }
+
+ if (vcpu->kvm->arch.pml_enabled)
+ vmcs_set_bits(SECONDARY_VM_EXEC_CONTROL,
+ SECONDARY_EXEC_ENABLE_PML);
+ else
+ vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL,
+ SECONDARY_EXEC_ENABLE_PML);
+ }
+}


Since the execution controls are shadowed, they can be read quite efficiently. This means that there's no need for vcpu->kvm->arch.pml_enabled, and also that the copy can be done unconditionally in prepare_vmcs02 and nested_vmx_vmexit.

If the above is not true, we should at least combine change_vmcs01_virtual_apic_mode, reload_vmcs01_apic_access_page and the new field in a single bit field, for example vmx->nested.dirty_vmcs01_fields or vmx->nested.vmexit_requests.

In any case I expect Sean to take care of submitting this patch and I have to do nothing more about it, right?

Paolo