--- /dev/null
+#include <palacios/vmm_direct_paging.h>
+
+// Inline handler functions for each cpu mode
+#include "vmm_direct_paging_32.h"
+
+#include <palacios/vmm_paging.h>
+#include <palacios/vmm.h>
+#include <palacios/vm_guest_mem.h>
+#include <palacios/vm_guest.h>
+
+pde32_t * v3_create_direct_passthrough_pts(struct guest_info * info) {
+ v3_vm_cpu_mode_t mode = v3_get_cpu_mode(info);
+ switch(mode) {
+ case REAL:
+ //break;
+ case PROTECTED:
+ PrintError("ABC\n");
+ return v3_create_direct_passthrough_pts_32(info);
+ case PROTECTED_PAE:
+ break;
+ case LONG:
+ break;
+ case LONG_32_COMPAT:
+ break;
+ default:
+ PrintError("Unknown CPU Mode\n");
+ break;
+ }
+ return NULL;
+}
+
+int v3_handle_shadow_pagefault_physical_mode(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
+ v3_vm_cpu_mode_t mode = v3_get_cpu_mode(info);
+ switch(mode) {
+ case REAL:
+ // break;
+ case PROTECTED:
+ return v3_handle_shadow_pagefault_physical_mode_32(info, fault_addr, error_code);
+ case PROTECTED_PAE:
+ break;
+ case LONG:
+ break;
+ case LONG_32_COMPAT:
+ break;
+ default:
+ PrintError("Unknown CPU Mode\n");
+ break;
+ }
+ return -1;
+}
--- /dev/null
+#ifndef __VMM_DIRECT_PAGING_32_H__
+#define __VMM_DIRECT_PAGING_32_H__
+
+#include <palacios/vmm_mem.h>
+#include <palacios/vmm_paging.h>
+#include <palacios/vmm.h>
+#include <palacios/vm_guest_mem.h>
+#include <palacios/vm_guest.h>
+
+static pde32_t * create_pde32() {
+ void * pde = 0;
+ pde = V3_VAddr(V3_AllocPages(1));
+ memset(pde, 0, PAGE_SIZE);
+
+ return (pde32_t *) pde;
+}
+
+
+static pte32_t * create_pte32() {
+ void * pte = 0;
+ pte = V3_VAddr(V3_AllocPages(1));
+ memset(pte, 0, PAGE_SIZE);
+
+ return (pte32_t *) pte;
+}
+
+
+static inline pde32_t * v3_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) {
+ // 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) {
+ 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;
+ 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));
+ 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;
+ 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);
+ }
+ }
+ return 0;
+}
+
+
+#endif
#include <palacios/vmm_hashtable.h>
+#include <palacios/vmm_direct_paging.h>
+
#ifndef DEBUG_SHADOW_PAGING
#undef PrintDebug
#define PrintDebug(fmt, args...)
if (v3_get_mem_mode(info) == PHYSICAL_MEM) {
// If paging is not turned on we need to handle the special cases
- return handle_special_page_fault(info, fault_addr, fault_addr, error_code);
+ return v3_handle_shadow_pagefault_physical_mode(info, fault_addr, error_code);
} else if (v3_get_mem_mode(info) == VIRTUAL_MEM) {
switch (v3_get_cpu_mode(info)) {