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.


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