diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2012-03-19 13:39:42 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-03-19 13:39:42 -0500 |
commit | 33cf629a3754b58a1e2dbbe01d91d97e712b7c06 (patch) | |
tree | fcf874262294eba07fb2f9eca11d594096847679 /xen-mapcache.c | |
parent | b85a4ec8a7ce348f3f385a53df4e418f2f54c182 (diff) | |
parent | c234572ded381423abca9801ebf5a32abd2495ef (diff) | |
download | qemu-33cf629a3754b58a1e2dbbe01d91d97e712b7c06.zip qemu-33cf629a3754b58a1e2dbbe01d91d97e712b7c06.tar.gz qemu-33cf629a3754b58a1e2dbbe01d91d97e712b7c06.tar.bz2 |
Merge remote-tracking branch 'sstabellini/saverestore-8' into staging
* sstabellini/saverestore-8:
xen: do not allocate RAM during INMIGRATE runstate
xen mapcache: check if memory region has moved.
xen: record physmap changes to xenstore
Set runstate to INMIGRATE earlier
Introduce "xen-save-devices-state"
cirrus_vga: do not reset videoram
Conflicts:
qapi-schema.json
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'xen-mapcache.c')
-rw-r--r-- | xen-mapcache.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/xen-mapcache.c b/xen-mapcache.c index 585b559..a456479 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -78,6 +78,9 @@ typedef struct MapCache { uint8_t *last_address_vaddr; unsigned long max_mcache_size; unsigned int mcache_bucket_shift; + + phys_offset_to_gaddr_t phys_offset_to_gaddr; + void *opaque; } MapCache; static MapCache *mapcache; @@ -91,13 +94,16 @@ static inline int test_bits(int nr, int size, const unsigned long *addr) return 0; } -void xen_map_cache_init(void) +void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque) { unsigned long size; struct rlimit rlimit_as; mapcache = g_malloc0(sizeof (MapCache)); + mapcache->phys_offset_to_gaddr = f; + mapcache->opaque = opaque; + QTAILQ_INIT(&mapcache->locked_entries); mapcache->last_address_index = -1; @@ -193,9 +199,14 @@ uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; - target_phys_addr_t address_index = phys_addr >> MCACHE_BUCKET_SHIFT; - target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); + target_phys_addr_t address_index; + target_phys_addr_t address_offset; target_phys_addr_t __size = size; + bool translated = false; + +tryagain: + address_index = phys_addr >> MCACHE_BUCKET_SHIFT; + address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); trace_xen_map_cache(phys_addr); @@ -237,6 +248,11 @@ uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, if(!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_address_index = -1; + if (!translated && mapcache->phys_offset_to_gaddr) { + phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque); + translated = true; + goto tryagain; + } trace_xen_map_cache_return(NULL); return NULL; } |