qemu-xen-traditionnal, Fix dirty logging during migration.
PATCH v2 1/1 qemu-xen-traditionnal, Fix dirty logging during migration.
This moves the xen_modified_memory call from cpu_physical_memory_map to cpu_physical_memory_unmap because the memory could be migrated before the device model have written to it.
But because we need to know the guest address and to avoid rewriting a new function, the call is moved to qemu_invalidate_entry. So this later has to new parameters, the length of the mapping and if it was a write.
---
Change since first version:
- No more extra function to get the guest address from a pointer.
Quoted 1 line
The
xc_hvm_modied_memoryis moved toqemu_invalidate_entry
hw/xen_machine_fv.c | 16 ++++++++++++++-- i386-dm/exec-dm.c | 6 +----- qemu-xen.h | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-)
hw/xen_machine_fv.c +14 -2
@@ -174,7 +174,8 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, uint8_t lock)return last_address_vaddr + address_offset; } -void qemu_invalidate_entry (uint8_t *buffer) +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t access_len, +int was_written) {struct map_cache *entry =NULL , *pentry =NULL ;struct map_cache_rev *reventry;
@@ -210,6 +211,17 @@ void qemu_invalidate_entry(uint8_t *buffer)fprintf (logfile,"Trying to unmap address %p that is not in the mapcache!\n" , buffer);return ; } +if (xen_logdirty_enable && was_written) { +unsigned long addr = (paddr_index <<MCACHE_BUCKET_SHIFT ) + + ((unsigned long )buffer) - ((unsigned long )entry->vaddr_base); +if (access_len ==0 ) + access_len =TARGET_PAGE_SIZE ; +xc_hvm_modified_memory (xc_handle, domid, + addr >>TARGET_PAGE_BITS , + ((addr + access_len +TARGET_PAGE_SIZE -1 ) >>TARGET_PAGE_BITS ) + - (addr >>TARGET_PAGE_BITS )); + } + entry->lock--;if (entry->lock >0 || pentry ==NULL )return ;
@@ -265,7 +277,7 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, uint8_t lock)void qemu_invalidate_map_cache (void ) {}; -void qemu_invalidate_entry (uint8_t *buffer) {}; +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t len,int w) {};#endif /* defined(MAPCACHE) */
i386-dm/exec-dm.c +1 -5
@@ -820,10 +820,6 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,if ((*plen) > l) *plen = l;#endif -if (xen_logdirty_enable) -xc_hvm_modified_memory (xc_handle, domid, addr >>TARGET_PAGE_BITS , - ((addr + l +TARGET_PAGE_SIZE -1 ) >>TARGET_PAGE_BITS ) - - (addr >>TARGET_PAGE_BITS ));return qemu_map_cache (addr,1 ); }
@@ -835,6 +831,6 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,void cpu_physical_memory_unmap (void *buffer,target_phys_addr_t len,int is_write,target_phys_addr_t access_len) { -qemu_invalidate_entry (buffer); +qemu_invalidate_entry (buffer, access_len, is_write);cpu_notify_map_clients (); }
qemu-xen.h +1 -1
@@ -28,7 +28,7 @@ extern int vga_ram_size;#endif uint8_t *qemu_map_cache (target_phys_addr_t phys_addr,uint8_t lock); -void qemu_invalidate_entry (uint8_t *buffer); +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t len,int w);void qemu_invalidate_map_cache (void );#define mapcache_lock () ((void)0)
Signature · 1 line
Anthony PERARD
Quoted 9 lines · Anthony PERARD
This moves the
xen_modified_memorycall fromcpu_physical_memory_maptocpu_physical_memory_unmapbecause the memory could be migrated before the device model have written to it.But because we need to know the guest address and to avoid rewriting a new function, the call is moved to
qemu_invalidate_entry. So this later has to new parameters, the length of the mapping and if it was a write.Signed-off-by Anthony PERARD <[email protected]>
Quoted 89 lines
Change since first version:
- No more extra function to get the guest address from a pointer.Quoted 1 line
The
xc_hvm_modied_memoryis moved toqemu_invalidate_entryhw/xen_machine_fv.c | 16 ++++++++++++++-- i386-dm/exec-dm.c | 6 +----- qemu-xen.h | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-)hw/xen_machine_fv.c +14
-2@@ -174,7 +174,8 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, uint8_t lock)return last_address_vaddr + address_offset; } -void qemu_invalidate_entry (uint8_t *buffer) +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t access_len, +int was_written) {struct map_cache *entry =NULL , *pentry =NULL ;struct map_cache_rev *reventry;@@ -210,6 +211,17 @@ void qemu_invalidate_entry(uint8_t *buffer)fprintf (logfile,"Trying to unmap address %p that is not in the mapcache!\n" , buffer);return ; } +if (xen_logdirty_enable && was_written) { +unsigned long addr = (paddr_index <<MCACHE_BUCKET_SHIFT ) + + ((unsigned long )buffer) - ((unsigned long )entry->vaddr_base); +if (access_len ==0 ) + access_len =TARGET_PAGE_SIZE ; +xc_hvm_modified_memory (xc_handle, domid, + addr >>TARGET_PAGE_BITS , + ((addr + access_len +TARGET_PAGE_SIZE -1 ) >>TARGET_PAGE_BITS ) + - (addr >>TARGET_PAGE_BITS )); + } + entry->lock--;if (entry->lock >0 || pentry ==NULL )return ;@@ -265,7 +277,7 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, uint8_t lock)void qemu_invalidate_map_cache (void ) {}; -void qemu_invalidate_entry (uint8_t *buffer) {}; +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t len,int w) {};#endif /* defined(MAPCACHE) */ i386-dm/exec-dm.c +1
-5@@ -820,10 +820,6 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,if ((*plen) > l) *plen = l;#endif -if (xen_logdirty_enable) -xc_hvm_modified_memory (xc_handle, domid, addr >>TARGET_PAGE_BITS , - ((addr + l +TARGET_PAGE_SIZE -1 ) >>TARGET_PAGE_BITS ) - - (addr >>TARGET_PAGE_BITS ));return qemu_map_cache (addr,1 ); }@@ -835,6 +831,6 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,void cpu_physical_memory_unmap (void *buffer,target_phys_addr_t len,int is_write,target_phys_addr_t access_len) { -qemu_invalidate_entry (buffer); +qemu_invalidate_entry (buffer, access_len, is_write);cpu_notify_map_clients (); }qemu-xen.h +1
-1@@ -28,7 +28,7 @@ extern int vga_ram_size;#endif uint8_t *qemu_map_cache (target_phys_addr_t phys_addr,uint8_t lock); -void qemu_invalidate_entry (uint8_t *buffer); +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t len,int w);void qemu_invalidate_map_cache (void );#define mapcache_lock () ((void)0)Signature · 1 line
Anthony PERARD
Hi,
This patch have never been applied.
Regards,
Quoted 104 lines · Stefano Stabellini
Quoted 9 lines · Anthony PERARD
This moves the
xen_modified_memorycall fromcpu_physical_memory_maptocpu_physical_memory_unmapbecause the memory could be migrated before the device model have written to it.But because we need to know the guest address and to avoid rewriting a new function, the call is moved to
qemu_invalidate_entry. So this later has to new parameters, the length of the mapping and if it was a write.Signed-off-by Anthony PERARD <[email protected]>Quoted 89 lines
Change since first version:
- No more extra function to get the guest address from a pointer.Quoted 1 line
The
xc_hvm_modied_memoryis moved toqemu_invalidate_entryhw/xen_machine_fv.c | 16 ++++++++++++++-- i386-dm/exec-dm.c | 6 +----- qemu-xen.h | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-)hw/xen_machine_fv.c +14
-2@@ -174,7 +174,8 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, uint8_t lock)return last_address_vaddr + address_offset; } -void qemu_invalidate_entry (uint8_t *buffer) +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t access_len, +int was_written) {struct map_cache *entry =NULL , *pentry =NULL ;struct map_cache_rev *reventry;@@ -210,6 +211,17 @@ void qemu_invalidate_entry(uint8_t *buffer)fprintf (logfile,"Trying to unmap address %p that is not in the mapcache!\n" , buffer);return ; } +if (xen_logdirty_enable && was_written) { +unsigned long addr = (paddr_index <<MCACHE_BUCKET_SHIFT ) + + ((unsigned long )buffer) - ((unsigned long )entry->vaddr_base); +if (access_len ==0 ) + access_len =TARGET_PAGE_SIZE ; +xc_hvm_modified_memory (xc_handle, domid, + addr >>TARGET_PAGE_BITS , + ((addr + access_len +TARGET_PAGE_SIZE -1 ) >>TARGET_PAGE_BITS ) + - (addr >>TARGET_PAGE_BITS )); + } + entry->lock--;if (entry->lock >0 || pentry ==NULL )return ;@@ -265,7 +277,7 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, uint8_t lock)void qemu_invalidate_map_cache (void ) {}; -void qemu_invalidate_entry (uint8_t *buffer) {}; +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t len,int w) {};#endif /* defined(MAPCACHE) */ i386-dm/exec-dm.c +1
-5@@ -820,10 +820,6 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,if ((*plen) > l) *plen = l;#endif -if (xen_logdirty_enable) -xc_hvm_modified_memory (xc_handle, domid, addr >>TARGET_PAGE_BITS , - ((addr + l +TARGET_PAGE_SIZE -1 ) >>TARGET_PAGE_BITS ) - - (addr >>TARGET_PAGE_BITS ));return qemu_map_cache (addr,1 ); }@@ -835,6 +831,6 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,void cpu_physical_memory_unmap (void *buffer,target_phys_addr_t len,int is_write,target_phys_addr_t access_len) { -qemu_invalidate_entry (buffer); +qemu_invalidate_entry (buffer, access_len, is_write);cpu_notify_map_clients (); }qemu-xen.h +1
-2@@ -28,7 +28,7 @@ extern int vga_ram_size;#endif uint8_t *qemu_map_cache (target_phys_addr_t phys_addr,uint8_t lock); -void qemu_invalidate_entry (uint8_t *buffer); +void qemu_invalidate_entry (uint8_t *buffer,target_phys_addr_t len,int w);void qemu_invalidate_map_cache (void );#define mapcache_lock () ((void)0) --Anthony PERARD
Signature · 1 line
Anthony PERARD