mirror of https://gitee.com/openkylin/linux.git
KVM: x86: check against irqchip_mode in kvm_set_routing_entry()
Let's replace the checks for pic_in_kernel() and ioapic_in_kernel() by checks against irqchip_mode. Also make sure that creation of any route is only possible if we have an lapic in kernel (irqchip_in_kernel()) or if we are currently inititalizing the irqchip. This is necessary to switch pic_in_kernel() and ioapic_in_kernel() to irqchip_mode, too. Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
This commit is contained in:
parent
637e3f86fa
commit
8bf463f3ba
|
@ -282,24 +282,26 @@ int kvm_set_routing_entry(struct kvm *kvm,
|
||||||
int delta;
|
int delta;
|
||||||
unsigned max_pin;
|
unsigned max_pin;
|
||||||
|
|
||||||
|
/* also allow creation of routes during KVM_IRQCHIP_INIT_IN_PROGRESS */
|
||||||
|
if (kvm->arch.irqchip_mode == KVM_IRQCHIP_NONE)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
/* Matches smp_wmb() when setting irqchip_mode */
|
||||||
|
smp_rmb();
|
||||||
switch (ue->type) {
|
switch (ue->type) {
|
||||||
case KVM_IRQ_ROUTING_IRQCHIP:
|
case KVM_IRQ_ROUTING_IRQCHIP:
|
||||||
|
if (irqchip_split(kvm))
|
||||||
|
goto out;
|
||||||
delta = 0;
|
delta = 0;
|
||||||
switch (ue->u.irqchip.irqchip) {
|
switch (ue->u.irqchip.irqchip) {
|
||||||
case KVM_IRQCHIP_PIC_SLAVE:
|
case KVM_IRQCHIP_PIC_SLAVE:
|
||||||
delta = 8;
|
delta = 8;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case KVM_IRQCHIP_PIC_MASTER:
|
case KVM_IRQCHIP_PIC_MASTER:
|
||||||
if (!pic_in_kernel(kvm))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
e->set = kvm_set_pic_irq;
|
e->set = kvm_set_pic_irq;
|
||||||
max_pin = PIC_NUM_PINS;
|
max_pin = PIC_NUM_PINS;
|
||||||
break;
|
break;
|
||||||
case KVM_IRQCHIP_IOAPIC:
|
case KVM_IRQCHIP_IOAPIC:
|
||||||
if (!ioapic_in_kernel(kvm))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
max_pin = KVM_IOAPIC_NUM_PINS;
|
max_pin = KVM_IOAPIC_NUM_PINS;
|
||||||
e->set = kvm_set_ioapic_irq;
|
e->set = kvm_set_ioapic_irq;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue