From nobody Sat Nov 23 22:39:03 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1730679674; cv=none; d=zohomail.com; s=zohoarc; b=GAo+S/5Rr6We8NfGZzEwqJhmb0NSn9CDtwAOrE18jgxEW0P6Hmu8tdzeXi/x3seVKp4NTZEdWjYrWXAPNDN2twaro8GX6Ro39IqH3MpaC9QnXs10FAA0GHUQBiN69A5r/hBR2A1TyE86ttNXeq4psrT8+GT0iV2WmLYGI+GuFeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730679674; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=moXUYmUT2iEbA51wj0j9OUXY0sQDkte1US2SvpeeNdM=; b=WumTpVxivILtsxL3+NzdmadmeIjMQZiWzbJoZM+JSLH7TGBtoJ7pvUiEPhe1rLeWKHcXRNm/0KqQvQEmd89N6btZTDR84VB2KEY4bzkJ0nHYvsTQeIn9a7dUJw9qxMUj0G4YJsZ1jDLyE2KfoBFw4f7BlH+L7iXUZnv0bsQsHyk= 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 1730679674305755.1555184312929; Sun, 3 Nov 2024 16:21:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7koX-00073x-Ad; Sun, 03 Nov 2024 19:19:25 -0500 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 1t7koU-00073I-IK; Sun, 03 Nov 2024 19:19:23 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t7koR-0002Ds-CE; Sun, 03 Nov 2024 19:19:21 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21116b187c4so22346915ad.3; Sun, 03 Nov 2024 16:19:18 -0800 (PST) Received: from wheely.local0.net (124-171-217-17.tpgi.com.au. [124.171.217.17]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ee45a0081esm5900648a12.59.2024.11.03.16.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 16:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730679557; x=1731284357; 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=moXUYmUT2iEbA51wj0j9OUXY0sQDkte1US2SvpeeNdM=; b=ikN1ERi+D3pyKTkHUJhRaNO6hWoki5yGbQODK9s2W2QMnvYRd+inL6W2ZafghusuOE OQNcYfP/m+rgx0Tdzca8PxMpgJ8FGsgvfQziy7xBF9SgpdQVh0fNkwtY8cGp3AnLFaIh bE9WwnkelafO3AtG5qhMuz4sZESan/ob4TzhPktTbRE7znaGHti8ChVf8dXy2KdwkYtc SDNA6caP/7P2qDGIB69V9NQxxnWJ8UOuoKAD3SmY81awQ4czYU84pHW8z+bqqqEORfQF /UpbODx0R4JaFNt1Bisfp7yvO/CjU+a1Q2RcJehKnvrW9bAW06jmRjLkC0gVDVpkaLMx xeGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730679557; x=1731284357; 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=moXUYmUT2iEbA51wj0j9OUXY0sQDkte1US2SvpeeNdM=; b=nTArBTDn/0lrT+iB3boCcf+VrE24B2rfX3ASis6xvfZGP6dOphz8h+lDt5nix7uXto RULyQ6EbGBIaB6MJfDaTmkdRELK5yTpXlMQEfjLQ34EpwUiNKxbEbUYBvRcuy+ONUbAF cuFD+mZs7sMU0B1Fr0gTzIWbr8JlrpssRegH37/LL9iPtMA1ODMh5Cp8cudul52Dlyev UUorwVq/W7H12Qztf1SWLjfuwmjIxR2HCRSo1PqR/q/3jqqe3om7J2oWv3N+zw0MdBST q3OaA1JSahxJZ5I/iatXLzOWvBefvdYQRko/XTMQ0VV6tA3micCr1pfds7uY8KbHxm2a Np/A== X-Forwarded-Encrypted: i=1; AJvYcCWchtbNPE1yWv2BPAUG9BYw/uJCicL5FbgjdO6UV0MrLbe3vOLTSvyuviLsQ1aNiz2lSJuAG/Fyvw==@nongnu.org, AJvYcCXs4Q2BbMS7/7koLFZVkOmx48zpTdd4bmFseFecEYIQaS7Sg3uh6tdAKpPy5hjTfFImxOBtxeWdz/9E+AI=@nongnu.org X-Gm-Message-State: AOJu0Yzg5STZkPCc7ZogWRfFCkO2KdOWduSwcKZpDOJ+80NlWIwwbPYH HdNYqcfkk0rzLPlejMMyvjmHk50bYg7u/1DthCLGbs+RmsRxyrEc1RN8jQ== X-Google-Smtp-Source: AGHT+IHjw3SgxGmv5hJ6XRK51Q/72mSVWi94IMEx0C1wu8AFQvlj3AeVWvK3mkFhwQoldPkcHrZ3Yw== X-Received: by 2002:a17:903:1c7:b0:206:a87c:2864 with SMTP id d9443c01a7336-2111afd6ca6mr121910665ad.42.1730679555374; Sun, 03 Nov 2024 16:19:15 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , qemu-ppc@nongnu.org, Ilya Leoshkevich , qemu-stable@nongnu.org, Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 01/67] target/ppc: Set ctx->opcode for decode_insn32() Date: Mon, 4 Nov 2024 10:17:50 +1000 Message-ID: <20241104001900.682660-2-npiggin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104001900.682660-1-npiggin@gmail.com> References: <20241104001900.682660-1-npiggin@gmail.com> 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::630; envelope-from=npiggin@gmail.com; helo=mail-pl1-x630.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, FREEMAIL_FROM=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1730679675127116600 From: Ilya Leoshkevich divdu (without a dot) sometimes updates cr0, even though it shouldn't. The reason is that gen_op_arith_divd() checks Rc(ctx->opcode), which is not initialized. This field is initialized only for instructions that go through decode_legacy(), and not decodetree. There already was a similar issue fixed in commit 86e6202a57b1 ("target/ppc: Make divw[u] handler method decodetree compatible."). It's not immediately clear what else may access the uninitialized ctx->opcode, so instead of playing whack-a-mole and changing the check to compute_rc0, simply initialize ctx->opcode. Cc: qemu-stable@nongnu.org Fixes: 99082815f17f ("target/ppc: Add infrastructure for prefixed insns") Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Ilya Leoshkevich Signed-off-by: Nicholas Piggin --- target/ppc/translate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 7689b2ac2e..be93777cf6 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -6423,8 +6423,6 @@ static bool decode_legacy(PowerPCCPU *cpu, DisasConte= xt *ctx, uint32_t insn) opc_handler_t **table, *handler; uint32_t inval; =20 - ctx->opcode =3D insn; - LOG_DISAS("translate opcode %08x (%02x %02x %02x %02x) (%s)\n", insn, opc1(insn), opc2(insn), opc3(insn), opc4(insn), ctx->le_mode ? "little" : "big"); @@ -6558,6 +6556,7 @@ static void ppc_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) ctx->base.pc_next =3D pc +=3D 4; =20 if (!is_prefix_insn(ctx, insn)) { + ctx->opcode =3D insn; ok =3D (decode_insn32(ctx, insn) || decode_legacy(cpu, ctx, insn)); } else if ((pc & 63) =3D=3D 0) { --=20 2.45.2