From nobody Tue Apr 7 21:28:20 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1773257932; cv=none; d=zohomail.com; s=zohoarc; b=GPDIl3yiGHXcjFsxxVlYFOln+nxpIRyM5LQxPzjuvcWgXC+41XIkEQCPADvu3lUCkCDUs7C57I+gguinOKPJ//JPpENn1989so6JNVBhd3W0qED6UzA2QfViWtmsbPk2+vZUObmVq3THHj8XFqPSn7AAy/j2guIbnYaieBIblS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773257932; 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=EBJGnh26UKDRUTtoOQBNyCSMopgYabHsalo2QEMmU6k=; b=K1h2kKxzZtdDnWGP+8xGMJL2mwUgZb+2EsRAK5fGbCjvw8r/brcR0d1kTDhqHh5F+Q4Zw8qYeK1CNV34aDyV1rY1G5bqO1G3dM6mVIrAzOp+iO9PgW9ukyATO0kk9VtD1iNQyyLgYq53tJuO3bKkdOgDEefoRjDifwJSwwQ94bE= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773257932856441.0872929838963; Wed, 11 Mar 2026 12:38:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0PNG-0003i7-Ec; Wed, 11 Mar 2026 15:37:42 -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 1w0PN3-0003Li-J6; Wed, 11 Mar 2026 15:37:32 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0PN1-0000Ql-Eb; Wed, 11 Mar 2026 15:37:29 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 8EE33192106; Wed, 11 Mar 2026 22:34:28 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id CE4EE37C46B; Wed, 11 Mar 2026 22:35:06 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1773257668; bh=TILD+g/uDzhycfS2pBoj1b6TYap1W7Ll1VVHsgb+D8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Db7eMmN1xwBTtk/gd7vLT1mggiPGlZLGQuV4rlq3+ehIu8QJtCs83XE8I7KxHpz8Z fAY8VFltMMrHpwlp1dVnH9VDAq9s0PTvivRiNCyKKy9ET6VOtYwuSGA3Bu7VT/xoxd j0BUG5ZzTHMUnKqpPqyzl81TtP5aeL03HbGimIrBbQZV4lZWrWyEpA3hS2BLhhCbM2 VMzQf4a1nglXOSoi2/fIYo/wmxYbm2JV+XafwUBbhFN/qGJ1ggpkwpZ8CH5l5TcQNf rXoZgbeO2c81EQZG4kUPvsCFZD4OOoYAU5r8w9ITESd/OWMExzimB1Ydd/tFuvv0tA p3j5yP2foxvHg== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Glenn Miles , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Harsh Prateek Bora , Michael Tokarev Subject: [Stable-10.2.2 30/53] target/ppc/translate: Fix TCG debug assert translating CLRBWIBC Date: Wed, 11 Mar 2026 22:34:23 +0300 Message-ID: <20260311193449.1096110-30-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @tls.msk.ru) X-ZM-MESSAGEID: 1773257934995158500 From: Peter Maydell The test case in the ppe42 functional test triggers a TCG debug assertion, which causes the test to fail in an --enable-debug build or when the sanitizers are enabled: #6 0x00007ffff4a3b517 in __assert_fail (assertion=3D0x5555562e7589 "!temp_readonly(ots)", file=3D0x5555562e5b2= 3 "../../tcg/tcg.c", line=3D4928, function=3D0x5555562e8900 <__PRETTY_FUNCT= ION__.23> "tcg_reg_alloc_mov") at ./assert/assert.c:105 #7 0x0000555555cc2189 in tcg_reg_alloc_mov (s=3D0x7fff60000b70, op=3D0x7ff= f600126f8) at ../../tcg/tcg.c:4928 #8 0x0000555555cc74e0 in tcg_gen_code (s=3D0x7fff60000b70, tb=3D0x7fffa802= f540, pc_start=3D4294446080) at ../../tcg/tcg.c:6667 #9 0x0000555555d02abe in setjmp_gen_code (env=3D0x555556cbe610, tb=3D0x7fffa802f540, pc=3D4294446080, host_pc=3D= 0x7fffeea00c00, max_insns=3D0x7fffee9f9d74, ti=3D0x7fffee9f9d90) at ../../accel/tcg/translate-all.c:257 #10 0x0000555555d02d75 in tb_gen_code (cpu=3D0x555556cba590, s=3D...) at ..= /../accel/tcg/translate-all.c:325 #11 0x0000555555cf5922 in cpu_exec_loop (cpu=3D0x555556cba590, sc=3D0x7fffe= e9f9ee0) at ../../accel/tcg/cpu-exec.c:970 #12 0x0000555555cf5aae in cpu_exec_setjmp (cpu=3D0x555556cba590, sc=3D0x7ff= fee9f9ee0) at ../../accel/tcg/cpu-exec.c:1016 #13 0x0000555555cf5b4b in cpu_exec (cpu=3D0x555556cba590) at ../../accel/tc= g/cpu-exec.c:1042 #14 0x0000555555d1e7ab in tcg_cpu_exec (cpu=3D0x555556cba590) at ../../acce= l/tcg/tcg-accel-ops.c:82 #15 0x0000555555d1ff97 in rr_cpu_thread_fn (arg=3D0x555556cba590) at ../../= accel/tcg/tcg-accel-ops-rr.c:285 #16 0x00005555561586c9 in qemu_thread_start (args=3D0x555556ee3c90) at ../.= ./util/qemu-thread-posix.c:393 #17 0x00007ffff4a9caa4 in start_thread (arg=3D) at ./nptl/pt= hread_create.c:447 #18 0x00007ffff4b29c6c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/cl= one3.S:78 This can be reproduced "by hand": ./build/clang/qemu-system-ppc -display none -vga none \ -machine ppe42_machine -serial stdio \ -device loader,file=3D$HOME/.cache/qemu/download/03c1ac0fb7f6c025102a02= 776a93b35101dae7c14b75e4eab36a337e39042ea8 \ -device loader,addr=3D0xfff80040,cpu-num=3D0 (assuming you have the image file from the functional test in your local cache). This happens for this input: IN: 0xfff80c00: 07436004 .byte 0x07, 0x43, 0x60, 0x04 which generates (among other things): not_i32 $0x80000,$0x80000 which the TCG optimization pass turns into: mov_i32 $0x80000,$0xfff7ffff dead: 1 pref=3D0xffff and where we then assert because we tried to write to a constant. This happens for the CLRBWIBC instruction which ends up in do_mask_branch() with rb_is_gpr false and invert true. In this case we will generate code that sets mask to a tcg_constant_tl() but then uses it as the LHS in tcg_gen_not_tl(). Fix the assertion by doing the invert in the translate time C code for the "mask is constant" case. Cc: qemu-stable@nongnu.org Fixes: f7ec91c23906 ("target/ppc: Add IBM PPE42 special instructions") Signed-off-by: Peter Maydell Reviewed-by: Glenn Miles Reviewed-by: Philippe Mathieu-Daud=C3=A9 Link: https://lore.kernel.org/qemu-devel/20260212150753.1749448-1-peter.may= dell@linaro.org Signed-off-by: Harsh Prateek Bora (cherry picked from commit 78c6b6010ce7cfa54874dda514e694640b76f1e4) Signed-off-by: Michael Tokarev diff --git a/target/ppc/translate/ppe-impl.c.inc b/target/ppc/translate/ppe= -impl.c.inc index 0a0590344e..1c27facb89 100644 --- a/target/ppc/translate/ppe-impl.c.inc +++ b/target/ppc/translate/ppe-impl.c.inc @@ -424,11 +424,15 @@ static bool do_mask_branch(DisasContext *ctx, arg_FCB= * a, bool invert, shift =3D tcg_temp_new(); tcg_gen_andi_tl(shift, cpu_gpr[a->rb], 0x1f); tcg_gen_shr_tl(mask, tcg_constant_tl(0x80000000), shift); + if (invert) { + tcg_gen_not_tl(mask, mask); + } } else { - mask =3D tcg_constant_tl(PPC_BIT32(a->rb)); - } - if (invert) { - tcg_gen_not_tl(mask, mask); + target_ulong mask_const =3D PPC_BIT32(a->rb); + if (invert) { + mask_const =3D ~mask_const; + } + mask =3D tcg_constant_tl(mask_const); } =20 /* apply mask to ra */ --=20 2.47.3