void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)

{

    RAMBlock *block;

    ram_addr_t offset;

    int flags;

    void *area, *vaddr;



    QTAILQ_FOREACH(block, &ram_list.blocks, next) {

        offset = addr - block->offset;

        if (offset < block->length) {

            vaddr = block->host + offset;

            if (block->flags & RAM_PREALLOC_MASK) {

                ;

            } else if (xen_enabled()) {

                abort();

            } else {

                flags = MAP_FIXED;

                munmap(vaddr, length);

                if (mem_path) {

#if defined(__linux__) && !defined(TARGET_S390X)

                    if (block->fd) {

#ifdef MAP_POPULATE

                        flags |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :

                            MAP_PRIVATE;

#else

                        flags |= MAP_PRIVATE;

#endif

                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,

                                    flags, block->fd, offset);

                    } else {

                        flags |= MAP_PRIVATE | MAP_ANONYMOUS;

                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,

                                    flags, -1, 0);

                    }

#else

                    abort();

#endif

                } else {

#if defined(TARGET_S390X) && defined(CONFIG_KVM)

                    flags |= MAP_SHARED | MAP_ANONYMOUS;

                    area = mmap(vaddr, length, PROT_EXEC|PROT_READ|PROT_WRITE,

                                flags, -1, 0);

#else

                    flags |= MAP_PRIVATE | MAP_ANONYMOUS;

                    area = mmap(vaddr, length, PROT_READ | PROT_WRITE,

                                flags, -1, 0);

#endif

                }

                if (area != vaddr) {

                    fprintf(stderr, "Could not remap addr: "

                            RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",

                            length, addr);

                    exit(1);

                }

                memory_try_enable_merging(vaddr, length);

                qemu_ram_setup_dump(vaddr, length);

            }

            return;

        }

    }

}

void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)

{

    RAMBlock *block;

    ram_addr_t offset;

    int flags;

    void *area, *vaddr;



    QTAILQ_FOREACH(block, &ram_list.blocks, next) {

        offset = addr - block->offset;

        if (offset < block->length) {

            vaddr = block->host + offset;

            if (block->flags & RAM_PREALLOC_MASK) {

                ;

            } else if (xen_enabled()) {

                abort();

            } else {

                flags = MAP_FIXED;

                munmap(vaddr, length);

                if (mem_path) {

#if defined(__linux__) && !defined(TARGET_S390X)

                    if (block->fd) {

#ifdef MAP_POPULATE

                        flags |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :

                            MAP_PRIVATE;

#else

                        flags |= MAP_PRIVATE;

#endif

                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,

                                    flags, block->fd, offset);

                    } else {

                        flags |= MAP_PRIVATE | MAP_ANONYMOUS;

                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,

                                    flags, -1, 0);

                    }

#else

                    abort();

#endif

                } else {

#if defined(TARGET_S390X) && defined(CONFIG_KVM)

                    flags |= MAP_SHARED | MAP_ANONYMOUS;

                    area = mmap(vaddr, length, PROT_EXEC|PROT_READ|PROT_WRITE,

                                flags, -1, 0);

#else

                    flags |= MAP_PRIVATE | MAP_ANONYMOUS;

                    area = mmap(vaddr, length, PROT_READ | PROT_WRITE,

                                flags, -1, 0);

#endif

                }

                if (area != vaddr) {

                    fprintf(stderr, "Could not remap addr: "

                            RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",

                            length, addr);

                    exit(1);

                }

                memory_try_enable_merging(vaddr, length);

                qemu_ram_setup_dump(vaddr, length);

            }

            return;

        }

    }

}

void FUNC_0(ram_addr_t VAR_0, ram_addr_t VAR_1)

{

    RAMBlock *block;

    ram_addr_t offset;

    int VAR_2;

    void *VAR_3, *VAR_4;



    QTAILQ_FOREACH(block, &ram_list.blocks, next) {

        offset = VAR_0 - block->offset;

        if (offset < block->VAR_1) {

            VAR_4 = block->host + offset;

            if (block->VAR_2 & RAM_PREALLOC_MASK) {

                ;

            } else if (xen_enabled()) {

                abort();

            } else {

                VAR_2 = MAP_FIXED;

                munmap(VAR_4, VAR_1);

                if (mem_path) {

#if defined(__linux__) && !defined(TARGET_S390X)

                    if (block->fd) {

#ifdef MAP_POPULATE

                        VAR_2 |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :

                            MAP_PRIVATE;

#else

                        VAR_2 |= MAP_PRIVATE;

#endif

                        VAR_3 = mmap(VAR_4, VAR_1, PROT_READ | PROT_WRITE,

                                    VAR_2, block->fd, offset);

                    } else {

                        VAR_2 |= MAP_PRIVATE | MAP_ANONYMOUS;

                        VAR_3 = mmap(VAR_4, VAR_1, PROT_READ | PROT_WRITE,

                                    VAR_2, -1, 0);

                    }

#else

                    abort();

#endif

                } else {

#if defined(TARGET_S390X) && defined(CONFIG_KVM)

                    VAR_2 |= MAP_SHARED | MAP_ANONYMOUS;

                    VAR_3 = mmap(VAR_4, VAR_1, PROT_EXEC|PROT_READ|PROT_WRITE,

                                VAR_2, -1, 0);

#else

                    VAR_2 |= MAP_PRIVATE | MAP_ANONYMOUS;

                    VAR_3 = mmap(VAR_4, VAR_1, PROT_READ | PROT_WRITE,

                                VAR_2, -1, 0);

#endif

                }

                if (VAR_3 != VAR_4) {

                    fprintf(stderr, "Could not remap VAR_0: "

                            RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",

                            VAR_1, VAR_0);

                    exit(1);

                }

                memory_try_enable_merging(VAR_4, VAR_1);

                qemu_ram_setup_dump(VAR_4, VAR_1);

            }

            return;

        }

    }

}

void FUNC_0(ram_addr_t VAR_0, ram_addr_t VAR_1)
{ RAMBlock *block; ram_addr_t offset; int VAR_2; void *VAR_3, *VAR_4; QTAILQ_FOREACH(block, &ram_list.blocks, next) { offset = VAR_0 - block->offset; if (offset < block->VAR_1) { VAR_4 = block->host + offset; if (block->VAR_2 & RAM_PREALLOC_MASK) { ; } else if (xen_enabled()) { abort(); } else { VAR_2 = MAP_FIXED; munmap(VAR_4, VAR_1); if (mem_path) { #if defined(__linux__) && !defined(TARGET_S390X)
if (block->fd) { #ifdef MAP_POPULATE
VAR_2 |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :
MAP_PRIVATE; #else
VAR_2 |= MAP_PRIVATE; #endif
VAR_3 = mmap(VAR_4, VAR_1, PROT_READ | PROT_WRITE,
VAR_2, block->fd, offset); } else { VAR_2 |= MAP_PRIVATE | MAP_ANONYMOUS; VAR_3 = mmap(VAR_4, VAR_1, PROT_READ | PROT_WRITE,
VAR_2, -1, 0); } #else
abort(); #endif
} else { #if defined(TARGET_S390X) && defined(CONFIG_KVM)
VAR_2 |= MAP_SHARED | MAP_ANONYMOUS; VAR_3 = mmap(VAR_4, VAR_1, PROT_EXEC|PROT_READ|PROT_WRITE,
VAR_2, -1, 0); #else
VAR_2 |= MAP_PRIVATE | MAP_ANONYMOUS; VAR_3 = mmap(VAR_4, VAR_1, PROT_READ | PROT_WRITE,
VAR_2, -1, 0); #endif
} if (VAR_3 != VAR_4) { fprintf(stderr, "Could not remap VAR_0: "
RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",
VAR_1, VAR_0); exit(1); } memory_try_enable_merging(VAR_4, VAR_1); qemu_ram_setup_dump(VAR_4, VAR_1); } return; } } }