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.


lots of changes...
[palacios.git] / palacios / include / palacios / vmm_mem.h
1 #ifndef __VMM_MEM_H
2 #define __VMM_MEM_H
3
4
5
6 #include <palacios/vmm_types.h>
7
8
9 typedef ulong_t addr_t;
10
11 struct guest_info;
12
13
14 /*
15
16         Guest                  Shadow                 Host
17   Virtual   Physical    Virtual     Physical   Virtual     Physical
18                OK                      OK
19                OK                      NOK
20                NOK                     OK
21                NOK                     NOK
22
23 */
24
25 // These are the types of physical memory address regions
26 // from the perspective of the guest
27 typedef enum guest_region_type { 
28   GUEST_REGION_NOTHING, 
29   GUEST_REGION_PHYSICAL_MEMORY, 
30   GUEST_REGION_MEMORY_MAPPED_DEVICE} guest_region_type_t;
31
32 // These are the types of physical memory address regions
33 // from the perspective of the HOST
34 typedef enum host_region_type { 
35   HOST_REGION_INVALID,                    // This region is INVALID (this is a return type, to denote errors)
36   HOST_REGION_NOTHING,                    // This region is mapped as not present (always generate page faults)
37   HOST_REGION_PHYSICAL_MEMORY,            // Region is a section of host memory
38   HOST_REGION_MEMORY_MAPPED_DEVICE,       // Region is allocated for DMA
39   HOST_REGION_UNALLOCATED,                // Region is mapped on demand
40   HOST_REGION_REMOTE,                     // Region is located on a remote machine
41   HOST_REGION_SWAPPED,                    // Region is swapped
42 } host_region_type_t;
43
44
45
46 #define shadow_mem_type_t host_region_type_t
47
48 typedef struct shadow_region {
49   guest_region_type_t     guest_type;
50   addr_t                  guest_start; 
51   addr_t                  guest_end; 
52
53   host_region_type_t      host_type;
54   union host_addr_t {
55     struct physical_addr { 
56        addr_t                  host_start; 
57     }                     phys_addr;
58     // Other addresses, like on disk, etc, would go here
59   }                       host_addr;
60   struct shadow_region *next, *prev;
61 } shadow_region_t;
62
63
64
65 struct shadow_map {
66   uint_t num_regions;
67
68   shadow_region_t * head;
69 };
70
71
72 void init_shadow_region(shadow_region_t * entry,
73                            addr_t               guest_addr_start,
74                            addr_t               guest_addr_end,
75                            guest_region_type_t  guest_region_type,
76                            host_region_type_t   host_region_type);
77
78 /*
79 void init_shadow_region_physical(shadow_region_t * entry,
80                                     addr_t               guest_addr_start,
81                                     addr_t               guest_addr_end,
82                                     guest_region_type_t  guest_region_type,
83                                     addr_t               host_addr_start,
84                                     host_region_type_t   host_region_type);
85 */
86
87 int add_shadow_region_passthrough(struct guest_info * guest_info, 
88                                   addr_t guest_addr_start,
89                                   addr_t guest_addr_end,
90                                   addr_t host_addr_start);
91
92 void init_shadow_map(struct shadow_map * map);
93 void free_shadow_map(struct shadow_map * map);
94
95 shadow_region_t * get_shadow_region_by_addr(struct shadow_map * map, addr_t guest_addr);
96
97 shadow_region_t * get_shadow_region_by_index(struct shadow_map * map, uint_t index);
98
99 host_region_type_t lookup_shadow_map_addr(struct shadow_map * map, addr_t guest_addr, addr_t * host_addr);
100
101 host_region_type_t get_shadow_addr_type(struct guest_info * info, addr_t guest_addr);
102 addr_t get_shadow_addr(struct guest_info * info, addr_t guest_addr);
103
104 // Semantics:
105 // Adding a region that overlaps with an existing region results is undefined
106 // and will probably fail
107 int add_shadow_region(struct shadow_map * map, shadow_region_t * entry);
108
109 // Semantics:
110 // Deletions result in splitting
111 int delete_shadow_region(struct shadow_map * map,
112                              addr_t guest_start, 
113                              addr_t guest_end);
114
115
116 void print_shadow_map(struct shadow_map * map);
117
118
119
120
121 #endif