static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section,

                                         unsigned long *bitmap)

{

    unsigned int i, j;

    unsigned long page_number, c;

    hwaddr addr, addr1;

    unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS;

    unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;



    /*

     * bitmap-traveling is faster than memory-traveling (for addr...)

     * especially when most of the memory is not dirty.

     */

    for (i = 0; i < len; i++) {

        if (bitmap[i] != 0) {

            c = leul_to_cpu(bitmap[i]);

            do {

                j = ffsl(c) - 1;

                c &= ~(1ul << j);

                page_number = (i * HOST_LONG_BITS + j) * hpratio;

                addr1 = page_number * TARGET_PAGE_SIZE;

                addr = section->offset_within_region + addr1;

                memory_region_set_dirty(section->mr, addr,

                                        TARGET_PAGE_SIZE * hpratio);

            } while (c != 0);

        }

    }

    return 0;

}

static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section,

                                         unsigned long *bitmap)

{

    unsigned int i, j;

    unsigned long page_number, c;

    hwaddr addr, addr1;

    unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS;

    unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;



    







    for (i = 0; i < len; i++) {

        if (bitmap[i] != 0) {

            c = leul_to_cpu(bitmap[i]);

            do {

                j = ffsl(c) - 1;

                c &= ~(1ul << j);

                page_number = (i * HOST_LONG_BITS + j) * hpratio;

                addr1 = page_number * TARGET_PAGE_SIZE;

                addr = section->offset_within_region + addr1;

                memory_region_set_dirty(section->mr, addr,

                                        TARGET_PAGE_SIZE * hpratio);

            } while (c != 0);

        }

    }

    return 0;

}

static int FUNC_0(MemoryRegionSection *VAR_0,

                                         unsigned long *VAR_1)

{

    unsigned int VAR_2, VAR_3;

    unsigned long VAR_4, VAR_5;

    hwaddr addr, addr1;

    unsigned int VAR_6 = ((VAR_0->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS;

    unsigned long VAR_7 = getpagesize() / TARGET_PAGE_SIZE;



    







    for (VAR_2 = 0; VAR_2 < VAR_6; VAR_2++) {

        if (VAR_1[VAR_2] != 0) {

            VAR_5 = leul_to_cpu(VAR_1[VAR_2]);

            do {

                VAR_3 = ffsl(VAR_5) - 1;

                VAR_5 &= ~(1ul << VAR_3);

                VAR_4 = (VAR_2 * HOST_LONG_BITS + VAR_3) * VAR_7;

                addr1 = VAR_4 * TARGET_PAGE_SIZE;

                addr = VAR_0->offset_within_region + addr1;

                memory_region_set_dirty(VAR_0->mr, addr,

                                        TARGET_PAGE_SIZE * VAR_7);

            } while (VAR_5 != 0);

        }

    }

    return 0;

}

static int FUNC_0(MemoryRegionSection *VAR_0,
unsigned long *VAR_1)
{ unsigned int VAR_2, VAR_3; unsigned long VAR_4, VAR_5; hwaddr addr, addr1; unsigned int VAR_6 = ((VAR_0->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; unsigned long VAR_7 = getpagesize() / TARGET_PAGE_SIZE; for (VAR_2 = 0; VAR_2 < VAR_6; VAR_2++) { if (VAR_1[VAR_2] != 0) { VAR_5 = leul_to_cpu(VAR_1[VAR_2]); do { VAR_3 = ffsl(VAR_5) - 1; VAR_5 &= ~(1ul << VAR_3); VAR_4 = (VAR_2 * HOST_LONG_BITS + VAR_3) * VAR_7; addr1 = VAR_4 * TARGET_PAGE_SIZE; addr = VAR_0->offset_within_region + addr1; memory_region_set_dirty(VAR_0->mr, addr,
TARGET_PAGE_SIZE * VAR_7); } while (VAR_5 != 0); } } return 0; }