From nobody Mon Nov 23 04:44:08 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; dmarc=pass(p=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1792461176; cv=none; d=zohomail.com; s=zohoarc; b=SbCVCrjpCxvygI/fp6H7QFs5vxaBTVUaH08+xWa4SqFyHHcc6MzVqfxuRkQLKAIBdqj8xKhpbJLDNZqo3UnrAk3ddw+Qr6PZmjJZjgmkqNJd475aBBFy5qJuF/bOo2renomY9x/Uq3FyUlpiz05Y15x2Zz9RysRXQj0O6SoxnM4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792461176; h=Content-Type: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=t/GUMiao7kD7HhZtVSrMfaekGjAneUfs22Gw1ryYd9s=; b=jCA0IsYN5cJuUUT6HiHrmyQlAjeJNEQLbvPBN+fUj7kQHh2dwv7/sYywBMUqiwPQvG9/bJXnaaQmKDnk63KIyqHqYt0i+UUyHflbxB8YQfIBS2BNI+4DnnhNc5Ao/lyG7Dp2NyBAtB4xYciTRtakirP7zIXcTJRrARxZ5KoAeiM= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792461175993527.9953662685242; Mon, 19 Oct 2026 18:52:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIz1K-0008GR-Bf; Mon, 19 Oct 2026 21:52:06 -0400 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 1xIz1G-0008Fx-Oy for qemu-devel@nongnu.org; Mon, 19 Oct 2026 21:52:02 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIz1D-0002pg-LM for qemu-devel@nongnu.org; Mon, 19 Oct 2026 21:52:02 -0400 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69K1DoeG744225 for ; Tue, 20 Oct 2026 01:51:57 GMT Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hdw5pge6h-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 20 Oct 2026 01:51:57 +0000 (GMT) Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-3662e7a9299so805403eec.1 for ; Mon, 19 Oct 2026 18:51:57 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-360820a02b8sm38966065eec.17.2026.10.19.18.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 18:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=t/GUMiao7kD7HhZtVSrMfa ekGjAneUfs22Gw1ryYd9s=; b=p6LqXVd91ThQH8jvz+kiAfhKwDfTLbTUH7KfBa wSUJcN9ojeWhSCpQAbn5/y+jnJohDg69x+sanY0JqIfHwmTwagqPjc7GvLkPjWaS NpaPlAukEakM7Th+0vb9yEbIwI4LYX6ASgpq2YAd+zxbKKnX4Cpzw3bQl3RdC5In OdheuVNXohXwYVba1TjnDOj2k7MTOVYBkBy+0eoxM+ro3eD5ac5OqcCXdIjhAuxr aTQWjyqQK6mHq4s3j3WGxHFeiMn9idMX6LO2KMVYUM307r+3Cazjq3tCUzIRdpze +dqAkfzb0tkm3XtdGyF4BJr3NjLpcf17LKLXoXCxeSDzpyhg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1792461116; x=1793065916; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=t/GUMiao7kD7HhZtVSrMfaekGjAneUfs22Gw1ryYd9s=; b=IQbtB1o2V0g4/CIPMHtV2DO9pn0+zoVFZOKno6Uz0JxFcDA8ZBwFo25um20C8ECJlC CRv1SoCWolchfyG+1I1+FM7+H5Aa1JB+sh4wKfNd5Crolx3Dtj3UF/+Zy7X/Gw89kc/P hLE002DCMdY/sy4ufG0ugcpjBq6Qm6K34cXcDjT/r2CiDbOvJueyxUjl7VhBZUrJ8ovu 3sp1PMsOrZr7AHkmitTgg+cuEvWlAjzX1WvcrUvOxH/L2EqxV4kkhao3pogyxEEo7Q+x ajf00fG7c8fIZCEa4TY1IczDS3h7V6a6/73nIyui2zV2WM66aZCUNgXSrEamrzbSggph wwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792461116; x=1793065916; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=t/GUMiao7kD7HhZtVSrMfaekGjAneUfs22Gw1ryYd9s=; b=rvkUQlfLv7vvDBoX3sk4Lr1TgIv7eNSb3JIrIsKygxRreahBnUpk9Cy852i3bKZO/r k9rKokpKPJFz6+L5uHK2DdTTM36hoLFmFPuJU6Y7WdCGJreiN7j0+XxOZOAPSJ6oWDqJ DjHv8k+SeQ5+hQi7BFCBN6Z0KhDJa/sP/AsOKqRCZ1kES5c/1qFy3eszE9EHPVjoDpHR agQORKSmuknBgQSqUl5j8biglTwBi1Az7b0R37kH9mt67Xg+o13IxS63h2Vsd9nC3uKi w/NqToKL7nbWXwGCLL/iGvc0+ZORoAoiAriKNXc4ISz59P/hRsZtSZMTL+p/I2m3WJR1 qN0w== X-Gm-Message-State: AFq9FYK2l9VeZCu3u4oq5SC+tLFSWlWn1rcIHicPTYKZcSrH2mVIGrUy mak5UjcNbe4sNt4ZojnCb/5dnxbYW6JKixPBq851GckpkoyK3EfccjCrjp+vuCFiBvWCHhGqAAB x2gMNCZxvT3AAMWVsjuaZPaFpOWIHNT5mL/b38ih/A3KQEH03D2waNV6CHQh3SSVUHQ== X-Gm-Gg: AYBFou19J/6N+gg+rLM+4g1mI+0JYp+mFQBSX2uaxVpmmkOYX+Suk8CDQggs3n9k1Hx pn5RxNued9CzLC08xFTAz+SxVacyjfbDKdBsHPP6YowxsAr49zxiuCcf8UDD4hCbhGZEaEJkfHh dukocazNCg66T9ykdxcyUUcgcVX7eAIZ9F2u0GJk8vtPsN9905tNu7W2w1YgWEGFvctDud1A9pG 7buiMJ4+I+LMw4nHvjU+4sDFcxyAdrP/kffptzFHdsfc1qutLbRcOcNlmta6YobUOYyCD/9u9p+ O5uF1cmTop3D+HnVC45DYU9bwJgZC0Jo5pu434TS3utZrJ4U44WM8qn9fw94pKIwEnS0QX3ZGKL CKTpzBpDVnuQEwhti29re/GjcYBEM0Y6Rk+pJdZK9GBiJllM= X-Received: by 2002:a05:7301:7305:b0:35c:dd03:55d2 with SMTP id 5a478bee46e88-361a2a3ec54mr11621058eec.26.1792461116251; Mon, 19 Oct 2026 18:51:56 -0700 (PDT) X-Received: by 2002:a05:7301:7305:b0:35c:dd03:55d2 with SMTP id 5a478bee46e88-361a2a3ec54mr11621032eec.26.1792461115684; Mon, 19 Oct 2026 18:51:55 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: Marco Liebel , Brian Cain , Anton Johansson , Alessandro Di Federico , Pierrick Bouvier Subject: [PATCH v2] target/hexagon: fix allocframe FRAMEKEY scrambling Date: Mon, 19 Oct 2026 18:51:54 -0700 Message-Id: <20261020015154.3600098-1-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=a7WlZkSF c=1 sm=1 tr=0 ts=6ad6c93d cx=c_pps a=PfFC4Oe2JQzmKTvty2cRDw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=K1JGG7mlgpTgzTha6HsA:9 a=QEXdDO2ut3YA:10 a=6Ab_bkdmUrQuMsNx7PHu:22 X-Proofpoint-ORIG-GUID: 8seyVFHwnOKaOem3ZSxF2gB8RlzhLqTx X-Proofpoint-GUID: 8seyVFHwnOKaOem3ZSxF2gB8RlzhLqTx X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDIwMDAwNyBTYWx0ZWRfX7lsTt3gM1TZT dMQNbakruU0ESs7OG0L8DZp42ywL0DZ+Dt9vOy+lG5KfOtNbrg31a2+itoYAz0Jx4s67NxYFq2K Nx4tHvlNU34zco4j2wS79IDH4h7RJc4SegFnBCYSvTwKWPeyflPUDI6inDCtHQbPWZaR57VyeLP gd0h1/Mfk5rnAmv4l8ybGjoFrAWJyC+KWtuaU+m9AmWUQ454zZPgJi8CA83leYX/0Om7dvhcJcy tZZwTyITAYDKzUSxPEU/fcX9IpXvhWozmULKvahbIK8Z/cb7a3uMIMvcw2n/rJeOwI9yoOs4PYj nI5/2CfeVFefDC8tdefoZjYJw2bWpiDjrbvRmaF3fyj10iEcPxu3lmtyhzjYl1apsYEN2sKcTn0 yWFX/OioE4CwYpXTN6d1B9LgSTmfc6tiSjmvaHkXr0Tf0n3kSxP0bcOOwNFJhNUNdOFdm2gW9Ey JRS/NL8GUKbw/mSHdIA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDIwMDAwNyBTYWx0ZWRfXyf7MyoHS/1K2 n7rl7kX2r4VenjBDGCQwOL53v0M+reLXegtJKRNKQzqEruu6L5fvITA7BWgqjLKVwnG0rwwlthF SeWgLYWU8yLA//rx9AC/8fZW78u2oFo= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-20_01,2026-10-19_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 adultscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610200007 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.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, 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: 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 @qualcomm.com) X-ZM-MESSAGEID: 1792461177439158500 The architecture scrambles only the LR word of the {FP, LR} frame that allocframe stores. With the idef parser enabled, fFRAME_SCRAMBLE built the XOR key with FRAMEKEY in both halves of the 64-bit value, so the stored FP was scrambled as well. deallocframe is also parser-generated and applies the same incorrect transform a second time, which masks the error. dealloc_return uses the hand-written TCG implementation that correctly descrambles only LR, so it leaves FP corrupt when returning from a frame allocated by the parser. Add a regression test that sets a nonzero FRAMEKEY, allocates a frame, and returns through dealloc_return to validate the restored FP. Uncovered by testing some boot images using QuRT. Signed-off-by: Brian Cain Reviewed-by: Marco Liebel --- target/hexagon/idef-parser/parser-helpers.c | 2 +- tests/tcg/hexagon/framekey.c | 54 +++++++++++++++++++++ tests/tcg/hexagon/meson.build | 1 + 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/hexagon/framekey.c diff --git a/target/hexagon/idef-parser/parser-helpers.c b/target/hexagon/i= def-parser/parser-helpers.c index 49cc11fddd8..14840d98737 100644 --- a/target/hexagon/idef-parser/parser-helpers.c +++ b/target/hexagon/idef-parser/parser-helpers.c @@ -1989,7 +1989,7 @@ HexValue gen_rvalue_fscr(Context *c, YYLTYPE *locp, H= exValue *value) *value =3D gen_rvalue_extend(c, locp, value); OUT(c, locp, "gen_read_reg(", &frame_key, ", HEX_REG_FRAMEKEY);\n"); OUT(c, locp, "tcg_gen_concat_i32_i64(", - &key, ", ", &frame_key, ", ", &frame_key, ");\n"); + &key, ", tcg_constant_tl(0), ", &frame_key, ");\n"); OUT(c, locp, "tcg_gen_xor_i64(", &res, ", ", value, ", ", &key, ");\n"= ); return res; } diff --git a/tests/tcg/hexagon/framekey.c b/tests/tcg/hexagon/framekey.c new file mode 100644 index 00000000000..14c7fcbc654 --- /dev/null +++ b/tests/tcg/hexagon/framekey.c @@ -0,0 +1,54 @@ +/* + * Copyright(c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +int err; + +#include "hex_test.h" + +/* + * allocframe pushes {LR, FP}, scrambling LR with FRAMEKEY. Return through + * dealloc_return and report the FP that it restores. + */ +static inline uint32_t frame_roundtrip(uint32_t key, uint32_t fp) +{ + uint32_t fp_back, saved_fp, saved_lr; + + asm volatile("%[saved_fp] =3D r30\n\t" + "%[saved_lr] =3D r31\n\t" + "framekey =3D %[key]\n\t" + "r30 =3D %[fp]\n\t" + "r31 =3D ##1f\n\t" + "allocframe(#0)\n\t" + "r31 =3D #0\n\t" + "dealloc_return\n\t" + "1:\n\t" + "%[fp_back] =3D r30\n\t" + "framekey =3D %[zero]\n\t" + "r30 =3D %[saved_fp]\n\t" + "r31 =3D %[saved_lr]\n" + : [fp_back] "=3D&r"(fp_back), + [saved_fp] "=3D&r"(saved_fp), [saved_lr] "=3D&r"(saved_= lr) + : [key] "r"(key), [fp] "r"(fp), [zero] "r"(0) + : "memory", "framekey"); + return fp_back; +} + +static void check_frame(uint32_t key, uint32_t fp) +{ + check32(frame_roundtrip(key, fp), fp); +} + +int main() +{ + check_frame(0, 0x1234fff0); + check_frame(0xf21f20a0, 0x1234fff0); + + puts(err ? "FAIL" : "PASS"); + return err; +} diff --git a/tests/tcg/hexagon/meson.build b/tests/tcg/hexagon/meson.build index a6ace4c77c2..0fd62ce7e4c 100644 --- a/tests/tcg/hexagon/meson.build +++ b/tests/tcg/hexagon/meson.build @@ -68,6 +68,7 @@ tests +=3D { 'overflow.c': {'cflags': cflags, 'exe_name': 'hex-overflow'}, 'preg_alias.c': {'cflags': cflags}, 'dual_stores.c': {'cflags': cflags}, + 'framekey.c': {'cflags': cflags}, 'multi_result.c': {'cflags': cflags}, 'mem_noshuf.c': {'cflags': cflags}, 'mem_noshuf_exception.c': {'cflags': cflags}, --=20 2.34.1