Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


changed shadow memory map to use Red Black Tree
[palacios.git] / palacios / include / palacios / vmm_mem.h
1 /*
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.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
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.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21 #ifndef __VMM_MEM_H
22 #define __VMM_MEM_H
23
24
25 #ifdef __V3VEE__ 
26
27
28 #include <palacios/vmm_types.h>
29
30 #include <palacios/vmm_paging.h>
31 #include <palacios/vmm_rbtree.h>
32
33
34 struct guest_info;
35
36
37
38 // These are the types of physical memory address regions
39 // from the perspective of the HOST
40 typedef enum shdw_region_type { 
41   SHDW_REGION_INVALID,                    // This region is INVALID (this is a return type to denote errors)
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;
46
47
48 typedef struct rb_root v3_shdw_map_t;
49
50
51 struct v3_shadow_region {
52   addr_t                  guest_start; 
53   addr_t                  guest_end; 
54
55   v3_shdw_region_type_t   host_type;
56   
57   addr_t                  host_addr; // This either points to a host address mapping
58
59
60   // Called when data is read from a memory page
61   int (*read_hook)(addr_t guest_addr, void * dst, uint_t length, void * priv_data);
62   // Called when data is written to a memory page
63   int (*write_hook)(addr_t guest_addr, void * src, uint_t length, void * priv_data);
64
65   void * priv_data;
66
67   struct rb_node tree_node;
68 };
69
70
71
72 void v3_init_shadow_map(struct guest_info * info);
73 void v3_delete_shadow_map(struct guest_info * info);
74
75
76 int v3_add_shadow_mem(struct guest_info * guest_info, 
77                       addr_t guest_addr_start,
78                       addr_t guest_addr_end,
79                       addr_t host_addr);
80
81 int v3_hook_full_mem(struct guest_info * info, addr_t guest_addr_start, addr_t guest_addr_end,
82                      int (*read)(addr_t guest_addr, void * dst, uint_t length, void * priv_data),
83                      int (*write)(addr_t guest_addr, void * src, uint_t length, void * priv_data),
84                      void * priv_data);
85
86 int v3_hook_write_mem(struct guest_info * info, addr_t guest_addr_start, addr_t guest_addr_end,
87                       addr_t host_addr,
88                       int (*write)(addr_t guest_addr, void * src, uint_t length, void * priv_data),
89                       void * priv_data);
90
91
92
93
94
95
96 void v3_delete_shadow_region(struct guest_info * info, struct v3_shadow_region * reg);
97
98
99 struct v3_shadow_region * v3_get_shadow_region(struct guest_info * info, addr_t guest_addr);
100 addr_t v3_get_shadow_addr(struct v3_shadow_region * reg, addr_t guest_addr);
101
102
103
104
105
106 void print_shadow_map(struct guest_info * info);
107
108
109
110
111
112 const uchar_t * v3_shdw_region_type_to_str(v3_shdw_region_type_t type);
113
114
115
116 int handle_special_page_fault(struct guest_info * info, addr_t fault_addr, addr_t gp_addr, pf_error_t access_info);
117
118 int v3_handle_mem_wr_hook(struct guest_info * info, addr_t guest_va, addr_t guest_pa, 
119                           struct v3_shadow_region * reg, pf_error_t access_info);
120 int v3_handle_mem_full_hook(struct guest_info * info, addr_t guest_va, addr_t guest_pa, 
121                             struct v3_shadow_region * reg, pf_error_t access_info);
122
123 #endif // ! __V3VEE__
124
125
126 #endif