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.


removed old memory region type enumeration
[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 #include <palacios/vmm_list.h>
33
34 struct guest_info;
35 struct v3_vm_info;
36
37
38
39 #define V3_MEM_CORE_ANY ((uint16_t)-1)
40
41
42
43 typedef struct {
44     union {
45         uint16_t value;
46         struct {
47             uint8_t read   : 1;
48             uint8_t write  : 1;
49             uint8_t exec   : 1;
50             uint8_t hook   : 1;
51             uint8_t base   : 1;
52             uint8_t alloced : 1;
53         } __attribute__((packed));
54     } __attribute__((packed));
55 } __attribute__((packed)) v3_mem_flags_t;
56
57
58
59 struct v3_shadow_region {
60     addr_t                  guest_start; 
61     addr_t                  guest_end; 
62
63     v3_mem_flags_t          flags;
64
65     addr_t                  host_addr; // This either points to a host address mapping
66
67     // Called when data is read from a memory page
68     int (*read_hook)(struct guest_info * core, addr_t guest_addr, void * dst, uint_t length, void * priv_data);
69     // Called when data is written to a memory page
70     int (*write_hook)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data);
71
72     void * priv_data;
73
74     int core_id;
75
76     struct rb_node tree_node; // This for memory regions mapped to the global map
77 };
78
79
80 struct v3_mem_map {
81     struct v3_shadow_region base_region;
82
83     struct rb_root shdw_regions;
84
85     void * hook_hvas; // this is an array of pages, equal to the number of cores
86 };
87
88
89 int v3_init_mem_map(struct v3_vm_info * vm);
90 void v3_delete_mem_map(struct v3_vm_info * vm);
91
92
93
94
95 int v3_add_shadow_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
98 int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id,
99                      addr_t guest_addr_start, addr_t guest_addr_end,
100                      int (*read)(struct guest_info * core, addr_t guest_addr, void * dst, uint_t length, void * priv_data),
101                      int (*write)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data),
102                      void * priv_data);
103
104 int v3_hook_write_mem(struct v3_vm_info * vm, uint16_t core_id, 
105                       addr_t guest_addr_start, addr_t guest_addr_end, addr_t host_addr,
106                       int (*write)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data),
107                       void * priv_data);
108
109
110 int v3_unhook_mem(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr_start);
111
112
113
114
115
116 void v3_delete_shadow_region(struct v3_vm_info * vm, struct v3_shadow_region * reg);
117
118
119
120
121 struct v3_shadow_region * v3_get_shadow_region(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr);
122
123
124 addr_t v3_get_shadow_addr(struct v3_shadow_region * reg, uint16_t core_id, addr_t guest_addr);
125
126
127
128
129
130 void v3_print_mem_map(struct v3_vm_info * vm);
131
132
133
134 int v3_handle_mem_hook(struct guest_info * info, addr_t guest_va, addr_t guest_pa, 
135                        struct v3_shadow_region * reg, pf_error_t access_info);
136
137
138 #endif // ! __V3VEE__
139
140
141 #endif