Revision c8a706fe exec.c

b/exec.c
234 234
        FILE *f;
235 235
        int n;
236 236

  
237
        mmap_lock();
237 238
        last_brk = (unsigned long)sbrk(0);
238 239
        f = fopen("/proc/self/maps", "r");
239 240
        if (f) {
......
251 252
            } while (!feof(f));
252 253
            fclose(f);
253 254
        }
255
        mmap_unlock();
254 256
    }
255 257
#endif
256 258
}
......
326 328
static void tlb_protect_code(ram_addr_t ram_addr);
327 329
static void tlb_unprotect_code_phys(CPUState *env, ram_addr_t ram_addr,
328 330
                                    target_ulong vaddr);
331
#define mmap_lock() do { } while(0)
332
#define mmap_unlock() do { } while(0)
329 333
#endif
330 334

  
331 335
#define DEFAULT_CODE_GEN_BUFFER_SIZE (32 * 1024 * 1024)
......
1049 1053
    unsigned int h;
1050 1054
    TranslationBlock **ptb;
1051 1055

  
1056
    /* Grab the mmap lock to stop another thread invalidating this TB
1057
       before we are done.  */
1058
    mmap_lock();
1052 1059
    /* add in the physical hash table */
1053 1060
    h = tb_phys_hash_func(phys_pc);
1054 1061
    ptb = &tb_phys_hash[h];
......
1075 1082
#ifdef DEBUG_TB_CHECK
1076 1083
    tb_page_check();
1077 1084
#endif
1085
    mmap_unlock();
1078 1086
}
1079 1087

  
1080 1088
/* find the TB 'tb' such that tb[0].tc_ptr <= tc_ptr <
......
2002 2010
    PageDesc *p;
2003 2011
    target_ulong addr;
2004 2012

  
2013
    /* mmap_lock should already be held.  */
2005 2014
    start = start & TARGET_PAGE_MASK;
2006 2015
    end = TARGET_PAGE_ALIGN(end);
2007 2016
    if (flags & PAGE_WRITE)
......
2065 2074
    PageDesc *p, *p1;
2066 2075
    target_ulong host_start, host_end, addr;
2067 2076

  
2077
    /* Technically this isn't safe inside a signal handler.  However we
2078
       know this only ever happens in a synchronous SEGV handler, so in
2079
       practice it seems to be ok.  */
2080
    mmap_lock();
2081

  
2068 2082
    host_start = address & qemu_host_page_mask;
2069 2083
    page_index = host_start >> TARGET_PAGE_BITS;
2070 2084
    p1 = page_find(page_index);
2071
    if (!p1)
2085
    if (!p1) {
2086
        mmap_unlock();
2072 2087
        return 0;
2088
    }
2073 2089
    host_end = host_start + qemu_host_page_size;
2074 2090
    p = p1;
2075 2091
    prot = 0;
......
2091 2107
#ifdef DEBUG_TB_CHECK
2092 2108
            tb_invalidate_check(address);
2093 2109
#endif
2110
            mmap_unlock();
2094 2111
            return 1;
2095 2112
        }
2096 2113
    }
2114
    mmap_unlock();
2097 2115
    return 0;
2098 2116
}
2099 2117

  

Also available in: Unified diff