5 #include <palacios/vmm_types.h>
7 typedef ulong_t addr_t;
12 Virtual Physical Virtual Physical Virtual Physical
20 // These are the types of physical memory address regions
21 // from the perspective of the guest
22 typedef enum guest_region_type {
24 GUEST_REGION_PHYSICAL_MEMORY,
25 GUEST_REGION_MEMORY_MAPPED_DEVICE} guest_region_type_t;
27 // These are the types of physical memory address regions
28 // from the perspective of the HOST
29 typedef enum host_region_type {
30 HOST_REGION_INVALID, // This region is INVALID (this is a return type, to denote errors)
31 HOST_REGION_NOTHING, // This region is mapped as not present (always generate page faults)
32 HOST_REGION_PHYSICAL_MEMORY, // Region is a section of host memory
33 HOST_REGION_MEMORY_MAPPED_DEVICE, // Region is allocated for DMA
34 HOST_REGION_UNALLOCATED, // Region is mapped on demand
35 HOST_REGION_REMOTE, // Region is located on a remote machine
36 HOST_REGION_SWAPPED, // Region is swapped
41 typedef struct shadow_region {
42 guest_region_type_t guest_type;
46 host_region_type_t host_type;
48 struct physical_addr {
51 // Other addresses, like on disk, etc, would go here
53 struct shadow_region *next, *prev;
58 typedef struct shadow_map {
61 shadow_region_t * head;
65 void init_shadow_region(shadow_region_t * entry,
66 addr_t guest_addr_start,
67 addr_t guest_addr_end,
68 guest_region_type_t guest_region_type,
69 host_region_type_t host_region_type);
71 void init_shadow_region_physical(shadow_region_t * entry,
72 addr_t guest_addr_start,
73 addr_t guest_addr_end,
74 guest_region_type_t guest_region_type,
75 addr_t host_addr_start,
76 host_region_type_t host_region_type);
78 void init_shadow_map(shadow_map_t * map);
79 void free_shadow_map(shadow_map_t * map);
81 shadow_region_t * get_shadow_region_by_addr(shadow_map_t * map, addr_t guest_addr);
83 shadow_region_t * get_shadow_region_by_index(shadow_map_t * map, uint_t index);
85 host_region_type_t lookup_shadow_map_addr(shadow_map_t * map, addr_t guest_addr, addr_t * host_addr);
89 // Adding a region that overlaps with an existing region results is undefined
90 // and will probably fail
91 int add_shadow_region(shadow_map_t * map, shadow_region_t * entry);
94 // Deletions result in splitting
95 int delete_shadow_region(shadow_map_t * map,
100 void print_shadow_map(shadow_map_t * map);