6 #include <palacios/vmm_types.h>
9 typedef ulong_t addr_t;
17 Virtual Physical Virtual Physical Virtual Physical
25 // These are the types of physical memory address regions
26 // from the perspective of the guest
27 typedef enum guest_region_type {
29 GUEST_REGION_PHYSICAL_MEMORY,
30 GUEST_REGION_MEMORY_MAPPED_DEVICE} guest_region_type_t;
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
46 #define shadow_mem_type_t host_region_type_t
48 typedef struct shadow_region {
49 guest_region_type_t guest_type;
53 host_region_type_t host_type;
55 struct physical_addr {
58 // Other addresses, like on disk, etc, would go here
60 struct shadow_region *next, *prev;
68 shadow_region_t * head;
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);
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);
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);
92 void init_shadow_map(struct shadow_map * map);
93 void free_shadow_map(struct shadow_map * map);
95 shadow_region_t * get_shadow_region_by_addr(struct shadow_map * map, addr_t guest_addr);
97 shadow_region_t * get_shadow_region_by_index(struct shadow_map * map, uint_t index);
99 host_region_type_t lookup_shadow_map_addr(struct shadow_map * map, addr_t guest_addr, addr_t * host_addr);
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);
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);
110 // Deletions result in splitting
111 int delete_shadow_region(struct shadow_map * map,
116 void print_shadow_map(struct shadow_map * map);