diff options
author | Robert Mustacchi <rm@joyent.com> | 2011-06-03 10:58:57 -0700 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2011-06-03 10:58:57 -0700 |
commit | 9d50cf8230354b464fe8df697eed20df04f08a84 (patch) | |
tree | 71719b4117a02658087706a980e7eae068aaaf10 | |
parent | c52f5bc0b1638576d0f75fe6fdebab7bc86801a7 (diff) | |
download | illumos-kvm-9d50cf8230354b464fe8df697eed20df04f08a84.tar.gz |
HVM-278 remove duplicate ioapic code
-rw-r--r-- | kvm_ioapic.c | 64 | ||||
-rw-r--r-- | kvm_x86.c | 79 |
2 files changed, 33 insertions, 110 deletions
diff --git a/kvm_ioapic.c b/kvm_ioapic.c index 09c88f1..3e53bcf 100644 --- a/kvm_ioapic.c +++ b/kvm_ioapic.c @@ -41,32 +41,12 @@ #include "kvm_ioapic.h" #include "irq.h" -static int -ioapic_deliver(struct kvm_ioapic *ioapic, int irq) -{ - union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq]; - struct kvm_lapic_irq irqe; - - irqe.dest_id = entry->fields.dest_id; - irqe.vector = entry->fields.vector; - irqe.dest_mode = entry->fields.dest_mode; - irqe.trig_mode = entry->fields.trig_mode; - irqe.delivery_mode = entry->fields.delivery_mode << 8; - irqe.level = 1; - irqe.shorthand = 0; +static int ioapic_deliver(struct kvm_ioapic *, int); -#ifdef CONFIG_X86 - /* Always delivery PIT interrupt to vcpu 0 */ - if (irq == 0) { - irqe.dest_mode = 0; /* Physical mode. */ - /* - * need to read apic_id from apic regiest since - * it can be rewritten - */ - irqe.dest_id = ioapic->kvm->bsp_vcpu->vcpu_id; - } -#endif - return (kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe)); +struct kvm_ioapic * +ioapic_irqchip(struct kvm *kvm) +{ + return (kvm->arch.vioapic); } static unsigned long @@ -191,6 +171,34 @@ ioapic_write_indirect(struct kvm_ioapic *ioapic, uint32_t val) } } +static int +ioapic_deliver(struct kvm_ioapic *ioapic, int irq) +{ + union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq]; + struct kvm_lapic_irq irqe; + + irqe.dest_id = entry->fields.dest_id; + irqe.vector = entry->fields.vector; + irqe.dest_mode = entry->fields.dest_mode; + irqe.trig_mode = entry->fields.trig_mode; + irqe.delivery_mode = entry->fields.delivery_mode << 8; + irqe.level = 1; + irqe.shorthand = 0; + +#ifdef CONFIG_X86 + /* Always delivery PIT interrupt to vcpu 0 */ + if (irq == 0) { + irqe.dest_mode = 0; /* Physical mode. */ + /* + * need to read apic_id from apic regiest since + * it can be rewritten + */ + irqe.dest_id = ioapic->kvm->bsp_vcpu->vcpu_id; + } +#endif + return (kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe)); +} + int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level) { @@ -464,9 +472,3 @@ kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state) return (0); } - -struct kvm_ioapic * -ioapic_irqchip(struct kvm *kvm) -{ - return (kvm->arch.vioapic); -} @@ -40,7 +40,6 @@ #include "percpu-defs.h" #include "kvm_coalesced_mmio.h" #include "kvm.h" -#include "kvm_ioapic.h" #include "irq.h" #include "kvm_i8254.h" #include "kvm_lapic.h" @@ -475,84 +474,6 @@ kvm_inject_nmi(struct kvm_vcpu *vcpu) vcpu->arch.nmi_pending = 1; } - -static int -ioapic_deliver(struct kvm_ioapic *ioapic, int irq) -{ - union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq]; - struct kvm_lapic_irq irqe; - - irqe.dest_id = entry->fields.dest_id; - irqe.vector = entry->fields.vector; - irqe.dest_mode = entry->fields.dest_mode; - irqe.trig_mode = entry->fields.trig_mode; - irqe.delivery_mode = entry->fields.delivery_mode << 8; - irqe.level = 1; - irqe.shorthand = 0; - -#ifdef CONFIG_X86 - /* Always delivery PIT interrupt to vcpu 0 */ - if (irq == 0) { - irqe.dest_mode = 0; /* Physical mode. */ - /* - * need to read apic_id from apic regiest since - * it can be rewritten - */ - irqe.dest_id = ioapic->kvm->bsp_vcpu->vcpu_id; - } -#endif - return (kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe)); -} - -static int -ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx) -{ - union kvm_ioapic_redirect_entry *pent; - int injected = -1; - - pent = &ioapic->redirtbl[idx]; - - if (!pent->fields.mask) { - injected = ioapic_deliver(ioapic, idx); - if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG) - pent->fields.remote_irr = 1; - } - return (injected); -} - -static void -__kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int vector, int trigger_mode) -{ - int i; - - for (i = 0; i < IOAPIC_NUM_PINS; i++) { - union kvm_ioapic_redirect_entry *ent = &ioapic->redirtbl[i]; - - if (ent->fields.vector != vector) - continue; - - /* - * We are dropping lock while calling ack notifiers because ack - * notifier callbacks for assigned devices call into IOAPIC - * recursively. Since remote_irr is cleared only after call - * to notifiers if the same vector will be delivered while lock - * is dropped it will be put into irr and will be delivered - * after ack notifier returns. - */ - mutex_exit(&ioapic->lock); - kvm_notify_acked_irq(ioapic->kvm, KVM_IRQCHIP_IOAPIC, i); - mutex_enter(&ioapic->lock); - - if (trigger_mode != IOAPIC_LEVEL_TRIG) - continue; - - ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG); - ent->fields.remote_irr = 0; - if (!ent->fields.mask && (ioapic->irr & (1 << i))) - ioapic_service(ioapic, i); - } -} - extern void kvm_timer_fire(void *); extern int kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu); |