X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_shadow_paging.c;h=009785381aa37be8d959604a147c5d3a5b60fb9b;hb=e0d21d7727f32ab299e90a1ad602373a4a415c29;hp=9eeecc6c2ad9106b9ae366e2e1f64d4e7ea6d331;hpb=cbf35ad72de3a7a1f6eee3e8b2b35d7f31df22a5;p=palacios.releases.git diff --git a/palacios/src/palacios/vmm_shadow_paging.c b/palacios/src/palacios/vmm_shadow_paging.c index 9eeecc6..0097853 100644 --- a/palacios/src/palacios/vmm_shadow_paging.c +++ b/palacios/src/palacios/vmm_shadow_paging.c @@ -11,7 +11,20 @@ #endif -int init_shadow_page_state(struct shadow_page_state * state) { + + + + +static int handle_shadow_pte32_fault(struct guest_info* info, + addr_t fault_addr, + pf_error_t error_code, + pte32_t * shadow_pte, + pte32_t * guest_pte); + +static int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_error_t error_code); + +int init_shadow_page_state(struct guest_info * info) { + struct shadow_page_state * state = &(info->shdw_pg_state); state->guest_mode = PDE32; state->shadow_mode = PDE32; @@ -47,7 +60,7 @@ int handle_shadow_pagefault(struct guest_info * info, addr_t fault_addr, pf_erro addr_t create_new_shadow_pt32(struct guest_info * info) { void * host_pde = 0; - V3_AllocPages(host_pde, 1); + host_pde = V3_AllocPages(1); memset(host_pde, 0, PAGE_SIZE); return (addr_t)host_pde; @@ -89,7 +102,7 @@ static int handle_pd32_nonaligned_4MB_page(struct guest_info * info, pte32_t * p return 0; } -int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) { +static int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) { pde32_t * guest_pd = NULL; pde32_t * shadow_pd = (pde32_t *)CR3_TO_PDE32(info->shdw_pg_state.shadow_cr3); addr_t guest_cr3 = CR3_TO_PDE32(info->shdw_pg_state.guest_cr3); @@ -132,7 +145,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er // inject page fault to the guest (Guest PDE fault) info->ctrl_regs.cr2 = fault_addr; - raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); + v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (pf error code=%d)\n", guest_pde_access, error_code); @@ -172,7 +185,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er if (guest_pde->large_page == 0) { pte32_t * shadow_pt = NULL; - V3_AllocPages(shadow_pt, 1); + shadow_pt = V3_AllocPages(1); memset(shadow_pt, 0, PAGE_SIZE); shadow_pde->pt_base_addr = PD32_BASE_ADDR(shadow_pt); @@ -195,7 +208,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er if (host_page_type == HOST_REGION_INVALID) { - raise_exception(info, MC_EXCEPTION); + v3_raise_exception(info, MC_EXCEPTION); PrintError("Invalid guest address in large page (0x%x)\n", guest_start_addr); return -1; } else if (host_page_type == HOST_REGION_PHYSICAL_MEMORY) { @@ -238,7 +251,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er shadow_pde->large_page = 0; - V3_AllocPages(shadow_pt, 1); + shadow_pt = V3_AllocPages(1); memset(shadow_pt, 0, PAGE_SIZE); if (handle_pd32_nonaligned_4MB_page(info, shadow_pt, guest_start_addr, large_shadow_pde) == -1) { @@ -285,7 +298,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er PrintDebug("Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x - injecting into guest\n", shadow_pde_access, guest_pde_access); info->ctrl_regs.cr2 = fault_addr; - raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); + v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); return 0; } else if (shadow_pde_access == PT_ACCESS_OK) { @@ -298,7 +311,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er PrintDebug("Invalid Guest PTE Address: 0x%x\n", PDE32_T_ADDR((*guest_pde))); // Machine check the guest - raise_exception(info, MC_EXCEPTION); + v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -312,7 +325,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er } else { // Unknown error raise page fault in guest info->ctrl_regs.cr2 = fault_addr; - raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); + v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); // For debugging we will return an error here for the time being, // this probably shouldn't ever happen @@ -334,7 +347,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er /* * We assume the the guest pte pointer has already been translated to a host virtual address */ -int handle_shadow_pte32_fault(struct guest_info * info, +static int handle_shadow_pte32_fault(struct guest_info * info, addr_t fault_addr, pf_error_t error_code, pte32_t * shadow_pt, @@ -379,7 +392,7 @@ int handle_shadow_pte32_fault(struct guest_info * info, // Inject page fault into the guest info->ctrl_regs.cr2 = fault_addr; - raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); + v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code); return 0; @@ -404,7 +417,7 @@ int handle_shadow_pte32_fault(struct guest_info * info, if (host_page_type == HOST_REGION_INVALID) { // Inject a machine check in the guest - raise_exception(info, MC_EXCEPTION); + v3_raise_exception(info, MC_EXCEPTION); #ifdef DEBUG_SHADOW_PAGING PrintDebug("Invalid Guest Address in page table (0x%x)\n", guest_pa); PrintDebug("fault_addr=0x%x next are guest and shadow ptes \n",fault_addr); @@ -459,7 +472,7 @@ int handle_shadow_pte32_fault(struct guest_info * info, // Inject page fault into the guest info->ctrl_regs.cr2 = fault_addr; - raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); + v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code); PrintError("PTE Page fault fell through... Not sure if this should ever happen\n"); PrintError("Manual Says to inject page fault into guest\n"); @@ -572,83 +585,3 @@ int handle_shadow_invlpg(struct guest_info * info) { } - -/* Deprecated */ -/* -addr_t setup_shadow_pt32(struct guest_info * info, addr_t virt_cr3) { - addr_t cr3_guest_addr = CR3_TO_PDE32(virt_cr3); - pde32_t * guest_pde; - pde32_t * host_pde = NULL; - int i; - - // Setup up guest_pde to point to the PageDir in host addr - if (guest_pa_to_host_va(info, cr3_guest_addr, (addr_t*)&guest_pde) == -1) { - return 0; - } - - V3_AllocPages(host_pde, 1); - memset(host_pde, 0, PAGE_SIZE); - - for (i = 0; i < MAX_PDE32_ENTRIES; i++) { - if (guest_pde[i].present == 1) { - addr_t pt_host_addr; - addr_t host_pte; - - if (guest_pa_to_host_va(info, PDE32_T_ADDR(guest_pde[i]), &pt_host_addr) == -1) { - return 0; - } - - if ((host_pte = setup_shadow_pte32(info, pt_host_addr)) == 0) { - return 0; - } - - host_pde[i].present = 1; - host_pde[i].pt_base_addr = PD32_BASE_ADDR(host_pte); - - // - // Set Page DIR flags - // - } - } - - PrintDebugPageTables(host_pde); - - return (addr_t)host_pde; -} - - - -addr_t setup_shadow_pte32(struct guest_info * info, addr_t pt_host_addr) { - pte32_t * guest_pte = (pte32_t *)pt_host_addr; - pte32_t * host_pte = NULL; - int i; - - V3_AllocPages(host_pte, 1); - memset(host_pte, 0, PAGE_SIZE); - - for (i = 0; i < MAX_PTE32_ENTRIES; i++) { - if (guest_pte[i].present == 1) { - addr_t guest_pa = PTE32_T_ADDR(guest_pte[i]); - shadow_mem_type_t page_type; - addr_t host_pa = 0; - - page_type = get_shadow_addr_type(info, guest_pa); - - if (page_type == HOST_REGION_PHYSICAL_MEMORY) { - host_pa = get_shadow_addr(info, guest_pa); - } else { - - // - // Setup various memory types - // - } - - host_pte[i].page_base_addr = PT32_BASE_ADDR(host_pa); - host_pte[i].present = 1; - } - } - - return (addr_t)host_pte; -} - -*/