From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944302; cv=none; d=zohomail.com; s=zohoarc; b=afFLB+7uxaR02QfTyzPT80t6asOexdWL3FZ3PI7gR52v5IK5mHvAW+VHwaeoYjLXiohia4XnkF8Ds+i86vgXJhePHLxdJ9w+3E+a2Znn1C+W4FuUyu39+JyX4Dfc2f2MJFc7vLxnP85IYKj4bOyw4Ig6isIa75aOgNdwFsblZss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944302; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y86kGv51d7MIe9EUA91Ip3mHFnX72SJuw4wm5LrzN7Y=; b=cPjpQVvdR4HAfHLtoJbl9WlguVviidT7BOoMqwPu6g2uWTbKkYgO9CF8gj29pnowqYrT5u2SpxOwMhgEfZIyTsWOwUzhfSrGG4bRtO2A0OjcA2Ai8y5ggDR8MWCWHrVVIpM+Kdy1BuilaRkmWi7kKDdSeZDq+eM/jhXMM+o5XJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944301771127.4882809758409; Fri, 28 Feb 2020 18:45:01 -0800 (PST) Received: from localhost ([::1]:56486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s7e-0008VU-PN for importer@patchew.org; Fri, 28 Feb 2020 21:44:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42682) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6d-00076R-4D for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6b-00031j-MZ for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:54 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:43915) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6b-0002z9-Fo for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:53 -0500 Received: by mail-pl1-x631.google.com with SMTP id p11so1946346plq.10 for ; Fri, 28 Feb 2020 18:43:53 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:50 -0800 (PST) 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=y86kGv51d7MIe9EUA91Ip3mHFnX72SJuw4wm5LrzN7Y=; b=xytwpTq9ApDp6icUVBSMnHhllCuXLfMChXfGzk7TPNxyid+H95ZLPTCaqkxBUiJgFR k8ai6yM16ObljfzrME1n1FJk//F1twlIx6HcVqXYKYfdep2k1InR1elaePvhKFBquOdY IzhsO/YBe8gWP6eANg2wqL8efAqwiKf8PYOxdGqB6vZT7q5lakTksIzl2QM+ZhF2oVFy G7Km9toE+Ib+JOv9UXnO4Kauct60xSxHgOJCo5L40XsHFARvrZDxM/Iem0U4o8nkzADl zCiQkuXMYx1uR/X+LhAgG5KaJzhZsvPJfOKri8Qz13B0o9V6we9VnA/eZV0O0RVhbNCA idgQ== 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=y86kGv51d7MIe9EUA91Ip3mHFnX72SJuw4wm5LrzN7Y=; b=VVQSGqYcVGEdRPiFmb7zwG8xAAqtXrKgFXRcx49j3qzhZSxIelilKX5bQf6Z0Vdf03 8a8bg1JpVugAQwekDLtEvG2hB9DbmeQorzRfga5caEbPzM/uU1vy97g6Xu1VfA8mwDCn LIwZUc2QTxP/dRWYQXU6U69jXGBQ9Nu9K/QPkfqylCo+f7jRA0fml7vQDloldUQ5P2yM kodqK1eCgPX5BCMrCNZiEwccuQtgjJ0XmoC14Swo8Mqniek4+pOkfnLkfVUi/kBYLG4y dlORqjBkhg3DVHUB1yWd5r9O0kAzF9MxPx2JTw2yWLG0pYAzSu18ysCjnypTF3KVc0I+ 6x7Q== X-Gm-Message-State: APjAAAXomwCB456ttZ9dnTGwOsRX8qRdX9TosjV+Zw57yv0lY+6kl6Mo GwM3852WYT0fs0YRx8ebzEgpQhls74I= X-Google-Smtp-Source: APXvYqw2a+1OjvyxVOmqitVYLB6RQH/0wCl4Rk2yL2UwZrNwTLdeldHHkZio6n3PXIQ7tBOQm60vlg== X-Received: by 2002:a17:902:b498:: with SMTP id y24mr6817446plr.343.1582944231603; Fri, 28 Feb 2020 18:43:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 1/8] accel/tcg: fix race in cpu_exec_step_atomic (bug 1863025) Date: Fri, 28 Feb 2020 18:43:40 -0800 Message-Id: <20200229024347.22826-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::631 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: peter.maydell@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Yifan , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Alex Benn=C3=A9e The bug describes a race whereby cpu_exec_step_atomic can acquire a TB which is invalidated by a tb_flush before we execute it. This doesn't affect the other cpu_exec modes as a tb_flush by it's nature can only occur on a quiescent system. The race was described as: B2. tcg_cpu_exec =3D> cpu_exec =3D> tb_find =3D> tb_gen_code B3. tcg_tb_alloc obtains a new TB C3. TB obtained with tb_lookup__cpu_state or tb_gen_code (same TB as B2) A3. start_exclusive critical section entered A4. do_tb_flush is called, TB memory freed/re-allocated A5. end_exclusive exits critical section B2. tcg_cpu_exec =3D> cpu_exec =3D> tb_find =3D> tb_gen_code B3. tcg_tb_alloc reallocates TB from B2 C4. start_exclusive critical section entered C5. cpu_tb_exec executes the TB code that was free in A4 The simplest fix is to widen the exclusive period to include the TB lookup. As a result we can drop the complication of checking we are in the exclusive region before we end it. Cc: Yifan Buglink: https://bugs.launchpad.net/qemu/+bug/1863025 Reviewed-by: Paolo Bonzini Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200214144952.15502-1-alex.bennee@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 2560c90eec..d95c4848a4 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -240,6 +240,8 @@ void cpu_exec_step_atomic(CPUState *cpu) uint32_t cf_mask =3D cflags & CF_HASH_MASK; =20 if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { + start_exclusive(); + tb =3D tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); if (tb =3D=3D NULL) { mmap_lock(); @@ -247,8 +249,6 @@ void cpu_exec_step_atomic(CPUState *cpu) mmap_unlock(); } =20 - start_exclusive(); - /* Since we got here, we know that parallel_cpus must be true. */ parallel_cpus =3D false; cc->cpu_exec_enter(cpu); @@ -271,14 +271,15 @@ void cpu_exec_step_atomic(CPUState *cpu) qemu_plugin_disable_mem_helpers(cpu); } =20 - if (cpu_in_exclusive_context(cpu)) { - /* We might longjump out of either the codegen or the - * execution, so must make sure we only end the exclusive - * region if we started it. - */ - parallel_cpus =3D true; - end_exclusive(); - } + + /* + * As we start the exclusive region before codegen we must still + * be in the region if we longjump out of either the codegen or + * the execution. + */ + g_assert(cpu_in_exclusive_context(cpu)); + parallel_cpus =3D true; + end_exclusive(); } =20 struct tb_desc { --=20 2.20.1 From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944443; cv=none; d=zohomail.com; s=zohoarc; b=gA3G5MgzOmH1d+gmjAXYMYcXZUUOzW7YAoaH060TmPW80JJVzjW2/xmJZP2OOh4dh7TxdcU2ChfBL0khzEH/RuqTU8fxV4kQ6yZpSCfzjkPJzra9EsxxkiGe7HIwz/rrDN5LdqeXqVuqGI/cfK20rgjsaKvhEyhDVaa0vVP4jHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944443; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A1rWgDcZdMUvykrNCtRPCIuuNASTYFpt0ciGUShM3Kc=; b=kbvhzYLHxH1gKgFh+VSrWNvDif7F2YOK3Ow/kSNalkxMCCNB8zv3faYQwA5BKvWjMwHISRwz+95GWrgI9pZyHOfh4QRE+SKxIk0modSum2ROIVz1X09BJG26tDRnst516EI0DsfFzRLH4MFLMDujW7bD3hs4knKzz/cAQ3gh31o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944443005951.8298835301199; Fri, 28 Feb 2020 18:47:23 -0800 (PST) Received: from localhost ([::1]:56560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s9x-0003pj-Rd for importer@patchew.org; Fri, 28 Feb 2020 21:47:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42690) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6e-00076S-Jm for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6c-00033K-Db for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:55 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:35321) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6c-00031Z-82 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:54 -0500 Received: by mail-pl1-x62d.google.com with SMTP id g6so1963974plt.2 for ; Fri, 28 Feb 2020 18:43:54 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:52 -0800 (PST) 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=A1rWgDcZdMUvykrNCtRPCIuuNASTYFpt0ciGUShM3Kc=; b=iUNDmyal666Idq4K/Sza2k1RrSTMcZGZQZxnekRDp3+6YuoWSv2nl70AOzBUuvuVVi k2xVa0AYms/GBQLV4GZMObuITuHmEtC1Rt62OUisTvEUF35oMXFPsxy8eSfUJOFz15ct LvW0FehECdHso91qVTZC6JrQ3F5III16ZTwszudRGxs/lej5d8N3vRgYzhHLn/Gev+0+ hT0cnGu98QZ6p6VgRZ7oXy7Zhc5nJnh2yuiBRrV2HnnF07WAd4fmiYE1zqPDI4MpvYOE +7pzZRDVxO0JVPfjVBV563pX8GX11J09he43qzhdTQa1x5YC+xkg3yLnqu2+ddnT04JW lEOA== 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=A1rWgDcZdMUvykrNCtRPCIuuNASTYFpt0ciGUShM3Kc=; b=bkN81vip6JAto2twiEdjcMRSBV32NuBypFwKS8QKHPQi2MNI/O+bbobA1NAPINB3Rw 4V/2Z+CrrWR891178MVYOKUZG9V0AhKBI+RSdQgOy4Gz2UdGJRytdPBhia0BV8bPZaxn zjT+c1bnkleNsZPiCAUlTlhh3cIzsP2vZR8RQJgvU6U9V8Vpa0V5S0wKn/lvg+f01whT NuVo8nE4hnX2e+1IV9nCgES4azAmwlvHj5UwPU9tAmcsani0zo7nZPvxTOJ0fW9b6OcF vc/RFMz9VZmTSZbMaxtNR6CFoRLcZvEwPc8EiKB7YLPEg8NUjCxAETOuHW6FcCyJ6DsV h7GQ== X-Gm-Message-State: APjAAAXTXAnc4t3nktuR+Gim51HJGTzD9fQAE06JCCeuKzl4ScCi3Kv+ DDiAR4qJ82WpZOuwZwpgZYwL8RM9PD4= X-Google-Smtp-Source: APXvYqzeBp6sccnE4u402S70mAkiIiL0EGoOzuFm9M2u/qk0we3lKKU5E3a8FBGN0ufPeMJHRhXHnQ== X-Received: by 2002:a17:90a:ff15:: with SMTP id ce21mr7814400pjb.124.1582944232773; Fri, 28 Feb 2020 18:43:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 2/8] compiler.h: Don't use compile-time assert when __NO_INLINE__ is defined Date: Fri, 28 Feb 2020 18:43:41 -0800 Message-Id: <20200229024347.22826-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62d 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: Zenghui Yu , peter.maydell@linaro.org, Euler Robot Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Zenghui Yu Our robot reported the following compile-time warning while compiling Qemu with -fno-inline cflags: In function 'load_memop', inlined from 'load_helper' at /qemu/accel/tcg/cputlb.c:1578:20, inlined from 'full_ldub_mmu' at /qemu/accel/tcg/cputlb.c:1624:12: /qemu/accel/tcg/cputlb.c:1502:9: error: call to 'qemu_build_not_reached' de= clared with attribute error: code path is reachable qemu_build_not_reached(); ^~~~~~~~~~~~~~~~~~~~~~~~ [...] It looks like a false-positive because only (MO_UB ^ MO_BSWAP) will hit the default case in load_memop() while need_swap (size > 1) has already ensured that MO_UB is not involved. So the thing is that compilers get confused by the -fno-inline and just can't accurately evaluate memop_size(op) at compile time, and then the qemu_build_not_reached() is wrongly triggered by (MO_UB ^ MO_BSWAP). Let's carefully don't use the compile-time assert when no functions will be inlined into their callers. Reported-by: Euler Robot Suggested-by: Richard Henderson Signed-off-by: Zenghui Yu Message-Id: <20200205141545.180-1-yuzenghui@huawei.com> Signed-off-by: Richard Henderson --- include/qemu/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 85c02c16d3..c76281f354 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -236,7 +236,7 @@ * supports QEMU_ERROR, this will be reported at compile time; otherwise * this will be reported at link time due to the missing symbol. */ -#ifdef __OPTIMIZE__ +#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__) extern void QEMU_NORETURN QEMU_ERROR("code path is reachable") qemu_build_not_reached(void); #else --=20 2.20.1 From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944307; cv=none; d=zohomail.com; s=zohoarc; b=LWe1gVd9chnRVchRET76/5qMT2E4IxzJcLGjZ5WSof3LUZuZMIdjeQ9MNc9rBYAZ5lTeDjaEHMsl/BEr8GBdVgv2it/8vSUx9GaA7OQ1wSN7bqfpxIrtIBIX7a4fpU+hgJVdIym1RY2q1zdgrvLdctsFzMAvFt67RUhG+Lyw3Fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944307; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vSmE5SkJs7bKw32GyNmYKHJ7/xdEHXIomHMfGHtsHSw=; b=dOXy+pyWlC8QkekMoM4l9X8XHhghqt7q1TT/lvwNn+h5EsOtQAVJRv5d0dldEjqxEjkNKvPwmdeHv8aWOfDdJ035BBuLkNzcQ6dLNa29FVHdbwfEAAdSeAu3Fl7Xe6KSlV/MNvb2YgxAwU6ChWCgLH9wADNTh5jL7chnqfDTiWM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944307019103.22398668272774; Fri, 28 Feb 2020 18:45:07 -0800 (PST) Received: from localhost ([::1]:56494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s7l-0000JR-MA for importer@patchew.org; Fri, 28 Feb 2020 21:45:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42715) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6g-00076g-LB for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6e-000378-Js for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:58 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:41617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6e-00034V-EP for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:56 -0500 Received: by mail-pl1-x62e.google.com with SMTP id t14so1950681plr.8 for ; Fri, 28 Feb 2020 18:43:55 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:53 -0800 (PST) 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=vSmE5SkJs7bKw32GyNmYKHJ7/xdEHXIomHMfGHtsHSw=; b=sIsrjMY62M5uoJsoSqolyGqkaDW2hQ/NhnqnCqy7UYdo4NPZKErLWMP0QNdggmmp+u p9thnGwGo35b53VXBcTTx0znZWvxEQYs+hMi3bzszSH/vblJnu1g2y6d41jmGZXEa2rO hwZi8W3FDCqIu3UTZrO44Hd9adkk5+KBYm4YdKB7IUoYWB9hOj7PWXg2/rEsxBOC/Oj7 10OMAIG0SZ3mggshw9Ao2A7IMOX6u0JlokNqt75BlcqxZjzPcqCn5q6DI46UMeQNW7Hy 4gScqBMsuhACsaQVwXC6Url8/ueotV6joNau6o5lkRrOomh4i3U65+ZOOGKA56cDeDj6 soUA== 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=vSmE5SkJs7bKw32GyNmYKHJ7/xdEHXIomHMfGHtsHSw=; b=p75pxC9TN73Rm1IHeAnhVcWqE4Pd0hsOy9g5vpcVaNtXgVyGNdEg10W60HhNfO2aOf 3zA73cWmKjrGI7IefiehaQ1eCNOl746HZ1Pd4QulI+gBiIakhssFsJ2z5yJzXLElJ/UA Oeq5bI3P0t/DGp3eZha1bqrf4Wsc+Rq/oUiHgxe7DCNlZtq98En60Fr5ZjJfUPY8IZ2W iIjqUT3ImtFJ3vBo+0cEOWECKIigQVuQuBMkpe7t3nl7IHC6IkfkMC/0O4E3jSWsnJdQ Ns2oerR/VBzbU6WcLi3jaB0vAfG0cyrfR9GidgmiK5gis0FA3lyMy921W/gn+76S4yRt 0m6A== X-Gm-Message-State: APjAAAVOX8lHxWhMCEUfLfDLWWAq6biDVuwgnChsiAWqRdhzL/h8VLg1 cofz4VQEDznWavde0LKQu1ppWV5lYCI= X-Google-Smtp-Source: APXvYqzGcKXhU+9d7yaAyappzbsP5xPoJpCoDZDowmv0P5dQds05WWb8Ueh2BIG6hdisJzS8XfzMHA== X-Received: by 2002:a17:902:8204:: with SMTP id x4mr6682194pln.225.1582944233921; Fri, 28 Feb 2020 18:43:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 3/8] tcg/arm: Split out tcg_out_epilogue Date: Fri, 28 Feb 2020 18:43:42 -0800 Message-Id: <20200229024347.22826-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62e 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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Richard Henderson We will shortly use this function from tcg_out_op as well. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.inc.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index fffb6611e2..e1aa740ba4 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -1746,6 +1746,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is64) } =20 static tcg_insn_unit *tb_ret_addr; +static void tcg_out_epilogue(TCGContext *s); =20 static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args) @@ -2284,19 +2285,17 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int = count) + TCG_TARGET_STACK_ALIGN - 1) \ & -TCG_TARGET_STACK_ALIGN) =20 +#define STACK_ADDEND (FRAME_SIZE - PUSH_SIZE) + static void tcg_target_qemu_prologue(TCGContext *s) { - int stack_addend; - /* Calling convention requires us to save r4-r11 and lr. */ /* stmdb sp!, { r4 - r11, lr } */ tcg_out32(s, (COND_AL << 28) | 0x092d4ff0); =20 /* Reserve callee argument and tcg temp space. */ - stack_addend =3D FRAME_SIZE - PUSH_SIZE; - tcg_out_dat_rI(s, COND_AL, ARITH_SUB, TCG_REG_CALL_STACK, - TCG_REG_CALL_STACK, stack_addend, 1); + TCG_REG_CALL_STACK, STACK_ADDEND, 1); tcg_set_frame(s, TCG_REG_CALL_STACK, TCG_STATIC_CALL_ARGS_SIZE, CPU_TEMP_BUF_NLONGS * sizeof(long)); =20 @@ -2310,11 +2309,15 @@ static void tcg_target_qemu_prologue(TCGContext *s) */ s->code_gen_epilogue =3D s->code_ptr; tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); - - /* TB epilogue */ tb_ret_addr =3D s->code_ptr; + tcg_out_epilogue(s); +} + +static void tcg_out_epilogue(TCGContext *s) +{ + /* Release local stack frame. */ tcg_out_dat_rI(s, COND_AL, ARITH_ADD, TCG_REG_CALL_STACK, - TCG_REG_CALL_STACK, stack_addend, 1); + TCG_REG_CALL_STACK, STACK_ADDEND, 1); =20 /* ldmia sp!, { r4 - r11, pc } */ tcg_out32(s, (COND_AL << 28) | 0x08bd8ff0); --=20 2.20.1 From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944536; cv=none; d=zohomail.com; s=zohoarc; b=AX2HgBD2LN81LUkbjg5bWsd/UER37i3VTMI1e/GfLzN1Gb1fhveNYvozGunA1OuFtJwqzvNTnEzhzxA3rLvubMoriHIcfLu0jlqU8vHBvHrWeMQzYpuyDXS7ryHfi9P3kxMzKrrdCZ0XSs0k03vxWIcp2+Y5f6OjV/jp3z/hPTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944536; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eSileXcCP7W6yOgW27jNaouMctoAYA46YTtTPUHqQM0=; b=KJa+wyLjpLIMO8IKfjNhGYFAHAm+sj33pJj7OjLsf6GCwWJK/3eg03bTA1HGKpPG2Px40xAGZ2NND8VJ/OdtWN1018DAFA9SjrIxOZI6Lh4ldixEsX3N5itY4UUUnQqKvO5j/qqmeonXKlvqPvYQU1Iz9mPw9wdtYZiHOECqY8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944536450474.66553233693753; Fri, 28 Feb 2020 18:48:56 -0800 (PST) Received: from localhost ([::1]:56600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7sBT-0006aN-Bk for importer@patchew.org; Fri, 28 Feb 2020 21:48:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42717) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6g-00076k-T2 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6e-00037g-TW for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:58 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:50604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6e-00036X-O0 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:56 -0500 Received: by mail-pj1-x1032.google.com with SMTP id r67so2036300pjb.0 for ; Fri, 28 Feb 2020 18:43:56 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:54 -0800 (PST) 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=eSileXcCP7W6yOgW27jNaouMctoAYA46YTtTPUHqQM0=; b=hBxoo4eP/HgO4S21xvK31T0j3Nh2JMEg+IlxlwwVWGgifMfZzDDuZUEZNJxoxE4ENF xb3Ms9DJf8Off0hO1BfIn366jo4yIbGgyIAh/6CSBZNxzuGZuYGRtlzy9g3hrKEJsLwA Os2XH96G65lse6r1/JxG8a+yMOfYje7z1/HwnAYbdxZv0wUhYYffR/9N67YJS6Tt7x54 RUdFi1QI6763LqCZphqdxzFgrVFL2Dv8N0sG24VLFngU9kE4lQpICPSvziZOc4qYnVWd 2s2iFzY+B4/uZMZmijZ9WGgK8dVu4AHLEWD4zficMvfZc5kTFAZ2Ns+6QIGJPUQ6VMQt FoCA== 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=eSileXcCP7W6yOgW27jNaouMctoAYA46YTtTPUHqQM0=; b=M6Vq2ERN0OC7zNBeH+jHlFhpmGJSDK+OvW1Mj+bkzTo0hHMPBRlcPQn3Aw3VT/ewzR 1aK7hOKWZMZLEYqTembhzk/GHmvIS3YM5JyRuNB3Kt8sWZQfCEj4qs/YFwTz/LUsiz6z F6kr2xOTKI43drMp4cdbSq5cIEQ0EV96kB18bmUdhi7ZyEsd9jWBK/aXrDDyXW32mRHM kdYHWzWMhro+TKN1rN93Nn8ms/4VeMImmF1WLfo1/l2dqdJm2fy0uhtNaS5E/HxbY1CB q5atqyP6leX/h/j6w/NLA5GFhno7Bp96rJfh6wOSy4hZDD/F06YLhqR28QJchL16DCr3 SACA== X-Gm-Message-State: APjAAAVFVtKFbr/0kikpdvM2GrC7J5s/ZgltSxwFdHold2fKUbWpyFs2 NAFX5azZvxyf76AUbRW4+ee6Ol5Bt94= X-Google-Smtp-Source: APXvYqwIeJyLdXOjUSTTGFSzQJYuWXBzosVrsqLIQuN9t+jkWx0gHhiWN31dIKyJiuRg/3XkEnVsgw== X-Received: by 2002:a17:902:41:: with SMTP id 59mr7130672pla.39.1582944235311; Fri, 28 Feb 2020 18:43:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 4/8] tcg/arm: Expand epilogue inline Date: Fri, 28 Feb 2020 18:43:43 -0800 Message-Id: <20200229024347.22826-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1032 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: peter.maydell@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson It is, after all, just two instructions. Profiling on a cortex-a15, using -d nochain to increase the number of exit_tb that are executed, shows a minor improvement of 0.5%. Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.inc.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index e1aa740ba4..6aa7757aac 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -1745,7 +1745,6 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is64) #endif } =20 -static tcg_insn_unit *tb_ret_addr; static void tcg_out_epilogue(TCGContext *s); =20 static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, @@ -1756,14 +1755,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpco= de opc, =20 switch (opc) { case INDEX_op_exit_tb: - /* Reuse the zeroing that exists for goto_ptr. */ - a0 =3D args[0]; - if (a0 =3D=3D 0) { - tcg_out_goto(s, COND_AL, s->code_gen_epilogue); - } else { - tcg_out_movi32(s, COND_AL, TCG_REG_R0, args[0]); - tcg_out_goto(s, COND_AL, tb_ret_addr); - } + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, args[0]); + tcg_out_epilogue(s); break; case INDEX_op_goto_tb: { @@ -2309,7 +2302,6 @@ static void tcg_target_qemu_prologue(TCGContext *s) */ s->code_gen_epilogue =3D s->code_ptr; tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); - tb_ret_addr =3D s->code_ptr; tcg_out_epilogue(s); } =20 --=20 2.20.1 From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944460; cv=none; d=zohomail.com; s=zohoarc; b=XPvg3ixWMx7yCKx1d5QLQzbgHuGXVnT3mHFzg6LNqaOb62cjlQ3PH9SWG8VDzqAd29ayOieTxrf3raeT52YjeJ38LljBzIboesO+1bJOXjzQjO+fzz9BdrhQ3lnpTUWgpinXrNyi+0qpoqF1bsYL8o0uIWMkGurw9nnC+Ft9Ecc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944460; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yoR4lHIMH0qpeMnLjOHbbbErJmJaq6BNdKSX4fGfFYE=; b=UVjEkJUwNQm2CEo2fvkm3sp8rKvgx7srHL7+8pOhUMuS9QFIEDJeyDbDV0IY8chvowsbW9z8/2YzTXiuMOaveaEAtXyXjbTqMuQAbxp+EGmVnacDdi7sh1HGwwtIA6fENY81cCP97cgFglcKIcM9ZKhb8C8PUoOXMCGZADtmBBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944460158536.8420503102693; Fri, 28 Feb 2020 18:47:40 -0800 (PST) Received: from localhost ([::1]:56564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7sAE-0004Eb-W2 for importer@patchew.org; Fri, 28 Feb 2020 21:47:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42739) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6i-00076w-Dr for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6h-0003BY-BY for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:00 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:35872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6h-00038c-4y for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:59 -0500 Received: by mail-pl1-x630.google.com with SMTP id a6so1963337plm.3 for ; Fri, 28 Feb 2020 18:43:59 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:55 -0800 (PST) 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=yoR4lHIMH0qpeMnLjOHbbbErJmJaq6BNdKSX4fGfFYE=; b=u9WwVTAYzRYg3KP4fU5p87GW67pe0yNzYMuOPrhid+PwGKRQnT/i+nEfA1U79/ddSp L8eu4ixwWumA20LPF7uWJ2A225oKetz4cRdxff7HtEOy0OjliXE5CS8bLOKOQBpOJpCZ ifZ8V4lRn/xPJDkgHXWVMnkdesAIztNUQt/czPfH2lJexZe/sq9nA1e6HHWKNc8j+W11 0azNHWJ/7IBoJx0Jaf8dH37X2oEfYaaTOLLRuplhja8EaEXzYOXwuNKyoLZIAaom7GrA vGgIWFRmrAdJXr0DOOz6q6CVDdGEjPq4c0LBfNt4XwOTpVUkpXbanN1xmFt1m2KGXnbb /tZA== 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=yoR4lHIMH0qpeMnLjOHbbbErJmJaq6BNdKSX4fGfFYE=; b=crnmamHFTzQiKU1Wyj42TaOte4YibVRdPFwPpfMGPd8HvMiiSjIw/o+PTooFS2QbO7 dFsi5tK9to6OYMp6uLyC9MPEEk8CDSWPO2RnP0vpmcTYcs0/kwLIQD36snXQqLNn+Tpy AmCtoppFbc0u3a/+gy+iCvD9NlO+zm27wRPCQiEKUwmlqEBxVNW3i/pnp/y3xt167G1j xmjmZXe46Yx7S206S4ZdDG0qNmuKdnIBTJ6YvamfkZtzOfFOMZtZHYfXK3Y2FaMby8rQ qITXjKZ8H3eMzx7f6ur478ubGeoYFuZ/URoD2fIMq6XecAwPSmTp0uRQ5EOjeBy0Mkbb RX0Q== X-Gm-Message-State: APjAAAWo2BeJRswPYQdmEk6tLfg5GLuaVFjBW77iHhFaWTa/EZxduw3C TKkpfIc6h6Dc7Vodq9IcSjDDEPxNrek= X-Google-Smtp-Source: APXvYqw09I/s86W6TGDp3ADpS+xkOCrpnlhBnr8CB3kiWkFU3YUy8ImY1Ejg22fqmNATTO0RxxPilA== X-Received: by 2002:a17:90a:6545:: with SMTP id f5mr8094175pjs.42.1582944236626; Fri, 28 Feb 2020 18:43:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 5/8] accel/tcg: use units.h for defining code gen buffer sizes Date: Fri, 28 Feb 2020 18:43:44 -0800 Message-Id: <20200229024347.22826-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::630 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: peter.maydell@linaro.org, Niek Linnenbank , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alex Benn=C3=A9e It's easier to read. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Niek Linnenbank Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200228192415.19867-2-alex.bennee@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a08ab11f65..238b0e575b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "qemu-common.h" =20 #define NO_CPU_IO_DEFS @@ -901,33 +902,33 @@ static void page_lock_pair(PageDesc **ret_p1, tb_page= _addr_t phys1, =20 /* Minimum size of the code gen buffer. This number is randomly chosen, but not so small that we can't have a fair number of TB's live. */ -#define MIN_CODE_GEN_BUFFER_SIZE (1024u * 1024) +#define MIN_CODE_GEN_BUFFER_SIZE (1 * MiB) =20 /* Maximum size of the code gen buffer we'd like to use. Unless otherwise indicated, this is constrained by the range of direct branches on the host cpu, as used by the TCG implementation of goto_tb. */ #if defined(__x86_64__) -# define MAX_CODE_GEN_BUFFER_SIZE (2ul * 1024 * 1024 * 1024) +# define MAX_CODE_GEN_BUFFER_SIZE (2 * GiB) #elif defined(__sparc__) -# define MAX_CODE_GEN_BUFFER_SIZE (2ul * 1024 * 1024 * 1024) +# define MAX_CODE_GEN_BUFFER_SIZE (2 * GiB) #elif defined(__powerpc64__) -# define MAX_CODE_GEN_BUFFER_SIZE (2ul * 1024 * 1024 * 1024) +# define MAX_CODE_GEN_BUFFER_SIZE (2 * GiB) #elif defined(__powerpc__) -# define MAX_CODE_GEN_BUFFER_SIZE (32u * 1024 * 1024) +# define MAX_CODE_GEN_BUFFER_SIZE (32 * MiB) #elif defined(__aarch64__) -# define MAX_CODE_GEN_BUFFER_SIZE (2ul * 1024 * 1024 * 1024) +# define MAX_CODE_GEN_BUFFER_SIZE (2 * GiB) #elif defined(__s390x__) /* We have a +- 4GB range on the branches; leave some slop. */ -# define MAX_CODE_GEN_BUFFER_SIZE (3ul * 1024 * 1024 * 1024) +# define MAX_CODE_GEN_BUFFER_SIZE (3 * GiB) #elif defined(__mips__) /* We have a 256MB branch region, but leave room to make sure the main executable is also within that region. */ -# define MAX_CODE_GEN_BUFFER_SIZE (128ul * 1024 * 1024) +# define MAX_CODE_GEN_BUFFER_SIZE (128 * MiB) #else # define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1) #endif =20 -#define DEFAULT_CODE_GEN_BUFFER_SIZE_1 (32u * 1024 * 1024) +#define DEFAULT_CODE_GEN_BUFFER_SIZE_1 (32 * MiB) =20 #define DEFAULT_CODE_GEN_BUFFER_SIZE \ (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \ --=20 2.20.1 From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944436; cv=none; d=zohomail.com; s=zohoarc; b=gf140nBSQ5nxh4VeNSZvUU/wq7ONNa8m2bIpUUc8vPl8WKTWd/+GsGwuJbpD/nesdJo+v73p0kuKOD0/qwAuXC2nSxiFm4VfodXiuOt7hCTIhY75xolEqV3iovGlXirjelMiA/njQWmk1H3LTqiMeTIE/xukAGKQsj9skDOlnbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944436; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gyGZkMpj+rKptKzAhufEEODcd3xDbylCrKGIVqFxQus=; b=CEMa1A6OLhWs0F6/wuV9mKkKfGwZIKWG1wtg/eXE87HDpISQqFJqy2qtnY7KvwrCXG/744bhpdeqSN5mvFmgijtZw+pfsODBoLvm/w6rct8w72pLKUJ+OZsjvCoRhG15FLu8TG9C1+EJXh6GZEZzP3r+fTyO+1lFrP/uTzHZLo8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944436150273.13067234657717; Fri, 28 Feb 2020 18:47:16 -0800 (PST) Received: from localhost ([::1]:56556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s9q-0003gG-Pb for importer@patchew.org; Fri, 28 Feb 2020 21:47:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42740) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6i-00076x-EH for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6h-0003C9-Gi for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:00 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:52087) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6h-0003AZ-B5 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:43:59 -0500 Received: by mail-pj1-x1031.google.com with SMTP id fa20so2037279pjb.1 for ; Fri, 28 Feb 2020 18:43:59 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:57 -0800 (PST) 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=gyGZkMpj+rKptKzAhufEEODcd3xDbylCrKGIVqFxQus=; b=uWS17YsviCNsgh8jF/jSG25FEsS1KRGPZuO2hVt5uvXo361D0qtV4UQGReX5fTG9lu Ss746eBJXVMQGBtILMWYxXIzxGnZRS3/9H/bckqSDBjX31tmkuvQbLsDtXnPrlW2zJsP iqna7q103QVpIPDO25avlUo7oJtkqk7cvGny6f1zfD+rShtmz2Pt3+iCdPenWjyQFDG/ VcJIVhVJowwGen6NKxDQSnt5D3RHuOutiEAsBeSlRgaeT/BI5c50ltl0EKQtYZn1heM1 9/T6hTD2jBT6UkvCrrx9BDF2hljKOq+zM5fCePR45wWJAnOeLVC7vHUcKR3maOOLSeMG eO8A== 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=gyGZkMpj+rKptKzAhufEEODcd3xDbylCrKGIVqFxQus=; b=aLd7tP+oQ35HorjO78/o7z6ymbh2kjtJXVlb90gYGleafGhJcAwaMvDJ2G+bO/JtYA sYNMij7yTNAkQCdxQmu0yviULukKJnmm3QSWN/u98jb1tSAyjoqs9Li0RIEoeVoL6hcC 7latzHtKx2n1C0EMYG3xtXRepcznfCrvPb4zncH+WsuaP1lVZLAYJbQGBv9p1LrQRW7n stWMx/c770bt7IvEGEWR/CNgj4MJTAUAX6hQqsTY4fp6p50ZTp3q7DRJqbSoHVjJtsMV tyOSaj7VIXj6pQpK7q9GWwKBgad8iWw2+dYPNLfBzspRM+Jj8ZcSFNBY2+AAvDE3KN2y kCNw== X-Gm-Message-State: APjAAAWCl4WJVvu9rgz0o8/6bJmKAYb1hYpV5t0ifOHNTDKsbEktqUoM B/ABMnx+klRDJNob/GL900OAz5HINy0= X-Google-Smtp-Source: APXvYqw52+dxMlfv5P25OvlpSUtYsZbcFD5DxLNkPkLFvQNNfGUrpzfstSs4z6OZLTUHkdxgMj5gxA== X-Received: by 2002:a17:902:c20b:: with SMTP id 11mr6119149pll.175.1582944238030; Fri, 28 Feb 2020 18:43:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 6/8] accel/tcg: remove link between guest ram and TCG cache size Date: Fri, 28 Feb 2020 18:43:45 -0800 Message-Id: <20200229024347.22826-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1031 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: peter.maydell@linaro.org, Niek Linnenbank , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alex Benn=C3=A9e Basing the TB cache size on the ram_size was always a little heuristic and was broken by a1b18df9a4 which caused ram_size not to be fully realised at the time we initialise the TCG translation cache. The current DEFAULT_CODE_GEN_BUFFER_SIZE may still be a little small but follow-up patches will address that. Fixes: a1b18df9a4 Cc: Igor Mammedov Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Niek Linnenbank Message-Id: <20200228192415.19867-3-alex.bennee@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 238b0e575b..5b66af783b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -938,15 +938,7 @@ static inline size_t size_code_gen_buffer(size_t tb_si= ze) { /* Size the buffer. */ if (tb_size =3D=3D 0) { -#ifdef USE_STATIC_CODE_GEN_BUFFER tb_size =3D DEFAULT_CODE_GEN_BUFFER_SIZE; -#else - /* ??? Needs adjustments. */ - /* ??? If we relax the requirement that CONFIG_USER_ONLY use the - static buffer, we could size this on RESERVED_VA, on the text - segment size of the executable, or continue to use the default.= */ - tb_size =3D (unsigned long)(ram_size / 4); -#endif } if (tb_size < MIN_CODE_GEN_BUFFER_SIZE) { tb_size =3D MIN_CODE_GEN_BUFFER_SIZE; --=20 2.20.1 From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944434; cv=none; d=zohomail.com; s=zohoarc; b=i0CIjut8y7vnt43SQ/zhsRRN1pdTwSI5b5h75QEKEes2Ps03nIhWNmNbOcyaCng/fWWjFZQcJ+fkSZIJHDoZPsc82Jd67vsOTIuo4cE46EMlIAfmpK6A82BNTlopF0q5aQkOK10/molMumLFZkjEp4LEgj5yuksIC0/zFDb0t7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944434; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TW57DhO0hZ+3P3SjnpzoFpldCfzCdzjtWoVxdqtBZb0=; b=m6wL4gwR4wSQECP0TDjZF9CJJVKRMwh5FjFGf++gPVRmBho4io6mBPOuSH9Zilzcomg1DPvFaBkcYxdkqEQYwPYMoGmcGNK1D6k+CnhcoX714+LT167I2udXwt1vOf8nNNLaZn1xQF+CgjrqCg6FmdHdZIjDwsckohAwUkd9y0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944434394695.4353862125457; Fri, 28 Feb 2020 18:47:14 -0800 (PST) Received: from localhost ([::1]:56552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s9p-0003d5-4x for importer@patchew.org; Fri, 28 Feb 2020 21:47:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42757) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6j-000781-LC for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6i-0003El-Lx for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:01 -0500 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:37137) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6i-0003DJ-Gp for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:00 -0500 Received: by mail-pj1-x1043.google.com with SMTP id o2so115036pjp.2 for ; Fri, 28 Feb 2020 18:44:00 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:58 -0800 (PST) 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=TW57DhO0hZ+3P3SjnpzoFpldCfzCdzjtWoVxdqtBZb0=; b=WTW2B6nS9zg235P5PEeVevoUS2Kka2++GMghpYF5V/3MbP21fMmWZ5nKm1mEeMXHgE 0YSOmUHyrKX7Uo4g1yx6Qwhxsv5Zd6dKB730HHNZd7Hsjbc12A4YMo4D05gJK0x04e8l jMApYDMmttWaL4kcXoDfndMACJPjzGubnmwkuBLFUQzRX5CxOy9V84x8bLIIK5X+8hHD vMXA6JGVO1FEB6jJe6UG12OCBEpKRgPYcQhN8pJPFPSkU9X8b0/bUQnSrMkcmnfWwMNw e7vHiq9x61uk55YFIA/b+NHWBAvU8G8vxd1TXXHLp+DqM0uvLt+OLEq9zHZFWHQdmwFm HUig== 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=TW57DhO0hZ+3P3SjnpzoFpldCfzCdzjtWoVxdqtBZb0=; b=ZnSnMImyNvgHA+elDnjzI/bhBWeEo745SdPoAXheiciidbdj0iY6VILB/ln8X+cND5 pFJsB0dnKPsz9TyyE+rGiHQs9W9GdrMG/PZ5ZwHp26pk8AOPR6sRbLwIJPtBH7AUu1Bd j4grGhlOtx+BIV2zszXEN3ADloZku56jeiogG51NnLgHUNK64kE8hyU2TjQrNPNK6aUX 9RYtMc7rS5DyPe7jIgvAkytCMWRExL9hQPdgS78Rbx3RrUKQQapve0k2HwCXQs+4+FeZ YCtKcijUPVnjlkfWPivKJUEaZn3d5V/eVbjkXV70G3102lgQ4/8C5dW81hr5Ks555kaz EAIA== X-Gm-Message-State: APjAAAWseuelQgrgkUT571Yb8MKuCcoD4YU8doAhfZg+W0BkVNsYJNxr oA4MYTobvmC76DXpyx6fNV7P5xU4HPM= X-Google-Smtp-Source: APXvYqyP7es76PbvnBkyl8/jeB38cgqs03EKnQSZ3nlao0Jm6PVOqxuuabIVjp+1gu3Bfr3xp9J8sQ== X-Received: by 2002:a17:902:bc4a:: with SMTP id t10mr6957286plz.103.1582944239196; Fri, 28 Feb 2020 18:43:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 7/8] accel/tcg: only USE_STATIC_CODE_GEN_BUFFER on 32 bit hosts Date: Fri, 28 Feb 2020 18:43:46 -0800 Message-Id: <20200229024347.22826-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1043 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: peter.maydell@linaro.org, Niek Linnenbank , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alex Benn=C3=A9e There is no particular reason to use a static codegen buffer on 64 bit hosts as we have address space to burn. Allow the common CONFIG_USER case to use the mmap'ed buffers like SoftMMU. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Niek Linnenbank Message-Id: <20200228192415.19867-4-alex.bennee@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 5b66af783b..4ce5d1b393 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -892,11 +892,12 @@ static void page_lock_pair(PageDesc **ret_p1, tb_page= _addr_t phys1, } } =20 -#if defined(CONFIG_USER_ONLY) -/* Currently it is not recommended to allocate big chunks of data in - user mode. It will change when a dedicated libc will be used. */ -/* ??? 64-bit hosts ought to have no problem mmaping data outside the - region in which the guest needs to run. Revisit this. */ +#if defined(CONFIG_USER_ONLY) && TCG_TARGET_REG_BITS =3D=3D 32 +/* + * For user mode on smaller 32 bit systems we may run into trouble + * allocating big chunks of data in the right place. On these systems + * we utilise a static code generation buffer directly in the binary. + */ #define USE_STATIC_CODE_GEN_BUFFER #endif =20 --=20 2.20.1 From nobody Wed Apr 9 17:59:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582944314; cv=none; d=zohomail.com; s=zohoarc; b=YTg7XDo1OaRKwjQre9Cc7B4jL4l138TS1jiwq8iwHb1RneEZjJeVaur1qxEnF36/qJlIgygz169FMgsfroVGSnfwneonIfEi+NLa2kY/yH7c+vydSizXJT/ynL/0HBwrQ/GU5bWb/zP/jQs+3ByK59C1g9mc/4DzMRb9T6D5NJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582944314; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VlxVvw9Nxub+F/a7czDjW6LNfb9GxIjz3UCnfFm+v5Q=; b=NA7qBhMc3m73AX48EH7nttRR7fF3FCWoDdu7Wt+uv7Vf2QM0NCYmhjQqu5TqeclX4T3GGIJT07aedLrv9sHFGcJKeCi/H54oPx4QlEkY4WZtj9rONl+pCGUqNnYnwqeYvHn+dTVlAaYImDdT8zhTeW40BWCPOjl+ZflTpj3Bwgs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582944314397754.2191416843717; Fri, 28 Feb 2020 18:45:14 -0800 (PST) Received: from localhost ([::1]:56498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s7t-0000fN-0J for importer@patchew.org; Fri, 28 Feb 2020 21:45:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42769) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7s6l-0007A3-4K for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7s6k-0003I9-2B for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:03 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:41219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7s6j-0003GO-S9 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 21:44:02 -0500 Received: by mail-pg1-x536.google.com with SMTP id b1so2454210pgm.8 for ; Fri, 28 Feb 2020 18:44:01 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id k9sm3649321pjo.19.2020.02.28.18.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 18:43:59 -0800 (PST) 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=VlxVvw9Nxub+F/a7czDjW6LNfb9GxIjz3UCnfFm+v5Q=; b=wJgvO2M9voJAm3Ydd5wUA9lnxPBEBL1Q2ejMnIk70UHL1CL5a5zMFW5TNkOW8igFS+ ky+ScSqWxtaLN2NYww8rAlA6zMTljABd/rDUvYP2FbFu7UnoBRiKLsBVw24TuRKWv8xL mK9g4iojiFoi9yEdK1uh0ZZZHDeR7Pbr4nok94JV7bLDEYeAnLd3s+vPwokZF6zCJ3gP Kp4ITdaw6j0guFoq9ZfiNiwblSYuuOsSayw3Ao1jtL34QgaIAr3Ce40ODpE8wQdBLGC2 rCzl2a3V0Br7KHdAtQ9vlUPIiYTCn5NJwJg6oUdDXV+g9VCqvD6iDtCmhL4Y0X/BxJDa 4yxw== 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=VlxVvw9Nxub+F/a7czDjW6LNfb9GxIjz3UCnfFm+v5Q=; b=nkKx6E/ZQRiRkZdia85eP9cAjHw7mTNdgmN+hSHp5ednXRF4e1kBB7p4G+GcpYu7IL ztnsCt3t4j9//MoF3iRL6uyKJxUcejxmBGfEgaILabHhQGbfbIyrRKciZjSHG4uHzk3p DGxkMbbfWjWQB2tYm10O91VvI4Xn1+xyWcC6Af6HwOzizp8QiqxudRvQ2PbPQfMPC8Vf 5x8a6Bl1ZPiRYE3LGsleBxo/e4GTIA7mtloNSwu0+P3q4jd83kiK9A31lEglsAXCSXKG /2GkVwCzgb0vcqNyWBh97nDbnPedyN6yWEM1C+87eSp7Y17fAFegBhlNWAFaVddlPLpe A0hA== X-Gm-Message-State: APjAAAX9CfXYlI4TJAeezIG5AsW6iFFRPkxfiAdyw1cWh5UCntsWYiuk b3omWC4L4sEfsrsLdl5F14lTk9g+SkM= X-Google-Smtp-Source: APXvYqyIdmEi+uWeXPTuAwabJYNuamrmjnlK2whuuk2R6G29sylVc586dgw+oGpqNXeclMDtMqCEFQ== X-Received: by 2002:a63:5522:: with SMTP id j34mr6715600pgb.97.1582944240355; Fri, 28 Feb 2020 18:44:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 8/8] accel/tcg: increase default code gen buffer size for 64 bit Date: Fri, 28 Feb 2020 18:43:47 -0800 Message-Id: <20200229024347.22826-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229024347.22826-1-richard.henderson@linaro.org> References: <20200229024347.22826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::536 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: peter.maydell@linaro.org, Niek Linnenbank , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alex Benn=C3=A9e While 32mb is certainly usable a full system boot ends up flushing the codegen buffer nearly 100 times. Increase the default on 64 bit hosts to take advantage of all that spare memory. After this change I can boot my tests system without any TB flushes. As we usually run more CONFIG_USER binaries at a time in typical usage we aren't quite as profligate for user-mode code generation usage. We also bring the static code gen defies to the same place to keep all the reasoning in the comments together. Signed-off-by: Alex Benn=C3=A9e Tested-by: Niek Linnenbank Reviewed-by: Niek Linnenbank Message-Id: <20200228192415.19867-5-alex.bennee@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4ce5d1b393..78914154bf 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -892,15 +892,6 @@ static void page_lock_pair(PageDesc **ret_p1, tb_page_= addr_t phys1, } } =20 -#if defined(CONFIG_USER_ONLY) && TCG_TARGET_REG_BITS =3D=3D 32 -/* - * For user mode on smaller 32 bit systems we may run into trouble - * allocating big chunks of data in the right place. On these systems - * we utilise a static code generation buffer directly in the binary. - */ -#define USE_STATIC_CODE_GEN_BUFFER -#endif - /* Minimum size of the code gen buffer. This number is randomly chosen, but not so small that we can't have a fair number of TB's live. */ #define MIN_CODE_GEN_BUFFER_SIZE (1 * MiB) @@ -929,7 +920,33 @@ static void page_lock_pair(PageDesc **ret_p1, tb_page_= addr_t phys1, # define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1) #endif =20 +#if TCG_TARGET_REG_BITS =3D=3D 32 #define DEFAULT_CODE_GEN_BUFFER_SIZE_1 (32 * MiB) +#ifdef CONFIG_USER_ONLY +/* + * For user mode on smaller 32 bit systems we may run into trouble + * allocating big chunks of data in the right place. On these systems + * we utilise a static code generation buffer directly in the binary. + */ +#define USE_STATIC_CODE_GEN_BUFFER +#endif +#else /* TCG_TARGET_REG_BITS =3D=3D 64 */ +#ifdef CONFIG_USER_ONLY +/* + * As user-mode emulation typically means running multiple instances + * of the translator don't go too nuts with our default code gen + * buffer lest we make things too hard for the OS. + */ +#define DEFAULT_CODE_GEN_BUFFER_SIZE_1 (128 * MiB) +#else +/* + * We expect most system emulation to run one or two guests per host. + * Users running large scale system emulation may want to tweak their + * runtime setup via the tb-size control on the command line. + */ +#define DEFAULT_CODE_GEN_BUFFER_SIZE_1 (1 * GiB) +#endif +#endif =20 #define DEFAULT_CODE_GEN_BUFFER_SIZE \ (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \ --=20 2.20.1