>>> However, adding new modes can silently make this check wrong (e.g. >>> grepping for KVM_IRQCHIP_KERNEL will no longer identify all users). Do >>> you think the optimization is worth it? >> >> I don't think we want to add new modes. > > I would prefer to write it like: > > kvm->arch.irqchip_mode > KVM_IRQCHIP_KERNEL_INIT; Agreed. > > Same assembly with simpler code. Setting KVM_IRQCHIP_KERNEL_INIT before > KVM_IRQCHIP_SPLIT would make it a bit more descriprive (and would allow > the check below as well). Okay, I added that. > >>>>> /* Matches with wmb after initializing kvm->irq_routing. */ >>>>> smp_rmb(); >>>>> diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c >>>>> index b96d389..4e4a67a 100644 >>>>> --- a/arch/x86/kvm/irq_comm.c >>>>> +++ b/arch/x86/kvm/irq_comm.c >>>>> @@ -282,22 +282,18 @@ int kvm_set_routing_entry(struct kvm *kvm, >>>>> >>>>> switch (ue->type) { >>>>> case KVM_IRQ_ROUTING_IRQCHIP: >>>>> + if (!irqchip_kernel(kvm) && !irqchip_kernel_init(kvm)) >>>>> + goto out; >>>>> delta = 0; >>>> >>>> This can be irqchip_in_kernel, after which irqchip_kernel_init can be >>>> removed. >>> >>> irqchip_in_kernel in its current form would allow KVM_IRQCHIP_SPLIT, >>> which is not what we want here, or am I missing something? >> >> Hmm, perhaps we can split the checks to rule out KVM_IRQCHIP_NONE >> outside the switch, and KVM_IRQCHIP_SPLIT here? > > Right, we don't want MSI or HV without LAPIC in kernel either. > Ok, I will see how this turns out! Thanks! -- Thanks, David