Re: [PATCH 6/6] KVM: VMX: enable IPI virtualization

From: Paolo Bonzini
Date: Sun Jul 18 2021 - 16:33:00 EST


On 17/07/21 05:55, Zeng Guang wrote:
     if (_cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS) {
-        u64 opt3 = 0;
+        u64 opt3 = enable_ipiv ? TERTIARY_EXEC_IPI_VIRT : 0;
         u64 min3 = 0;

I like the idea of changing opt3, but it's different from how setup_vmcs_config works for the other execution controls.  Let me think if it makes sense to clean this up, and move the handling of other module parameters from hardware_setup() to setup_vmcs_config().

May be an exception for ipiv feature ?

Yes, possibly. I'll look into using this idea for other parameters.

+    if (vmx->ipiv_active)
+        install_pid(vmx);

This should be if (enable_ipiv) instead, I think.

In fact, in all other places that are using vmx->ipiv_active, you can actually replace it with enable_ipiv; they are all reached only with kvm_vcpu_apicv_active(vcpu) == true.

enable_ipiv as a global variable indicates the hardware capability to enable IPIv. Each VM may have different IPIv configuration according to kvm_vcpu_apicv_active status. So we use ipiv_active per VM to enclose IPIv related operations.

Understood, but in practice all uses of vmx->ipiv_active are guarded by kvm_vcpu_apicv_active so they are always reached with vmx->ipiv_active == enable_ipiv.

The one above instead seems wrong and should just use enable_ipiv.

Paolo