From: Jack Lange Date: Thu, 23 Apr 2009 00:59:17 +0000 (-0500) Subject: added memory unhooking function X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=70d3ac1e7be22e42fbf8f778367e9bf6d32e5b7f added memory unhooking function --- diff --git a/palacios/include/palacios/vmm_mem.h b/palacios/include/palacios/vmm_mem.h index f87c8d0..927577e 100644 --- a/palacios/include/palacios/vmm_mem.h +++ b/palacios/include/palacios/vmm_mem.h @@ -99,12 +99,14 @@ int v3_hook_write_mem(struct guest_info * info, addr_t guest_addr_start, addr_t - +int v3_unhook_mem(struct guest_info * info, addr_t guest_addr_start); void v3_delete_shadow_region(struct guest_info * info, struct v3_shadow_region * reg); + + struct v3_shadow_region * v3_get_shadow_region(struct guest_info * info, addr_t guest_addr); addr_t v3_get_shadow_addr(struct v3_shadow_region * reg, addr_t guest_addr); diff --git a/palacios/src/devices/pci.c b/palacios/src/devices/pci.c index 6b5472d..602f47c 100644 --- a/palacios/src/devices/pci.c +++ b/palacios/src/devices/pci.c @@ -566,7 +566,7 @@ static void init_pci_busses(struct pci_internal * pci_state) { static int pci_init_device(struct vm_device * dev) { - struct pci_internal * pci_state = (struct pci_internal *)dev->private_data;; + struct pci_internal * pci_state = (struct pci_internal *)dev->private_data; int i = 0; PrintDebug("pci: init_device\n"); diff --git a/palacios/src/palacios/vmm_mem.c b/palacios/src/palacios/vmm_mem.c index 659fd27..dc3f1ae 100644 --- a/palacios/src/palacios/vmm_mem.c +++ b/palacios/src/palacios/vmm_mem.c @@ -150,6 +150,20 @@ int v3_hook_full_mem(struct guest_info * info, addr_t guest_addr_start, addr_t g } +// This will unhook the memory hook registered at start address +// We do not support unhooking subregions +int v3_unhook_mem(struct guest_info * info, addr_t guest_addr_start) { + struct v3_shadow_region * reg = v3_get_shadow_region(info, guest_addr_start); + + if ((reg->host_type != SHDW_REGION_FULL_HOOK) || + (reg->host_type != SHDW_REGION_WRITE_HOOK)) { + PrintError("Trying to unhook a non hooked memory region (addr=%p)\n", (void *)guest_addr_start); + return -1; + } + + return v3_delete_shadow_region(info, reg); +} + static inline