Revision 96c1606b kvm-all.c

b/kvm-all.c
304 304
    return 0;
305 305
}
306 306

  
307
static int test_le_bit(unsigned long nr, unsigned char *addr)
308
{
309
    return (addr[nr >> 3] >> (nr & 7)) & 1;
310
}
311

  
307 312
/**
308 313
 * kvm_physical_sync_dirty_bitmap - Grab dirty bitmap from kernel space
309 314
 * This function updates qemu's dirty bitmap using cpu_physical_memory_set_dirty().
......
357 362
        for (phys_addr = mem->start_addr, addr = mem->phys_offset;
358 363
             phys_addr < mem->start_addr + mem->memory_size;
359 364
             phys_addr += TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
360
            uint64_t *bitmap = (uint64_t *)d.dirty_bitmap;
365
            unsigned char *bitmap = (unsigned char *)d.dirty_bitmap;
361 366
            unsigned nr = (phys_addr - mem->start_addr) >> TARGET_PAGE_BITS;
362
            unsigned word = nr / (sizeof(*bitmap) * 8);
363
            unsigned bit = nr % (sizeof(*bitmap) * 8);
364 367

  
365
            if ((bitmap[word] >> bit) & 1) {
368
            if (test_le_bit(nr, bitmap)) {
366 369
                cpu_physical_memory_set_dirty(addr);
367 370
            } else if (r < 0) {
368 371
                /* When our KVM implementation doesn't know about dirty logging

Also available in: Unified diff