Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Lots of pedantic error checking in Palacios proper, especially for memory
[palacios.git] / palacios / src / palacios / mmu / vmm_shdw_pg_kvm.c
index fee869c..72e63af 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * This file is part of the Palacios Virtual Machine Monitor developed
- * by the V3VEE Project with funding from the United States National 
- * Science Foundation and the Department of Energy.  
- *
- * The V3VEE Project is a joint project between Northwestern University
- * and the University of New Mexico.  You can find out more at 
- * http://www.v3vee.org
- *
- * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
- * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
- * All rights reserved.
- *
- * Author: Jack Lange <jarusl@cs.northwestern.edu>
- *
- * This is free software.  You are permitted to use,
- * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ * Shadow page cache implementation that has been stolen from Linux's KVM Implementation
+ * This module is licensed under the GPL
  */
 
 #include <palacios/vmm_shadow_paging.h>
 #include <palacios/vmm_paging.h>
 
 
-#ifndef CONFIG_DEBUG_SHDW_CACHE
+#ifndef V3_CONFIG_DEBUG_SHDW_CACHE
 #undef PrintDebug
 #define PrintDebug(fmt, ...)
 #endif
 
-#ifdef CONFIG_SHADOW_CACHE
+#ifdef V3_CONFIG_SHADOW_CACHE
 
 struct pde_chain {
     addr_t shadow_pdes[NR_PTE_CHAIN_ENTRIES];
@@ -130,8 +116,13 @@ static void shadow_free_page (struct guest_info * core, struct shadow_page_cache
 {
     list_del(&page->link);
 
-    V3_FreePage((void *)page->page_pa);
+    V3_FreePages((void *)page->page_pa, 1);
     page->page_pa=(addr_t)V3_AllocPages(1);
+
+    if (!page->page_pa) { 
+       PrintError("Freeing shadow page failed on allocation\n");
+       return;
+    }
        
     list_add(&page->link,&core->free_pages);
     ++core->n_free_shadow_pages;       
@@ -177,7 +168,7 @@ static void free_shadow_pages(struct guest_info * core)
     while (!list_empty(&core->free_pages)) {
        page = list_entry(core->free_pages.next, struct shadow_page_cache_data, link);
        list_del(&page->link);
-       V3_FreePage((void *)page->page_pa);
+       V3_FreePages((void *)page->page_pa, 1);
        page->page_pa = ~(addr_t)0; //invalid address
     }
 }
@@ -192,6 +183,7 @@ static int alloc_shadow_pages(struct guest_info * core)
 
        INIT_LIST_HEAD(&page_header->link);
        if (!(page_header->page_pa = (addr_t)V3_AllocPages(1))) {
+           PrintError("Allocation failed in allocating shadow page\n");
            goto error_1;
        }
        addr_t shdw_page = (addr_t)V3_VAddr((void *)(page_header->page_pa));
@@ -633,7 +625,7 @@ static void shadow_zap_page(struct guest_info * core, struct shadow_page_cache_d
        }               
        shadow_page_put_page(core, page, shadow_pde);
        PrintDebug("zap_parent: pde: shadow %p\n",(void *)*((addr_t *)shadow_pde));
-       memset((void *)shadow_pde, 0, sizeof(struct pde32));    
+       memset((void *)shadow_pde, 0, sizeof(uint32_t));
     }
 
     shadow_page_unlink_children(core, page);
@@ -689,7 +681,7 @@ int shadow_zap_hierarchy_32(struct guest_info * core, struct shadow_page_cache_d
        guest_pde = (pde32_t*)&(guest_pd[i]);
        present = shadow_pde->present;
        if (shadow_pde->present) PrintDebug("ulink_child: pde shadow %x\n", *((uint32_t*)shadow_pde));
-       memset((void*)shadow_pde, 0, sizeof(struct pde32));
+       memset((void*)shadow_pde, 0, sizeof(uint32_t));
        if (present != 1) continue;
 
        struct shadow_page_cache_data *shdw_page;