}
-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;
}