From c6f644ea0c063180d0a04f23cc1cb4bea3b11d5c Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 30 Apr 2020 07:02:57 -0400 Subject: [PATCH] tcg: Remove softmmu code_gen_buffer fixed address The commentary talks about "in concert with the addresses assigned in the relevant linker script", except there is no linker script for softmmu, nor has there been for some time. (Do not confuse the user-only linker script editing that was removed in the previous patch, because user-only does not use this code_gen_buffer allocation method.) Backports commit 64547a3bb6c92781372994e4e9b25a89f6c88074 from qemu --- qemu/accel/tcg/translate-all.c | 40 +++++----------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/qemu/accel/tcg/translate-all.c b/qemu/accel/tcg/translate-all.c index 858d26b1..3beb4bb3 100644 --- a/qemu/accel/tcg/translate-all.c +++ b/qemu/accel/tcg/translate-all.c @@ -741,50 +741,20 @@ static inline void *alloc_code_gen_buffer(struct uc_struct *uc) { TCGContext *tcg_ctx = uc->tcg_ctx; int flags = MAP_PRIVATE | MAP_ANONYMOUS; - uintptr_t start = 0; size_t size = tcg_ctx->code_gen_buffer_size; void *buf; - /* Constrain the position of the buffer based on the host cpu. - Note that these addresses are chosen in concert with the - addresses assigned in the relevant linker script file. */ -# if defined(__PIE__) || defined(__PIC__) - /* Don't bother setting a preferred location if we're building - a position-independent executable. We're more likely to get - an address near the main executable if we let the kernel - choose the address. */ -# elif defined(__x86_64__) && defined(MAP_32BIT) - /* Force the memory down into low memory with the executable. - Leave the choice of exact location with the kernel. */ - flags |= MAP_32BIT; - /* Cannot expect to map more than 800MB in low memory. */ - if (size > 800u * 1024 * 1024) { - tcg_ctx->code_gen_buffer_size = size = 800u * 1024 * 1024; - } -# elif defined(__sparc__) - start = 0x40000000ul; -# elif defined(__s390x__) - start = 0x90000000ul; -# elif defined(__mips__) -# if _MIPS_SIM == _ABI64 - start = 0x68000000ul; -# elif _MIPS_SIM == _ABI64 - start = 0x128000000ul; -# else - start = 0x08000000ul; -# endif -# endif - - buf = mmap((void *)start, size + uc->qemu_real_host_page_size, - PROT_NONE, flags, -1, 0); + buf = mmap(NULL, size + uc->qemu_real_host_page_size, PROT_NONE, flags, -1, 0); if (buf == MAP_FAILED) { return NULL; } #ifdef __mips__ if (cross_256mb(buf, size)) { - /* Try again, with the original still mapped, to avoid re-acquiring - that 256mb crossing. This time don't specify an address. */ + /* + * Try again, with the original still mapped, to avoid re-acquiring + * the same 256mb crossing. + */ size_t size2; void *buf2 = mmap(NULL, size + uc->qemu_real_host_page_size, PROT_NONE, flags, -1, 0);