From patchwork Tue Apr 9 19:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787238 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383642wrs; Tue, 9 Apr 2024 12:37:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFPrQr/aF7FZBCxxBytLehn6LvSxEolMAf/bu6WgMfScqlPcpS9gJ7YX839zqrS/9a042xAdBhnJD9CNxpBoGq X-Google-Smtp-Source: AGHT+IE9ZVx5PBImEYLpjH4BREQ9K7RcXeu3vSYtqiwFtzM7O4v0kFb1MO3LIfEpbkFs0zWeNIoy X-Received: by 2002:a05:620a:198c:b0:78d:67b1:ca90 with SMTP id bm12-20020a05620a198c00b0078d67b1ca90mr919381qkb.62.1712691470143; Tue, 09 Apr 2024 12:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691470; cv=none; d=google.com; s=arc-20160816; b=bLfKrzkQ3EzDH+KLg01K1QlMSXOdxT6na2I86xBDBXWpg7iCvncKytZGwnjfdBUGlL 9ZcSNLQuBxkCz90zScZU9kfnM7jgoQmRZq/IBp9uc36TuMDZIxPRRy3H6r3r3MAQqsL8 E6/pMFATzsXbEpJqB/HQJGkcn9GaqUIHPKj0Dm2f6b/PGDe01qRh4bUTMHa1JOEKE/R0 2CpArCn1jsOww3sCX9K+DhcnLjv+55V1E/1mm7HSCJVdcFaHXSNs4qTzQLL9whaqD2+S M+3JH31cpDyklWpFPBFeHTx4olFNgI/kJ9H8KvFPfChWHc64owi5c93dZSdOaS7EjzPL 2KOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=RcrZGxEnfZgrLqlhciK4hABUGUNHIg16hIoNjeHOda0=; fh=UxcOinUvtH9RCUG8YjsmzGmJmYoXEUythTaZQ7RVwi0=; b=ZNv52PM09qp/ftM6AtCxvywYCQtaWA/hFn0q54zeTwSfzhZyRbkCRvl4Qf2bsmQQuI 9WbEft9ZZxJsRDs836BHxwvCyAZUhpuE4iroi4z/awmN7hexj4O6/k2Lo7MtS0EB1YYq w8X6ro28RhmQJ2mFqvth97tf/H60i3iLszstHxf7HSrb3EH6QrRb+veZoDQ82aroxKbZ /lt8gFl7k/dzGI0FVcdNIJRprD4PAk+8NCzDot6hXoEXaEvmJPk5Vdaywdk69elIT05e qY8HN/dE1RM7fGIFSafob3Uum+fkUQCBRzx7kwNSFeQli7ULf1ZuVfsUVIPL59X4Y0sH YTOg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O0XjgK0B; 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 v25-20020ae9e319000000b0078d5b690bcesi7562090qkf.681.2024.04.09.12.37.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:37:50 -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=O0XjgK0B; 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 1ruHGT-0000Yj-6a; Tue, 09 Apr 2024 15:36:17 -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 1ruHGR-0000Ya-V2 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:15 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGQ-0004dV-97 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:15 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e3ca546d40so32787645ad.3 for ; Tue, 09 Apr 2024 12:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691373; x=1713296173; darn=nongnu.org; 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=RcrZGxEnfZgrLqlhciK4hABUGUNHIg16hIoNjeHOda0=; b=O0XjgK0BOwClsrHSD5SVhItjS0tXD5REhSWHRaLcsuoHHSTR5ZKYWhk4sn4yr0uvy5 GpAhRKyJB52zRXjE11IY0FpYSD1MEYSU5xNypA1OW9HC7UqZhieTLx0e3Ckdm4E09pW7 I7nsWq8yJQBGHIO0CBqTIxbWwGFYXqI1RnwKhz9YIKMknIi6Z4S0lkDvvV8AcEIRkil9 KpQKIl6ZjZ++GORxWMbMk1PJpzPYo77idXjyJhOJi5BfYhrLOC2hxuVx2kWBRIlY+f7q WHNb5IowYYcPoSqZKRp/Ix3aNTXGFdgUAKzBHQ27oBHqr3Yq0q2rvopDRIJoIjRKVT9q e4HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691373; x=1713296173; 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=RcrZGxEnfZgrLqlhciK4hABUGUNHIg16hIoNjeHOda0=; b=BPGnub6gilv+W0pYLEsWTlyr8lkxehhroRgBhF0KLt8WU+r7CY5h5dvCHe7xbfQV// 8R6xKTO6Hx/WGf4P6RdpdXJeEgDP0mbkPJj4TSlY3Ym9L/HTZZf3FIRFCvHlU+/tIHeQ i3UKE2RoqCI58zQ/hZNwTzij7SsgrWN1W+Yon0Cz0F8aOi3rAKpxc16ib8bErhpp/7dB 10uiL2LrjvaJjdDHb8t3IrqXjVzK1lqu2O4sqRt4E7r59q2S/DzaCd+CGPUj8LTpBcw0 91fkdbHiIiZ1M7Ar+lOfRPrx00eYH9vMwU9wlbyuQ9pHiI6NYJOz8jMnGFGiHtg1MXsl yCxw== X-Gm-Message-State: AOJu0YzymKBEoT0HlmlkEdb22TTl2bVGmIKX+G0Qa2PMZOfhMFz2dIpY Z/3aVwGupvUTYlX4gz0rUmZ78yWBrxwaKQnamL0Xkm5bry/lApayRe+CXhgulvDlAZeELIMxmba A X-Received: by 2002:a17:902:e541:b0:1e2:a5b3:e4 with SMTP id n1-20020a170902e54100b001e2a5b300e4mr996525plf.0.1712691372878; Tue, 09 Apr 2024 12:36:12 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Zack Buhman , Yoshinori Sato , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL v2 05/20] target/sh4: mac.w: memory accesses are 16-bit words Date: Tue, 9 Apr 2024 09:35:48 -1000 Message-Id: <20240409193603.1703216-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Zack Buhman 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 = 0x1234 * 0x9abc + 0x0 mach = 0x0 second macw: macl = 0x5678 * 0xdefg + 0xb00a630 mach = 0x0 Observed behavior (qemu-sh4eb, prior to this commit): first macw : macl = 0x5678 * 0xdefg + 0x0 mach = 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: Yoshinori Sato Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240402093756.27466-1-zack@buhman.org> Signed-off-by: Richard Henderson --- 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 = tcg_temp_new(); tcg_gen_qemu_ld_i32(arg0, REG(B7_4), ctx->memidx, - MO_TESL | MO_ALIGN); + MO_TESW | MO_ALIGN); arg1 = 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);