KVM: Split IOAPIC reset function and export for kernel RESET
authorEddie Dong <eddie.dong@intel.com>
Wed, 10 Oct 2007 10:15:54 +0000 (12:15 +0200)
committerAvi Kivity <avi@qumranet.com>
Wed, 30 Jan 2008 15:52:55 +0000 (17:52 +0200)
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/ioapic.c
drivers/kvm/irq.h

index e14b7c724e6727b7d62b34c5d53dd1d5a31747e5..cf1d50b3549bb7b67776157d02230a11e1205d6c 100644 (file)
@@ -371,18 +371,27 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
        }
 }
 
+void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
+{
+       int i;
+
+       for (i = 0; i < IOAPIC_NUM_PINS; i++)
+               ioapic->redirtbl[i].fields.mask = 1;
+       ioapic->base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
+       ioapic->ioregsel = 0;
+       ioapic->irr = 0;
+       ioapic->id = 0;
+}
+
 int kvm_ioapic_init(struct kvm *kvm)
 {
        struct kvm_ioapic *ioapic;
-       int i;
 
        ioapic = kzalloc(sizeof(struct kvm_ioapic), GFP_KERNEL);
        if (!ioapic)
                return -ENOMEM;
        kvm->vioapic = ioapic;
-       for (i = 0; i < IOAPIC_NUM_PINS; i++)
-               ioapic->redirtbl[i].fields.mask = 1;
-       ioapic->base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
+       kvm_ioapic_reset(ioapic);
        ioapic->dev.read = ioapic_mmio_read;
        ioapic->dev.write = ioapic_mmio_write;
        ioapic->dev.in_range = ioapic_in_range;
index e08ae1002bd8589b009768b5b385d9226e346d25..5ad3cfd7622d79ed1adafb9a9a6633fd830bff47 100644 (file)
@@ -140,6 +140,7 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu);
 int kvm_create_lapic(struct kvm_vcpu *vcpu);
 void kvm_lapic_reset(struct kvm_vcpu *vcpu);
 void kvm_pic_reset(struct kvm_kpic_state *s);
+void kvm_ioapic_reset(struct kvm_ioapic *ioapic);
 void kvm_free_lapic(struct kvm_vcpu *vcpu);
 u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
 void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);