@@ -2438,27 +2438,34 @@ static int kvm_get_dirty_pages_log_range(unsigned long start_addr,
unsigned long offset,
unsigned long mem_size)
{
- unsigned int i, j, n = 0;
+ unsigned int i, j, k, start, end;
unsigned char c;
unsigned long page_number, addr, addr1;
ram_addr_t ram_addr;
- unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + 7) / 8;
+ unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + TARGET_LONG_BITS - 1) /
+ TARGET_LONG_BITS;
+ unsigned long *bitmap_ul = (unsigned long *)bitmap;
/*
* bitmap-traveling is faster than memory-traveling (for addr...)
* especially when most of the memory is not dirty.
*/
for (i = 0; i < len; i++) {
- c = bitmap[i];
- while (c > 0) {
- j = ffsl(c) - 1;
- c &= ~(1u << j);
- page_number = i * 8 + j;
- addr1 = page_number * TARGET_PAGE_SIZE;
- addr = offset + addr1;
- ram_addr = cpu_get_physical_page_desc(addr);
- cpu_physical_memory_set_dirty(ram_addr);
- n++;
+ if (bitmap_ul[i] != 0) {
+ start = i * TARGET_LONG_SIZE;
+ end = (i + 1) * TARGET_LONG_SIZE;
+ for (j = start; j < end; j++) {
+ c = bitmap[j];
+ while (c > 0) {
+ k = ffsl(c) - 1;
+ c &= ~(1u << k);
+ page_number = j * 8 + k;
+ addr1 = page_number * TARGET_PAGE_SIZE;
+ addr = offset + addr1;
+ ram_addr = cpu_get_physical_page_desc(addr);
+ cpu_physical_memory_set_dirty(ram_addr);
+ }
+ }
}
}
return 0;