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.


Context-based output infrastructure (V3_Print, etc) and modifications to use it
[palacios.git] / palacios / src / palacios / mmu / vmm_shdw_pg_kvm.c
index 72e63af..074e2ab 100644 (file)
@@ -39,7 +39,7 @@ static void *shadow_cache_alloc(struct shadow_cache *mc, size_t size)
 {
     void *p;
     if (!mc->nobjs) {
-       PrintDebug("at shadow_cache_alloc mc->nobjs non-exist\n");
+       PrintDebug(info->vm_info, info, "at shadow_cache_alloc mc->nobjs non-exist\n");
     }
 
     p = mc->objects[--mc->nobjs];
@@ -74,7 +74,7 @@ int shadow_topup_cache(struct shadow_cache * cache, size_t objsize, int min) {
     while (cache->nobjs < ARRAY_SIZE(cache->objects)) {
        obj = V3_Malloc(objsize);
        if (!obj) {
-           PrintDebug("at shadow_topup_cache obj alloc fail\n");
+           PrintDebug(info->vm_info, info, "at shadow_topup_cache obj alloc fail\n");
            return -1;
        }
        cache->objects[cache->nobjs++] = obj;
@@ -106,9 +106,9 @@ static struct pde_chain *shadow_alloc_pde_chain(struct guest_info *core)
 
 static void shadow_free_pde_chain(struct guest_info *core, struct pde_chain *pc)
 {
-    PrintDebug("shdw_free_pdechain: start\n");
+    PrintDebug(info->vm_info, info, "shdw_free_pdechain: start\n");
     shadow_cache_free(&core->shadow_pde_chain_cache, pc);
-    PrintDebug("shdw_free_pdechain: return\n");
+    PrintDebug(info->vm_info, info, "shdw_free_pdechain: return\n");
 }
 
 
@@ -120,7 +120,7 @@ static void shadow_free_page (struct guest_info * core, struct shadow_page_cache
     page->page_pa=(addr_t)V3_AllocPages(1);
 
     if (!page->page_pa) { 
-       PrintError("Freeing shadow page failed on allocation\n");
+       PrintError(info->vm_info, info, "Freeing shadow page failed on allocation\n");
        return;
     }
        
@@ -143,7 +143,7 @@ static struct shadow_page_cache_data * shadow_alloc_page(struct guest_info * cor
     page->shadow_pde = shadow_pde;
     --core->n_free_shadow_pages;
        
-    PrintDebug("alloc_page: n_free_shdw_pg %d page_pa %p page_va %p\n",
+    PrintDebug(info->vm_info, info, "alloc_page: n_free_shdw_pg %d page_pa %p page_va %p\n",
                core->n_free_shadow_pages,(void *)(page->page_pa),V3_VAddr((void *)(page->page_pa)));
 
     addr_t shdw_page = (addr_t)V3_VAddr((void *)(page->page_pa));
@@ -183,7 +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");
+           PrintError(info->vm_info, info, "Allocation failed in allocating shadow page\n");
            goto error_1;
        }
        addr_t shdw_page = (addr_t)V3_VAddr((void *)(page_header->page_pa));
@@ -191,7 +191,7 @@ static int alloc_shadow_pages(struct guest_info * core)
 
        list_add(&page_header->link, &core->free_pages);
        ++core->n_free_shadow_pages;
-       PrintDebug("alloc_shdw_pg: n_free_shdw_pg %d page_pa %p\n",
+       PrintDebug(info->vm_info, info, "alloc_shdw_pg: n_free_shdw_pg %d page_pa %p\n",
                core->n_free_shadow_pages,(void*)page_header->page_pa);
     }
     return 0;
@@ -253,24 +253,24 @@ static void shadow_page_remove_shadow_pde(struct guest_info * core,
     struct hlist_node * node;
     int i;
 
-    PrintDebug("rm_shdw_pde: multimap %d\n", page->multimapped);
+    PrintDebug(info->vm_info, info, "rm_shdw_pde: multimap %d\n", page->multimapped);
     if(!page->multimapped) {
-       PrintDebug("rm_shdw_pde: no multimap\n");
+       PrintDebug(info->vm_info, info, "rm_shdw_pde: no multimap\n");
        if(page->shadow_pde !=  shadow_pde) 
-           PrintDebug("rm_shdw_pde: error page->shadow_pde is not equal to shadow_pde\n");
+           PrintDebug(info->vm_info, info, "rm_shdw_pde: error page->shadow_pde is not equal to shadow_pde\n");
        page->shadow_pde = 0;
-       PrintDebug("rm_shdw_pde: return\n");
+       PrintDebug(info->vm_info, info, "rm_shdw_pde: return\n");
        return;
     }
        
-    PrintDebug("rm_shdw_pde: multimap\n");
+    PrintDebug(info->vm_info, info, "rm_shdw_pde: multimap\n");
 
     hlist_for_each_entry (pde_chain, node, &page->shadow_pdes, link)
     for (i=0; i < NR_PTE_CHAIN_ENTRIES; ++i) {
        if(!pde_chain->shadow_pdes[i]) break;
        if(pde_chain->shadow_pdes[i] != shadow_pde) continue;
 
-       PrintDebug("rm_shdw_pde: found shadow_pde at i %d\n",i);
+       PrintDebug(info->vm_info, info, "rm_shdw_pde: found shadow_pde at i %d\n",i);
        while (i+1 < NR_PTE_CHAIN_ENTRIES && pde_chain->shadow_pdes[i+1]) {
            pde_chain->shadow_pdes[i] = pde_chain->shadow_pdes[i+1];
            ++i;
@@ -278,7 +278,7 @@ static void shadow_page_remove_shadow_pde(struct guest_info * core,
        pde_chain->shadow_pdes[i] = 0;
 
        if(i==0) {
-           PrintDebug("rm_shdw_pde: only one!\n");
+           PrintDebug(info->vm_info, info, "rm_shdw_pde: only one!\n");
            hlist_del(&pde_chain->link);                                
            shadow_free_pde_chain(core, pde_chain);
            if(hlist_empty(&page->shadow_pdes)) {
@@ -287,10 +287,10 @@ static void shadow_page_remove_shadow_pde(struct guest_info * core,
            }
        }
 
-       PrintDebug("rm_shdw_pde: return\n");
+       PrintDebug(info->vm_info, info, "rm_shdw_pde: return\n");
        return;
     }
-    PrintDebug("rm_shdw_pde: return\n");
+    PrintDebug(info->vm_info, info, "rm_shdw_pde: return\n");
 }
 
 static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shadow_pde, 
@@ -305,16 +305,16 @@ static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shado
     addr_t pt_base_addr = 0;
     int metaphysical = 0;
 
-    PrintDebug("shadow_page_search_shadow_pde\n");
+    PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde\n");
     v3_cpu_mode_t mode = v3_get_vm_cpu_mode(core);
 
     if (mode == PROTECTED) {
 
-       PrintDebug("shadow_page_search_shadow_pde: PROTECTED\n");
+       PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: PROTECTED\n");
        pt_base_addr = ((pde32_t*)guest_pde)->pt_base_addr;
        
        if(((pde32_t*)guest_pde)->large_page == 1) {
-           PrintDebug("shadow_page_search_shadow_pde: large page\n");
+           PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: large page\n");
            hugepage_access = (((pde32_4MB_t *) guest_pde)->writable) | (((pde32_4MB_t*)guest_pde)->user_page << 1);
            metaphysical = 1;
            pt_base_addr = (addr_t) PAGE_BASE_ADDR(BASE_TO_PAGE_ADDR_4MB(((pde32_4MB_t*)guest_pde)->page_base_addr));
@@ -328,7 +328,7 @@ static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shado
                
     } else if (mode == LONG_32_COMPAT || mode == LONG) {
 
-       PrintDebug("shadow_page_search_shadow_pde: LONG_32_COMPAT/LONG\n");
+       PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: LONG_32_COMPAT/LONG\n");
        pt_base_addr = ((pde64_t*)guest_pde)->pt_base_addr;
 
                
@@ -370,7 +370,7 @@ static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shado
 
     hlist_for_each_entry(shdw_page, node, bucket, hash_link) 
     if (shdw_page->guest_fn == pt_base_addr  && shdw_page->role.word == role.word ) {
-       PrintDebug("shadow_page_search_shadow_pde: found\n");
+       PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: found\n");
        shadow_page_remove_shadow_pde(core, shdw_page, (addr_t)shadow_pde);
        
     } 
@@ -385,15 +385,15 @@ static struct shadow_page_cache_data * shadow_page_lookup_page(struct guest_info
     struct shadow_page_cache_data * page;
     struct hlist_node * node;
        
-    PrintDebug("lookup: guest_fn addr %p\n",(void *)BASE_TO_PAGE_ADDR(guest_fn));
+    PrintDebug(info->vm_info, info, "lookup: guest_fn addr %p\n",(void *)BASE_TO_PAGE_ADDR(guest_fn));
        
     index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES;
     bucket = &core->shadow_page_hash[index];
-    PrintDebug("lookup: index %d bucket %p\n",index,(void*)bucket);
+    PrintDebug(info->vm_info, info, "lookup: index %d bucket %p\n",index,(void*)bucket);
 
     hlist_for_each_entry(page, node, bucket, hash_link)
        if (opt == 0) {
-           PrintDebug("lookup: page->gfn %p gfn %p metaphysical %d\n",
+           PrintDebug(info->vm_info, info, "lookup: page->gfn %p gfn %p metaphysical %d\n",
                (void*)BASE_TO_PAGE_ADDR(page->guest_fn),(void*)BASE_TO_PAGE_ADDR(guest_fn),page->role.metaphysical);
            if (page->guest_fn == guest_fn && !page->role.metaphysical) {
                return page;
@@ -439,13 +439,13 @@ struct shadow_page_cache_data * shadow_page_get_page(struct guest_info *core,
     index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES;
     bucket = &core->shadow_page_hash[index];
 
-    if (force != 2) PrintDebug("get_page: lvl %d idx %d gfn %p role %x\n", level, index, (void *)guest_fn,role.word);
+    if (force != 2) PrintDebug(info->vm_info, info, "get_page: lvl %d idx %d gfn %p role %x\n", level, index, (void *)guest_fn,role.word);
 
     hlist_for_each_entry(page, node, bucket, hash_link)
        if (page->guest_fn == guest_fn && page->role.word == role.word) {
            shadow_page_add_shadow_pde(core, page, shadow_pde); //guest_fn is right there
            if(force != 2) 
-               PrintDebug("get_page: found guest_fn %p, index %d, multi %d, next %p\n", 
+               PrintDebug(info->vm_info, info, "get_page: found guest_fn %p, index %d, multi %d, next %p\n", 
                    (void *)page->guest_fn, index, page->multimapped, (void *)page->hash_link.next);
            if (force == 0 || force == 2) 
                return page;
@@ -455,12 +455,12 @@ struct shadow_page_cache_data * shadow_page_get_page(struct guest_info *core,
            }
        } else {
            if(force != 2) 
-               PrintDebug("get_page: no found guest_fn %p, index %d, multimapped %d, next %p\n", 
+               PrintDebug(info->vm_info, info, "get_page: no found guest_fn %p, index %d, multimapped %d, next %p\n", 
                    (void *)page->guest_fn, index, page->multimapped, (void *)page->hash_link.next);
        }
 
     if (force != 2) 
-       PrintDebug("get_page: no found\n");
+       PrintDebug(info->vm_info, info, "get_page: no found\n");
 
 new_alloc:
 
@@ -474,17 +474,17 @@ new_alloc:
     page->shadow_pde = 0;
        
     if (force != 2) 
-       PrintDebug("get_page: hadd h->first %p, n %p, n->next %p\n", 
+       PrintDebug(info->vm_info, info, "get_page: hadd h->first %p, n %p, n->next %p\n", 
            (void *)bucket->first, (void *)&page->hash_link, (void *)page->hash_link.next);
 
     hlist_add_head(&page->hash_link, bucket);
     shadow_page_add_shadow_pde(core, page, shadow_pde);
 
-    if (force != 2) PrintDebug("get_page: hadd h->first %p, n %p, n->next %p\n", 
+    if (force != 2) PrintDebug(info->vm_info, info, "get_page: hadd h->first %p, n %p, n->next %p\n", 
        (void *)bucket->first, (void *)&page->hash_link, (void *)page->hash_link.next); 
 
     if (!metaphysical) rmap_write_protect(core, guest_fn); //in case rmapped guest_fn being allocated as pt or pd
-    if (force != 2) PrintDebug("get_page: return\n");
+    if (force != 2) PrintDebug(info->vm_info, info, "get_page: return\n");
 
     return page;
 
@@ -510,45 +510,45 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow
        if (mode == PROTECTED) {
 
            shdw32_table = (uint32_t*) V3_VAddr((void *)(addr_t)CR3_TO_PDE32_PA(page->page_pa));                
-           PrintDebug("ulink_chil: pte lvl\n");
+           PrintDebug(info->vm_info, info, "ulink_chil: pte lvl\n");
 
            for (i = 0; i < PT32_ENT_PER_PAGE; ++i) {
                shdw32_entry = (uint32_t*)&(shdw32_table[i]);
                if (*shdw32_entry & PT_PRESENT_MASK) {
                    rmap_remove(core, (addr_t)shdw32_entry);
-                   PrintDebug("ulink_chil: %d pte: shadow %x\n", i, *shdw32_entry);
+                   PrintDebug(info->vm_info, info, "ulink_chil: %d pte: shadow %x\n", i, *shdw32_entry);
                }
                memset((void *)shdw32_entry, 0, sizeof(uint32_t));
            }
-           PrintDebug("ulink_chil: return pte\n");
+           PrintDebug(info->vm_info, info, "ulink_chil: return pte\n");
            return;     
                        
        } else if (mode == LONG_32_COMPAT || mode == LONG) {
 
            shdw64_table = (uint64_t*) V3_VAddr((void *)(addr_t)CR3_TO_PML4E64_PA(page->page_pa));              
-           PrintDebug("ulink_chil: pte lvl\n");
+           PrintDebug(info->vm_info, info, "ulink_chil: pte lvl\n");
 
            for (i = 0; i < PT_ENT_PER_PAGE; ++i) {                     
                shdw64_entry = (uint64_t*)&(shdw64_table[i]);
                if (*shdw64_entry & PT_PRESENT_MASK) {
                    rmap_remove(core, (addr_t)shdw64_entry);
-                   PrintDebug("ulink_chil: %d pte: shadow %p\n", i, (void*)*((uint64_t*)shdw64_entry));
+                   PrintDebug(info->vm_info, info, "ulink_chil: %d pte: shadow %p\n", i, (void*)*((uint64_t*)shdw64_entry));
                }
                memset((void *)shdw64_entry, 0, sizeof(uint64_t));
            }
 
-           PrintDebug("ulink_chil: return pte\n");
+           PrintDebug(info->vm_info, info, "ulink_chil: return pte\n");
            return;                             
        }
     }
 
-    PrintDebug("ulink_chil: pde lvl\n");
+    PrintDebug(info->vm_info, info, "ulink_chil: pde lvl\n");
     if (mode == PROTECTED) {
                
        shdw32_table = (uint32_t*) V3_VAddr((void*)(addr_t)CR3_TO_PDE32_PA(page->page_pa));
 
        if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(page->guest_fn), (addr_t*)&guest32_table) == -1) {
-           PrintError("Invalid Guest PDE Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
+           PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
            return;
        } 
                
@@ -557,13 +557,13 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow
            shdw32_entry = (uint32_t*)&(shdw32_table[i]);
            guest32_entry = (uint32_t*)&(guest32_table[i]);
            present = *shdw32_entry & PT_PRESENT_MASK;
-           if(present) PrintDebug("ulink_chil: pde %dth: shadow %x\n", i, *((uint32_t*)shdw32_entry));
+           if(present) PrintDebug(info->vm_info, info, "ulink_chil: pde %dth: shadow %x\n", i, *((uint32_t*)shdw32_entry));
            memset((void *)shdw32_entry, 0, sizeof(uint32_t));
            if (present != 1) continue;
 
            shadow_page_search_shadow_pde(core, (addr_t)shdw32_entry, (addr_t)guest32_entry, page->role.hlevels);
        }
-       PrintDebug("ulink_child: before return at pde lvel\n");
+       PrintDebug(info->vm_info, info, "ulink_child: before return at pde lvel\n");
        return;
 
     }else if(mode == LONG_32_COMPAT || mode == LONG)  {
@@ -572,11 +572,11 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow
 
        if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(page->guest_fn), (addr_t*)&guest64_table) == -1) {
            if(page->role.hlevels == PT_DIRECTORY_LEVEL) 
-               PrintError("Invalid Guest PDE Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
+               PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
            if(page->role.hlevels == PT32E_ROOT_LEVEL) 
-               PrintError("Invalid Guest PDPE Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
+               PrintError(info->vm_info, info, "Invalid Guest PDPE Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
            if(page->role.hlevels == PT64_ROOT_LEVEL) 
-               PrintError("Invalid Guest PML4E Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
+               PrintError(info->vm_info, info, "Invalid Guest PML4E Address: 0x%p\n",  (void *)BASE_TO_PAGE_ADDR(page->guest_fn));
            return;     
        }
 
@@ -585,7 +585,7 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow
            shdw64_entry = (uint64_t*)&(shdw64_table[i]);
            guest64_entry = (uint64_t*)&(guest64_table[i]);
            present = *shdw64_entry & PT_PRESENT_MASK;
-           if(present) PrintDebug("ulink_chil: pde: shadow %p\n",(void *)*((uint64_t *)shdw64_entry));
+           if(present) PrintDebug(info->vm_info, info, "ulink_chil: pde: shadow %p\n",(void *)*((uint64_t *)shdw64_entry));
            memset((void *)shdw64_entry, 0, sizeof(uint64_t));
            if (present != 1) continue;
 
@@ -594,16 +594,16 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow
        return;         
 
     }
-    //PrintDebug("ulink_chil: return pde\n");
+    //PrintDebug(info->vm_info, info, "ulink_chil: return pde\n");
 
 }
 
 static void shadow_page_put_page(struct guest_info *core, struct shadow_page_cache_data * page, addr_t shadow_pde) { 
 
-       PrintDebug("put_page: start\n");        
+       PrintDebug(info->vm_info, info, "put_page: start\n");   
        shadow_page_remove_shadow_pde(core, page, shadow_pde);
 
-       PrintDebug("put_page: end\n");
+       PrintDebug(info->vm_info, info, "put_page: end\n");
 
 } 
 
@@ -613,7 +613,7 @@ static void shadow_zap_page(struct guest_info * core, struct shadow_page_cache_d
     addr_t cr3_base_addr = 0;
     v3_cpu_mode_t mode = v3_get_vm_cpu_mode(core);
        
-    PrintDebug("zap: multimapped %d, metaphysical %d\n", page->multimapped, page->role.metaphysical);
+    PrintDebug(info->vm_info, info, "zap: multimapped %d, metaphysical %d\n", page->multimapped, page->role.metaphysical);
        
     while (page->multimapped || page->shadow_pde) {
        if (!page->multimapped) {
@@ -624,13 +624,13 @@ static void shadow_zap_page(struct guest_info * core, struct shadow_page_cache_d
            shadow_pde = chain->shadow_pdes[0];
        }               
        shadow_page_put_page(core, page, shadow_pde);
-       PrintDebug("zap_parent: pde: shadow %p\n",(void *)*((addr_t *)shadow_pde));
+       PrintDebug(info->vm_info, info, "zap_parent: pde: shadow %p\n",(void *)*((addr_t *)shadow_pde));
        memset((void *)shadow_pde, 0, sizeof(uint32_t));
     }
 
     shadow_page_unlink_children(core, page);
 
-    PrintDebug("zap: end of unlink\n");
+    PrintDebug(info->vm_info, info, "zap: end of unlink\n");
        
     if (mode == PROTECTED) {
        cr3_base_addr =  ((struct cr3_32 *)&(core->shdw_pg_state.guest_cr3))->pdt_base_addr;
@@ -639,23 +639,23 @@ static void shadow_zap_page(struct guest_info * core, struct shadow_page_cache_d
     }
     else return;       
 
-    PrintDebug("zap: before hlist_del\n");
-    PrintDebug("zap: page->guest_fn %p\n", (void*) page->guest_fn);
+    PrintDebug(info->vm_info, info, "zap: before hlist_del\n");
+    PrintDebug(info->vm_info, info, "zap: page->guest_fn %p\n", (void*) page->guest_fn);
 
     if (page->guest_fn !=  (addr_t)(cr3_base_addr)) {
-       PrintDebug("zap: first hlist_del\n");
+       PrintDebug(info->vm_info, info, "zap: first hlist_del\n");
 
        hlist_del(&page->hash_link);
        shadow_free_page(core, page);
 
     } else {
-       PrintDebug("zap: second hlist_del\n");
+       PrintDebug(info->vm_info, info, "zap: second hlist_del\n");
 
        list_del(&page->link);
        list_add(&page->link,&core->active_shadow_pages);
     }          
 
-    PrintDebug("zap: end hlist_del\n");
+    PrintDebug(info->vm_info, info, "zap: end hlist_del\n");
     return;
 }
 
@@ -671,7 +671,7 @@ int shadow_zap_hierarchy_32(struct guest_info * core, struct shadow_page_cache_d
 
     shadow_pd = CR3_TO_PDE32_VA(page->page_pa);
     if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(page->guest_fn), (addr_t*)&guest_pd) == -1) {
-       PrintError("Invalid Guest PDE Address: 0x%p\n", (void*)BASE_TO_PAGE_ADDR(page->guest_fn));
+       PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void*)BASE_TO_PAGE_ADDR(page->guest_fn));
        return -1;
     }
        
@@ -680,7 +680,7 @@ int shadow_zap_hierarchy_32(struct guest_info * core, struct shadow_page_cache_d
        shadow_pde = (pde32_t*)&(shadow_pd[i]);
        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));
+       if (shadow_pde->present) PrintDebug(info->vm_info, info, "ulink_child: pde shadow %x\n", *((uint32_t*)shadow_pde));
        memset((void*)shadow_pde, 0, sizeof(uint32_t));
        if (present != 1) continue;
 
@@ -735,18 +735,18 @@ int shadow_unprotect_page(struct guest_info * core, addr_t guest_fn) {
     r = 0;
     index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES;
     bucket = &core->shadow_page_hash[index];
-    PrintDebug("unprotect: gfn %p\n",(void *) guest_fn);
+    PrintDebug(info->vm_info, info, "unprotect: gfn %p\n",(void *) guest_fn);
        
     hlist_for_each_entry_safe(page, node, n, bucket, hash_link) {
     //hlist_for_each_entry(page, node, bucket, hash_link) {
        if ((page->guest_fn == guest_fn) && !(page->role.metaphysical)) {
-           PrintDebug("unprotect: match page.gfn %p page.role %x gfn %p\n",(void *) page->guest_fn,page->role.word,(void *)guest_fn);
+           PrintDebug(info->vm_info, info, "unprotect: match page.gfn %p page.role %x gfn %p\n",(void *) page->guest_fn,page->role.word,(void *)guest_fn);
            shadow_zap_page(core, page);
            r = 1;
        }
     }
        
-    PrintDebug("at shadow_unprotect_page return %d\n",r);
+    PrintDebug(info->vm_info, info, "at shadow_unprotect_page return %d\n",r);
     return r;
 }
 
@@ -769,45 +769,45 @@ void rmap_add(struct guest_info *core, addr_t shadow_pte) {
 
     if (mode == PROTECTED) {
        page_base_addr = ((pte32_t *)shadow_pte)->page_base_addr;
-       PrintDebug("at rmap_add shadow_pte: %x\n", (uint32_t)*((uint32_t*)shadow_pte));
+       PrintDebug(info->vm_info, info, "at rmap_add shadow_pte: %x\n", (uint32_t)*((uint32_t*)shadow_pte));
 
     } else if (mode == LONG_32_COMPAT || mode == LONG) {
        page_base_addr = ((pte64_t *)shadow_pte)->page_base_addr;
-       PrintDebug("at rmap_add shadow_pte: %p\n", (void*)*((uint64_t*)shadow_pte));
+       PrintDebug(info->vm_info, info, "at rmap_add shadow_pte: %p\n", (void*)*((uint64_t*)shadow_pte));
 
     }
     else return;       
        
-    PrintDebug("debug rmap: at rmap_add shadow_pte->page_base_addr (%p), shadow_pte_present %d, shadow_pte_writable %d\n", 
+    PrintDebug(info->vm_info, info, "debug rmap: at rmap_add shadow_pte->page_base_addr (%p), shadow_pte_present %d, shadow_pte_writable %d\n", 
        (void *)BASE_TO_PAGE_ADDR(page_base_addr), (shadow_pte_gen->present), (shadow_pte_gen->writable));
        
     if (shadow_pte_gen->present == 0 || shadow_pte_gen->writable == 0)
        return;
 
-    PrintDebug("at rmap_add host_fn %p\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr));
+    PrintDebug(info->vm_info, info, "at rmap_add host_fn %p\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr));
                
     mem_map = core->vm_info.mem_map.base_region.mem_map;
     page_private = mem_map[page_base_addr];
 
-    PrintDebug("at rmap_add page_private %p\n", (void *)page_private);
+    PrintDebug(info->vm_info, info, "at rmap_add page_private %p\n", (void *)page_private);
        
     if (!page_private) {
-       PrintDebug("at rmap_add initial\n");
+       PrintDebug(info->vm_info, info, "at rmap_add initial\n");
        mem_map[page_base_addr] = (addr_t)shadow_pte;
-       PrintDebug("rmap_add: shadow_pte %p\n", (void *)shadow_pte);
+       PrintDebug(info->vm_info, info, "rmap_add: shadow_pte %p\n", (void *)shadow_pte);
 
     } else if (!(page_private & 1)) {
-       PrintDebug("at rmap_add into multi\n");
+       PrintDebug(info->vm_info, info, "at rmap_add into multi\n");
 
        desc = shadow_alloc_rmap(core);
        desc->shadow_ptes[0] = page_private;
        desc->shadow_ptes[1] = shadow_pte;
        mem_map[page_base_addr] = (addr_t)desc | 1;
        desc->more = NULL;
-       PrintDebug("rmap_add: desc %p desc|1 %p\n",(void *)desc,(void *)((addr_t)desc |1));
+       PrintDebug(info->vm_info, info, "rmap_add: desc %p desc|1 %p\n",(void *)desc,(void *)((addr_t)desc |1));
 
     } else {
-       PrintDebug("at rmap_add multimap\n");
+       PrintDebug(info->vm_info, info, "at rmap_add multimap\n");
        desc = (struct rmap *)(page_private & ~1ul);
 
        while (desc->more && desc->shadow_ptes[RMAP_EXT-1]) desc = desc->more;
@@ -836,19 +836,19 @@ static void rmap_desc_remove_entry(struct guest_info *core,
     desc->shadow_ptes[j] = 0;
 
     if (j != 0) {
-       PrintDebug("rmap_desc_rm: i %d j %d\n",i,j);
+       PrintDebug(info->vm_info, info, "rmap_desc_rm: i %d j %d\n",i,j);
        return;
     }
 
     if (!prev_desc && !desc->more) {
-       PrintDebug("rmap_desc_rm: no more no less\n");
+       PrintDebug(info->vm_info, info, "rmap_desc_rm: no more no less\n");
        *page_private = desc->shadow_ptes[0];
     } else {           //more should be null
        if (prev_desc) {
-           PrintDebug("rmap_desc_rm: no more\n");
+           PrintDebug(info->vm_info, info, "rmap_desc_rm: no more\n");
            prev_desc->more = desc->more; 
        } else {
-           PrintDebug("rmap_desc_rm: no less\n");
+           PrintDebug(info->vm_info, info, "rmap_desc_rm: no less\n");
            *page_private = (addr_t) desc->more | 1;
        }
     }
@@ -867,49 +867,49 @@ static void rmap_remove(struct guest_info * core, addr_t shadow_pte) {
     v3_cpu_mode_t mode = v3_get_vm_cpu_mode(core);
 
     if (mode == PROTECTED) {
-       PrintDebug("rmap_rm: PROTECTED %d\n", mode);
+       PrintDebug(info->vm_info, info, "rmap_rm: PROTECTED %d\n", mode);
        page_base_addr = ((pte32_t *)shadow_pte)->page_base_addr;
 
     } else if (mode == LONG_32_COMPAT || mode == LONG) {
-       PrintDebug("rmap_rm: LONG_32_COMPAT/LONG %d\n", mode);
+       PrintDebug(info->vm_info, info, "rmap_rm: LONG_32_COMPAT/LONG %d\n", mode);
        page_base_addr = ((pte64_t *)shadow_pte)->page_base_addr;               
 
     }  else {
-       PrintDebug("rmap_rm: mode %d\n", mode);
+       PrintDebug(info->vm_info, info, "rmap_rm: mode %d\n", mode);
        return; 
     }
     shadow_pte_gen = (gen_pt_t*)shadow_pte;
 
     if (shadow_pte_gen->present == 0 || shadow_pte_gen->writable == 0) {
-       PrintDebug("rmap_rm: present %d, write %d, pte %p\n",
+       PrintDebug(info->vm_info, info, "rmap_rm: present %d, write %d, pte %p\n",
                shadow_pte_gen->present, shadow_pte_gen->writable,
                (void*)*((addr_t*)shadow_pte));
        return;
     }
-    PrintDebug("rmap_rm: shadow_pte->page_base_addr (%p)\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr));
+    PrintDebug(info->vm_info, info, "rmap_rm: shadow_pte->page_base_addr (%p)\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr));
 
     mem_map = core->vm_info.mem_map.base_region.mem_map;
     page_private = mem_map[page_base_addr];
 
-    PrintDebug("rmap_rm: page_private %p page_private&1 %p\n",(void *)page_private,(void*)(page_private&1));
+    PrintDebug(info->vm_info, info, "rmap_rm: page_private %p page_private&1 %p\n",(void *)page_private,(void*)(page_private&1));
        
     if (!page_private) {               
-       PrintDebug("rmap_rm: single page_prive %p\n",(void *)page_private);
+       PrintDebug(info->vm_info, info, "rmap_rm: single page_prive %p\n",(void *)page_private);
        
     } else if (!(page_private & 1)) {  
-       PrintDebug("rmap_rm: multi page_prive %p\n",(void *)page_private);
+       PrintDebug(info->vm_info, info, "rmap_rm: multi page_prive %p\n",(void *)page_private);
        mem_map[page_base_addr] = (addr_t)0;
 
     } else {
-       PrintDebug("rmap_rm: multimap page_prive %p\n",(void *)page_private);
+       PrintDebug(info->vm_info, info, "rmap_rm: multimap page_prive %p\n",(void *)page_private);
        desc = (struct rmap *)(page_private & ~1ul);
        prev_desc = NULL;
        
        while (desc) {
-           PrintDebug("rmap_rm: desc loop\n");
+           PrintDebug(info->vm_info, info, "rmap_rm: desc loop\n");
            for (i = 0; i < RMAP_EXT && desc->shadow_ptes[i]; ++i)
            if (desc->shadow_ptes[i] == shadow_pte) {
-               PrintDebug("rmap_rm: rmap_desc_remove_entry i %d\n",i);
+               PrintDebug(info->vm_info, info, "rmap_rm: rmap_desc_remove_entry i %d\n",i);
                rmap_desc_remove_entry(core, &mem_map[page_base_addr], desc, i, prev_desc);
                return;
            }
@@ -928,46 +928,46 @@ static void rmap_write_protect(struct guest_info * core, addr_t guest_fn) {
     addr_t page_private;
     addr_t host_pa;
 
-    PrintDebug("rmap_wrprot: gfn %p\n",(void *) guest_fn);
+    PrintDebug(info->vm_info, info, "rmap_wrprot: gfn %p\n",(void *) guest_fn);
 
     if (guest_pa_to_host_pa(core, BASE_TO_PAGE_ADDR(guest_fn), &host_pa)!=0) {
-       PrintDebug("rmap_wrprot: error \n");
+       PrintDebug(info->vm_info, info, "rmap_wrprot: error \n");
     }
 
     page_private = core->vm_info.mem_map.base_region.mem_map[PAGE_BASE_ADDR(host_pa)];
 
-    PrintDebug("rmap_wrprot: host_fn %p\n",(void *)PAGE_BASE_ADDR(host_pa));
+    PrintDebug(info->vm_info, info, "rmap_wrprot: host_fn %p\n",(void *)PAGE_BASE_ADDR(host_pa));
        
     while(page_private) {
-       PrintDebug("rmap_wrprot: page_private %p\n", (void*)page_private);
+       PrintDebug(info->vm_info, info, "rmap_wrprot: page_private %p\n", (void*)page_private);
        if(!(page_private & 1)) {
-           PrintDebug("rmap_wrprot: reverse desc single\n");
+           PrintDebug(info->vm_info, info, "rmap_wrprot: reverse desc single\n");
            shadow_pte = page_private;
                
        } else {
            desc = (struct rmap *) (page_private & ~1ul);
-           PrintDebug("rmap_wrprot: reverse desc multimap\n");
+           PrintDebug(info->vm_info, info, "rmap_wrprot: reverse desc multimap\n");
            shadow_pte = desc->shadow_ptes[0];
        }
                
-       PrintDebug("rmap_wrprot: pg_priv %p, host_fn %p, shdw_pte %p\n",
+       PrintDebug(info->vm_info, info, "rmap_wrprot: pg_priv %p, host_fn %p, shdw_pte %p\n",
                (void *)page_private, (void *)PAGE_BASE_ADDR(host_pa), (void*)*((uint64_t*)shadow_pte));
        
        //CHECKPOINT
        rmap_remove(core, shadow_pte); 
 
-       //PrintDebug("rmap_wrprot: shadow_pte->page_base_addr (%p)\n", 
+       //PrintDebug(info->vm_info, info, "rmap_wrprot: shadow_pte->page_base_addr (%p)\n", 
        //      (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr));
 
        ((gen_pt_t *)shadow_pte)->writable = 0;
-       PrintDebug("rmap_wrprot: %p\n",(void*)*((uint64_t *)shadow_pte));
+       PrintDebug(info->vm_info, info, "rmap_wrprot: %p\n",(void*)*((uint64_t *)shadow_pte));
                                
        page_private = core->vm_info.mem_map.base_region.mem_map[PAGE_BASE_ADDR(host_pa)];
 
-       PrintDebug("rmap_wrprot: page_private %p\n",(void*)page_private);
+       PrintDebug(info->vm_info, info, "rmap_wrprot: page_private %p\n",(void*)page_private);
     }  
 
-    PrintDebug("rmap_wrprot: done\n");
+    PrintDebug(info->vm_info, info, "rmap_wrprot: done\n");
 
 }
 
@@ -1000,13 +1000,13 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes,
        core->last_pt_write_count = 1;
     }
 
-    PrintDebug("shdw_pre-write: gpa %p byte %d force %d flood %d last_gfn %p last_cnt %d\n",
+    PrintDebug(info->vm_info, info, "shdw_pre-write: gpa %p byte %d force %d flood %d last_gfn %p last_cnt %d\n",
        (void *)guest_pa,bytes,force,flooded,(void*)core->last_pt_write_guest_fn,core->last_pt_write_count);
 
     index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES;
     bucket = &core->shadow_page_hash[index];
 
-    PrintDebug("shdw_pre-write: check point after bucket\n");
+    PrintDebug(info->vm_info, info, "shdw_pre-write: check point after bucket\n");
        
     //hlist_for_each_entry_safe(page, node, bucket, hash_link) {
     hlist_for_each_entry_safe(page, node, n, bucket, hash_link) {
@@ -1023,14 +1023,14 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes,
            * Misaligned accesses are too much trobule to fix up
            * also they usually indicate a page is not used as a page table
            */
-           PrintDebug("shdw_pre-write: misaligned\n");
+           PrintDebug(info->vm_info, info, "shdw_pre-write: misaligned\n");
            shadow_zap_page(core, page);
            continue;
        }       
 
        level = page->role.hlevels;             
                
-       PrintDebug("shdw_pre-write: found out one page at the level of %d\n", level);
+       PrintDebug(info->vm_info, info, "shdw_pre-write: found out one page at the level of %d\n", level);
        
        if (mode == PROTECTED) {
            shdw32_table = (uint32_t*)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(PAGE_BASE_ADDR(page->page_pa)));
@@ -1038,7 +1038,7 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes,
 
            if (*shdw32_entry & PT_PRESENT_MASK) {
                if (level == PT_PAGE_TABLE_LEVEL) {
-                   PrintDebug("shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint32_t)));
+                   PrintDebug(info->vm_info, info, "shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint32_t)));
                    rmap_remove(core, (addr_t)shdw32_entry);
                    memset((void*)shdw32_entry, 0, sizeof(uint32_t));
                
@@ -1055,7 +1055,7 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes,
 
            if (*shdw64_entry & PT_PRESENT_MASK) {
                if (level == PT_PAGE_TABLE_LEVEL) {
-                   PrintDebug("shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint64_t)));
+                   PrintDebug(info->vm_info, info, "shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint64_t)));
                    rmap_remove(core, (addr_t)shdw64_entry);
                    memset((void*)shdw64_entry, 0, sizeof(uint64_t));
                } else {
@@ -1076,7 +1076,7 @@ int shadow_unprotect_page_virt(struct guest_info * core, addr_t guest_va) {
     addr_t guest_pa;
 
     if (guest_va_to_guest_pa(core, guest_va, &guest_pa) != 0) {
-       PrintError("In GVA->HVA: Invalid GVA(%p)->GPA lookup\n", 
+       PrintError(info->vm_info, info, "In GVA->HVA: Invalid GVA(%p)->GPA lookup\n", 
                (void *)guest_va);
        return -1;
     }
@@ -1111,7 +1111,7 @@ static struct shadow_page_cache_data * create_new_shadow_pt(struct guest_info *
 
 static int vtlb_caching_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
 
-    V3_Print("VTLB Caching initialization\n");
+    V3_Print(info->vm_info, info, "VTLB Caching initialization\n");
     return 0;
 }
 
@@ -1121,7 +1121,7 @@ static int vtlb_caching_deinit(struct v3_vm_info * vm) {
 
 static int vtlb_caching_local_init(struct guest_info * core) {
 
-    V3_Print("VTLB local initialization\n");
+    V3_Print(info->vm_info, info, "VTLB local initialization\n");
 
     INIT_LIST_HEAD(&core->active_shadow_pages);
     INIT_LIST_HEAD(&core->free_pages);
@@ -1148,7 +1148,7 @@ static int vtlb_caching_activate_shdw_pt(struct guest_info * core) {
        case LONG_16_COMPAT:
            return activate_shadow_pt_64(core);
        default:
-           PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core)));
+           PrintError(info->vm_info, info, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core)));
            return -1;
     }
 
@@ -1174,7 +1174,7 @@ static int vtlb_caching_handle_pf(struct guest_info * core, addr_t fault_addr, p
                return handle_shadow_pagefault_64(core, fault_addr, error_code);
                break;
            default:
-               PrintError("Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core)));
+               PrintError(info->vm_info, info, "Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core)));
                return -1;
        }
 }
@@ -1192,7 +1192,7 @@ static int vtlb_caching_handle_invlpg(struct guest_info * core, addr_t vaddr) {
        case LONG_16_COMPAT:
            return handle_shadow_invlpg_64(core, vaddr);
        default:
-           PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core)));
+           PrintError(info->vm_info, info, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core)));
            return -1;
     }
 }