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, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
28 #include <palacios/vmm_types.h>
30 #include <palacios/vmm_paging.h>
31 #include <palacios/vmm_rbtree.h>
32 #include <palacios/vmm_list.h>
39 // These are the types of physical memory address regions
40 // from the perspective of the HOST
41 typedef enum shdw_region_type {
42 SHDW_REGION_WRITE_HOOK, // This region is mapped as read-only (page faults on write)
43 SHDW_REGION_FULL_HOOK, // This region is mapped as not present (always generate page faults)
44 SHDW_REGION_ALLOCATED, // Region is a section of host memory
45 } v3_shdw_region_type_t;
47 #define V3_MEM_CORE_ANY ((uint16_t)-1)
50 struct v3_shadow_region {
54 v3_shdw_region_type_t host_type;
56 addr_t host_addr; // This either points to a host address mapping
58 // Called when data is read from a memory page
59 int (*read_hook)(struct guest_info * core, addr_t guest_addr, void * dst, uint_t length, void * priv_data);
60 // Called when data is written to a memory page
61 int (*write_hook)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data);
67 struct rb_node tree_node; // This for memory regions mapped to the global map
72 struct v3_shadow_region base_region;
74 struct rb_root shdw_regions;
76 void * hook_hvas; // this is an array of pages, equal to the number of cores
80 int v3_init_mem_map(struct v3_vm_info * vm);
81 void v3_delete_mem_map(struct v3_vm_info * vm);
86 int v3_add_shadow_mem(struct v3_vm_info * vm, uint16_t core_id,
87 addr_t guest_addr_start, addr_t guest_addr_end, addr_t host_addr);
89 int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id,
90 addr_t guest_addr_start, addr_t guest_addr_end,
91 int (*read)(struct guest_info * core, addr_t guest_addr, void * dst, uint_t length, void * priv_data),
92 int (*write)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data),
95 int v3_hook_write_mem(struct v3_vm_info * vm, uint16_t core_id,
96 addr_t guest_addr_start, addr_t guest_addr_end, addr_t host_addr,
97 int (*write)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data),
101 int v3_unhook_mem(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr_start);
107 void v3_delete_shadow_region(struct v3_vm_info * vm, struct v3_shadow_region * reg);
112 struct v3_shadow_region * v3_get_shadow_region(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr);
113 addr_t v3_get_shadow_addr(struct v3_shadow_region * reg, uint16_t core_id, addr_t guest_addr);
119 void v3_print_mem_map(struct v3_vm_info * vm);
125 const uchar_t * v3_shdw_region_type_to_str(v3_shdw_region_type_t type);
129 int handle_special_page_fault(struct guest_info * info, addr_t fault_addr, addr_t gp_addr, pf_error_t access_info);
131 int v3_handle_mem_wr_hook(struct guest_info * info, addr_t guest_va, addr_t guest_pa,
132 struct v3_shadow_region * reg, pf_error_t access_info);
133 int v3_handle_mem_full_hook(struct guest_info * info, addr_t guest_va, addr_t guest_pa,
134 struct v3_shadow_region * reg, pf_error_t access_info);
136 #endif // ! __V3VEE__