Commit 141ac468abbd1f1d17d8969e8ee1b62cce65091e
1 parent
c070355d
Map code buffers below 2G on Sparc64
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4951 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
15 additions
and
6 deletions
exec.c
... | ... | @@ -89,9 +89,9 @@ int nb_tbs; |
89 | 89 | /* any access to the tbs or the page table must use this lock */ |
90 | 90 | spinlock_t tb_lock = SPIN_LOCK_UNLOCKED; |
91 | 91 | |
92 | -#if defined(__arm__) | |
93 | -/* The prologue must be reachable with a direct jump. ARM has a | |
94 | - limited branch range (possibly also PPC and SPARC?) so place it in a | |
92 | +#if defined(__arm__) || defined(__sparc_v9__) | |
93 | +/* The prologue must be reachable with a direct jump. ARM and Sparc64 | |
94 | + have limited branch ranges (possibly also PPC) so place it in a | |
95 | 95 | section close to code segment. */ |
96 | 96 | #define code_gen_section \ |
97 | 97 | __attribute__((__section__(".gen_code"))) \ |
... | ... | @@ -410,15 +410,23 @@ void code_gen_alloc(unsigned long tb_size) |
410 | 410 | #if defined(__linux__) |
411 | 411 | { |
412 | 412 | int flags; |
413 | + void *start = NULL; | |
414 | + | |
413 | 415 | flags = MAP_PRIVATE | MAP_ANONYMOUS; |
414 | 416 | #if defined(__x86_64__) |
415 | 417 | flags |= MAP_32BIT; |
416 | 418 | /* Cannot map more than that */ |
417 | 419 | if (code_gen_buffer_size > (800 * 1024 * 1024)) |
418 | 420 | code_gen_buffer_size = (800 * 1024 * 1024); |
419 | -#endif | |
420 | - code_gen_buffer = mmap(NULL, code_gen_buffer_size, | |
421 | - PROT_WRITE | PROT_READ | PROT_EXEC, | |
421 | +#elif defined(__sparc_v9__) | |
422 | + // Map the buffer below 2G, so we can use direct calls and branches | |
423 | + flags |= MAP_FIXED; | |
424 | + start = (void *) 0x60000000UL; | |
425 | + if (code_gen_buffer_size > (512 * 1024 * 1024)) | |
426 | + code_gen_buffer_size = (512 * 1024 * 1024); | |
427 | +#endif | |
428 | + code_gen_buffer = mmap(start, code_gen_buffer_size, | |
429 | + PROT_WRITE | PROT_READ | PROT_EXEC, | |
422 | 430 | flags, -1, 0); |
423 | 431 | if (code_gen_buffer == MAP_FAILED) { |
424 | 432 | fprintf(stderr, "Could not allocate dynamic translator buffer\n"); | ... | ... |