5 #include <palacios/vmm_types.h>
8 typedef ulong_t addr_t;
16 Virtual Physical Virtual Physical Virtual Physical
24 // These are the types of physical memory address regions
25 // from the perspective of the guest
26 typedef enum guest_region_type {
28 GUEST_REGION_PHYSICAL_MEMORY,
29 GUEST_REGION_MEMORY_MAPPED_DEVICE} guest_region_type_t;
31 // These are the types of physical memory address regions
32 // from the perspective of the HOST
33 typedef enum host_region_type {
34 HOST_REGION_INVALID, // This region is INVALID (this is a return type, to denote errors)
35 HOST_REGION_NOTHING, // This region is mapped as not present (always generate page faults)
36 HOST_REGION_PHYSICAL_MEMORY, // Region is a section of host memory
37 HOST_REGION_MEMORY_MAPPED_DEVICE, // Region is allocated for DMA
38 HOST_REGION_UNALLOCATED, // Region is mapped on demand
39 HOST_REGION_REMOTE, // Region is located on a remote machine
40 HOST_REGION_SWAPPED, // Region is swapped
45 typedef struct shadow_region {
46 guest_region_type_t guest_type;
50 host_region_type_t host_type;
52 struct physical_addr {
55 // Other addresses, like on disk, etc, would go here
57 struct shadow_region *next, *prev;
65 shadow_region_t * head;
69 void init_shadow_region(shadow_region_t * entry,
70 addr_t guest_addr_start,
71 addr_t guest_addr_end,
72 guest_region_type_t guest_region_type,
73 host_region_type_t host_region_type);
76 void init_shadow_region_physical(shadow_region_t * entry,
77 addr_t guest_addr_start,
78 addr_t guest_addr_end,
79 guest_region_type_t guest_region_type,
80 addr_t host_addr_start,
81 host_region_type_t host_region_type);
84 int add_shadow_region_passthrough(struct guest_info * guest_info,
85 addr_t guest_addr_start,
86 addr_t guest_addr_end,
87 addr_t host_addr_start);
89 void init_shadow_map(struct shadow_map * map);
90 void free_shadow_map(struct shadow_map * map);
92 shadow_region_t * get_shadow_region_by_addr(struct shadow_map * map, addr_t guest_addr);
94 shadow_region_t * get_shadow_region_by_index(struct shadow_map * map, uint_t index);
96 host_region_type_t lookup_shadow_map_addr(struct shadow_map * map, addr_t guest_addr, addr_t * host_addr);
100 // Adding a region that overlaps with an existing region results is undefined
101 // and will probably fail
102 int add_shadow_region(struct shadow_map * map, shadow_region_t * entry);
105 // Deletions result in splitting
106 int delete_shadow_region(struct shadow_map * map,
111 void print_shadow_map(struct shadow_map * map);