From: Peter Dinda Date: Tue, 28 May 2013 22:24:04 +0000 (-0500) Subject: Lock bugfixes - missing lock deinits This also adds deinit calls in the linux_module... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=1f8ac11d4550b1113d9a8c23e62b236cb8ad8404 Lock bugfixes - missing lock deinits This also adds deinit calls in the linux_module code so that these locks are correclty tracked --- diff --git a/linux_module/iface-console.c b/linux_module/iface-console.c index e91b46e..9364496 100644 --- a/linux_module/iface-console.c +++ b/linux_module/iface-console.c @@ -417,6 +417,8 @@ static void palacios_tty_close(void * console) { remove_guest_ctrl(cons->guest, V3_VM_CONSOLE_CONNECT); deinit_queue(cons->queue); + + palacios_spinlock_deinit(&(cons->lock)); palacios_free(cons); } diff --git a/linux_module/iface-file.c b/linux_module/iface-file.c index da5aabb..1e3d1ad 100644 --- a/linux_module/iface-file.c +++ b/linux_module/iface-file.c @@ -256,6 +256,8 @@ static int palacios_file_close(void * file_ptr) { list_del(&(pfile->file_node)); + palacios_spinlock_deinit(&(pfile->lock)); + palacios_free(pfile->path); palacios_free(pfile); diff --git a/linux_module/iface-host-dev.c b/linux_module/iface-host-dev.c index 6edc26b..86b0e0c 100644 --- a/linux_module/iface-host-dev.c +++ b/linux_module/iface-host-dev.c @@ -839,6 +839,8 @@ static int palacios_host_dev_close(v3_host_dev_t hostdev) palacios_spinlock_unlock_irqrestore(&(dev->lock),f2); palacios_spinlock_unlock_irqrestore(&(host_dev->lock),f1); + palacios_spinlock_deinit(&(dev->lock)); + palacios_host_dev_user_free(dev); return 0; @@ -1343,7 +1345,9 @@ static int host_dev_guest_init(struct v3_guest * guest, void ** vm_data ) { static int host_dev_guest_deinit(struct v3_guest * guest, void * vm_data) { - palacios_free(vm_data); + struct palacios_host_dev * host_dev = (struct palacios_host_dev *) vm_data; + palacios_spinlock_deinit(&(host_dev->lock)); + palacios_free(host_dev); return 0; } diff --git a/linux_module/iface-host-pci-hw.h b/linux_module/iface-host-pci-hw.h index e897e13..7254edc 100644 --- a/linux_module/iface-host-pci-hw.h +++ b/linux_module/iface-host-pci-hw.h @@ -451,3 +451,9 @@ static int read_hw_pci_config(struct host_pci_device * host_dev, u32 reg, void * return 0; } + + +// +// Should be a matching teardown function here, otherwise we +// are at least leaking the lock from the lockchecker's perspective +// we would like to be able to do a palacios_spinlock_deinit() here... diff --git a/linux_module/iface-host-pci.c b/linux_module/iface-host-pci.c index 13897ab..d9622c9 100644 --- a/linux_module/iface-host-pci.c +++ b/linux_module/iface-host-pci.c @@ -232,11 +232,15 @@ static int host_pci_init( void ) { return 0; } - +static int host_pci_deinit(void) { + palacios_spinlock_deinit(&lock); + return 0; +} static struct linux_ext host_pci_ext = { .name = "HOST_PCI", .init = host_pci_init, + .deinit = host_pci_deinit, }; diff --git a/linux_module/iface-keyed-stream.c b/linux_module/iface-keyed-stream.c index 34b39dc..3fa8ebe 100644 --- a/linux_module/iface-keyed-stream.c +++ b/linux_module/iface-keyed-stream.c @@ -3156,6 +3156,8 @@ static int deinit_keyed_streams( void ) { palacios_free_htable(mem_streams,1,1); + palacios_spinlock_deinit(&(user_streams->lock)); + palacios_free(user_streams); WARNING("Deinit of Palacios Keyed Streams likely leaked memory\n"); diff --git a/linux_module/iface-packet.c b/linux_module/iface-packet.c index bf19b0d..6ec4de0 100644 --- a/linux_module/iface-packet.c +++ b/linux_module/iface-packet.c @@ -361,6 +361,8 @@ static int packet_deinit( void ) { deinit_raw_interface(iface); palacios_free(iface); } + + palacios_spinlock_deinit(&(packet_state.lock)); return 0; } diff --git a/linux_module/iface-stream.c b/linux_module/iface-stream.c index 8604254..d6c6331 100644 --- a/linux_module/iface-stream.c +++ b/linux_module/iface-stream.c @@ -280,6 +280,7 @@ static void palacios_stream_close(struct v3_stream * v3_stream) { free_ringbuf(stream->out_ring); list_del(&(stream->stream_node)); + palacios_spinlock_deinit(&(stream->lock)); palacios_free(stream); } diff --git a/linux_module/palacios-vnet-brg.c b/linux_module/palacios-vnet-brg.c index 451b5e4..1dfe8a8 100644 --- a/linux_module/palacios-vnet-brg.c +++ b/linux_module/palacios-vnet-brg.c @@ -610,6 +610,8 @@ void vnet_bridge_deinit(void){ vnet_brg_s.status = 0; + palacios_spinlock_deinit(&(vnet_brg_s.lock)); + INFO("VNET LNX Bridge Deinit Finished\n"); } diff --git a/linux_module/palacios-vnet-ctrl.c b/linux_module/palacios-vnet-ctrl.c index 308a559..fc9f195 100644 --- a/linux_module/palacios-vnet-ctrl.c +++ b/linux_module/palacios-vnet-ctrl.c @@ -1010,6 +1010,8 @@ void vnet_ctrl_deinit(void){ vnet_ctrl_s.status = 0; + palacios_spinlock_deinit(&(vnet_ctrl_s.lock)); + INFO("VNET Control Deinit Finished\n"); } diff --git a/linux_module/util-queue.c b/linux_module/util-queue.c index 249b034..0dba00b 100644 --- a/linux_module/util-queue.c +++ b/linux_module/util-queue.c @@ -20,6 +20,7 @@ void deinit_queue(struct gen_queue * queue) { while (dequeue(queue)) { ERROR("Freeing non-empty queue. PROBABLE MEMORY LEAK DETECTED\n"); } + palacios_spinlock_deinit(&(queue->lock)); } struct gen_queue * create_queue(unsigned int max_entries) { diff --git a/palacios/src/devices/apic.c b/palacios/src/devices/apic.c index b6c2416..86286ce 100644 --- a/palacios/src/devices/apic.c +++ b/palacios/src/devices/apic.c @@ -283,7 +283,7 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u static void set_apic_tpr(struct apic_state *apic, uint32_t val); -// No lcoking done +// No locking done static void init_apic_state(struct apic_state * apic, uint32_t id) { apic->base_addr = DEFAULT_BASE_ADDR; @@ -1872,12 +1872,16 @@ static int apic_free(struct apic_dev_state * apic_dev) { v3_remove_timer(core, apic->timer); } + v3_lock_deinit(&(apic->irq_queue.lock)); + // unhook memory } v3_unhook_msr(vm, BASE_ADDR_MSR); + v3_lock_deinit(&(apic_dev->state_lock)); + V3_Free(apic_dev); return 0; } diff --git a/palacios/src/devices/keyboard.c b/palacios/src/devices/keyboard.c index f0d0c3a..2751cc0 100644 --- a/palacios/src/devices/keyboard.c +++ b/palacios/src/devices/keyboard.c @@ -1074,6 +1074,8 @@ static int keyboard_free(struct keyboard_internal * kbd) { // unhook host events + v3_lock_deinit(&(kbd->kb_lock)); + V3_Free(kbd); return 0; } diff --git a/palacios/src/devices/lnx_virtio_nic.c b/palacios/src/devices/lnx_virtio_nic.c index da3dd9d..7ead43d 100644 --- a/palacios/src/devices/lnx_virtio_nic.c +++ b/palacios/src/devices/lnx_virtio_nic.c @@ -753,6 +753,9 @@ static int virtio_free(struct virtio_dev_state * virtio) { V3_Free(backend); } + v3_lock_deinit(&(virtio->rx_lock)); + v3_lock_deinit(&(virtio->tx_lock)); + V3_Free(virtio); return 0; diff --git a/palacios/src/devices/lnx_virtio_vnet.c b/palacios/src/devices/lnx_virtio_vnet.c index eb889ed..69c1836 100644 --- a/palacios/src/devices/lnx_virtio_vnet.c +++ b/palacios/src/devices/lnx_virtio_vnet.c @@ -552,7 +552,10 @@ static int virtio_free(struct virtio_vnet_state * vnet_state) { // unregister from PCI + v3_lock_deinit(&(vnet_state->lock)); + V3_Free(vnet_state); + return 0; } diff --git a/palacios/src/devices/nvram.c b/palacios/src/devices/nvram.c index 912b5f5..f75a227 100644 --- a/palacios/src/devices/nvram.c +++ b/palacios/src/devices/nvram.c @@ -779,6 +779,8 @@ static int nvram_free(struct nvram_internal * nvram_state) { v3_remove_timer(info,nvram_state->timer); } + v3_lock_deinit(&(nvram_state->nvram_lock)); + V3_Free(nvram_state); return 0; } diff --git a/palacios/src/devices/telnet_cons.c b/palacios/src/devices/telnet_cons.c index 98562af..4e7471b 100644 --- a/palacios/src/devices/telnet_cons.c +++ b/palacios/src/devices/telnet_cons.c @@ -397,6 +397,8 @@ static int cons_free(struct cons_state * state) { // kill thread... ? + v3_lock_deinit(&(state->cons_lock)); + V3_Free(state); return 0; } diff --git a/palacios/src/palacios/vmm_intr.c b/palacios/src/palacios/vmm_intr.c index 5b5dad6..2e78872 100644 --- a/palacios/src/palacios/vmm_intr.c +++ b/palacios/src/palacios/vmm_intr.c @@ -72,6 +72,9 @@ void v3_deinit_intr_controllers(struct guest_info * core) { list_for_each_entry_safe(ctrlr, tmp, &(intr_state->controller_list), ctrl_node) { v3_remove_intr_controller(core, ctrlr); } + + v3_lock_deinit(&(intr_state->irq_lock)); + } @@ -93,6 +96,8 @@ void v3_deinit_intr_routers(struct v3_vm_info * vm) { list_for_each_entry_safe(rtr, tmp, &(vm->intr_routers.router_list), router_node) { v3_remove_intr_router(vm, rtr); } + + v3_lock_deinit(&(vm->intr_routers.irq_lock)); } void * v3_register_intr_controller(struct guest_info * info, struct intr_ctrl_ops * ops, void * priv_data) {