From patchwork Fri Feb 5 22:56:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 376997 Delivered-To: patch@linaro.org Received: by 2002:a17:906:48d2:0:0:0:0 with SMTP id d18csp2576661ejt; Fri, 5 Feb 2021 15:04:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyty6w+vwjKkMeWq1xqbS2nS9FTfnzAu1Abr2Px0cf1VdSSiAC3sAz2a/4SG+h+gOxBUBe2 X-Received: by 2002:a25:3056:: with SMTP id w83mr9086419ybw.504.1612566279125; Fri, 05 Feb 2021 15:04:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612566279; cv=none; d=google.com; s=arc-20160816; b=ZZ+2EEgdgmv2n92WDKAh0CU21lIpNjl+jCM4Qtk0x3BqlvKCsq+tuwd3twd+Locgxj UWOGaq/fFeXldRpbRCOyhgEpwXLvLjE7THzbpG4KWk29U89sKilnQ4QfyOJf3Eh5YMt/ DT79nzeUICkJE8/wi/tBpaesYzTwLbT203bAQGMakeIF7GvxPbdanpYlKx5tBDksNlx2 WxQ+7MVLTakjRwdUUQA56dLM69KLTAecXeoXw85Tohs5oMleHSU0A4AcuE/Wstj9MrWg RVsJNvZSiGmN5PZlgndjcP3LBbabvv95EGwvX7bixUgzBQccivEzl0GaYy7MDUvkLfZP /mSw== 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=GERD/esKSxShFOguv3KoJ5qwPYQvSGdHFbj2dQY7+2M=; b=TF560bVh3Rp1atG94Ep7+t9qFMuEbUE2ZxNqD+heWOrevD0WIbIX8KD4OnAbyAmMz2 R9vPhw/tR+CVQrKB6/rqHs3hpzz8QWfqGMndfXzUyC8EODJwA9MfifrEvhmwIksv8WmC U2dIGeX//4Z0PU24y5SQHlL8knUknxI8A/GSTnRfPAra0GZV744nbyk9YAHPOMpqBAQC An9PPjGfz5Ke7nuGrkr4O1q0wglQrfe5u3LtXPoMqLJBuy9SPn9nc38LNIHlM8l3BNe3 JUohWs49/D+HuzaB7DV+75xN4kW1MmBWfTzriOJNsUdTA1LSK2EZJIzrd5oIAUbGMGgG C6BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o0lNxANi; 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=pass (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 v6si9401065ybs.431.2021.02.05.15.04.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Feb 2021 15:04:39 -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=pass header.i=@linaro.org header.s=google header.b=o0lNxANi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8A9W-0003Jv-GE for patch@linaro.org; Fri, 05 Feb 2021 18:04:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8A2E-0001Sw-PW for qemu-devel@nongnu.org; Fri, 05 Feb 2021 17:57:06 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:46930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8A2D-0003D4-1l for qemu-devel@nongnu.org; Fri, 05 Feb 2021 17:57:06 -0500 Received: by mail-pl1-x636.google.com with SMTP id u11so4289774plg.13 for ; Fri, 05 Feb 2021 14:57:04 -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=GERD/esKSxShFOguv3KoJ5qwPYQvSGdHFbj2dQY7+2M=; b=o0lNxANib8fu5MqZ0FUHOgr5gkOwK8PgPdachVt11ZErBZ5rYLKp7SEEfR4VN6kqw6 SFIe5rA4n2DY6He+7uBmdHGKH0y0lwI3xcOCMsMf8vmDyl/hNWM57i7DUvxdzYLMnOSj A84PJzmzWfNsYf7E5Hc2ibe6edvTn+E0oB5MOlUc/o4u8UAr/D+V8L+RbCFBRiLqyxxs RQjxspaARavgBABsJS0tYNhal91t7uErOrh+gMh8zwVPjEc08leEPIxPbZXQPvE8hXxi j2cgcbsl6J3uPtSPUCUbiUt9pdNjvCpw8UlW+pyufuj3H4BWb2fiFvyuD4VMAGMlV75+ 9gRA== 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=GERD/esKSxShFOguv3KoJ5qwPYQvSGdHFbj2dQY7+2M=; b=PbiQyhxL2HeaMJgVCdufAqe3gR20K8m97uW3YJxws447H9vm9X2JBfb7YAzxq5Uf47 kD6cNOvRw5VPyPpKIM3fjVNMBwvWT6Tn7xoZSCnRyecaWxfg9Rd6Gf2r33AzZdwdMlQh dk9NqHtgC/jZlY5IaZJQKynZq4ljFbOUtOcoSpsp1A4KiGeXydTqixwWgppsqO6OrcC4 f7BabFCzcn1MB8hmWMqi3YfqYVeIinvfdOSGnxDJDMH2bgW6aXGrb7c+tNSJqGzANL6d zRjl0NABchi6wlPdX3/3X+npDLf/FTvi149AqDEfGIFq4FkLF5j1PRuQ3Qy6xJfVcL4J yg2A== X-Gm-Message-State: AOAM530+ap6No+GnkQfr1Yt463J/DGQhAXq2rrcs4TXCiYjrcXWYfE6w /17Y78G/E2FCsZvrrkUHlmTfBqFJmkHBbxMV X-Received: by 2002:a17:90a:f416:: with SMTP id ch22mr6233955pjb.61.1612565823735; Fri, 05 Feb 2021 14:57:03 -0800 (PST) Received: from localhost.localdomain (cpe-66-27-222-29.hawaii.res.rr.com. [66.27.222.29]) by smtp.gmail.com with ESMTPSA id c23sm12155149pgc.72.2021.02.05.14.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:57:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/46] tcg/tci: Make tci_tb_ptr thread-local Date: Fri, 5 Feb 2021 12:56:09 -1000 Message-Id: <20210205225650.1330794-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205225650.1330794-1-richard.henderson@linaro.org> References: <20210205225650.1330794-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Each thread must have its own pc, even under TCI. Remove the GETPC ifdef, because GETPC is always available for helpers, and thus is always required. Move the assignment under INDEX_op_call, because the value is only visible when we make a call to a helper function. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20210204014509.882821-6-richard.henderson@linaro.org> --- include/exec/exec-all.h | 2 +- tcg/tcg-common.c | 4 ---- tcg/tci.c | 7 +++---- 3 files changed, 4 insertions(+), 9 deletions(-) -- 2.25.1 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 125000bcf7..f933c74c44 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -544,7 +544,7 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); /* GETPC is the true target of the return instruction that we'll execute. */ #if defined(CONFIG_TCG_INTERPRETER) -extern uintptr_t tci_tb_ptr; +extern __thread uintptr_t tci_tb_ptr; # define GETPC() tci_tb_ptr #else # define GETPC() \ diff --git a/tcg/tcg-common.c b/tcg/tcg-common.c index 7e1992e79e..aa0c4f60c9 100644 --- a/tcg/tcg-common.c +++ b/tcg/tcg-common.c @@ -25,10 +25,6 @@ #include "qemu/osdep.h" #include "tcg/tcg.h" -#if defined(CONFIG_TCG_INTERPRETER) -uintptr_t tci_tb_ptr; -#endif - TCGOpDef tcg_op_defs[] = { #define DEF(s, oargs, iargs, cargs, flags) \ { #s, oargs, iargs, cargs, iargs + oargs + cargs, flags }, diff --git a/tcg/tci.c b/tcg/tci.c index 3fc82d3c79..b3f9531a73 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -57,6 +57,8 @@ typedef uint64_t (*helper_function)(tcg_target_ulong, tcg_target_ulong, tcg_target_ulong, tcg_target_ulong); #endif +__thread uintptr_t tci_tb_ptr; + static tcg_target_ulong tci_read_reg(const tcg_target_ulong *regs, TCGReg index) { tci_assert(index < TCG_TARGET_NB_REGS); @@ -526,16 +528,13 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, #endif TCGMemOpIdx oi; -#if defined(GETPC) - tci_tb_ptr = (uintptr_t)tb_ptr; -#endif - /* Skip opcode and size entry. */ tb_ptr += 2; switch (opc) { case INDEX_op_call: t0 = tci_read_ri(regs, &tb_ptr); + tci_tb_ptr = (uintptr_t)tb_ptr; #if TCG_TARGET_REG_BITS == 32 tmp64 = ((helper_function)t0)(tci_read_reg(regs, TCG_REG_R0), tci_read_reg(regs, TCG_REG_R1),