From patchwork Wed Feb 10 22:10:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 380241 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1557170jah; Wed, 10 Feb 2021 14:16:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3lEVzzJns/Fy/xTPR5DRtfiKSmRNQnwqYlyGQHufvAc9LqmPSrQHF38sp/3bhC8tsJTBH X-Received: by 2002:a25:910a:: with SMTP id v10mr7500961ybl.506.1612995418128; Wed, 10 Feb 2021 14:16:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612995418; cv=none; d=google.com; s=arc-20160816; b=smAJ8U8GtbyJOAZcEpIOlcd2ypd8LOaSdt7yk833BL+b2ZGRJrB2roycsMThVZlAmu rdGXry4yVAxSnyBvXXWN+5wl0Ps0uHkqR2LVD5/xegkCX/xiFdfPlSr0nVxZgphh2nro W94uwE0x5j62M4EKo34fNDc/ZvOucGgXl9nZ2TLPWSaue/o+0QVwOPjWVknqNdZ8adyZ NjQd9Cc2jcGjizXJdh633vIofG3B6cse80+eZzCmWUifvna0gx30M1kFLNpbzjdWaOE0 S2qeC0PiediravH5aUagNjTivCugAH/+Eq+4klx1c5Wv1c9NK1dUFaVp5BXZFmzJxeVY D1KA== 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=o81Mz4W9KCvutw0rCkPpru0KeoeXZKNx1XZY/IHOEHo=; b=E+bTcykDaL3LXMGiKSOYwKeXZmZqye8aJAuIZxp1XtCyqBdiypz+rfP+oTPZneIaTk AIaaQGupRgG1dP2rCGFTVUb1Clsgvq9s/EWE0buzMch+nBfM8/D46MuNIBfQdRj+THRx rsD9QbrJ+lWAL2tjXZdT/ABDnxKZV6tuOrP1voBo4NviuzNxq5LjKdmkKr6VKcHMvtes 6jDmVMTtO/W4OjxyfYSd0KAPzDAzOE/5BdGMc3G6S1hRWrmH3zPVm8tLYErhPTZ5Y4ZV xLH7yYLd1KZIs7uG3X0U5NvF9MY9vPsCDPn9dSifjDUxTXaoIwPVyAgYlA5D7yoBiy2l 98gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S6cHlkWE; 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 i14si2782589ybe.71.2021.02.10.14.16.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Feb 2021 14:16:58 -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=S6cHlkWE; 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]:57432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9xn7-0001L4-Gc for patch@linaro.org; Wed, 10 Feb 2021 17:16:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9xhk-0006Gr-NY for qemu-devel@nongnu.org; Wed, 10 Feb 2021 17:11:24 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:51425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9xhf-0003Ku-Ch for qemu-devel@nongnu.org; Wed, 10 Feb 2021 17:11:24 -0500 Received: by mail-wm1-x32f.google.com with SMTP id t142so3200570wmt.1 for ; Wed, 10 Feb 2021 14:11:18 -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=o81Mz4W9KCvutw0rCkPpru0KeoeXZKNx1XZY/IHOEHo=; b=S6cHlkWEYWDuU77TQtbJkZlDr+0/+TkKe6tT8EbUjDKj4PnwHS3g+nf8ngx2pbI0Xv NL/wvdbj6EB5KKeX8/1VdX5VWntmBQaa5qreZQVsHOYkQDUAneoSW1AX+4mDJv/WN2Wc Ac5qVloPOQc+p8+RHN3BIWZG3DDMiaVYAdkos8NSrRuLflKwFo8LDlEFWmsIwmGlHI1I w80RcZSnttxC8U4JbjTwqE30SgMwueJydjUKzWCXbD1yJHiTiqwAg7us6cewysbRQwjv yZjtPeh+P0YPzj0dM2vWliadAARiQM0dXdpDeLefXZUSmMrToUe3mE2vLaiaBdneHHVr WL/w== 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=o81Mz4W9KCvutw0rCkPpru0KeoeXZKNx1XZY/IHOEHo=; b=sbdgDJyU9RRtXM5WQPDbCF+aNEdmeqClVf7O5Ust7vmMT9SjwbcrpXkHwIQkKDeP4u 1hBLTOp74Au2kKK/a8zTI3s7jm6QtCBXqjahy6o6IDiUzaJ1Inr8AIEHTMw+XPKk9Fgf oKpyEs7yHPuvLJB9XgDZ1giSdY3VYuoTrkJ7ZkbnCZpTPdofX+xvje7Db7oPrToX7Emc QAfusdkAnNBLHbRASrMty6hP4g4SZB01+LZ2wtWQH49ixGH70WtqfV3Cwh3d3fDRRV8C rr2XIwsgAPVLclh8g09zeN1oy1pE1NnWfJ3QJ9Lr3hE7NPov6TOPtj0S1B8cJuyECs3C iucA== X-Gm-Message-State: AOAM533MbMET4YdkLJsMcEsTmxGfl5ozoXxOnpjYFynuRqFnUpfulzkB I9nzlmGdjgHpGFnEtWo/DHokbQ== X-Received: by 2002:a1c:220a:: with SMTP id i10mr1162872wmi.102.1612995078102; Wed, 10 Feb 2021 14:11:18 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o124sm5304658wmb.5.2021.02.10.14.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 14:11:13 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 60B5D1FF98; Wed, 10 Feb 2021 22:10:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/21] accel/tcg/plugin-gen: fix the call signature for inline callbacks Date: Wed, 10 Feb 2021 22:10:41 +0000 Message-Id: <20210210221053.18050-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210210221053.18050-1-alex.bennee@linaro.org> References: <20210210221053.18050-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.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: Richard Henderson , robhenry@microsoft.com, mahmoudabdalghany@outlook.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A recent change to the handling of constants in TCG changed the pattern of ops emitted for a constant add. We no longer emit a mov and the constant can be applied directly to the TCG_op_add arguments. This was causing SEGVs when running the insn plugin with arg=inline. Fix this by updating copy_add_i64 to do the right thing while also adding a comment at the top of the append section as an aide memoir if something like this happens again. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Cc: Emilio G. Cota Message-Id: <20210210172751.11669-1-alex.bennee@linaro.org> --- accel/tcg/plugin-gen.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) -- 2.20.1 diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index e5dc9d0ca9..8a1bb801e0 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -320,22 +320,6 @@ static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) return op; } -static TCGOp *copy_const_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) -{ - if (TCG_TARGET_REG_BITS == 32) { - /* 2x mov_i32 */ - op = copy_op(begin_op, op, INDEX_op_mov_i32); - op->args[1] = tcgv_i32_arg(tcg_constant_i32(v)); - op = copy_op(begin_op, op, INDEX_op_mov_i32); - op->args[1] = tcgv_i32_arg(tcg_constant_i32(v >> 32)); - } else { - /* mov_i64 */ - op = copy_op(begin_op, op, INDEX_op_mov_i64); - op->args[1] = tcgv_i64_arg(tcg_constant_i64(v)); - } - return op; -} - static TCGOp *copy_extu_tl_i64(TCGOp **begin_op, TCGOp *op) { if (TARGET_LONG_BITS == 32) { @@ -374,14 +358,17 @@ static TCGOp *copy_st_i64(TCGOp **begin_op, TCGOp *op) return op; } -static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op) +static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) { if (TCG_TARGET_REG_BITS == 32) { /* all 32-bit backends must implement add2_i32 */ g_assert(TCG_TARGET_HAS_add2_i32); op = copy_op(begin_op, op, INDEX_op_add2_i32); + op->args[4] = tcgv_i32_arg(tcg_constant_i32(v)); + op->args[5] = tcgv_i32_arg(tcg_constant_i32(v >> 32)); } else { op = copy_op(begin_op, op, INDEX_op_add_i64); + op->args[2] = tcgv_i64_arg(tcg_constant_i64(v)); } return op; } @@ -431,6 +418,12 @@ static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func, return op; } +/* + * When we append/replace ops here we are sensitive to changing patterns of + * TCGOps generated by the tcg_gen_FOO calls when we generated the + * empty callbacks. This will assert very quickly in a debug build as + * we assert the ops we are replacing are the correct ones. + */ static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *cb_idx) { @@ -462,11 +455,8 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, /* ld_i64 */ op = copy_ld_i64(&begin_op, op); - /* const_i64 */ - op = copy_const_i64(&begin_op, op, cb->inline_insn.imm); - /* add_i64 */ - op = copy_add_i64(&begin_op, op); + op = copy_add_i64(&begin_op, op, cb->inline_insn.imm); /* st_i64 */ op = copy_st_i64(&begin_op, op);