2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Steven Jaconette <stevenjaconette2007@u.northwestern.edu>
11 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
12 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
13 * All rights reserved.
15 * Author: Steven Jaconette <stevenjaconette2007@u.northwestern.edu>
17 * This is free software. You are permitted to use,
18 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
22 #ifndef __VMM_DIRECT_PAGING_32_H__
23 #define __VMM_DIRECT_PAGING_32_H__
25 #include <palacios/vmm_mem.h>
26 #include <palacios/vmm_paging.h>
27 #include <palacios/vmm.h>
28 #include <palacios/vm_guest_mem.h>
29 #include <palacios/vm_guest.h>
32 static inline int handle_passthrough_pagefault_32(struct guest_info * info,
34 pf_error_t error_code) {
35 // Check to see if pde and pte exist (create them if not)
36 pde32_t * pde = CR3_TO_PDE32_VA(info->ctrl_regs.cr3);
40 int pde_index = PDE32_INDEX(fault_addr);
41 int pte_index = PTE32_INDEX(fault_addr);
43 struct v3_shadow_region * region = v3_get_shadow_region(info, fault_addr);
45 if ((region == NULL) ||
46 (region->host_type == SHDW_REGION_INVALID)) {
47 PrintError("Invalid region in passthrough page fault 32, addr=%p\n",
52 host_addr = v3_get_shadow_addr(region, fault_addr);
54 // Fix up the PDE entry
55 if (pde[pde_index].present == 0) {
56 pte = (pte32_t *)create_generic_pt_page();
58 pde[pde_index].present = 1;
59 pde[pde_index].writable = 1;
60 pde[pde_index].user_page = 1;
61 pde[pde_index].pt_base_addr = PAGE_BASE_ADDR((addr_t)V3_PAddr(pte));
64 pte = V3_VAddr((void*)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr));
67 // Fix up the PTE entry
68 if (pte[pte_index].present == 0) {
70 pte[pte_index].user_page = 1;
72 if (region->host_type == SHDW_REGION_ALLOCATED) {
74 pte[pte_index].present = 1;
75 pte[pte_index].writable = 1;
77 pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr);
78 } else if (region->host_type == SHDW_REGION_WRITE_HOOK) {
80 pte[pte_index].present = 1;
81 pte[pte_index].writable = 0;
83 pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr);
84 } else if (region->host_type == SHDW_REGION_FULL_HOOK) {
86 return v3_handle_mem_full_hook(info, fault_addr, fault_addr, region, error_code);
88 PrintError("Unknown Region Type...\n");
93 if ( (region->host_type == SHDW_REGION_WRITE_HOOK) &&
94 (error_code.write == 1) ) {
95 return v3_handle_mem_wr_hook(info, fault_addr, fault_addr, region, error_code);