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.


Add swapping and pinning capability to Palacios
[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 #ifdef V3_CONFIG_SWAPPING
38 #include <palacios/vmm_swapping.h>
39 #endif
40
41
42
43
44 #define V3_MEM_CORE_ANY ((uint16_t)-1)
45
46
47
48 typedef struct {
49     union {
50         uint16_t value;
51         struct {
52             // These reflect the VMM's intent for the shadow or nested pts 
53             // that will implement the region.   The guest's intent is in
54             // its own page tables.
55             uint8_t read   : 1;
56             uint8_t write  : 1;
57             uint8_t exec   : 1;
58             uint8_t base   : 1;
59             uint8_t alloced : 1;
60             uint8_t limit32 : 1; // must be < 4GB in host
61 #ifdef V3_CONFIG_SWAPPING 
62             uint8_t swapped : 1;
63             uint8_t pinned : 1;
64 #endif 
65         } __attribute__((packed));
66     } __attribute__((packed));
67 } __attribute__((packed)) v3_mem_flags_t;
68
69
70
71 struct v3_mem_region {
72     addr_t                  guest_start; 
73     addr_t                  guest_end; 
74
75     v3_mem_flags_t          flags;
76
77     addr_t                  host_addr; // This either points to a host address mapping
78
79     int (*unhandled)(struct guest_info * info, addr_t guest_va, addr_t guest_pa, 
80                      struct v3_mem_region * reg, pf_error_t access_info);
81
82     void * priv_data;
83
84     int core_id;     // The virtual core this region is assigned to (-1 means all cores)
85     int numa_id;     // The NUMA node this region is allocated from
86
87 #ifdef V3_CONFIG_SWAPPING 
88     struct v3_swap_region_state swap_state;
89 #endif
90
91     struct rb_node tree_node; // This for memory regions mapped to the global map
92 };
93
94
95 struct v3_mem_map {
96
97     struct rb_root mem_regions;
98     
99     uint32_t num_base_regions;
100     struct v3_mem_region * base_regions;
101 };
102
103
104 int v3_init_mem_map(struct v3_vm_info * vm);
105 void v3_delete_mem_map(struct v3_vm_info * vm);
106
107
108
109
110
111 struct v3_mem_region * v3_create_mem_region(struct v3_vm_info * vm, uint16_t core_id, 
112                                                addr_t guest_addr_start, addr_t guest_addr_end);
113
114 int v3_insert_mem_region(struct v3_vm_info * vm, struct v3_mem_region * reg);
115
116 void v3_delete_mem_region(struct v3_vm_info * vm, struct v3_mem_region * reg);
117
118
119 /* This is a shortcut function for creating + inserting a memory region which redirects to host memory */
120 int v3_add_shadow_mem(struct v3_vm_info * vm, uint16_t core_id,
121                       addr_t guest_addr_start, addr_t guest_addr_end, addr_t host_addr);
122
123
124
125 struct v3_mem_region * v3_get_mem_region(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr);
126 struct v3_mem_region * v3_get_base_region(struct v3_vm_info * vm, addr_t gpa);
127
128
129 uint32_t v3_get_max_page_size(struct guest_info * core, addr_t fault_addr, v3_cpu_mode_t mode);
130
131
132 void v3_print_mem_map(struct v3_vm_info * vm);
133
134
135 void v3_init_mem();
136 void v3_deinit_mem();
137
138
139 #endif /* ! __V3VEE__ */
140
141
142 #endif