Revision cd19cfa2 exec.c

b/exec.c
2867 2867

  
2868 2868
    if (host) {
2869 2869
        new_block->host = host;
2870
        new_block->flags |= RAM_PREALLOC_MASK;
2870 2871
    } else {
2871 2872
        if (mem_path) {
2872 2873
#if defined (__linux__) && !defined(TARGET_S390X)
......
2920 2921
    QLIST_FOREACH(block, &ram_list.blocks, next) {
2921 2922
        if (addr == block->offset) {
2922 2923
            QLIST_REMOVE(block, next);
2923
            if (mem_path) {
2924
            if (block->flags & RAM_PREALLOC_MASK) {
2925
                ;
2926
            } else if (mem_path) {
2924 2927
#if defined (__linux__) && !defined(TARGET_S390X)
2925 2928
                if (block->fd) {
2926 2929
                    munmap(block->host, block->length);
......
2943 2946

  
2944 2947
}
2945 2948

  
2949
#ifndef _WIN32
2950
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
2951
{
2952
    RAMBlock *block;
2953
    ram_addr_t offset;
2954
    int flags;
2955
    void *area, *vaddr;
2956

  
2957
    QLIST_FOREACH(block, &ram_list.blocks, next) {
2958
        offset = addr - block->offset;
2959
        if (offset < block->length) {
2960
            vaddr = block->host + offset;
2961
            if (block->flags & RAM_PREALLOC_MASK) {
2962
                ;
2963
            } else {
2964
                flags = MAP_FIXED;
2965
                munmap(vaddr, length);
2966
                if (mem_path) {
2967
#if defined(__linux__) && !defined(TARGET_S390X)
2968
                    if (block->fd) {
2969
#ifdef MAP_POPULATE
2970
                        flags |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :
2971
                            MAP_PRIVATE;
2972
#else
2973
                        flags |= MAP_PRIVATE;
2974
#endif
2975
                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
2976
                                    flags, block->fd, offset);
2977
                    } else {
2978
                        flags |= MAP_PRIVATE | MAP_ANONYMOUS;
2979
                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
2980
                                    flags, -1, 0);
2981
                    }
2982
#endif
2983
                } else {
2984
#if defined(TARGET_S390X) && defined(CONFIG_KVM)
2985
                    flags |= MAP_SHARED | MAP_ANONYMOUS;
2986
                    area = mmap(vaddr, length, PROT_EXEC|PROT_READ|PROT_WRITE,
2987
                                flags, -1, 0);
2988
#else
2989
                    flags |= MAP_PRIVATE | MAP_ANONYMOUS;
2990
                    area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
2991
                                flags, -1, 0);
2992
#endif
2993
                }
2994
                if (area != vaddr) {
2995
                    fprintf(stderr, "Could not remap addr: %lx@%lx\n",
2996
                            length, addr);
2997
                    exit(1);
2998
                }
2999
                qemu_madvise(vaddr, length, QEMU_MADV_MERGEABLE);
3000
            }
3001
            return;
3002
        }
3003
    }
3004
}
3005
#endif /* !_WIN32 */
3006

  
2946 3007
/* Return a host pointer to ram allocated with qemu_ram_alloc.
2947 3008
   With the exception of the softmmu code in this file, this should
2948 3009
   only be used for local memory (e.g. video ram) that the device owns,

Also available in: Unified diff