Revision 17e2377a exec.c

b/exec.c
263 263
{
264 264
    PageDesc **lp, *p;
265 265

  
266
#if TARGET_LONG_BITS > 32
267
    /* Host memory outside guest VM.  For 32-bit targets we have already
268
       excluded high addresses.  */
269
    if (index > ((target_ulong)L2_SIZE * L1_SIZE * TARGET_PAGE_SIZE))
270
        return NULL;
271
#endif
266 272
    lp = &l1_map[index >> L2_BITS];
267 273
    p = *lp;
268 274
    if (!p) {
269 275
        /* allocate if not found */
270
        p = qemu_malloc(sizeof(PageDesc) * L2_SIZE);
271
        memset(p, 0, sizeof(PageDesc) * L2_SIZE);
276
#if defined(CONFIG_USER_ONLY)
277
        unsigned long addr;
278
        size_t len = sizeof(PageDesc) * L2_SIZE;
279
        /* Don't use qemu_malloc because it may recurse.  */
280
        p = mmap(0, len, PROT_READ | PROT_WRITE,
281
                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
282
        *lp = p;
283
        addr = h2g(p);
284
        if (addr == (target_ulong)addr) {
285
            page_set_flags(addr & TARGET_PAGE_MASK,
286
                           TARGET_PAGE_ALIGN(addr + len),
287
                           PAGE_RESERVED); 
288
        }
289
#else
290
        p = qemu_mallocz(sizeof(PageDesc) * L2_SIZE);
272 291
        *lp = p;
292
#endif
273 293
    }
274 294
    return p + (index & (L2_SIZE - 1));
275 295
}
......
1912 1932
        flags |= PAGE_WRITE_ORG;
1913 1933
    for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
1914 1934
        p = page_find_alloc(addr >> TARGET_PAGE_BITS);
1935
        /* We may be called for host regions that are outside guest
1936
           address space.  */
1937
        if (!p)
1938
            return;
1915 1939
        /* if the write protection is set, then we invalidate the code
1916 1940
           inside */
1917 1941
        if (!(p->flags & PAGE_WRITE) &&

Also available in: Unified diff