void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)

{

    RAMBlock *block;

    ram_addr_t offset;

    int flags;

    void *area, *vaddr;



    QLIST_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 {

                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;


                        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);

                    }



#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);


                    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: %lx@%lx\n",

                            length, addr);

                    exit(1);

                }

                qemu_madvise(vaddr, length, QEMU_MADV_MERGEABLE);

            }

            return;

        }

    }

}
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)

{

    RAMBlock *block;

    ram_addr_t offset;

    int flags;

    void *area, *vaddr;



    QLIST_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 {

                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;


                        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);

                    }



#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);


                    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: %lx@%lx\n",

                            length, addr);

                    exit(1);

                }

                qemu_madvise(vaddr, length, QEMU_MADV_MERGEABLE);

            }

            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;



    QLIST_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 {

                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;


                        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);

                    }



#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);


                    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: %lx@%lx\n",

                            VAR_1, VAR_0);

                    exit(1);

                }

                qemu_madvise(VAR_4, VAR_1, QEMU_MADV_MERGEABLE);

            }

            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; QLIST_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 { 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; 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); } #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); 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: %lx@%lx\n",
VAR_1, VAR_0); exit(1); } qemu_madvise(VAR_4, VAR_1, QEMU_MADV_MERGEABLE); } return; } } }