X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_direct_paging_32.h;h=2b34cf2cfdeecfb0d52b7b90be396e63d3bc96f2;hb=debabd511ff9dc2d0e6cd608045ac44295fe7319;hp=d075e74d6f06b9b91d77b7226792f9e4b571d8ad;hpb=75aa9d6205930057dc8163238d325558bcb1fd9b;p=palacios.git diff --git a/palacios/src/palacios/vmm_direct_paging_32.h b/palacios/src/palacios/vmm_direct_paging_32.h index d075e74..2b34cf2 100644 --- a/palacios/src/palacios/vmm_direct_paging_32.h +++ b/palacios/src/palacios/vmm_direct_paging_32.h @@ -25,52 +25,67 @@ static pte32_t * create_pte32() { } -static inline pde32_t * v3_create_direct_passthrough_pts_32(struct guest_info * info) { +static inline pde32_t * create_direct_passthrough_pts_32(struct guest_info * info) { return create_pde32(); } -static inline int v3_handle_shadow_pagefault_physical_mode_32(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) { +static inline int handle_passthrough_pagefault_32(struct guest_info * info, + addr_t fault_addr, + pf_error_t error_code) { // Check to see if pde and pte exist (create them if not) pde32_t * pde = CR3_TO_PDE32_VA(info->ctrl_regs.cr3); int pde_index = PDE32_INDEX(fault_addr); int pte_index = PTE32_INDEX(fault_addr); - if(pde[pde_index].present != 1) { + + if (pde[pde_index].present != 1) { + PrintError("Creating new page table for PTE index: %d\n", pde_index); + pte32_t * pte = create_pte32(); addr_t host_addr; + if(guest_pa_to_host_pa(info, fault_addr, &host_addr) == -1) return -1; + struct v3_shadow_region * region = v3_get_shadow_region(info, PAGE_BASE_ADDR(host_addr)); + + pte[pte_index].present = 1; + pte[pte_index].writable = 1; + pte[pte_index].user_page = 1; + pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr); + + pde[pde_index].present = 1; + pde[pde_index].writable = 1; + pde[pde_index].user_page = 1; + pde[pde_index].pt_base_addr = PAGE_BASE_ADDR((addr_t)V3_PAddr(pte)); + + if (region->host_type == SHDW_REGION_WRITE_HOOK) { + pte[pte_index].writable = 0; + } + + PrintError("Fault Addr: 0x%p\nHost Addr: 0x%p\n", (void*)fault_addr, (void*)host_addr); + + } else { + pte32_t * pte = V3_VAddr((void*)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr)); + + if (pte[pte_index].present != 1) { + addr_t host_addr; + + if (guest_pa_to_host_pa(info, fault_addr, &host_addr) == -1) return -1; + + struct v3_shadow_region * region = v3_get_shadow_region(info, PAGE_BASE_ADDR(host_addr)); + pte[pte_index].present = 1; pte[pte_index].writable = 1; pte[pte_index].user_page = 1; pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr); - - pde[pde_index].present = 1; - pde[pde_index].writable = 1; - pde[pde_index].user_page = 1; - pde[pde_index].pt_base_addr = PAGE_BASE_ADDR((addr_t)V3_PAddr(pte)); - if(region->host_type == SHDW_REGION_WRITE_HOOK) { + + if (region->host_type == SHDW_REGION_WRITE_HOOK) { pte[pte_index].writable = 0; } - PrintError("Fault Addr: 0x%p\nHost Addr: 0x%p\n", (void*)fault_addr, (void*)host_addr); - } - else { - pte32_t * pte = (void*)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr); - if(pte[pte_index].present != 1) { - addr_t host_addr; - if(guest_pa_to_host_pa(info, fault_addr, &host_addr) == -1) return -1; - struct v3_shadow_region * region = v3_get_shadow_region(info, PAGE_BASE_ADDR(host_addr)); - pte[pte_index].present = 1; - pte[pte_index].writable = 1; - pte[pte_index].user_page = 1; - pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr); - if(region->host_type == SHDW_REGION_WRITE_HOOK) { - pte[pte_index].writable = 0; - } - } } - return 0; + } + return 0; }