From patchwork Thu Mar 11 00:21:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 397381 Delivered-To: patch@linaro.org Received: by 2002:a17:906:a383:0:0:0:0 with SMTP id k3csp1440ejz; Wed, 10 Mar 2021 16:28:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvlsHEFXBfCDpm1BYhtZZlsoQRdp3yXGBW7l5+VAhf/xAUzyBangPdpKFGtQg8296V5bfT X-Received: by 2002:a05:6e02:1d85:: with SMTP id h5mr5042436ila.246.1615422482118; Wed, 10 Mar 2021 16:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615422482; cv=none; d=google.com; s=arc-20160816; b=f7hFgm6GL9IqcM5o8E9hAQAJ43A8WwnYZwXx6K9XeP6fzAyydc9k8WXzsTIg41ZToj SPn5DzpMEb/7NODGHI5c1ZSQhUYyQzNNjAD8hnHzgiFpguun4/xQ4/WRbWQ2SJEUkIll jiRYhFiyB0njIrxec8M4P0MRwKakcD5dl2Iz5vTAmpI9E0GIXC19CJf2pB7c8OQuQDuV oSsskkYgBnV43eQi9DMbyDx330AKg/p+ekUzamU5ZEtPq8/AmaCYXAc0vQjrApvopW5x v4XuFwgu/csU7tP37jPXLq2PVmGizOyTCsCvRf16oBOK+gMsI1XadUT6TjIjEprmlXqm tlbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=EQ+ywpBmHDVC3DOo5FVJf1bXQ/r+fWvVCtSN9ZnyiEg=; b=y1yD84Cmt7RQUZe7ohQAxqye/cv1N0zV+FTOeZVAOiV2crI6Gx2U1ilx2fn7v7oebY Rt8mROZcNPNao5MysJ8s8w8cYEXK6mFRMiWfSHMYOrTWuifWqQU1cBZWi+u+n0bgi5oY WEENwEsG9lxBEeHt4uFfVMIhu2sVrOWENfeiyUnXFbAx1Dv+IN4rQcshonaRsawVj19x CnhO34mZXCqORuBRoBPtvXbYRUw6JiD4wEir0hUlNqYzFunp7yr4zFMJ44mFt+12nPN8 X78KFc2VuWc1fwcP0/xlvcsfKdnLYYgpSvU6uhRCUEg6qYLqMDTh2pGUUVPG4PVXXEyO 6aIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="tePEB/mK"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f9si1172508ilu.12.2021.03.10.16.28.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Mar 2021 16:28:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="tePEB/mK"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK9BJ-0003HY-9g for patch@linaro.org; Wed, 10 Mar 2021 19:28:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lK95g-0004f2-6x for qemu-devel@nongnu.org; Wed, 10 Mar 2021 19:22:12 -0500 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]:37814) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lK95d-0001Kq-Q0 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 19:22:11 -0500 Received: by mail-ot1-x32a.google.com with SMTP id 75so15057185otn.4 for ; Wed, 10 Mar 2021 16:22:08 -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=EQ+ywpBmHDVC3DOo5FVJf1bXQ/r+fWvVCtSN9ZnyiEg=; b=tePEB/mK+us80Wh9mMSDL3XT+XJRgWOfeEJJypJALP+x1v2Y8Ud3ZYR7leRakdYBNw wUpgI6CnSDz8R04T3HrFIHLcXgwXUOaKSZLsfFof/Q8q54rBxxJvm0bhhQ1JZ3C1/J29 3k6PBbXnnpCQBxqVEudbiJ1o2CgFPMF6BnGSzdsOMTgcXfy5qmOTAVEWJJVIyih8coer zk+0nLbdMuaduOf0oQ+3ZFL6Ji2vp8KD5zrER48I6Iy/bqmREP00hGGfgHZfQ61Cpm2V 9V9VGHyUGJfhCvT2BV97REQx/GLbgIwR9P82LcCB+jqFvQMNFWididdRnTRcgmO3NGAF Yu5Q== 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=EQ+ywpBmHDVC3DOo5FVJf1bXQ/r+fWvVCtSN9ZnyiEg=; b=Ke1nIOx8+jom4zuNAQszP2huMTxXFKUEdw8aIkx6X+kiut6Pe291fpMgx4eZVNtI+Z Kdv/V6kV+xofRqiCWWHc5VJsCqDXQ85z5Loc4YDUYZxV3W4cnTrTzIe69qrZv4GMjrrN FcrK/wcZrNlhTJAc4QuMREnUrtq4CAOLZiuep2dXKgPswfeDSJFXI/IEO6EpiSj31eUG 6BkaVhlRJuX/1REEMxYVIK0b6Q/ltGuD8A1rrMkEJC9/Q/9OInbdwVYjWdsK9OAte+oq 6VsbWXhIcIGp/Tpfl8KBAj539Wkz21F2GQYHa4hAAWogWhH1ap2Bdsjo4Bp0ErvjsLcv fk4A== X-Gm-Message-State: AOAM532wfuA0BstI98kGta0pmhRlJFlD5h9k43o48ZCRMq9oTEL+ebEg swpA4qbMufHcgsh9dlNfsJW9+QBUp23quRsG X-Received: by 2002:a05:6830:1c6e:: with SMTP id s14mr4775576otg.17.1615422128128; Wed, 10 Mar 2021 16:22:08 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id a6sm300962otq.79.2021.03.10.16.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 16:22:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/26] tcg: Split out tcg_region_prologue_set Date: Wed, 10 Mar 2021 18:21:37 -0600 Message-Id: <20210311002156.253711-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311002156.253711-1-richard.henderson@linaro.org> References: <20210311002156.253711-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: r.bolshakov@yadro.com, j@getutm.app Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This has only one user, but will make more sense after some code motion. Always leave the tcg_init_ctx initialized to the first region, in preparation for tcg_prologue_init(). This also requires that we don't re-allocate the region for the first cpu, lest we hit the assertion for total number of regions allocated . Signed-off-by: Richard Henderson --- tcg/tcg.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) -- 2.25.1 diff --git a/tcg/tcg.c b/tcg/tcg.c index 3316a22bde..5b3525d52a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -880,10 +880,26 @@ void tcg_region_init(void) tcg_region_trees_init(); - /* In user-mode we support only one ctx, so do the initial allocation now */ -#ifdef CONFIG_USER_ONLY - tcg_region_initial_alloc__locked(tcg_ctx); -#endif + /* + * Leave the initial context initialized to the first region. + * This will be the context into which we generate the prologue. + * It is also the only context for CONFIG_USER_ONLY. + */ + tcg_region_initial_alloc__locked(&tcg_init_ctx); +} + +static void tcg_region_prologue_set(TCGContext *s) +{ + /* Deduct the prologue from the first region. */ + g_assert(region.start == s->code_gen_buffer); + region.start = s->code_ptr; + + /* Recompute boundaries of the first region. */ + tcg_region_assign(s, 0); + + /* Register the balance of the buffer with gdb. */ + tcg_register_jit(tcg_splitwx_to_rx(region.start), + region.end - region.start); } #ifdef CONFIG_DEBUG_TCG @@ -963,10 +979,10 @@ void tcg_register_thread(void) if (n > 0) { alloc_tcg_plugin_context(s); + tcg_region_initial_alloc(s); } tcg_ctx = s; - tcg_region_initial_alloc(s); } #endif /* !CONFIG_USER_ONLY */ @@ -1206,8 +1222,6 @@ void tcg_prologue_init(TCGContext *s) { size_t prologue_size; - /* Put the prologue at the beginning of code_gen_buffer. */ - tcg_region_assign(s, 0); s->code_ptr = s->code_gen_ptr; s->code_buf = s->code_gen_ptr; s->data_gen_ptr = NULL; @@ -1239,14 +1253,7 @@ void tcg_prologue_init(TCGContext *s) (uintptr_t)s->code_buf, prologue_size); #endif - /* Deduct the prologue from the first region. */ - region.start = s->code_ptr; - - /* Recompute boundaries of the first region. */ - tcg_region_assign(s, 0); - - tcg_register_jit(tcg_splitwx_to_rx(region.start), - region.end - region.start); + tcg_region_prologue_set(s); #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) {