From nobody Tue May 7 21:40:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1667702342; cv=none; d=zohomail.com; s=zohoarc; b=UGJTQmwHgMbXSrGgG43gcJ7i6zIgUXGY3Mq1Ei2sUsevi77lkxp3xsQhngq/NQpEhskn3KEkszHZYFD+l05UhKlvsjNYUmKasaDM1ukOfNuyRd3vFxMLLEqUxNFn/7QJCZtnF6E+/DBEgiLY4znqGhdbQUsrL44RLEFIY4intA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667702342; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8bxbWEJoBOyBo+VR3YhlP4vcU+d1LVS2IqLK4lRXDSc=; b=DWYA6qx7xuOenDAfckkdiVJ5r06LpxdMpDnm4H5i9AmglwX/TRlW4cYi5SZh+TShxsLSbXzJ+8jxwFG+24hCxIajgNC4mTzMqLs59gaD0Fs/6Hzpx58eWzGbw5WS9H7dCpAwx6DAnWhviqj9hSFr+YHJpAON+F/K9gdCYIuvZjc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667702342041885.9691544931345; Sat, 5 Nov 2022 19:39:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orVXh-00007c-RL; Sat, 05 Nov 2022 22:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orVXf-00007H-Fr for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:47 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orVXd-0003Je-Q3 for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:47 -0400 Received: by mail-pf1-x42b.google.com with SMTP id k22so7751849pfd.3 for ; Sat, 05 Nov 2022 19:37:45 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:d918:7a00:e617:679e:af7:63d]) by smtp.gmail.com with ESMTPSA id m21-20020a170902d19500b0018862bb3976sm2259457plb.308.2022.11.05.19.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 19:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8bxbWEJoBOyBo+VR3YhlP4vcU+d1LVS2IqLK4lRXDSc=; b=B3RoaapCzBJW3nhw+wBbjruevOuVxFJpxmJEEiQgS+lsJOqlis1IHpm3AlZWV/mHtd NsiI9P9n52U/SE4SZz5M0oKgtSi9eZXiX25gzB4IeFR74HU0xJX9vfFzUX4p7AktGLIm pghyhoSLL3798lLt4n1gupVA8YYStapxoUn/ZE1s+tgWUbYIW9KxjjptHAr6mO1eJIhu VHbVHaTryTOK77nP3X6H2P+GI1MO3QjzCeyfbwnFj36ZCtgL1aFkeclvPZOzUbnM4iuh x82bMqn6QMWHU3PVdL2MiM687Odiw8yjTbTDCgXy2r7ObuprBQm7kNyB9fnfeJbEFJhz Husg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8bxbWEJoBOyBo+VR3YhlP4vcU+d1LVS2IqLK4lRXDSc=; b=k4YorXMr9I8aLJtTIwcU0ecg+PB8wRegu4n4mVCWZRFc0IQDuBtjnYbimDRPC0922O yU47LYNGbe1XKaoiaXx/2dfL7JqCB8fVSvIsiht8N/BL3gzz90fr0St39amqebWiezCV vUPd8bs/KnVfw5paEd2f688d2qg90+iqG7nBsKPfIVnHtcjL3QsKcANh4Vq8NfA9gnnk IeMCCgbPX2v42Uc0hcJJ71sNcFe9A8c4wWRq6f7vvElXpogw74FxlSTflQMDVJTVRFSI ly4us72ATxzJB1CYj6jgptkTRBq/9X4lw3up5mXZYqNFimkq2T9+GUwX5/zSACCI/DUu Z1UA== X-Gm-Message-State: ACrzQf3toNnxItgQyZgq48ZhG4vClsnLy1zSTmZGb9k88lLTFCijV26P yvTzFdC8ABrh//sD0Qwed6kz9sgjnTzZVPDF X-Google-Smtp-Source: AMsMyM6qT7UOMXfTMbjpuVX73vf17kpEB7Kbu0940jSqz9NUH/5NJOFJblLhegjDnghpuKZsElzi/Q== X-Received: by 2002:a05:6a02:199:b0:469:d0e6:dab8 with SMTP id bj25-20020a056a02019900b00469d0e6dab8mr37757606pgb.97.1667702264479; Sat, 05 Nov 2022 19:37:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, sw@weilnetz.de Subject: [RESEND PATCH 1/6] disas/nanomips: Move setjmp into nanomips_dis Date: Sun, 6 Nov 2022 13:37:30 +1100 Message-Id: <20221106023735.5277-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221106023735.5277-1-richard.henderson@linaro.org> References: <20221106023735.5277-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1667702343962100013 Reduce the number of local variables within the scope of the setjmp by moving it to the existing helper. The actual length returned from Disassemble is not used, because we have already determined the length while reading bytes. Fixes: nanomips.c: In function =E2=80=98print_insn_nanomips=E2=80=99: nanomips.c:21925:14: error: variable =E2=80=98insn1=E2=80=99 might be clobb= ered by =E2=80=98longjmp=E2=80=99 or =E2=80=98vfork=E2=80=99 [-Werror=3Dclo= bbered] nanomips.c:21925:25: error: variable =E2=80=98insn2=E2=80=99 might be clobb= ered by =E2=80=98longjmp=E2=80=99 or =E2=80=98vfork=E2=80=99 [-Werror=3Dclo= bbered] nanomips.c:21925:36: error: variable =E2=80=98insn3=E2=80=99 might be clobb= ered by =E2=80=98longjmp=E2=80=99 or =E2=80=98vfork=E2=80=99 [-Werror=3Dclo= bbered] nanomips.c:21926:22: error: variable =E2=80=98buf=E2=80=99 might be clobber= ed by =E2=80=98longjmp=E2=80=99 or =E2=80=98vfork=E2=80=99 [-Werror=3Dclobb= ered] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- disas/nanomips.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/disas/nanomips.c b/disas/nanomips.c index 9647f1a8e3..9a69e6880a 100644 --- a/disas/nanomips.c +++ b/disas/nanomips.c @@ -21905,22 +21905,27 @@ static const Pool MAJOR[2] =3D { 0x0 }, /* P16 */ }; =20 -static int nanomips_dis(char **buf, - Dis_info *info, - unsigned short one, - unsigned short two, - unsigned short three) +static bool nanomips_dis(char **buf, Dis_info *info, + unsigned short one, + unsigned short two, + unsigned short three) { uint16 bits[3] =3D {one, two, three}; - TABLE_ENTRY_TYPE type; - int size =3D Disassemble(bits, buf, &type, MAJOR, 2, info); - return size; + int ret; + + ret =3D sigsetjmp(info->buf, 0); + if (ret !=3D 0) { + return false; + } + + ret =3D Disassemble(bits, buf, &type, MAJOR, 2, info); + return ret >=3D 0; } =20 int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) { - int status; + int status, length; bfd_byte buffer[2]; uint16_t insn1 =3D 0, insn2 =3D 0, insn3 =3D 0; g_autofree char *buf =3D NULL; @@ -21950,6 +21955,7 @@ int print_insn_nanomips(bfd_vma memaddr, struct dis= assemble_info *info) } else { insn1 =3D bfd_getl16(buffer); } + length =3D 2; (*info->fprintf_func)(info->stream, "%04x ", insn1); =20 /* Handle 32-bit opcodes. */ @@ -21965,6 +21971,7 @@ int print_insn_nanomips(bfd_vma memaddr, struct dis= assemble_info *info) } else { insn2 =3D bfd_getl16(buffer); } + length =3D 4; (*info->fprintf_func)(info->stream, "%04x ", insn2); } else { (*info->fprintf_func)(info->stream, " "); @@ -21982,27 +21989,16 @@ int print_insn_nanomips(bfd_vma memaddr, struct d= isassemble_info *info) } else { insn3 =3D bfd_getl16(buffer); } + length =3D 6; (*info->fprintf_func)(info->stream, "%04x ", insn3); } else { (*info->fprintf_func)(info->stream, " "); } =20 /* Handle runtime errors. */ - if (sigsetjmp(disassm_info.buf, 0) !=3D 0) { - info->insn_type =3D dis_noninsn; - return insn3 ? 6 : insn2 ? 4 : 2; + if (nanomips_dis(&buf, &disassm_info, insn1, insn2, insn3)) { + (*info->fprintf_func) (info->stream, "%s", buf); } =20 - int length =3D nanomips_dis(&buf, &disassm_info, insn1, insn2, insn3); - - /* FIXME: Should probably use a hash table on the major opcode here. = */ - - (*info->fprintf_func) (info->stream, "%s", buf); - if (length > 0) { - return length / 8; - } - - info->insn_type =3D dis_noninsn; - - return insn3 ? 6 : insn2 ? 4 : 2; + return length; } --=20 2.34.1 From nobody Tue May 7 21:40:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1667702337; cv=none; d=zohomail.com; s=zohoarc; b=VLXJI1ksdodUV72g7DbXnqhd433M001237bU0bduEEucfLX1nX+qRki9FrVFmpJdN9eJDiFzzDKAuSb0IYGMxMvAaUy+kt+n9ai0xCHTDx0jwJOdbSCzd53YcFXNiQl0JZ7Fu5gR0ZerkCSDxMdt0mTtkY2K6tUP76Ty/toRpXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667702337; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2jPzAKdkfldBdnnuFvfcLc/ZV8BFriybI/aQvY3kdAw=; b=QX6Vx/q9Eq2NrdP0I6GCGRqsg+JKL2JB8Iz+86IpgZqp3IrLnDOTgJxgT0ZrXfbJxoaHc9SY6qPji8RPFLFy6KmYVs05lsjeGk/YQw/1lIlboT4KAWapMH3xYoEj981nLf1bjflVW6a7IcliLl1sN0bzEenSbtNNem52BK1ivEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667702337806146.8276175024971; Sat, 5 Nov 2022 19:38:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orVXk-000088-By; Sat, 05 Nov 2022 22:37:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orVXi-00007y-UV for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:50 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orVXh-0003Jv-Al for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:50 -0400 Received: by mail-pg1-x530.google.com with SMTP id 78so7583626pgb.13 for ; Sat, 05 Nov 2022 19:37:48 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:d918:7a00:e617:679e:af7:63d]) by smtp.gmail.com with ESMTPSA id m21-20020a170902d19500b0018862bb3976sm2259457plb.308.2022.11.05.19.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 19:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2jPzAKdkfldBdnnuFvfcLc/ZV8BFriybI/aQvY3kdAw=; b=iXImIvMwFkFd/zbpk+4x1ANl3PVa9PS3hqkO8OWD2PNmp2gxBgnwh7PPngfhy82OOM vM6cTGXtTYHppneuqGl7amCdY3dRl08+J0sKljSUUmLXRL3Bq7R4q5Gf2SPddMbRh5PV rwsGuH6sGOPUpWHeuoxelmNAag4qNN+FkotZsrHDLeCtJ40sgMzxVpqoxW+NAQHx8Qos JYj13vMvYF+8VOSHMNPkWd8j8Hx5gcBHVb8vJrMgo1eRdnJGr83TWMlihJBm7TA8rex6 jK5sEJElrdRbUJ535GyD9PtZVseeZHSB5MfoevvXAv9qmjjG4l1uoVMieF2D1Z14iRjT JJgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2jPzAKdkfldBdnnuFvfcLc/ZV8BFriybI/aQvY3kdAw=; b=DaRn7FF+mmGqQjeUw9AtwoARMov86KXlqlail1OY76U/yxUp3bHFrQVpySgffR53AD Zum6QHpsgzFrW8XAM2aPeLaOMTurG/mUEDGNOu9U3RgA0bsQJNjPQzlBEkmdxMPTS351 oogQ7kVmOx6TbSSlMXoPTkF0hvyyG5IFjIGb7CWFqMHXoLL56xnZq0BhRnh73dnWg1iK R+/1Xxi2PzKosYlICtM3mP6k+kF1eAIu31N+0/p9EguJSrOTdufD2FFKwGL+FAZhyyEM or74L69rx3c5ST+XdH6BSsCrjCgyytiBUr/FXCxkkBXc7hRy8w0H9i71+2PvogpX2NRU xaBg== X-Gm-Message-State: ACrzQf2rLHBbUz+d8oANIEZuds7F/5KPU0ZhXXGxqjktn4o2WXCOdaCN FmPWpKuMDva7sYytCPkvQ8gElGbx9dquN0vt X-Google-Smtp-Source: AMsMyM6pOLq3Ye5RfrTG8dmV1PIuPLYmWC+V8eMCF7lRWnR9TlR6vkhQU22tkbjNeD3p/brXENaZyQ== X-Received: by 2002:aa7:818f:0:b0:562:dc99:8a84 with SMTP id g15-20020aa7818f000000b00562dc998a84mr43320902pfi.30.1667702267861; Sat, 05 Nov 2022 19:37:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, sw@weilnetz.de Subject: [RESEND PATCH 2/6] disas/nanomips: Merge insn{1,2,3} into words[3] Date: Sun, 6 Nov 2022 13:37:31 +1100 Message-Id: <20221106023735.5277-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221106023735.5277-1-richard.henderson@linaro.org> References: <20221106023735.5277-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1667702339961100003 Content-Type: text/plain; charset="utf-8" Since Disassemble wants the data in this format, collect it that way. This allows using a loop to print the bytes. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- disas/nanomips.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/disas/nanomips.c b/disas/nanomips.c index 9a69e6880a..5438def9af 100644 --- a/disas/nanomips.c +++ b/disas/nanomips.c @@ -21905,12 +21905,8 @@ static const Pool MAJOR[2] =3D { 0x0 }, /* P16 */ }; =20 -static bool nanomips_dis(char **buf, Dis_info *info, - unsigned short one, - unsigned short two, - unsigned short three) +static bool nanomips_dis(char **buf, Dis_info *info, uint16_t words[3]) { - uint16 bits[3] =3D {one, two, three}; TABLE_ENTRY_TYPE type; int ret; =20 @@ -21919,7 +21915,7 @@ static bool nanomips_dis(char **buf, Dis_info *info, return false; } =20 - ret =3D Disassemble(bits, buf, &type, MAJOR, 2, info); + ret =3D Disassemble(words, buf, &type, MAJOR, 2, info); return ret >=3D 0; } =20 @@ -21927,7 +21923,7 @@ int print_insn_nanomips(bfd_vma memaddr, struct dis= assemble_info *info) { int status, length; bfd_byte buffer[2]; - uint16_t insn1 =3D 0, insn2 =3D 0, insn3 =3D 0; + uint16_t words[3] =3D { }; g_autofree char *buf =3D NULL; =20 info->bytes_per_chunk =3D 2; @@ -21951,15 +21947,14 @@ int print_insn_nanomips(bfd_vma memaddr, struct d= isassemble_info *info) } =20 if (info->endian =3D=3D BFD_ENDIAN_BIG) { - insn1 =3D bfd_getb16(buffer); + words[0] =3D bfd_getb16(buffer); } else { - insn1 =3D bfd_getl16(buffer); + words[0] =3D bfd_getl16(buffer); } length =3D 2; - (*info->fprintf_func)(info->stream, "%04x ", insn1); =20 /* Handle 32-bit opcodes. */ - if ((insn1 & 0x1000) =3D=3D 0) { + if ((words[0] & 0x1000) =3D=3D 0) { status =3D (*info->read_memory_func)(memaddr + 2, buffer, 2, info); if (status !=3D 0) { (*info->memory_error_func)(status, memaddr + 2, info); @@ -21967,17 +21962,15 @@ int print_insn_nanomips(bfd_vma memaddr, struct d= isassemble_info *info) } =20 if (info->endian =3D=3D BFD_ENDIAN_BIG) { - insn2 =3D bfd_getb16(buffer); + words[1] =3D bfd_getb16(buffer); } else { - insn2 =3D bfd_getl16(buffer); + words[1] =3D bfd_getl16(buffer); } length =3D 4; - (*info->fprintf_func)(info->stream, "%04x ", insn2); - } else { - (*info->fprintf_func)(info->stream, " "); } + /* Handle 48-bit opcodes. */ - if ((insn1 >> 10) =3D=3D 0x18) { + if ((words[0] >> 10) =3D=3D 0x18) { status =3D (*info->read_memory_func)(memaddr + 4, buffer, 2, info); if (status !=3D 0) { (*info->memory_error_func)(status, memaddr + 4, info); @@ -21985,18 +21978,23 @@ int print_insn_nanomips(bfd_vma memaddr, struct d= isassemble_info *info) } =20 if (info->endian =3D=3D BFD_ENDIAN_BIG) { - insn3 =3D bfd_getb16(buffer); + words[2] =3D bfd_getb16(buffer); } else { - insn3 =3D bfd_getl16(buffer); + words[2] =3D bfd_getl16(buffer); } length =3D 6; - (*info->fprintf_func)(info->stream, "%04x ", insn3); - } else { - (*info->fprintf_func)(info->stream, " "); + } + + for (int i =3D 0; i < 6; i +=3D 2) { + if (i < length) { + (*info->fprintf_func)(info->stream, "%04x ", words[i / 2]); + } else { + (*info->fprintf_func)(info->stream, " "); + } } =20 /* Handle runtime errors. */ - if (nanomips_dis(&buf, &disassm_info, insn1, insn2, insn3)) { + if (nanomips_dis(&buf, &disassm_info, words)) { (*info->fprintf_func) (info->stream, "%s", buf); } =20 --=20 2.34.1 From nobody Tue May 7 21:40:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1667702333; cv=none; d=zohomail.com; s=zohoarc; b=i80+eg82kNlEG7U1bV9dPsgPf5i3POQUq62K4eKvOToJVCLmuT7gEW8v3FJqQyan2g7T3oD1rKvdvMugkRighv+RBA6Y5o8DqHIPUd/I/IFjUh7CuB6ft+n8Bk4bkzdYMqEQp5Qvn0bIOLDkGjDhos2mKtjD7EboHUYRg6VCRKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667702333; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fVCbfw0csIXiWDQ0FsOhbz/g5Esc2yTlzzD2ayr9qL0=; b=V3Qz5f4v11mkJFwJd9kD9ntPt22nHn4RAjJS0yIkSzaGuzSF3stubJjSTnFP4osCEGWn3N4D0u5zLQy9ecj92mIGxdR4LpXxzz8hlKN29DpJXNroE0kpFGVQXdExynM8eN2CLg6pothdzp2yPSLRwcs4ICyteMvYywQbpch8NhU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667702333412279.67296760688225; Sat, 5 Nov 2022 19:38:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orVXn-00008r-TZ; Sat, 05 Nov 2022 22:37:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orVXm-00008Z-Ao for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:54 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orVXk-0003K7-Kx for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:54 -0400 Received: by mail-pf1-x434.google.com with SMTP id b29so7721286pfp.13 for ; Sat, 05 Nov 2022 19:37:52 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:d918:7a00:e617:679e:af7:63d]) by smtp.gmail.com with ESMTPSA id m21-20020a170902d19500b0018862bb3976sm2259457plb.308.2022.11.05.19.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 19:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fVCbfw0csIXiWDQ0FsOhbz/g5Esc2yTlzzD2ayr9qL0=; b=oyixP5DpzWiRo0ifM8QOISfUEqHQ/94x0fj6H2oaPLom420TGK+ytB8CDvbR0kcJ0J NkFMXJxDJiOkkMi/10vEvTCdvAqD3PnwI5VqF66fyTXyZ540c1YbqpbnoabvP/kvLqQD c758ZGBdJozt4y5wUqj0E7V+oct6QiyjcjrYnURkiV1pPkEqk7on7iTAHSYXbgWDFm/I xYySCH8siycmZljljuhxqRdWezqxA0ajlZjU3wUU2sBtN1DX01oDab2TDITQJ8RqtD81 /yiV8ZjhIlbqN+fVkxL+huO6D1So3do9zN+66reu77dPI0tHMhRhNehxk5JDDouICR68 lFsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fVCbfw0csIXiWDQ0FsOhbz/g5Esc2yTlzzD2ayr9qL0=; b=Nx0nmxyz08TKG5b76yr5eLy4J+s8lg1ACTCxNUJe0bI4VrU1Mma3uoDL3gSSAGlVZf ZVw6HEvM7JGVt8ZGOKCAN1Rrne09k2KOWgjbezBm612AIws+C5rYho8KNYNJ9X5i/df0 Kk9PLu32oxnTy4VW5x/UfYTAit7959tk2hIcNX5INtXg/CmzcGQXPLeMQycfxJ/Lorjf BawefaLvZ4qR5M/RzNgBv3Nl3vMmVbenkRuO7X0i9M8pQyH85KR1GrnvxVZ9/Kceyxsm CZMABwClkSJY1oTv2n0NSOBlGyu2/yVAWkQsCBI+JedPB6NPmnjnuzmumbxKTJvoSPbj /XKg== X-Gm-Message-State: ACrzQf2ouPEK7nPyiFAVYByG4Rt6yUcK4j4QC1jwdlDoQ7D8H94icB3l ihrjzQ+w6AQB6rEkih4ScXFjzx8++xYZdJaJ X-Google-Smtp-Source: AMsMyM7w8WO40xRK1Uk8jtRCYbmcjwvxkfWzIHPYTH6rs+QTgtsYv8JupXGWQgU/sMMwZhqaxz8lIg== X-Received: by 2002:a05:6a00:cc6:b0:56d:3028:23ea with SMTP id b6-20020a056a000cc600b0056d302823eamr39449193pfv.19.1667702271075; Sat, 05 Nov 2022 19:37:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, sw@weilnetz.de Subject: [RESEND PATCH 3/6] disas/nanomips: Split out read_u16 Date: Sun, 6 Nov 2022 13:37:32 +1100 Message-Id: <20221106023735.5277-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221106023735.5277-1-richard.henderson@linaro.org> References: <20221106023735.5277-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1667702334772100001 Content-Type: text/plain; charset="utf-8" Split out a helper function for reading a uint16_t with the correct endianness. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- disas/nanomips.c | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/disas/nanomips.c b/disas/nanomips.c index 5438def9af..52c7537379 100644 --- a/disas/nanomips.c +++ b/disas/nanomips.c @@ -21919,10 +21919,24 @@ static bool nanomips_dis(char **buf, Dis_info *in= fo, uint16_t words[3]) return ret >=3D 0; } =20 +static bool read_u16(uint16_t *ret, bfd_vma memaddr, + struct disassemble_info *info) +{ + int status =3D (*info->read_memory_func)(memaddr, (bfd_byte *)ret, 2, = info); + if (status !=3D 0) { + (*info->memory_error_func)(status, memaddr, info); + return false; + } + + if ((info->endian =3D=3D BFD_ENDIAN_BIG) !=3D HOST_BIG_ENDIAN) { + bswap16s(ret); + } + return true; +} + int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) { - int status, length; - bfd_byte buffer[2]; + int length; uint16_t words[3] =3D { }; g_autofree char *buf =3D NULL; =20 @@ -21940,48 +21954,24 @@ int print_insn_nanomips(bfd_vma memaddr, struct d= isassemble_info *info) disassm_info.fprintf_func =3D info->fprintf_func; disassm_info.stream =3D info->stream; =20 - status =3D (*info->read_memory_func)(memaddr, buffer, 2, info); - if (status !=3D 0) { - (*info->memory_error_func)(status, memaddr, info); + if (!read_u16(&words[0], memaddr, info)) { return -1; } - - if (info->endian =3D=3D BFD_ENDIAN_BIG) { - words[0] =3D bfd_getb16(buffer); - } else { - words[0] =3D bfd_getl16(buffer); - } length =3D 2; =20 /* Handle 32-bit opcodes. */ if ((words[0] & 0x1000) =3D=3D 0) { - status =3D (*info->read_memory_func)(memaddr + 2, buffer, 2, info); - if (status !=3D 0) { - (*info->memory_error_func)(status, memaddr + 2, info); + if (!read_u16(&words[1], memaddr + 2, info)) { return -1; } - - if (info->endian =3D=3D BFD_ENDIAN_BIG) { - words[1] =3D bfd_getb16(buffer); - } else { - words[1] =3D bfd_getl16(buffer); - } length =3D 4; } =20 /* Handle 48-bit opcodes. */ if ((words[0] >> 10) =3D=3D 0x18) { - status =3D (*info->read_memory_func)(memaddr + 4, buffer, 2, info); - if (status !=3D 0) { - (*info->memory_error_func)(status, memaddr + 4, info); + if (!read_u16(&words[1], memaddr + 4, info)) { return -1; } - - if (info->endian =3D=3D BFD_ENDIAN_BIG) { - words[2] =3D bfd_getb16(buffer); - } else { - words[2] =3D bfd_getl16(buffer); - } length =3D 6; } =20 --=20 2.34.1 From nobody Tue May 7 21:40:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1667702347; cv=none; d=zohomail.com; s=zohoarc; b=RuZUV8OCRTEUmlhFO4/2Hrw554SV4neNN1TVJrwYDAtfYlLJ96yC3k702ruDu5qs6NJXz6/ArEE1REx/McBF6uI28NM+53GGQ8F/7Ex7ciaVaJmXmZOaf1RQGFIerxY59qM98Etb1AxSAXLrSonDQBOUSuS4v7qD0tewCqxHr/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667702347; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dpGJViuDySHrQ5ECzH4yPy8F2cBMov2h53f2wnD62c0=; b=HhOkCEv9r7mIN5KVUne0I2EVMFu4RyowFmJBLEyrt5joBhP3rO4gBGSwXpUKLqO402mZIXPLhx0kUdNg0vL7DBBp16RPobIlih2wqqXXMpaVdB8KdKaAnFbvF2u9fNLk3467hHUlLaj0KkThezRs7CSTgYteGCXs6GKGM1SRuXs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667702347667922.4372386168845; Sat, 5 Nov 2022 19:39:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orVXq-0000Cn-HW; Sat, 05 Nov 2022 22:37:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orVXp-0000C3-Ko for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:57 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orVXn-0003KK-Oz for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:37:57 -0400 Received: by mail-pg1-x52b.google.com with SMTP id v3so7607080pgh.4 for ; Sat, 05 Nov 2022 19:37:55 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:d918:7a00:e617:679e:af7:63d]) by smtp.gmail.com with ESMTPSA id m21-20020a170902d19500b0018862bb3976sm2259457plb.308.2022.11.05.19.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 19:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dpGJViuDySHrQ5ECzH4yPy8F2cBMov2h53f2wnD62c0=; b=Ns0FRD63XW7TAiOShxbT0OysYMLH/q5OvN6eTnx0E1orLttPG0N+fxniLMegbAAskk ENarESS9uQ+HEyCrq2ISmOCQxae7Ex+YDI86KYKnPWLAS7e9EgvN7tLbwrbBaWNvAY9w j96Oa+3o+oR+/xOpaeu+logNwYvCEkPDK2WVdj1xE0WqFLSa7+ckPX3bsTdHwNxlsRDH bn+symyoqx3FOCYSuX+W+u/8lcxmmR7D9uE1crjPKX/H4nBIdgmpE9HyNmekW+EA5Pza +kxpE0TqyB2hPkDdw6sbBfeARw16XVuiT5sYJjtIBXNuPXrS2kilYJjg953TMtREwA3q jGYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dpGJViuDySHrQ5ECzH4yPy8F2cBMov2h53f2wnD62c0=; b=rZHDzOWDvg0MiUDba9h2R+36BbW3SmzG6lyChOln1q+KuSzIFmePlBnD5RU+3ZW/uA n8k15w/oCGSEvLBSfMFfCDubQNMjpdoicV/STd92UEPKUMGYERcs2wvY7YxtfZTT1x+o 3kviZ8s5HLfIPPR+9D6AFlfJzESW/N1yWR/bbs40sffdGmlMUQ2gY/9PpKWAjgrsxcKP EhzEbJ7RY7x8W6KPzfTYSirkAkHJ/fYDRMaouyl+9KInL1P5SuU3drrBhyPIljEOqZP1 6YVh96fg1KdwyBvPpEmCGfk+DBdOV0mX+Nv7q+IrjCeUtsmgSw9RB03Qj/P6LsTu+Mod MqPA== X-Gm-Message-State: ACrzQf19TF3bAF5/ZhsGbXRCjpgB9wakS57gQrqINX1mNhsFE5TvY3S0 xWSCkZnnOaeKw+qnO4frBLFfPaHAzXwt/4yj X-Google-Smtp-Source: AMsMyM6M/nSnBdEzAfxYfBXRHX98/9dYIJ93UNep7GW6WBUrcFLxGRtbqZrj6C43a1t/Dfkowr5wMg== X-Received: by 2002:a05:6a02:202:b0:42b:d711:f27c with SMTP id bh2-20020a056a02020200b0042bd711f27cmr36596350pgb.246.1667702274122; Sat, 05 Nov 2022 19:37:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, sw@weilnetz.de Subject: [RESEND PATCH 4/6] disas/nanomips: Tidy read for 48-bit opcodes Date: Sun, 6 Nov 2022 13:37:33 +1100 Message-Id: <20221106023735.5277-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221106023735.5277-1-richard.henderson@linaro.org> References: <20221106023735.5277-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1667702348027100001 Content-Type: text/plain; charset="utf-8" There is no point in looking for a 48-bit opcode if we've not read the second word for a 32-bit opcode. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- disas/nanomips.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/disas/nanomips.c b/disas/nanomips.c index 52c7537379..092ea0ca0c 100644 --- a/disas/nanomips.c +++ b/disas/nanomips.c @@ -21965,14 +21965,14 @@ int print_insn_nanomips(bfd_vma memaddr, struct d= isassemble_info *info) return -1; } length =3D 4; - } =20 - /* Handle 48-bit opcodes. */ - if ((words[0] >> 10) =3D=3D 0x18) { - if (!read_u16(&words[1], memaddr + 4, info)) { - return -1; + /* Handle 48-bit opcodes. */ + if ((words[0] >> 10) =3D=3D 0x18) { + if (!read_u16(&words[1], memaddr + 4, info)) { + return -1; + } + length =3D 6; } - length =3D 6; } =20 for (int i =3D 0; i < 6; i +=3D 2) { --=20 2.34.1 From nobody Tue May 7 21:40:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1667702360; cv=none; d=zohomail.com; s=zohoarc; b=ZrP/rSRzBWWbvk27ffS82L9T5eTJ9FnYmVzjrRCNrmESiacYkmwx/FAFtI3E+LeF8b+Bnza+d8ib2rVAy07tXoKyZCyvKt1Hw4atqUieSNOjdKsJlEPJEm9qtbtLgCkp+OW2vOJCZic4c78f0robLbvVSV3f5daHRA2saVt3lkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667702360; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nFcVkwwKAdXNW2Qi73KZvrPPSPwknY42Yj0GP3GIix0=; b=Uxmg8spSjoPzvtU243fjxW5XLRi/xtL6FuvFbDtRYLgpo8Ex78EQzUkIkhdJe0uw1JPlQQy+DkOWMU6iuRblDO9U/0hHfoU65TwQqYizmxE5OQUo0ITSCegVhxEmo7Dk2/S4A2U7P34Lxq+N63UqIfFcbwjJelGUHNgkffItHtk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667702360332532.6820608451768; Sat, 5 Nov 2022 19:39:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orVXv-0000Qy-3V; Sat, 05 Nov 2022 22:38:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orVXs-0000Iz-8S for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:38:00 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orVXq-0003KV-Pm for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:38:00 -0400 Received: by mail-pj1-x1034.google.com with SMTP id f5-20020a17090a4a8500b002131bb59d61so10131189pjh.1 for ; Sat, 05 Nov 2022 19:37:58 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:d918:7a00:e617:679e:af7:63d]) by smtp.gmail.com with ESMTPSA id m21-20020a170902d19500b0018862bb3976sm2259457plb.308.2022.11.05.19.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 19:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nFcVkwwKAdXNW2Qi73KZvrPPSPwknY42Yj0GP3GIix0=; b=e+58qIxgbt7v3Ue2YIY+lIGTDQBnuupUXpPzvHKIQGFCkQAfDagkw8XBKR8U2O6mon qvIHiSQQhgVZ+pc7rK0oBb4CSSIPVzJgmo3w/1H0vxG6xY/AnU1UhEc1m8F4Jywtnj7n JwO6dvGOC6Sd0EgqHaadA0CmyG3DT3Vflu37lV51MO9lqoqzEd/s5r1GoWMPSJTj8BOG kAP09GQdJi4bY6xF3CfgHxRp1awNi93X6knpzFkuOqLgktG8sZtgfXpWY8BBIPZ9LpcA 5XLrp/YHfI/SqdBq/LgueezupjYu0Z4cCYTW7gTBEe6kyXBPxYowgPe6NVkVskQz8uwS TyBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nFcVkwwKAdXNW2Qi73KZvrPPSPwknY42Yj0GP3GIix0=; b=XNqaAQR8SQvvsnFunoJiP5LbqmibCIwoXZGoU664+FzN+w1R6oKZ/agw3F83Jl+tnX d4WQYPabyGjw68sOOTKcTDYl/w3vJKpSty91sCG9EHzefmlN4rCHs7JEr2XdbeeenfgT /rdCHorc8jfvQ49C4TCQrGtqSnRzw7VnnlalQOtMI+PT/13Oxf08RkO+GKGEpNZ7yok+ z5j0W70hKRLKvpTRKBMxV3WimYwU5H1cvgOg9iTZHN1PYQsPXC7MhTM/n/VP7HhMKptx g2IQ7V2Y9oXw+kfCeXURoOUxjlZUw4B/ctE/kr6ufCgv189jtGahzKy5lrvSqM9q85oc bODg== X-Gm-Message-State: ACrzQf3nxmg1Lb6j2dmY8rMtvGRVeJWfEulRwOTQTgrxfKE4QwH6hLWx wYtF8B5buFFX/bU0p4PvWXt79OzyibaU/Ewy X-Google-Smtp-Source: AMsMyM44rcRHAzCtU1bNlbWz+GMw5EeIvYqBOR1RoJo4ivKwBF5sEBSxifeYFODcjLsmV8uDeM6wMQ== X-Received: by 2002:a17:90a:18a:b0:213:1127:897e with SMTP id 10-20020a17090a018a00b002131127897emr570469pjc.246.1667702277334; Sat, 05 Nov 2022 19:37:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, sw@weilnetz.de Subject: [RESEND PATCH 5/6] tcg: Move TCG_TARGET_HAS_direct_jump init to tb_gen_code Date: Sun, 6 Nov 2022 13:37:34 +1100 Message-Id: <20221106023735.5277-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221106023735.5277-1-richard.henderson@linaro.org> References: <20221106023735.5277-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1667702362138100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/tcg/translate-all.c | 10 ---------- tcg/tcg.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 921944a5ab..9ee21f7f52 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -821,16 +821,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, trace_translate_block(tb, pc, tb->tc.ptr); =20 /* generate machine code */ - tb->jmp_reset_offset[0] =3D TB_JMP_RESET_OFFSET_INVALID; - tb->jmp_reset_offset[1] =3D TB_JMP_RESET_OFFSET_INVALID; - tcg_ctx->tb_jmp_reset_offset =3D tb->jmp_reset_offset; - if (TCG_TARGET_HAS_direct_jump) { - tcg_ctx->tb_jmp_insn_offset =3D tb->jmp_target_arg; - tcg_ctx->tb_jmp_target_addr =3D NULL; - } else { - tcg_ctx->tb_jmp_insn_offset =3D NULL; - tcg_ctx->tb_jmp_target_addr =3D tb->jmp_target_arg; - } =20 #ifdef CONFIG_PROFILER qatomic_set(&prof->tb_count, prof->tb_count + 1); diff --git a/tcg/tcg.c b/tcg/tcg.c index b43b6a7981..436fcf6ebd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4228,6 +4228,18 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb= , target_ulong pc_start) } #endif =20 + /* Initialize goto_tb jump offsets. */ + tb->jmp_reset_offset[0] =3D TB_JMP_RESET_OFFSET_INVALID; + tb->jmp_reset_offset[1] =3D TB_JMP_RESET_OFFSET_INVALID; + tcg_ctx->tb_jmp_reset_offset =3D tb->jmp_reset_offset; + if (TCG_TARGET_HAS_direct_jump) { + tcg_ctx->tb_jmp_insn_offset =3D tb->jmp_target_arg; + tcg_ctx->tb_jmp_target_addr =3D NULL; + } else { + tcg_ctx->tb_jmp_insn_offset =3D NULL; + tcg_ctx->tb_jmp_target_addr =3D tb->jmp_target_arg; + } + tcg_reg_alloc_start(s); =20 /* --=20 2.34.1 From nobody Tue May 7 21:40:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1667702342; cv=none; d=zohomail.com; s=zohoarc; b=C6wSHQZFXjSL5HJAIRlVT9RQ37BTb8DCEucH0yJkwZP4jXo8ri6r9RYb5MknGNl2DzWLwXikcTVIp7eh54Jo6pRDvi4KTMUi+j6oGI7Jjjwwy3gBNvKHSoUPFrAPJBMG72MipafbktypZxkzeZhU1gVSQtLG6KAKF603sYUlS9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667702342; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j7WXfOWK53ahgYMgHy1i+j/q7xrqgYKDWQCtOds9hEc=; b=K1Fa1I1d6n+z+M4cjAbNv/5PseM/r1Jm1HgHFl9VUaXEn3pF061msOzZjOFlrzT62oxyj8emsKZch8A5qyDZ44SpBPC1ksySREk9INmos4Hh4PzXSzTER/uky21jGYiW9HfiIkT0nx7t9n9W+iDrh+V2UweBBO70SirPbc5PMj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667702342134349.51024065225374; Sat, 5 Nov 2022 19:39:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orVXz-0000VU-2b; Sat, 05 Nov 2022 22:38:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orVXw-0000TA-Ow for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:38:04 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orVXu-0003Kf-M8 for qemu-devel@nongnu.org; Sat, 05 Nov 2022 22:38:04 -0400 Received: by mail-pl1-x636.google.com with SMTP id l2so8198188pld.13 for ; Sat, 05 Nov 2022 19:38:01 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:d918:7a00:e617:679e:af7:63d]) by smtp.gmail.com with ESMTPSA id m21-20020a170902d19500b0018862bb3976sm2259457plb.308.2022.11.05.19.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 19:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j7WXfOWK53ahgYMgHy1i+j/q7xrqgYKDWQCtOds9hEc=; b=wsaGAT4T6SmnR4faXM1n3hLPx9BoU3RInTpVobHXXwy/Ad07Sp4VlNrQkkiyDt+SXn F2nyw3vZT8mKcN9F0n2gw2b/nU+qHbm8ULVZ5sm56RwCTDHk8d25vvmvjd174WrM+xA3 9p1vEqK0vPJIaMo4xCvVf232F3bZ4AXSOAVLekb3eiUaDdzRzzR88/rivpM29pT+t8yM dpAPYQRzgSPdVfI7ue35uqc3PgZlG7SFSSdVSzVouEBlUctlu86kgjiSyuFhniCy5KC6 r5B+h3Ljz8dOjTFRaGhQN7AIbotcTcwkVYvuWIn1watPLDu+GYq+H7lq0GQ951rYxhjM 0zKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j7WXfOWK53ahgYMgHy1i+j/q7xrqgYKDWQCtOds9hEc=; b=bl209WG9BhLJusiZNLk1GkaWp2sgP4O2tg+I8QeqjpNnub9h/Ctqv1R1UCWzDXD/xk zWWiqU+LjMMDCPS87tNoHyZIh8FgC3Gc2ojCr+7c2+Oj78f3Wr8dIKSNZAqo9Z0aw+6v gMXmZT0GBEwRftUiMDKm5us5S6VGSXCm0RoBDqBV9OjyvAVO4cGzXPJeJHvVjznGGTID 40iasiSrOXEaeYetu1ksbY4JnV7V1Zyp6m7d2snFwRunev2Mi6JWEjH1KbardDuaWJwF xRDlP3MVyYvFtbJaFfS5GnamlqGGF3e4GG6Sn4+bAg/hns+Ji4RhiqsFfB5vHQC7/Ex3 Q6rQ== X-Gm-Message-State: ACrzQf39mZYOymzL/xKuPfBn8Za+IKZNSnTRYF7yg/QWjT+3fpFLpKI2 obNgphs2ss6S0jMn5pl8lRF+T32KcHpQgA2N X-Google-Smtp-Source: AMsMyM7/r/g5enyVcDZY5d/AEOeGgy8GT7pQ56CHZpUM+F5fAyy1tBuBfMOa9SDauO5OlK618Cg3PQ== X-Received: by 2002:a17:902:e846:b0:187:2127:cbb with SMTP id t6-20020a170902e84600b0018721270cbbmr35070168plg.125.1667702280878; Sat, 05 Nov 2022 19:38:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, sw@weilnetz.de Subject: [RESEND PATCH 6/6] accel/tcg: Split out setjmp_gen_code Date: Sun, 6 Nov 2022 13:37:35 +1100 Message-Id: <20221106023735.5277-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221106023735.5277-1-richard.henderson@linaro.org> References: <20221106023735.5277-1-richard.henderson@linaro.org> 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=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1667702344004100014 Isolate the code protected by setjmp. Fixes: translate-all.c: In function =E2=80=98tb_gen_code=E2=80=99: translate-all.c:748:51: error: argument =E2=80=98cflags=E2=80=99 might be c= lobbered by =E2=80=98longjmp=E2=80=99 or =E2=80=98vfork=E2=80=99 [-Werror= =3Dclobbered] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/tcg/translate-all.c | 58 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9ee21f7f52..ac3ee3740c 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -742,6 +742,37 @@ void page_collection_unlock(struct page_collection *se= t) =20 #endif /* !CONFIG_USER_ONLY */ =20 +/* + * Isolate the portion of code gen which can setjmp/longjmp. + * Return the size of the generated code, or negative on error. + */ +static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb, + target_ulong pc, void *host_pc, + int *max_insns, int64_t *ti) +{ + int ret =3D sigsetjmp(tcg_ctx->jmp_trans, 0); + if (unlikely(ret !=3D 0)) { + return ret; + } + + tcg_func_start(tcg_ctx); + + tcg_ctx->cpu =3D env_cpu(env); + gen_intermediate_code(env_cpu(env), tb, *max_insns, pc, host_pc); + assert(tb->size !=3D 0); + tcg_ctx->cpu =3D NULL; + *max_insns =3D tb->icount; + +#ifdef CONFIG_PROFILER + qatomic_set(&tcg_ctx->prof.tb_count, tcg_ctx->prof.tb_count + 1); + qatomic_set(&tcg_ctx->prof.interm_time, + tcg_ctx->prof.interm_time + profile_getclock() - *ti); + *ti =3D profile_getclock(); +#endif + + return tcg_gen_code(tcg_ctx, tb, pc); +} + /* Called with mmap_lock held for user mode emulation. */ TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, target_ulong cs_base, @@ -754,8 +785,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, int gen_code_size, search_size, max_insns; #ifdef CONFIG_PROFILER TCGProfile *prof =3D &tcg_ctx->prof; - int64_t ti; #endif + int64_t ti; void *host_pc; =20 assert_memory_lock(); @@ -805,33 +836,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu, ti =3D profile_getclock(); #endif =20 - gen_code_size =3D sigsetjmp(tcg_ctx->jmp_trans, 0); - if (unlikely(gen_code_size !=3D 0)) { - goto error_return; - } - - tcg_func_start(tcg_ctx); - - tcg_ctx->cpu =3D env_cpu(env); - gen_intermediate_code(cpu, tb, max_insns, pc, host_pc); - assert(tb->size !=3D 0); - tcg_ctx->cpu =3D NULL; - max_insns =3D tb->icount; - trace_translate_block(tb, pc, tb->tc.ptr); =20 - /* generate machine code */ - -#ifdef CONFIG_PROFILER - qatomic_set(&prof->tb_count, prof->tb_count + 1); - qatomic_set(&prof->interm_time, - prof->interm_time + profile_getclock() - ti); - ti =3D profile_getclock(); -#endif - - gen_code_size =3D tcg_gen_code(tcg_ctx, tb, pc); + gen_code_size =3D setjmp_gen_code(env, tb, pc, host_pc, &max_insns, &t= i); if (unlikely(gen_code_size < 0)) { - error_return: switch (gen_code_size) { case -1: /* --=20 2.34.1