X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fmmu%2Fvmm_shdw_pg_tlb.c;h=d6f77d8a6e6c09ce40f36ba054a96fadd24d1f1b;hb=b58fe2254858e3ecc94be5d86f2a93f2cfe0a0d5;hp=f38f6baeb9db656bbe16d74f30e398bfc2484579;hpb=65ffa7d1ac6dfb3399ba2b217d27519e258ee00a;p=palacios.git diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c index f38f6ba..d6f77d8 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c @@ -12,6 +12,8 @@ * All rights reserved. * * Author: Jack Lange + * Author: Chunxiao Diao + * * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "V3VEE_LICENSE". @@ -24,7 +26,7 @@ #include -#ifndef CONFIG_DEBUG_SHDW_PG_VTLB +#ifndef V3_CONFIG_DEBUG_SHDW_PG_VTLB #undef PrintDebug #define PrintDebug(fmt, ...) #endif @@ -53,6 +55,7 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core); #include "vmm_shdw_pg_tlb_64.h" + static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) { struct v3_shdw_pg_state * state = &(core->shdw_pg_state); struct vtlb_local_state * impl_state = (struct vtlb_local_state *)(state->local_impl_data); @@ -65,7 +68,7 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) if (page_tail->cr3 != cur_cr3) { - PrintDebug("Reusing old shadow Page: %p (cur_CR3=%p)(page_cr3=%p) \n", + PrintDebug(core->vm_info, core, "Reusing old shadow Page: %p (cur_CR3=%p)(page_cr3=%p) \n", (void *)(addr_t)page_tail->page_pa, (void *)(addr_t)cur_cr3, (void *)(addr_t)(page_tail->cr3)); @@ -82,9 +85,20 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) // else page_tail = (struct shadow_page_data *)V3_Malloc(sizeof(struct shadow_page_data)); - page_tail->page_pa = (addr_t)V3_AllocPages(1); - PrintDebug("Allocating new shadow Page: %p (cur_cr3=%p)\n", + if (!page_tail) { + PrintError(core->vm_info, core, "Cannot allocate\n"); + return NULL; + } + + page_tail->page_pa = (addr_t)V3_AllocPagesExtended(1,PAGE_SIZE_4KB,-1,0,0); + + if (!page_tail->page_pa) { + PrintError(core->vm_info, core, "Cannot allocate page\n"); + return NULL; + } + + PrintDebug(core->vm_info, core, "Allocating new shadow Page: %p (cur_cr3=%p)\n", (void *)(addr_t)page_tail->page_pa, (void *)(addr_t)cur_cr3); @@ -101,7 +115,7 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) static int vtlb_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { - V3_Print("VTLB initialization\n"); + V3_Print(vm, VCORE_NONE, "VTLB initialization\n"); return 0; } @@ -113,10 +127,15 @@ static int vtlb_local_init(struct guest_info * core) { struct v3_shdw_pg_state * state = &(core->shdw_pg_state); struct vtlb_local_state * vtlb_state = NULL; - V3_Print("VTLB local initialization\n"); + V3_Print(core->vm_info, core, "VTLB local initialization\n"); vtlb_state = (struct vtlb_local_state *)V3_Malloc(sizeof(struct vtlb_local_state)); + if (!vtlb_state) { + PrintError(core->vm_info, core, "Cannot allocate\n"); + return -1; + } + INIT_LIST_HEAD(&(vtlb_state->page_list)); state->local_impl_data = vtlb_state; @@ -151,15 +170,19 @@ static int vtlb_activate_shdw_pt(struct guest_info * core) { case PROTECTED: return activate_shadow_pt_32(core); + break; case PROTECTED_PAE: return activate_shadow_pt_32pae(core); + break; case LONG: case LONG_32_COMPAT: case LONG_16_COMPAT: return activate_shadow_pt_64(core); + break; default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; + break; } return 0; @@ -171,7 +194,7 @@ static int vtlb_invalidate_shdw_pt(struct guest_info * core) { static int vtlb_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error_t error_code) { - + switch (v3_get_vm_cpu_mode(core)) { case PROTECTED: return handle_shadow_pagefault_32(core, fault_addr, error_code); @@ -184,7 +207,7 @@ static int vtlb_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error_ 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(core->vm_info, core, "Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } @@ -195,15 +218,19 @@ static int vtlb_handle_invlpg(struct guest_info * core, addr_t vaddr) { switch (v3_get_vm_cpu_mode(core)) { case PROTECTED: return handle_shadow_invlpg_32(core, vaddr); + break; case PROTECTED_PAE: return handle_shadow_invlpg_32pae(core, vaddr); + break; case LONG: case LONG_32_COMPAT: case LONG_16_COMPAT: return handle_shadow_invlpg_64(core, vaddr); + break; default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; + break; } }