From patchwork Thu Mar 11 14:39:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 397487 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp374741jai; Thu, 11 Mar 2021 06:44:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJw18iy2Tl+r800x5UmWMbpQ0hnSWyIjjGL0CuRjmCEuJ6q7jAGlF+vO+Dz1EvuYup/+/DwL X-Received: by 2002:a6b:f909:: with SMTP id j9mr6560587iog.138.1615473858946; Thu, 11 Mar 2021 06:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615473858; cv=none; d=google.com; s=arc-20160816; b=ElDOxzRZZ4IXIpw2qbf827sIZgzwL9oxI55sxiHOy3uh0/lWFXH4U3jjUf1YkMTOLX ETjuvolNnXvhjjnRbr5RSJKTSVfgP37Vl3Dn4aZWhmNCgd9RPOA0PzCz66UcBoOaKye0 RTKVch0HvJwWxNN6ZYhTET8BQYGGzozA9Hyz0OO5JjIC40Tajhg67Vi+OBJHcWcNPSvg BJXZ3Qil+WJq611mT6T0/LH3jiQhwoMavH0jlxEh/3m3Z0IBblwR4xXwYTQJTKhuFqcc nt+/FeXS/rO6/rY9ScJgJiBkmWaYyPSkbFrZQepsDJg9313icQ2rlWnAPoeJ/WR9mW5A AnMg== 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=tDBHUplRWlhhF0tIGzcFewPFwl6oh2HCB/aPTX+DVBc=; b=QYnsXeVGTafbk5LNnr/uLt28Ox8zrOHv+ZMCJcBvSfWRstXcHmdH+GOvRVXAgjkUV0 iSfdz5NxezWb0FPMrLcgQcKMs2wamspCFDMV4KhybN6khTdYPfyQ1sjn2JGiDf0ctvtI MnJYBTfbdLr3/vSFpAkf8cH2evthMk0i6NJjuKlEUQzMmWjHxDo37nWYCvJjc56ehnCg kLRpLaGomDU8VBiugFEqujcKm6R7LZbDw+BjqSyrhxUkUjpfN7l6UaIZKjRexb+37kgv 7/benM4u8fcFpglaZmTsV7SQVShTM+KaaTJrsJtwqOP+48SPmSVrCWe85lTmg9y+uDnY D47A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K23fPZWY; 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 p14si3003658iog.41.2021.03.11.06.44.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Mar 2021 06:44:18 -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=K23fPZWY; 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]:50454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKMXy-0007Hf-Dy for patch@linaro.org; Thu, 11 Mar 2021 09:44:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKMU9-0003EN-6U for qemu-devel@nongnu.org; Thu, 11 Mar 2021 09:40:21 -0500 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:39436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKMU7-0006IX-2F for qemu-devel@nongnu.org; Thu, 11 Mar 2021 09:40:20 -0500 Received: by mail-qt1-x830.google.com with SMTP id g24so1268066qts.6 for ; Thu, 11 Mar 2021 06:40:17 -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=tDBHUplRWlhhF0tIGzcFewPFwl6oh2HCB/aPTX+DVBc=; b=K23fPZWY01m1UBpz8VCVQrmX9mD9Ucoze/PjqgxmTBa++65AnevNa8TIMklSfACYLJ U1YLu/N5hVP9cG9xd05Z+7YTmildxAA6RSi9SaxgaX0tciWbu+NJR/5yeLnK9NwZD+nR F0oPCJJCXvgkNclqRButmUAs04VM1fmEZDVTqfvXuy3msIGa4C3ojUbCnZu8eRnaPWPa 6PIw6TAI0jfbzE4CwjPp87V5J2BuvPaJEYpGy1jLc4kkbmxJZMovsXjlezbC415sTlEJ qexFnsKoBuVxJTBCXPuaXh1gQQUD9gPpy2uYcMWB0VNRl7sXzJ2XLl46H8T9XjFNkxhZ wOXA== 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=tDBHUplRWlhhF0tIGzcFewPFwl6oh2HCB/aPTX+DVBc=; b=Svb9vMPx9JxTi5/YnbYrwloan3sL9kkSFnpCuCNs2ZjVMpW16y4O75ohWBPwfPet0C m4uzGE+mL+b7bqbOzkbmI7dg6FkMc/WlHKPsoTRPyJAo/M8PipjacTgqNE89nDmnbWrK 79Vj8W69jkjO+LKrVVMCi4Fx45M4UxVCwpDpAR0Vyasu1mP6dHcyEICVj74O1OId8kol OQBP6fGfeIPmEKyYgH/xcwNVT7vNfKz5qTjk1y3QEhEoAnwdLFRdyrsMgeDwRJQCPwz1 HJRYX4E/TJll+K8ouDeb+F/jDnaURZTFIrADpiw+SVciYflg5ehp2E/1y+2yA6rlHflG vCxw== X-Gm-Message-State: AOAM530pzqGp0Bqiqx0gKTrt3kW/NAvQ0PBiviBOOOB+i39OkPO9Mj5x BwzJ3MvE/YtgnBMN98ocgrNfRnap7anSBX3I X-Received: by 2002:aed:3886:: with SMTP id k6mr6274889qte.167.1615473616277; Thu, 11 Mar 2021 06:40:16 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id d84sm2070324qke.53.2021.03.11.06.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 06:40:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 13/57] tcg/tci: Reuse tci_args_l for goto_tb Date: Thu, 11 Mar 2021 08:39:14 -0600 Message-Id: <20210311143958.562625-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311143958.562625-1-richard.henderson@linaro.org> References: <20210311143958.562625-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x830.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: sw@weilnetz.de, alex.bennee@linaro.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert to indirect jumps, as it's less complicated. Then we just have a pointer to the tb address at which the chain is stored, from which we read. Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 11 +++-------- tcg/tci.c | 8 +++----- tcg/tci/tcg-target.c.inc | 13 +++---------- 3 files changed, 9 insertions(+), 23 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 9c0021a26f..9285c930a2 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -87,7 +87,7 @@ #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 #define TCG_TARGET_HAS_goto_ptr 0 -#define TCG_TARGET_HAS_direct_jump 1 +#define TCG_TARGET_HAS_direct_jump 0 #define TCG_TARGET_HAS_qemu_st8_i32 0 #if TCG_TARGET_REG_BITS == 64 @@ -174,12 +174,7 @@ void tci_disas(uint8_t opc); #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, - uintptr_t jmp_rw, uintptr_t addr) -{ - /* patch the branch destination */ - qatomic_set((int32_t *)jmp_rw, addr - (jmp_rx + 4)); - /* no need to flush icache explicitly */ -} +/* not defined -- call should be eliminated at compile time */ +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #endif /* TCG_TARGET_H */ diff --git a/tcg/tci.c b/tcg/tci.c index 6fbbc48ecf..3fe0831b33 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -816,13 +816,11 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, return (uintptr_t)ptr; case INDEX_op_goto_tb: - /* Jump address is aligned */ - tb_ptr = QEMU_ALIGN_PTR_UP(tb_ptr, 4); - t0 = qatomic_read((int32_t *)tb_ptr); - tb_ptr += sizeof(int32_t); + tci_args_l(&tb_ptr, &ptr); tci_assert(tb_ptr == old_code_ptr + op_size); - tb_ptr += (int32_t)t0; + tb_ptr = *(void **)ptr; continue; + case INDEX_op_qemu_ld_i32: t0 = *tb_ptr++; taddr = tci_read_ulong(regs, &tb_ptr); diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index ff8040510f..2c64b4f617 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -405,16 +405,9 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, break; case INDEX_op_goto_tb: - if (s->tb_jmp_insn_offset) { - /* Direct jump method. */ - /* Align for atomic patching and thread safety */ - s->code_ptr = QEMU_ALIGN_PTR_UP(s->code_ptr, 4); - s->tb_jmp_insn_offset[args[0]] = tcg_current_code_size(s); - tcg_out32(s, 0); - } else { - /* Indirect jump method. */ - TODO(); - } + tcg_debug_assert(s->tb_jmp_insn_offset == 0); + /* indirect jump method. */ + tcg_out_i(s, (uintptr_t)(s->tb_jmp_target_addr + args[0])); set_jmp_reset_offset(s, args[0]); break;