From nobody Sat May 18 04:46:15 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=buhman.org ARC-Seal: i=1; a=rsa-sha256; t=1712063818; cv=none; d=zohomail.com; s=zohoarc; b=V8vlZkr9NqIBIEYxmRDWkSTvGXB+fgzm8ER2iZt1N9seLoUO/pMlZJmDwQe/wqnDaRXABVib7JsNzf5H0ruGpS/ZeqOPisPfYKMzCiTGN1a6K+n3UzNBR06wn8rv28Dz+J5sv3uM6xZQyLC9pSTt7J21XpSRlDhgtW8bMrjqxAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1712063818; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YsKv+bFAZ2EQPJnFPmYAy+P5/ddlPIJeOzyys1yYUfc=; b=L+edT2/tJvfWxTnVBOEW7HNhIIB6Mih6TaF73TPz2flxDntQSWy/cZaqKqZ9HBGux+cTO/yZ678PnpEk+LZ0+kKDzYsFLo7ZbmntswNEA0UR+MxtmGGa0HrzoZZ2R+gYXDqZXkScez3wU/O4nQjjJtwZlUO1jPj6fZXSQ3AOEzE= 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 1712063817745431.7891866929972; Tue, 2 Apr 2024 06:16:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrdz8-0004tE-BO; Tue, 02 Apr 2024 09:15:31 -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 1rraaR-0002JA-11 for qemu-devel@nongnu.org; Tue, 02 Apr 2024 05:37:47 -0400 Received: from fhigh3-smtp.messagingengine.com ([103.168.172.154]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rraaK-0001gM-KP for qemu-devel@nongnu.org; Tue, 02 Apr 2024 05:37:46 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 151CD11400AC; Tue, 2 Apr 2024 05:37:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 02 Apr 2024 05:37:34 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 Apr 2024 05:37:32 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=buhman.org; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm2; t=1712050654; x=1712137054; bh=YsKv+bFAZ2EQPJnFPmYAy +P5/ddlPIJeOzyys1yYUfc=; b=o+uqr12YSnPHY7QUP3el05SCBZ/qMYyPvRgVx bMK7iAk0jlbX1R7KFDcsKpmpK+KyhpTyYNa60gNhrxGt/jHVSIEKyp/8JbMHorKc l1AK1j03s5bC1/pRGqb36W39P1rBSoBOlk+FhLWxhG4PYqoujGPyCgUCMbsp+sbA pv4IUNKo/cF+0XznOKtncUpsjn11nm5GLG4avH3r9UioR5F4t3j1Uuw3x96iF8Rn XIKvbvhi5CtKUKLZVDq36LBpwIL+KV+XLk+B+qsVHNGF3eSUyLpbt605nb5Fa2/w LCz88a343oUgKbWfc30vTGwcsh9JrcDgqKkqpWG6UwIQ9oQbQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712050654; x=1712137054; bh=YsKv+bFAZ2EQPJnFPmYAy+P5/ddl PIJeOzyys1yYUfc=; b=U2y2tu5SP5aKX4Yry59QFnm6ToKbS/5z+hQKtIKSRpjo +bvFBPZlgW6S0WY4ClYlTSFaOXCSm1oxgbdTG0nmbrLx0YTOtyLkKcaCJbys1xka HowzzRWYE5dBO3290e+fjTbfxWjtHPKCuddZ7MLFMs67tYHmEb3YNwv2sykCFJSE aW9jUt7waIC4gq94cm2bw2/3JQeX2LdTD3oQ6o/JdqS/zhjdnw5tq7B6G1DrIgwl nKzaudZDEQf48EvvLfSQNgHHZX6NJtwHQ6bZzajTUrlyfqV/OBDqpc38ZGxQ1Y1l MI+lHlGpp6gDHOcDDbfcOjYI6U+H5zZYmxCGMP7qqw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefvddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffoggfgsedtkeertd ertddtnecuhfhrohhmpegkrggtkhcuuehuhhhmrghnuceoiigrtghksegsuhhhmhgrnhdr ohhrgheqnecuggftrfgrthhtvghrnhepudetueelleefudffjeellefgffeihfeuheeutd efieefueeghfeltddvheduieeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepiigrtghksegsuhhhmhgrnhdrohhrgh X-ME-Proxy: Feedback-ID: i1541475f:Fastmail From: Zack Buhman To: qemu-devel@nongnu.org Cc: Zack Buhman Subject: [PATCH] sh4: mac.w: memory accesses are 16-bit words Date: Tue, 2 Apr 2024 17:37:49 +0800 Message-ID: <20240402093756.27466-1-zack@buhman.org> X-Mailer: git-send-email 2.41.0 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=103.168.172.154; envelope-from=zack@buhman.org; helo=fhigh3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 02 Apr 2024 09:15:23 -0400 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @buhman.org) X-ZM-MESSAGEID: 1712063819254100001 Content-Type: text/plain; charset="utf-8" Before this change, executing a code sequence such as: mova tblm,r0 mov r0,r1 mova tbln,r0 clrs clrmac mac.w @r0+,@r1+ mac.w @r0+,@r1+ .align 4 tblm: .word 0x1234 .word 0x5678 tbln: .word 0x9abc .word 0xdefg Does not result in correct behavior: Expected behavior: first macw : macl =3D 0x1234 * 0x9abc + 0x0 mach =3D 0x0 second macw: macl =3D 0x5678 * 0xdefg + 0xb00a630 mach =3D 0x0 Observed behavior (qemu-sh4eb, prior to this commit): first macw : macl =3D 0x5678 * 0xdefg + 0x0 mach =3D 0x0 second macw: (unaligned longword memory access, SIGBUS) Various SH-4 ISA manuals also confirm that `mac.w` is a 16-bit word memory access, not a 32-bit longword memory access. Signed-off-by: Zack Buhman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Yoshinori Sato --- target/sh4/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index a9b1bc7524..6643c14dde 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -816,10 +816,10 @@ static void _decode_opc(DisasContext * ctx) TCGv arg0, arg1; arg0 =3D tcg_temp_new(); tcg_gen_qemu_ld_i32(arg0, REG(B7_4), ctx->memidx, - MO_TESL | MO_ALIGN); + MO_TESW | MO_ALIGN); arg1 =3D tcg_temp_new(); tcg_gen_qemu_ld_i32(arg1, REG(B11_8), ctx->memidx, - MO_TESL | MO_ALIGN); + MO_TESW | MO_ALIGN); gen_helper_macw(tcg_env, arg0, arg1); tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 2); tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 2); --=20 2.41.0