From patchwork Fri Mar 27 22:03:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1263065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=TywaZMPB; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pwv71y1Gz9sSG for ; Sat, 28 Mar 2020 09:07:15 +1100 (AEDT) Received: from localhost ([::1]:47576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHx8D-0006xQ-5D for incoming@patchwork.ozlabs.org; Fri, 27 Mar 2020 18:07:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49250) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHx57-0003Bj-5x for qemu-devel@nongnu.org; Fri, 27 Mar 2020 18:04:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHx56-0000Ox-2Z for qemu-devel@nongnu.org; Fri, 27 Mar 2020 18:04:01 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:46339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHx55-0000JZ-TF for qemu-devel@nongnu.org; Fri, 27 Mar 2020 18:04:00 -0400 Received: by mail-pg1-x542.google.com with SMTP id k191so5213653pgc.13 for ; Fri, 27 Mar 2020 15:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AVWo3TkNC8dRck4gxr30FMdUL1YEqwhhQceYuT351jQ=; b=TywaZMPBxS36l1077IGjGjRIwMvxk6h+ckm+IZ2ZxT4wkG2fvSASNvVRwC74lg9IBK RWkYPVXbZQAS14XwoRydTHccywGqvyxEkIPN7ZOS6BvLsu6whpessyympzMfHn+HYXF+ qvw5DExOM13dPeQ47KUW5HS4R5D8xbFTXGg42zLPW/wfI2CEX2KrAF043ZuHlvBQAf2T dJzB0IjhjhgL8l0kLQKx7JGmlsxtWUWuh5Z5a0wFlgoHtzNi327oSNkmLZIAN6BF1oYN hGETAKSoHICMbT30GLiwyV1owGs0wC/8gqhvoxlLE+UvISSvY+oksTaE3wPrOderYn6h ofQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AVWo3TkNC8dRck4gxr30FMdUL1YEqwhhQceYuT351jQ=; b=akpbeSwfR7OnNhyCpcBX6wnoHw6NwlbpSfIrgLWEKBPwndcs6gcPCH0SXFwK2rzAMF BqHXE85gIKpRrIysqWx+8YtCfaJp95fZRBeV50lUSuI7SwKSlpte9tgJFXHBIwqIQKSQ 806fP3SfeBgT5Ti76Wp5DNxEuhvyafW7CSY+mvnMdVuDjvPpHuKG3cVr3Y4ja+qc9j6x 9gC7IS8PTIaZugnBo+POtKwJ0pDtvXKc5vBodfnsrGCJINpIJI/SRUwLbSqKcVnpD7A2 G3xeIRDT/hPafn99eRGdezItIh54EYRJf/06C6hCNKp3sPbDd/UVL9qFlbaB21hW+df2 CP6A== X-Gm-Message-State: ANhLgQ0u9xZ0k+6ALu7CP6xaJa1fiR8J74NhN+b+agBGjKH1qkMuAUKI MQbtiXoiCxzg9gO4parFzQNkMQRVqdA= X-Google-Smtp-Source: ADFU+vt1BaMX3C12VyD+uTFPajirso7jSCoEdnN1WgNIxypn00i9s7+3r2eygsJaV1QCfCRZtuiO2g== X-Received: by 2002:a63:bf4e:: with SMTP id i14mr1405683pgo.41.1585346638398; Fri, 27 Mar 2020 15:03:58 -0700 (PDT) Received: from localhost.localdomain (174-21-138-234.tukw.qwest.net. [174.21.138.234]) by smtp.gmail.com with ESMTPSA id y29sm4516929pge.22.2020.03.27.15.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2020 15:03:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-5.0 v3 2/7] tcg: Remove softmmu code_gen_buffer fixed address Date: Fri, 27 Mar 2020 15:03:48 -0700 Message-Id: <20200327220353.27233-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200327220353.27233-1-richard.henderson@linaro.org> References: <20200327220353.27233-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dim@FreeBSD.org, Thomas Huth , alex.bennee@linaro.org, roger.pau@citrix.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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.) Reviewed-by: Alex Bennée Reviewed-by: Thomas Huth Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 78914154bf..9924e66d1f 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1043,47 +1043,20 @@ static inline void *alloc_code_gen_buffer(void) { int prot = PROT_WRITE | PROT_READ | PROT_EXEC; 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 = 0x128000000ul; -# else - start = 0x08000000ul; -# endif -# endif - - buf = mmap((void *)start, size, prot, flags, -1, 0); + buf = mmap(NULL, size, prot, 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, prot, flags, -1, 0); switch ((int)(buf2 != MAP_FAILED)) {