From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@patchew.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=1612978486; cv=none; d=zohomail.com; s=zohoarc; b=fJKtbSfptcxtqu3r9ihS7u/jOAu8lXSNkSFgUhfpqjP0CDcEQq39F1DCu5SCWhy83s+m8jUnddq6IK7mrGf4XkaI97nabys86KojDFVizDD9l3jxUTrMoI9xN45ih1+moVvY732JlsU4W5+8/QQSju2NXOvncCyDa0HYLV/ehJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612978486; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fTOzNZghVoYBw/AbWPKlEY9hNlgw1YSGWz++TP6+PhU=; b=eFtfJ94pwf4b7vVj7tD1MmKBfJAECZ84HIJzi7hgAfTC6BS1pl/xbdFEV5WEp2Jq/k2VrStLjTOGYBYlo1CQvYfgDBc/e20acjZlyJPeJfOvh/c8Y4RmhEjiC5J6/vfBP2aJJB/HU9SsKEznkXaz8cnhECuOsfKMCc4RtBacyqc= 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 1612978486070994.5355051109209; Wed, 10 Feb 2021 09:34:46 -0800 (PST) Received: from localhost ([::1]:53710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9tO1-0005SG-1L for importer@patchew.org; Wed, 10 Feb 2021 12:34:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9tHa-0006kC-QU for qemu-devel@nongnu.org; Wed, 10 Feb 2021 12:28:06 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:33709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9tHW-0004Uu-BW for qemu-devel@nongnu.org; Wed, 10 Feb 2021 12:28:06 -0500 Received: by mail-wm1-x333.google.com with SMTP id a16so4154933wmm.0 for ; Wed, 10 Feb 2021 09:28:01 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k11sm4169226wrl.84.2021.02.10.09.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 09:27:58 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1F8B21FF7E; Wed, 10 Feb 2021 17:27:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fTOzNZghVoYBw/AbWPKlEY9hNlgw1YSGWz++TP6+PhU=; b=LNcB+CmsEYl2fxrAr6NNHtLtKzBFaLUBOapEKj2wHFy9RA7kLT7OU5cxNH2INvWr1D oiWtibao/6SPONY8c52jG+PF8TEvL1AqC//dWTt9KpXuzrT/sI+cQ0Ro0HsFZAieJTSe LwOljArpLCuxn0nc3eW3NppCk1CR3chnflKPgZsR44i/KaEKyzUQe+Sz3cEZEXVMwTDs hXNw9WDNv6CqM4yAcFpE3cggvUEA5cKfbxeush0IOUXk7/y4d32CPQpjMH+PZ8H546CX 43vkHar86vRJwT8ELuDCzCla7Kwbcah4fpKsse7qHRCcx3pdXtkgjrBXl3Um2XV1tMKC A/Cg== 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:mime-version :content-transfer-encoding; bh=fTOzNZghVoYBw/AbWPKlEY9hNlgw1YSGWz++TP6+PhU=; b=J1zGPQELBvTaT7r6Ph3xfnmC9K6BtGG4WkP9fQIdUD8GHKTjbt5txQfWlxTQJYcGjP BIuIjxSIH7lpLxgG4YpFIW5c5EX+LGqek3A9ZaDw6OuCrs5zGdphMr2CxI6c+7UpxCS7 mPBskc9UdwydYVRZ7eh5/77TUPqm9UjkccBz1tAgTJlqlszlak2aWSSzZGdJ6okHfsh3 XWW/SKh4Ftpiq21oIGdVAI0FxCboMj9t/EC47qiJnWTD6cMaE54mgyDS7UCdJ94X/6Wp SXlnOAkLEQbU3dMhzJU75RtWcumz14u2zRD1XBfWuIwwBeNuqh8DouJ7NBZfmqDnADm9 2Xxw== X-Gm-Message-State: AOAM530IVkUJEgbnuMQ6I1h9vSmVTZfc2hzrjkZRbaLZXKkSznhJZShF EmJOQHnOoDQpZchXzmisYAVeEQ== X-Google-Smtp-Source: ABdhPJwRuLsc7n96tzvLIJ5hHBPK7kd1C1r1Cyh3t7Bb6rjjHrC3T9MBHDJ0W+W+paQU7kPH8JFB4g== X-Received: by 2002:a7b:c14b:: with SMTP id z11mr3817984wmi.97.1612978079913; Wed, 10 Feb 2021 09:27:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH] accel/tcg/plugin-gen: fix the call signature for inline callbacks Date: Wed, 10 Feb 2021 17:27:51 +0000 Message-Id: <20210210172751.11669-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Emilio G . Cota" , richard.henderson@linaro.org, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=3Dinline. 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=C3=A9e Cc: Emilio G. Cota Reviewed-by: Richard Henderson --- accel/tcg/plugin-gen.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) 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; } =20 -static TCGOp *copy_const_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) -{ - if (TCG_TARGET_REG_BITS =3D=3D 32) { - /* 2x mov_i32 */ - op =3D copy_op(begin_op, op, INDEX_op_mov_i32); - op->args[1] =3D tcgv_i32_arg(tcg_constant_i32(v)); - op =3D copy_op(begin_op, op, INDEX_op_mov_i32); - op->args[1] =3D tcgv_i32_arg(tcg_constant_i32(v >> 32)); - } else { - /* mov_i64 */ - op =3D copy_op(begin_op, op, INDEX_op_mov_i64); - op->args[1] =3D tcgv_i64_arg(tcg_constant_i64(v)); - } - return op; -} - static TCGOp *copy_extu_tl_i64(TCGOp **begin_op, TCGOp *op) { if (TARGET_LONG_BITS =3D=3D 32) { @@ -374,14 +358,17 @@ static TCGOp *copy_st_i64(TCGOp **begin_op, TCGOp *op) return op; } =20 -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 =3D=3D 32) { /* all 32-bit backends must implement add2_i32 */ g_assert(TCG_TARGET_HAS_add2_i32); op =3D copy_op(begin_op, op, INDEX_op_add2_i32); + op->args[4] =3D tcgv_i32_arg(tcg_constant_i32(v)); + op->args[5] =3D tcgv_i32_arg(tcg_constant_i32(v >> 32)); } else { op =3D copy_op(begin_op, op, INDEX_op_add_i64); + op->args[2] =3D tcgv_i64_arg(tcg_constant_i64(v)); } return op; } @@ -431,6 +418,12 @@ static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, v= oid *empty_func, return op; } =20 +/* + * 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_plugi= n_dyn_cb *cb, /* ld_i64 */ op =3D copy_ld_i64(&begin_op, op); =20 - /* const_i64 */ - op =3D copy_const_i64(&begin_op, op, cb->inline_insn.imm); - /* add_i64 */ - op =3D copy_add_i64(&begin_op, op); + op =3D copy_add_i64(&begin_op, op, cb->inline_insn.imm); =20 /* st_i64 */ op =3D copy_st_i64(&begin_op, op); --=20 2.20.1