diff options
Diffstat (limited to 'drivers/kvm')
-rw-r--r-- | drivers/kvm/irq.h | 2 | ||||
-rw-r--r-- | drivers/kvm/kvm_main.c | 4 | ||||
-rw-r--r-- | drivers/kvm/lapic.c | 19 |
3 files changed, 11 insertions, 14 deletions
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h index 11fc014e2b30..508280ea6fcf 100644 --- a/drivers/kvm/irq.h +++ b/drivers/kvm/irq.h | |||
@@ -139,7 +139,7 @@ int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu); | |||
139 | int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu); | 139 | int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu); |
140 | int kvm_create_lapic(struct kvm_vcpu *vcpu); | 140 | int kvm_create_lapic(struct kvm_vcpu *vcpu); |
141 | void kvm_lapic_reset(struct kvm_vcpu *vcpu); | 141 | void kvm_lapic_reset(struct kvm_vcpu *vcpu); |
142 | void kvm_free_apic(struct kvm_lapic *apic); | 142 | void kvm_free_lapic(struct kvm_vcpu *vcpu); |
143 | u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu); | 143 | u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu); |
144 | void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8); | 144 | void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8); |
145 | void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value); | 145 | void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value); |
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 2bb1f2f66efa..b19734606cd9 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -268,10 +268,8 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_init); | |||
268 | 268 | ||
269 | void kvm_vcpu_uninit(struct kvm_vcpu *vcpu) | 269 | void kvm_vcpu_uninit(struct kvm_vcpu *vcpu) |
270 | { | 270 | { |
271 | kvm_free_lapic(vcpu); | ||
271 | kvm_mmu_destroy(vcpu); | 272 | kvm_mmu_destroy(vcpu); |
272 | if (vcpu->apic) | ||
273 | hrtimer_cancel(&vcpu->apic->timer.dev); | ||
274 | kvm_free_apic(vcpu->apic); | ||
275 | free_page((unsigned long)vcpu->pio_data); | 273 | free_page((unsigned long)vcpu->pio_data); |
276 | free_page((unsigned long)vcpu->run); | 274 | free_page((unsigned long)vcpu->run); |
277 | } | 275 | } |
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c index 238fcad3cece..8e8dab08be58 100644 --- a/drivers/kvm/lapic.c +++ b/drivers/kvm/lapic.c | |||
@@ -762,19 +762,17 @@ static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr) | |||
762 | return ret; | 762 | return ret; |
763 | } | 763 | } |
764 | 764 | ||
765 | void kvm_free_apic(struct kvm_lapic *apic) | 765 | void kvm_free_lapic(struct kvm_vcpu *vcpu) |
766 | { | 766 | { |
767 | if (!apic) | 767 | if (!vcpu->apic) |
768 | return; | 768 | return; |
769 | 769 | ||
770 | hrtimer_cancel(&apic->timer.dev); | 770 | hrtimer_cancel(&vcpu->apic->timer.dev); |
771 | 771 | ||
772 | if (apic->regs_page) { | 772 | if (vcpu->apic->regs_page) |
773 | __free_page(apic->regs_page); | 773 | __free_page(vcpu->apic->regs_page); |
774 | apic->regs_page = 0; | ||
775 | } | ||
776 | 774 | ||
777 | kfree(apic); | 775 | kfree(vcpu->apic); |
778 | } | 776 | } |
779 | 777 | ||
780 | /* | 778 | /* |
@@ -962,7 +960,7 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) | |||
962 | if (apic->regs_page == NULL) { | 960 | if (apic->regs_page == NULL) { |
963 | printk(KERN_ERR "malloc apic regs error for vcpu %x\n", | 961 | printk(KERN_ERR "malloc apic regs error for vcpu %x\n", |
964 | vcpu->vcpu_id); | 962 | vcpu->vcpu_id); |
965 | goto nomem; | 963 | goto nomem_free_apic; |
966 | } | 964 | } |
967 | apic->regs = page_address(apic->regs_page); | 965 | apic->regs = page_address(apic->regs_page); |
968 | memset(apic->regs, 0, PAGE_SIZE); | 966 | memset(apic->regs, 0, PAGE_SIZE); |
@@ -980,8 +978,9 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) | |||
980 | apic->dev.private = apic; | 978 | apic->dev.private = apic; |
981 | 979 | ||
982 | return 0; | 980 | return 0; |
981 | nomem_free_apic: | ||
982 | kfree(apic); | ||
983 | nomem: | 983 | nomem: |
984 | kvm_free_apic(apic); | ||
985 | return -ENOMEM; | 984 | return -ENOMEM; |
986 | } | 985 | } |
987 | EXPORT_SYMBOL_GPL(kvm_create_lapic); | 986 | EXPORT_SYMBOL_GPL(kvm_create_lapic); |