From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EC73606A322 for ; Fri, 4 Dec 2026 20:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=rispop.dev header.i=@rispop.dev header.a=rsa-sha256 header.s=protonmail header.b=PvknwzDo Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZZjR-00076H-GN; Fri, 04 Dec 2026 15:18:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZZj8-00074X-Hc; Fri, 04 Dec 2026 15:17:56 -0500 Received: from mail-07.mail-europe.com ([37.187.220.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZZj6-0003U0-KC; Fri, 04 Dec 2026 15:17:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rispop.dev; s=protonmail; t=1796415458; x=1796674658; bh=7E910rvZ0fl+nV9ubxrEM09/J/2+D69+FvJUFfbhaNI=; h=From:To:Cc:Subject:Date:Message-ID:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=PvknwzDoCAkLyEdBrbEIY92rtd00xKNdj6aUPetE2H6cOF40GR5IT5nUiaE4QNWRD PyIpzJ6+MWyZ+tYkCU7tSzZZXm0gMhK8+/+naf2W1B7tcy5sdQpmGsq/Byr009IwMw E9sLD0NM8bOZZrnT6wfxeCLbK3ikZRX9FIWUedaV4dN0z3oOElgv+iAj46VkqyOGjg K3peTS5DI4HB746BIGUeiOzCZSZrZSf4QUO5CcWQvvLA1lQiRF7ie2GdvxhONQjhff /OmUkB9pepj59l8ZyCqEqIadhg9ARh48495dSnQ6OxRC9/R33Yf3mJkmTPE6G+yN6u BucB+IgClG0kA== X-Pm-Submission-Id: 4jh2q34JfDz1DDLh From: Rishab Pradeep To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com, alistair.francis@wdc.com, liwei1518@gmail.com, daniel.barboza@oss.qualcomm.com, zhiwei_liu@linux.alibaba.com, chao.liu@processmission.com, Rishab Pradeep Subject: [PATCH 0/2] target/riscv: apply pointer masking to flh/fsh and Zcmp push/pop Date: Fri, 4 Dec 2026 14:17:30 -0600 Message-ID: <20261204201732.254081-1-rishab@rispop.dev> X-Mailer: git-send-email 2.56.0 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=37.187.220.204; envelope-from=rishab@rispop.dev; helo=mail-07.mail-europe.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_PASS,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 With pointer masking enabled, the ignore transformation applies to every explicit memory access. flh/fsh and the Zcmp stack instructions (cm.push, cm.pop, cm.popret, cm.popretz) form their addresses without it, so a tagged pointer or tagged sp raises a load/store access fault, whereas lw/flw/fld and ld/sd through the same pointer work. Spike, Sail and Whisper mask flh/fsh as expected. Patch 1 builds the flh/fsh address with get_address(), as flw/fsw and fld/fsd already do. Neither instruction applied the mask before. Patch 2 masks each access address in gen_pop() and trans_cm_push(), recomputed from the current address on every iteration. sp is still written back with its tag, and the cm.popret jump target is unchanged since it is an instruction fetch, not an explicit data access. Tested with the reproducer from the issue; both ELFs (pm_flh_fsh, pm_zcmp_push_pop) pass with these patches and fail on master. Based on riscv-to-apply.next (9d45369e7f), which carries the #4758 series that adds gen_pm_adjust_addr(). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4967 Rishab Pradeep (2): target/riscv: apply pointer masking to flh/fsh target/riscv: apply pointer masking to Zcmp push/pop target/riscv/tcg/insn_trans/trans_rvzce.c.inc | 8 ++++++-- target/riscv/tcg/insn_trans/trans_rvzfh.c.inc | 14 ++------------ 2 files changed, 8 insertions(+), 14 deletions(-) -- 2.56.0