From patchwork Sun Nov 6 02:37:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622084 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1285531pvb; Sat, 5 Nov 2022 19:39:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7lshDQBdbYUWdD5i3TK6fzErxKcgkHWoF4JaZUOUeN5uWQOSouATDqHrxiZp/TKLlb5cR0 X-Received: by 2002:ac8:7f51:0:b0:3a5:5e3d:4b56 with SMTP id g17-20020ac87f51000000b003a55e3d4b56mr10913548qtk.519.1667702344638; Sat, 05 Nov 2022 19:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667702344; cv=none; d=google.com; s=arc-20160816; b=N4psPkbti0mt76Q6BYxe1EY24R/SKU2wnws2wLcdz/z9Vbxnwp2xZY9Y2hkfXAyuIE T35vIpfhSzYdNNbqn6AnEy7xfgGp2wzcetzP4Ic6gljHXvILNoiqK/scg58RqCnIo+ky 22OIIXb0+jnPpN6+E12WWAnL9rDwxqIlIsviRC0tHtng+2vWvnIuJ2W3OOkJ1HacDSIE YhulN0huyK4aRfQGxBKNG9jfI0sU3i71HXsi7mRXkTPLISFnmH3lX/4ewVEj6WNrS88r Abj7ldIH/oJQfSWOl6HHOuxFNu/repXlewfa+MoHkaCuWG83UPFvzE15MYWEjjeo+TCK UB5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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:cc:to :from:dkim-signature; bh=8bxbWEJoBOyBo+VR3YhlP4vcU+d1LVS2IqLK4lRXDSc=; b=Maoll7EucW8xGcQ+OatJKD2cKGGDZqkLyZONIi3nzXH2HZ7f5bTzUogqeaj5w2gHNC DiIZF/NanBQF+cL/lC+4J+pauK9j0D2/1wvw8XnBPkxzBHtiHgEogLdxGHqcqJIB4ToT 546mvy/g8qZSesfVps5ZNhjknQcfSfRwIDuGQYME2pq9sX7UxYkE/uSrDS3WEEHIOFmq GzdlK7YCmONA4PQlNBqlexTd4vdXWghycDjMzz+fBfrvMVVhY8iZWd/5BIO4Z0YI9lQQ KS950AkEQEA8aTyHaDGo+X4bvLca61Hz+za3y/cDHM3G37GmLFdLeYntg676R9kOqKcs xIIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B3RoaapC; 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 bv20-20020a05622a0a1400b0039767d63424si2378659qtb.174.2022.11.05.19.39.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Nov 2022 19:39:04 -0700 (PDT) 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=B3RoaapC; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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 ‘print_insn_nanomips’: nanomips.c:21925:14: error: variable ‘insn1’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] nanomips.c:21925:25: error: variable ‘insn2’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] nanomips.c:21925:36: error: variable ‘insn3’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] nanomips.c:21926:22: error: variable ‘buf’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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] = { 0x0 }, /* P16 */ }; -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] = {one, two, three}; - TABLE_ENTRY_TYPE type; - int size = Disassemble(bits, buf, &type, MAJOR, 2, info); - return size; + int ret; + + ret = sigsetjmp(info->buf, 0); + if (ret != 0) { + return false; + } + + ret = Disassemble(bits, buf, &type, MAJOR, 2, info); + return ret >= 0; } int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) { - int status; + int status, length; bfd_byte buffer[2]; uint16_t insn1 = 0, insn2 = 0, insn3 = 0; g_autofree char *buf = NULL; @@ -21950,6 +21955,7 @@ int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) } else { insn1 = bfd_getl16(buffer); } + length = 2; (*info->fprintf_func)(info->stream, "%04x ", insn1); /* Handle 32-bit opcodes. */ @@ -21965,6 +21971,7 @@ int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) } else { insn2 = bfd_getl16(buffer); } + length = 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 disassemble_info *info) } else { insn3 = bfd_getl16(buffer); } + length = 6; (*info->fprintf_func)(info->stream, "%04x ", insn3); } else { (*info->fprintf_func)(info->stream, " "); } /* Handle runtime errors. */ - if (sigsetjmp(disassm_info.buf, 0) != 0) { - info->insn_type = dis_noninsn; - return insn3 ? 6 : insn2 ? 4 : 2; + if (nanomips_dis(&buf, &disassm_info, insn1, insn2, insn3)) { + (*info->fprintf_func) (info->stream, "%s", buf); } - int length = 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 = dis_noninsn; - - return insn3 ? 6 : insn2 ? 4 : 2; + return length; } From patchwork Sun Nov 6 02:37:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622082 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1285503pvb; Sat, 5 Nov 2022 19:39:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Rp2sdFmKK4d1GLvqMjgzKNdv3fQW4aSPLhGyadreka5AYtCLlrVhY0UIE3mmPaPkXXI7W X-Received: by 2002:a05:622a:5c99:b0:3a5:40b5:2d82 with SMTP id ge25-20020a05622a5c9900b003a540b52d82mr20564395qtb.544.1667702340194; Sat, 05 Nov 2022 19:39:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667702340; cv=none; d=google.com; s=arc-20160816; b=gjML4Nqfdbo7Nu+4Zhqy5saBOjQ3urK7scX1rcQeK2geTv5RuOyfYWqZTdKG6X1cTl BX/l8RhRWghyb8ZYGkFcvlFP7LzTtymf6eW1b+USmMQ/ZPHg5LRgPl+7TVXTqdKql1gP P9A56uS8wX6AvQxCAEQKWaHDG8CovLbUqvV6XmT9RGuGezBzF+n4DfSoyAlqxjwY4fC3 d+j41SpHefZXzoMR7qLMH8NzCYJsXsJCAdMR6Q34IsuQ30vSGNO/bZcfQCA02wsVVKZm 46v0XknADhwEDApxN14HyzZWTh9K3Ecjrde4nDPXZx7Krbu9iuLK7OaRnXWr+8q85dcy 9H2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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:cc:to :from:dkim-signature; bh=2jPzAKdkfldBdnnuFvfcLc/ZV8BFriybI/aQvY3kdAw=; b=rAVr8QNIfwuPPdZPkqLvvLs6Fn/yJ0m8I9EMyHBvuRX2eAj63i5gWSNBc463gqSgNI s0kr5+e1BXDXPIcMIXUEVtv/ZQJthVqJNDoVxwjtuMFlcrcdg7WXofaRBf5MZkTg7tps Ry1+Kgb+F3BwZvSdlDyfgXmdCNOhcsZoIFnA788mu6oH/eu+VQVFQ7i5vqlRXDGUFh4u rPBpNV/zJhmBWjjkdjBWiqbuU7pBa9kOG14CIU5OIMTmCwVmYjmbnjfGD54rfDXrkWEQ csfUQuGywnl3nHEgkvVURS03YCEkQIxtg+N4ll7kUUvlbtROFcpdUW8gTYVWIC0hxP5O /TmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iXImIvMw; 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 s9-20020a05622a1a8900b003a4eb27e5f7si2626898qtc.529.2022.11.05.19.39.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Nov 2022 19:39:00 -0700 (PDT) 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=iXImIvMw; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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é --- 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] = { 0x0 }, /* P16 */ }; -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] = {one, two, three}; TABLE_ENTRY_TYPE type; int ret; @@ -21919,7 +21915,7 @@ static bool nanomips_dis(char **buf, Dis_info *info, return false; } - ret = Disassemble(bits, buf, &type, MAJOR, 2, info); + ret = Disassemble(words, buf, &type, MAJOR, 2, info); return ret >= 0; } @@ -21927,7 +21923,7 @@ int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) { int status, length; bfd_byte buffer[2]; - uint16_t insn1 = 0, insn2 = 0, insn3 = 0; + uint16_t words[3] = { }; g_autofree char *buf = NULL; info->bytes_per_chunk = 2; @@ -21951,15 +21947,14 @@ int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) } if (info->endian == BFD_ENDIAN_BIG) { - insn1 = bfd_getb16(buffer); + words[0] = bfd_getb16(buffer); } else { - insn1 = bfd_getl16(buffer); + words[0] = bfd_getl16(buffer); } length = 2; - (*info->fprintf_func)(info->stream, "%04x ", insn1); /* Handle 32-bit opcodes. */ - if ((insn1 & 0x1000) == 0) { + if ((words[0] & 0x1000) == 0) { status = (*info->read_memory_func)(memaddr + 2, buffer, 2, info); if (status != 0) { (*info->memory_error_func)(status, memaddr + 2, info); @@ -21967,17 +21962,15 @@ int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) } if (info->endian == BFD_ENDIAN_BIG) { - insn2 = bfd_getb16(buffer); + words[1] = bfd_getb16(buffer); } else { - insn2 = bfd_getl16(buffer); + words[1] = bfd_getl16(buffer); } length = 4; - (*info->fprintf_func)(info->stream, "%04x ", insn2); - } else { - (*info->fprintf_func)(info->stream, " "); } + /* Handle 48-bit opcodes. */ - if ((insn1 >> 10) == 0x18) { + if ((words[0] >> 10) == 0x18) { status = (*info->read_memory_func)(memaddr + 4, buffer, 2, info); if (status != 0) { (*info->memory_error_func)(status, memaddr + 4, info); @@ -21985,18 +21978,23 @@ int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) } if (info->endian == BFD_ENDIAN_BIG) { - insn3 = bfd_getb16(buffer); + words[2] = bfd_getb16(buffer); } else { - insn3 = bfd_getl16(buffer); + words[2] = bfd_getl16(buffer); } length = 6; - (*info->fprintf_func)(info->stream, "%04x ", insn3); - } else { - (*info->fprintf_func)(info->stream, " "); + } + + for (int i = 0; i < 6; i += 2) { + if (i < length) { + (*info->fprintf_func)(info->stream, "%04x ", words[i / 2]); + } else { + (*info->fprintf_func)(info->stream, " "); + } } /* 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); } From patchwork Sun Nov 6 02:37:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622081 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1285495pvb; Sat, 5 Nov 2022 19:38:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KN6ay6zbu/Y+1BQZSY3pI8VYdeYPhpoPK/ZqcIoMdjTAFByzX13HPBnBuGFlne3k9zXC1 X-Received: by 2002:ae9:ef15:0:b0:6fa:bb6:3485 with SMTP id d21-20020ae9ef15000000b006fa0bb63485mr31110391qkg.322.1667702338923; Sat, 05 Nov 2022 19:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667702338; cv=none; d=google.com; s=arc-20160816; b=Zg4HYDaSSFPSugCTA0tlGKDfAcoMCylMrZwWrToi5xoDAxqo/yBIRjDFF5VOq9Rrl/ hNvgXfmBjUUavgjvn3Mfj4++IFDc2uQzxuMG7MiPXHW3F336eUKvovsbsobL0vIPq6ra FU82IRCE3q6WGWi0xHRS+Cl2XNArAB6AEmrpdJCAP29am1PwupqSfloxtMGFCZzkCpK5 B/CZOd6mnL8nAt6+I4GtBQ0zfmrSOaehz3gthb++DsQHPiMbqoFqSMi/0c5L57OqO5sp SmC/JhEuIakLHtFwXn6d7RD1xy69nKsVCtrpbMBW6h3CTxVu7IdPl04GvbDGkPsf4VU/ Hl3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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:cc:to :from:dkim-signature; bh=fVCbfw0csIXiWDQ0FsOhbz/g5Esc2yTlzzD2ayr9qL0=; b=MFGmiZr7/GNnHOH32rsrdku1ZmHJZSFIXy8/exVQwWFMCq3FPvLXQkgsLnVtX+YblB ZizI81eo8SEJA04eQ0ep3mMs4voQE1IS7UpyhkE3MP28ssEnUbr2PemS5iZiyIRpcNK7 v1EL1L32zOV/nIvVfYmq8sC7HtP4T90poPQESELfU0QlcmXgW5fRrqa4IWP3z8CN/0CA FH/6d9Zbm9Y7iGFXuNlYMcVS2DapkfgoqYSwh6rssj554JrgrfYz+KjzRuDYo50Pb3r5 f1J24pVmJwRjmjYo958e3LhEsWvmT68v9eLcx2LReT22ydXw3aR6TNODrn0WzYEo9JAZ At4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oyixP5Dp; 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 i22-20020a05620a405600b006f10ac5e376si2452943qko.199.2022.11.05.19.38.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Nov 2022 19:38:58 -0700 (PDT) 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=oyixP5Dp; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Split out a helper function for reading a uint16_t with the correct endianness. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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 *info, uint16_t words[3]) return ret >= 0; } +static bool read_u16(uint16_t *ret, bfd_vma memaddr, + struct disassemble_info *info) +{ + int status = (*info->read_memory_func)(memaddr, (bfd_byte *)ret, 2, info); + if (status != 0) { + (*info->memory_error_func)(status, memaddr, info); + return false; + } + + if ((info->endian == BFD_ENDIAN_BIG) != 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] = { }; g_autofree char *buf = NULL; @@ -21940,48 +21954,24 @@ int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info) disassm_info.fprintf_func = info->fprintf_func; disassm_info.stream = info->stream; - status = (*info->read_memory_func)(memaddr, buffer, 2, info); - if (status != 0) { - (*info->memory_error_func)(status, memaddr, info); + if (!read_u16(&words[0], memaddr, info)) { return -1; } - - if (info->endian == BFD_ENDIAN_BIG) { - words[0] = bfd_getb16(buffer); - } else { - words[0] = bfd_getl16(buffer); - } length = 2; /* Handle 32-bit opcodes. */ if ((words[0] & 0x1000) == 0) { - status = (*info->read_memory_func)(memaddr + 2, buffer, 2, info); - if (status != 0) { - (*info->memory_error_func)(status, memaddr + 2, info); + if (!read_u16(&words[1], memaddr + 2, info)) { return -1; } - - if (info->endian == BFD_ENDIAN_BIG) { - words[1] = bfd_getb16(buffer); - } else { - words[1] = bfd_getl16(buffer); - } length = 4; } /* Handle 48-bit opcodes. */ if ((words[0] >> 10) == 0x18) { - status = (*info->read_memory_func)(memaddr + 4, buffer, 2, info); - if (status != 0) { - (*info->memory_error_func)(status, memaddr + 4, info); + if (!read_u16(&words[1], memaddr + 4, info)) { return -1; } - - if (info->endian == BFD_ENDIAN_BIG) { - words[2] = bfd_getb16(buffer); - } else { - words[2] = bfd_getl16(buffer); - } length = 6; } From patchwork Sun Nov 6 02:37:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622086 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1285566pvb; Sat, 5 Nov 2022 19:39:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xYqoJArYhuLCmma3QZs1PHPoby8u9CsQOt7O8LSsgKMu/27Y8OV53FFEEbXVBlY3lfZyQ X-Received: by 2002:a05:6214:ac7:b0:4bb:6236:e190 with SMTP id g7-20020a0562140ac700b004bb6236e190mr38785534qvi.87.1667702350081; Sat, 05 Nov 2022 19:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667702350; cv=none; d=google.com; s=arc-20160816; b=YblXQzu+MJd21K9TRGxh+WI7Pm66TvdreDJg4aw11VNkHpwANph5fjhJLPDUchGhfD 9iNSfvQ8SfjnJxs1+0RyTODs7G8yszgBYOdGMD0X4q9j804u5v5+QB3j3PUxDv6Wv2mT d/bDj8e4Kr0TWT8X1QBxa4Gy362YATNyc62oaDZmxCg/yzYYk7Uxa0GcWml6sgQ5CWIc IOlgB42FpS/+6XeAj80qSbUUYULhKIq6C/Z48wkYgX/YndtwlssVVIrH1QEeYWy59JJr SE6hPR/S+PQMhrDqfBW8hfE68ZGnhPmtryL99nT8iIpVdH6TvGW8MthB1ivoXsNGvHwG Nllg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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:cc:to :from:dkim-signature; bh=dpGJViuDySHrQ5ECzH4yPy8F2cBMov2h53f2wnD62c0=; b=JlwPG+sjBBnNFbZ03Y4nqfVMpdzFTPU9sy2fNCljx2hTkJPHOeGhvQKsmOeM9YAU0M 8iCAPeFMhbSisEedx7nuzWUlnRT8pqnCYCSBCgjG9/srnSwCQ4VhpDQmm7CrRmc96GFq Cx16S3IFrnuaDqon1qaXepQY738jT0TpFj4yXGqjj7ssTYpWTnIg2Cmecn5cDD7QcLlB w34SejlHFj4BEbXANRqWwuuZl6tSKJdlfceQxkNY4w26Cnq/zH8YuqhPKcZEkbWUt1rt JKJ+hU0P9CO+KhLfl+fz2etx5quCoF3XKriNr5uG/dGKd7lwtyySOrOwabQZJ2/jfKQT DKXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ns0FRD63; 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 t1-20020a05620a450100b006ee2868be71si2428855qkp.310.2022.11.05.19.39.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Nov 2022 19:39:10 -0700 (PDT) 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=Ns0FRD63; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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é --- 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 disassemble_info *info) return -1; } length = 4; - } - /* Handle 48-bit opcodes. */ - if ((words[0] >> 10) == 0x18) { - if (!read_u16(&words[1], memaddr + 4, info)) { - return -1; + /* Handle 48-bit opcodes. */ + if ((words[0] >> 10) == 0x18) { + if (!read_u16(&words[1], memaddr + 4, info)) { + return -1; + } + length = 6; } - length = 6; } for (int i = 0; i < 6; i += 2) { From patchwork Sun Nov 6 02:37:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622087 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1285642pvb; Sat, 5 Nov 2022 19:39:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wag9jL6j2mFLvAaTV8yPofOYvmPM4RwOnFehZw2kQhz2J4OKD/yvwZWRKGjDiq5l+U1gD X-Received: by 2002:a05:620a:2698:b0:6f5:7127:76a4 with SMTP id c24-20020a05620a269800b006f5712776a4mr29502425qkp.216.1667702366016; Sat, 05 Nov 2022 19:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667702366; cv=none; d=google.com; s=arc-20160816; b=peFwNwdXzQzVl/PfK6wvYvjZIzXzP3fDqSzDLFvhzlc6OBMMJA+DPKU2U0V2rnOp22 fwMSr3Yvg5A0efSn7Om6p/bxpkH8k0sQ89e6WugL4+WzvaG/VRmfS4/b9MEWVuRm9P5P ErnU9xJraNQby+Q5XdNUorHJjycMSHbhWhxAqEN1O2lhdUZYi+tNNRbzIOUhDwv7GZn8 kcu40+KhGL7i72g5ny+ao1WMhFRXk1jWcTZmDXgy9gn7rLLotPD7pjW7Wez9jPSlHhQE HXumNFsdnUqdqA0V9dYEdhK5Gr4iowuM6gz4aG7fo18OVrxbmvNRmGwmegn6Sdyjda6x Etzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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:cc:to :from:dkim-signature; bh=nFcVkwwKAdXNW2Qi73KZvrPPSPwknY42Yj0GP3GIix0=; b=CfpyHjSwua0hHgOch0oVDaPy4kp7NUvKS2Gcf22QIxjsBMsJ+Ab5fN3oQxoiy5J2NN 7AA/CnngPWwjm/hNLqowLAyWyGf8BWWbPa9bDeY/irzMlBhes1On5JbWrXHv1u/6HYkg +9MPQWibKuDq9ZL+3sx0rQUjVBpKtJQpZcjk5tqPudUQ0ZUgxsjc618aF0DRNBzpUxtw QA5uiORwT4slMhDCfBmqPr/zVy6IL8VvjwJXjIgzgey4d3REOLaewN4NBdeh4o65opZd 6w6Y3IhDIaTr/gwUyt1h/gVTrEYTCfGo1jadQJ2SXlHitTvcw5p6ag5jklOh+r2lYZtn H7+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e+58qIxg; 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 ay18-20020a05622a229200b003a55ff978eesi2224967qtb.16.2022.11.05.19.39.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Nov 2022 19:39:26 -0700 (PDT) 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=e+58qIxg; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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); /* generate machine code */ - tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; - tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; - tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset; - if (TCG_TARGET_HAS_direct_jump) { - tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg; - tcg_ctx->tb_jmp_target_addr = NULL; - } else { - tcg_ctx->tb_jmp_insn_offset = NULL; - tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg; - } #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 + /* Initialize goto_tb jump offsets. */ + tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; + tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; + tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset; + if (TCG_TARGET_HAS_direct_jump) { + tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg; + tcg_ctx->tb_jmp_target_addr = NULL; + } else { + tcg_ctx->tb_jmp_insn_offset = NULL; + tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg; + } + tcg_reg_alloc_start(s); /* From patchwork Sun Nov 6 02:37:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622085 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1285534pvb; Sat, 5 Nov 2022 19:39:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fZVu+9sVineAV+GuR7r2QcTpcNaGACaqyz3PqsFIVdqvtVTzXerjSAASl5OkEwLC/lU0Y X-Received: by 2002:a05:6214:c88:b0:4bb:5b29:e96a with SMTP id r8-20020a0562140c8800b004bb5b29e96amr38831401qvr.6.1667702344845; Sat, 05 Nov 2022 19:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667702344; cv=none; d=google.com; s=arc-20160816; b=Evu4r45l8CiqQpjQKuzUkFOzQUvYMAL88Zxd/En0z9BsGWfWAts9T8UQGXGwKaYvBN majI/13KM7srJr/5Tq/jzJxTDGK0mb/VAd1TUoQbGN9n3Bvzi3X4Dxr6e9jKMiANSy12 sh6zkvU+WnGQp2NMDZsfpu9G5kYDcVyV6hCNE7is5L+fqCP9nKLPdSZpiQ6d/OIM6hyh uRxlWld6HL+Y/XscgDQ7KDExoCnjruQNZn1Mg9e0oBRKne+Kwf+s6nz/q/ymXH1BdXhl EGA8tyZcuk6qa1+4qa9pbvNOEdt+gqBxLeJyuP8gsIM2woC7EvnNmciUeP4tIDFzfOne pgfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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:cc:to :from:dkim-signature; bh=j7WXfOWK53ahgYMgHy1i+j/q7xrqgYKDWQCtOds9hEc=; b=L0aBltWCOYYy509zPVbx9b1a7I+AzX2DPx2tTiWaMwd1O5TmI6s9KGzzGI9MtLM939 9RVUNJtTYGxczYTgpMMeGcAhtZSO4GvAYs8UJNSWAnzIk1Rp0EgjLj0Vm627jW33dHrv IgGfKD6ixGIRKC7Jags7Wlw/OJE1jtFGkbtFzDXJ9hY8fFIIabUEeLrK29uVTiCWiHdE Az3Vvq8OoOa2jqLOuIbyPiTqAYhQtYlSt32Akl8rDvyDx90IjxpYSSEAJ1y+UnplXB/Y 98TSBJKcrYZOi+NKHSFv6OVcOu25uigCRlO6X/WTQNcCCykj9uO8+Oc/qp78ejKrHp9l DWiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wsaGAT4T; 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 fv13-20020a056214240d00b004bbff08b6casi2226683qvb.102.2022.11.05.19.39.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Nov 2022 19:39:04 -0700 (PDT) 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=wsaGAT4T; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Isolate the code protected by setjmp. Fixes: translate-all.c: In function ‘tb_gen_code’: translate-all.c:748:51: error: argument ‘cflags’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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 *set) #endif /* !CONFIG_USER_ONLY */ +/* + * 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 = sigsetjmp(tcg_ctx->jmp_trans, 0); + if (unlikely(ret != 0)) { + return ret; + } + + tcg_func_start(tcg_ctx); + + tcg_ctx->cpu = env_cpu(env); + gen_intermediate_code(env_cpu(env), tb, *max_insns, pc, host_pc); + assert(tb->size != 0); + tcg_ctx->cpu = NULL; + *max_insns = 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 = 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 = &tcg_ctx->prof; - int64_t ti; #endif + int64_t ti; void *host_pc; assert_memory_lock(); @@ -805,33 +836,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu, ti = profile_getclock(); #endif - gen_code_size = sigsetjmp(tcg_ctx->jmp_trans, 0); - if (unlikely(gen_code_size != 0)) { - goto error_return; - } - - tcg_func_start(tcg_ctx); - - tcg_ctx->cpu = env_cpu(env); - gen_intermediate_code(cpu, tb, max_insns, pc, host_pc); - assert(tb->size != 0); - tcg_ctx->cpu = NULL; - max_insns = tb->icount; - trace_translate_block(tb, pc, tb->tc.ptr); - /* 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 = profile_getclock(); -#endif - - gen_code_size = tcg_gen_code(tcg_ctx, tb, pc); + gen_code_size = setjmp_gen_code(env, tb, pc, host_pc, &max_insns, &ti); if (unlikely(gen_code_size < 0)) { - error_return: switch (gen_code_size) { case -1: /*