lkml.org 
[lkml]   [2021]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH 6/6] KVM: VMX: enable IPI virtualization
From
Date
On 19/07/21 14:38, Zeng Guang wrote:
>> 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.
>
> enable_ipiv associate with "IPI virtualization" setting in tertiary
> exec controls and enable_apicv which depends on cpu_has_vmx_apicv().
> kvm_vcpu_apicv_active still can be false even if enable_ipiv is true,
> e.g. in case irqchip not emulated in kernel.

Right, kvm_vcpu_apicv_active *is* set in init_vmcs. But there's an
"if (kvm_vcpu_apicv_active(&vmx->vcpu))" above. You can just stick

if (enable_ipicv)
install_pid(vmx);

inside there. As to the other occurrences of vmx->ipiv_active, look here:

> + if (!kvm_vcpu_apicv_active(vcpu))
> + return;
> +
> + if ((!kvm_arch_has_assigned_device(vcpu->kvm) ||
> + !irq_remapping_cap(IRQ_POSTING_CAP)) &&
> + !to_vmx(vcpu)->ipiv_active)
> return;
>

This one can be enable_ipiv because APICv must be active.

> + if (!kvm_vcpu_apicv_active(vcpu))
> + return 0;
> +
> + /* Put vCPU into a list and set NV to wakeup vector if it is
> + * one of the following cases:
> + * 1. any assigned device is in use.
> + * 2. IPI virtualization is enabled.
> + */
> + if ((!kvm_arch_has_assigned_device(vcpu->kvm) ||
> + !irq_remapping_cap(IRQ_POSTING_CAP)) && !to_vmx(vcpu)->ipiv_active)
> return 0;

This one can be !enable_ipiv because APICv must be active.

>
> @@ -3870,6 +3877,8 @@ static void vmx_update_msr_bitmap_x2apic(struct kvm_vcpu *vcpu, u8 mode)
> vmx_enable_intercept_for_msr(vcpu, X2APIC_MSR(APIC_TMCCT), MSR_TYPE_RW);
> vmx_disable_intercept_for_msr(vcpu, X2APIC_MSR(APIC_EOI), MSR_TYPE_W);
> vmx_disable_intercept_for_msr(vcpu, X2APIC_MSR(APIC_SELF_IPI), MSR_TYPE_W);
> + vmx_set_intercept_for_msr(vcpu, X2APIC_MSR(APIC_ICR),
> + MSR_TYPE_RW, !to_vmx(vcpu)->ipiv_active);
> }
> }

Is inside "if (mode & MSR_BITMAP_MODE_X2APIC_APICV)" so APICv must be
activ; so it can be enable_ipiv as well.

In conclusion, you do not need vmx->ipiv_active.

Paolo

\
 
 \ /
  Last update: 2021-07-19 15:58    [W:1.236 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site