From nobody Mon Nov 23 04:26:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793878910; cv=none; d=zohomail.com; s=zohoarc; b=lBZmQQdKljIIpOFMRsFYm0v1uD2K/nk0RuFuOgIu3UeCEXpNDteD8O48RPDbADNUIDGa4iDKLa4Hnnwqs46qoSLYRp6pYSlp4dLG7IvLuIV/baWbxb828g5hyNvqmTV3A0Ay49a8nXViWy3SW8bo6yoAOU9VBw9bz/cGKX0L/TM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793878910; h=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:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=IX2s5FOKwLuntAmNIkgPK9S3/yywQuzdbBqMAIeuOHc=; b=ciE+SsmTm0q53lb/sRv/Hgwc1IXsCtmx4lVfQeT5II/z53VQgosRHPGBFRFmUPC6iH3waP4J6ZijBv/DUq2ZqNfmpCciTZVWTQPHPei2cG80U70Z75CKGRQlgiDBBIrEW4ltpmcTe1GfogtkUSz8b9GBWpzATwRCVE8B6dqJuNM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1793878910926545.620210968878; Thu, 5 Nov 2026 03:41:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOvqJ-0002LA-7U; Thu, 05 Nov 2026 06:41:19 -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 1xOvqC-0002JZ-3d for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:12 -0500 Received: from rev.ng ([94.130.142.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOvqA-0005Hr-M5 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive:List-Unsubscribe:List-Unsubscribe-Post: List-Help; bh=IX2s5FOKwLuntAmNIkgPK9S3/yywQuzdbBqMAIeuOHc=; b=FMQYlPC60EFErCa k736Pg2EZbkyYfc6vNGK9MEUabJxa1BcPujioKsoUWMzx4hcyYPyWrcSRDZ/9uISraxlsBbiN45CB idSZb4RObvegajgNuC4F3prlkljdaKEb1Dh5bxSfwee23E5569VM9FnIso7LpTa+kpgsbJSMreZ/L oY=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v2 1/4] target/hexagon: HLX, preserve scalar :mem_noshuf ordering Date: Thu, 5 Nov 2026 12:46:30 +0100 Message-ID: <20261105114633.597-2-anjo@rev.ng> In-Reply-To: <20261105114633.597-1-anjo@rev.ng> References: <20261105114633.597-1-anjo@rev.ng> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=94.130.142.21; envelope-from=anjo@rev.ng; helo=rev.ng 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_PASS=-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: , Reply-to: Anton Johansson From: Anton Johansson via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1793878912413158500 Content-Type: text/plain; charset="utf-8" A packet containing HLX instructions currently defers all stores to the end of the packet, this breaks scalar :mem_noshuf ordering. Only reorder HLX stores. Fixes: a6fae6da070d66b9 ("target/hexagon: translate packets with HLX instru= ctions") Signed-off-by: Anton Johansson Reviewed-by: Brian Cain Reviewed-by: Marco Liebel --- target/hexagon/translate.c | 7 ++++--- tests/tcg/hexagon/hlx_mem.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 8ab28d40d3..f9d4c3fb66 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -1525,8 +1525,10 @@ static void decode_and_translate_packet(CPUHexagonSt= ate *env, DisasContext *ctx) for (int pass =3D 0; pass < 3; pass++) { for (i =3D 0; i < ctx->pkt.num_insns; i++) { Insn *insn =3D &ctx->pkt.insn[i]; + bool hlx =3D GET_ATTRIB(insn->opcode, A_HLX); bool tmp =3D GET_ATTRIB(insn->opcode, A_HLX_TMP); - bool store =3D !tmp && GET_ATTRIB(insn->opcode, A_STOR= E); + bool store =3D !tmp && hlx && + GET_ATTRIB(insn->opcode, A_STORE); if (pass !=3D (tmp ? 0 : store ? 2 : 1)) { continue; } @@ -1534,8 +1536,7 @@ static void decode_and_translate_packet(CPUHexagonSta= te *env, DisasContext *ctx) if (insn->hlx_new_zero) { gen_hlx_new_zero(insn); } - if (GET_ATTRIB(insn->opcode, A_HLX) && - trace_event_get_state_backends( + if (hlx && trace_event_get_state_backends( TRACE_HEXAGON_HLX_OP)) { gen_helper_hlx_trace_op(tcg_env, tcg_constant_i32(insn->opcode)); diff --git a/tests/tcg/hexagon/hlx_mem.c b/tests/tcg/hexagon/hlx_mem.c index 643b499fd9..f5af95115a 100644 --- a/tests/tcg/hexagon/hlx_mem.c +++ b/tests/tcg/hexagon/hlx_mem.c @@ -229,6 +229,25 @@ static void test_store_fault(void) check_h("LX_S16b_new (fault)", buf_out, expected, HLX_HALF_ELEMS); } =20 +static void test_preserve_scalar_noshuf(void) +{ + uint32_t ret =3D 0; + uint32_t ptr =3D 0; + uint32_t val =3D 0x1234; + asm volatile("{\n" + ".word 0xe5007822\n" + " memw(%1) =3D %2\n" + " %0 =3D memw(%1)\n" + "}:mem_noshuf\n" + : "=3Dr"(ret) + : "r"(&ptr), "r"(val) + : "memory"); + if (ret !=3D val) { + printf("FAIL broken scalar :mem_noshuf ordering\n"); + err++; + } +} + int main(void) { init_vtcm(); @@ -253,6 +272,9 @@ int main(void) /* Store in a faulting packet */ test_store_fault(); =20 + /* Make sure HLX packets preserve scalar :mem_noshuf ordering */ + test_preserve_scalar_noshuf(); + puts(err ? "FAIL" : "PASS"); return err; } --=20 2.52.0 From nobody Mon Nov 23 04:26:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793878893; cv=none; d=zohomail.com; s=zohoarc; b=HtLD2bGPUrWP9xFLfwEM/5BqDv5mGJ4tAJU9ci5WfZPyQQ0wCU1VOqn8zglBos7jXqARUtPLu9iLEln60FzoETLcvwlGnciCiZoi1QooSOjNB1m1Jki9mQ5jDIm5ZdYpS02KYSdVJY6HnpdE3kyQqjPvld50nPDNSH91D3fLq8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793878893; h=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:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=JUb/pXiQVev4JAys45i1iRg1UIcTa9J9UmXGod6AghI=; b=mXdWcZbqfii0hBjMWv8tcjFJqr2ee22hOvWfEOxHlV7wANX0vOxzVXr8RniIK7cQVPJ8VfFkuoANsWjOJc5tblI0fjFaOOhpuiMorMbR3K3q8KpnzilNh/X7KUxT7KmfwnOORl0TqESeRUoinrjDjwKxa60gkCv1mYhNRFXzl3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1793878893680758.7669634306085; Thu, 5 Nov 2026 03:41:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOvqJ-0002Lo-Tw; Thu, 05 Nov 2026 06:41:19 -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 1xOvqD-0002Js-CG for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:13 -0500 Received: from rev.ng ([94.130.142.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOvqB-0005Hx-8U for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive:List-Unsubscribe:List-Unsubscribe-Post: List-Help; bh=JUb/pXiQVev4JAys45i1iRg1UIcTa9J9UmXGod6AghI=; b=kfqC6BDj9mW2i1N f1QHuf91r4IWn2HgOy2cVghj8VKeJbiH518hoMPseA6TEJ133LkgkJ94wrAF5sb94E3JfRrzG3H3S hn0OMxCekHaWQz0a1E8sLu9KdwVQLqckAKxM1DF7FlrlXggmQxX0JNPP5/Bomrb/Cwy9H9qkgoO1e EI=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v2 2/4] target/hexagon: HLX, search for .new values in pair high register Date: Thu, 5 Nov 2026 12:46:31 +0100 Message-ID: <20261105114633.597-3-anjo@rev.ng> In-Reply-To: <20261105114633.597-1-anjo@rev.ng> References: <20261105114633.597-1-anjo@rev.ng> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=94.130.142.21; envelope-from=anjo@rev.ng; helo=rev.ng 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_PASS=-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: , Reply-to: Anton Johansson From: Anton Johansson via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1793878896045158500 Content-Type: text/plain; charset="utf-8" Otherwise, the following packet { L7:6 =3D combine(L0, L1) memw(R7) =3D L7.new } results in memw(R7) being zero-intialized, compared to L6.new which would correctly write the lower bytes of the pair. Fixes: ef81d1b047337e81 ("target/hexagon: decode HLX packets and add load a= nd store") Signed-off-by: Anton Johansson --- target/hexagon/decode.c | 20 +++++++++++++++-- tests/tcg/hexagon/hlx_assign_conv.c | 35 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/target/hexagon/decode.c b/target/hexagon/decode.c index d48630da87..8921ff765d 100644 --- a/target/hexagon/decode.c +++ b/target/hexagon/decode.c @@ -110,9 +110,25 @@ static int hlx_find_new_value_producer(Packet *packet,= int consumer, { for (int i =3D 0; i < packet->num_insns; i++) { Insn *insn =3D &packet->insn[i]; + uint8_t regno; =20 - if (i !=3D consumer && GET_ATTRIB(insn->opcode, A_HLX) && - insn->dest_idx !=3D -1 && insn->regno[insn->dest_idx] =3D=3D l= reg) { + /* + * Skip ourselves, instructions without return values, and + * any non-HLX instructions. + */ + if (i =3D=3D consumer || !GET_ATTRIB(insn->opcode, A_HLX) || + insn->dest_idx =3D=3D -1) { + continue; + } + + regno =3D insn->regno[insn->dest_idx]; + + /* + * Compare against the base register number, and against the top + * register for instructions returning pairs. + */ + if (regno =3D=3D lreg || + (GET_ATTRIB(insn->opcode, A_HLX_PAIRED_ALU) && regno + 1 =3D= =3D lreg)) { return i; } } diff --git a/tests/tcg/hexagon/hlx_assign_conv.c b/tests/tcg/hexagon/hlx_as= sign_conv.c index 8192882b8e..aef82dd63b 100644 --- a/tests/tcg/hexagon/hlx_assign_conv.c +++ b/tests/tcg/hexagon/hlx_assign_conv.c @@ -120,6 +120,40 @@ static void test_assign_rw(void) check_wp("LX_assign_rw", pw_out_lo, pw_out_hi, expected_w, HLX_HALF_EL= EMS); } =20 +static void test_combine_assign_hi(void) +{ + /* + * Tests that a combine operation acts as a producer of a .new value f= or + * the high vector in a pair. + */ + HLX_Vector l_lo; + HLX_Vector l_hi; + + fill_w(pw_a_lo, pw_a_hi, VAL_W); + + l_lo =3D Q6_L_tmp_mem_A(pw_a_lo); + l_hi =3D Q6_L_tmp_mem_A(pw_a_hi); + + hlx_put_v(0, l_lo); + hlx_put_v(2, l_hi); + /* + * { + * L7:6 =3D combine(L0, L1) + * memw(R7) =3D L7.new + * } + */ + asm volatile(HLX_PTRS HLX_LD0 HLX_LD2 + ".word 0xef24602d\n" + ".word 0xa487c007\n" + : : [stage] "r"(hlx_stage) : HLX_CLOBBERS); + Q6_mem_Ku16_new_AL(buf_a, hlx_get_v(7)); + + for (int j =3D 0; j < HLX_HALF_ELEMS; j++) { + expected[j] =3D VAL_A; + } + check_h("LX_assign_w (hi only)", buf_a, expected, HLX_HALF_ELEMS); +} + =20 static void test_combine_w(void) { @@ -336,6 +370,7 @@ int main(void) test_assign_s(); test_assign_u(); test_assign_rw(); + test_combine_assign_hi(); =20 /* Combine and mux */ test_combine_w(); --=20 2.52.0 From nobody Mon Nov 23 04:26:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793878915; cv=none; d=zohomail.com; s=zohoarc; b=AKXBHmlwa0EEnyUkRBXL7TC3vrb6cssoL27CvieIdV3gL8qkdrBstj6aBRhK02N025TbDyII5NwotspObjxNqHX6J8kTtUe3Mc4LzD5Ck/1qEjihWNJj3//Y1zvuR5WUfF2dcvJF+ID9y/yQwTo/UQWmP9pHAjfj1HTFK9bky1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793878915; h=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:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=SS5EZNI55xYFhgZ1f/eQKuS59xqG/dZERCdqlsXPMBw=; b=MWirL6oNy6z0S1F5+2BU60jyy9JdO0UonGzHe/Mcgk42Y/t9QNIHvN3NkFvhVOvdgp2YWfrZqnfKJgcuEdEDnzQbKw3JzVN9Ojxc/0FxNA4ANlH9S22Dv+RW1D/DJKCrsgcKxltPlZLnx1iBaMXU4oF69fN8/cm88cFrshyAG4s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1793878915556789.395818571371; Thu, 5 Nov 2026 03:41:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOvqJ-0002Le-Qp; Thu, 05 Nov 2026 06:41:19 -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 1xOvqD-0002Jv-Lx for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:13 -0500 Received: from rev.ng ([94.130.142.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOvqC-0005I3-0M for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive:List-Unsubscribe:List-Unsubscribe-Post: List-Help; bh=SS5EZNI55xYFhgZ1f/eQKuS59xqG/dZERCdqlsXPMBw=; b=RBqDmvNrHUPVJkU mLzEdEDSWL8frQ70Touuk/XFloO+EVRa2hvPczbSW7nGwSaBjQYwOfyYoDaaxsiNCLm15KcsAAyCd 6Ihrj7ECD3LnhEsuGWKiw49yip2SpKnj2JKq7F40dtj9t0ZArF52W4BtkXma9jSYoEYjL9x7Iwu+q 4Y=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v2 3/4] target/hexagon: Forward return address to HLX load/store helpers Date: Thu, 5 Nov 2026 12:46:32 +0100 Message-ID: <20261105114633.597-4-anjo@rev.ng> In-Reply-To: <20261105114633.597-1-anjo@rev.ng> References: <20261105114633.597-1-anjo@rev.ng> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=94.130.142.21; envelope-from=anjo@rev.ng; helo=rev.ng 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_PASS=-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: , Reply-to: Anton Johansson From: Anton Johansson via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1793878916497158500 Content-Type: text/plain; charset="utf-8" Fixes: 2db29a3615a5ad2a3 ("target/hexagon: add HLX helper support") Signed-off-by: Anton Johansson Reviewed-by: Marco Liebel --- target/hexagon/hlx_helper.h | 19 +++++++++++++++++++ target/hexagon/macros.h | 13 +++++++++---- target/hexagon/hlx_helper.c | 31 ++++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 target/hexagon/hlx_helper.h diff --git a/target/hexagon/hlx_helper.h b/target/hexagon/hlx_helper.h new file mode 100644 index 0000000000..ab36cc1049 --- /dev/null +++ b/target/hexagon/hlx_helper.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HEXAGON_HLX_HELPER_H +#define HEXAGON_HLX_HELPER_H + +#include "cpu.h" + +void hlx_load_vec_ra(CPUHexagonState *env, void *dst_void, + target_ulong ea, uint32_t above, uint32_t below, + uintptr_t ra); + +void hlx_store_vec_ra(CPUHexagonState *env, target_ulong ea, + void *src_void, uint32_t above, uint32_t below, + uintptr_t ra); + +#endif diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index 2748e26d6c..5799016ea4 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -22,6 +22,7 @@ #include "hex_regs.h" #include "reg_fields.h" #include "accel/tcg/getpc.h" +#include "hlx_helper.h" =20 #define GET_FIELD(FIELD, REGIN) \ fEXTRACTU_BITS(REGIN, reg_field_info[FIELD].width, \ @@ -738,8 +739,10 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val= , int shift) EA, tcg_constant_i32(ABOVE), \ tcg_constant_i32(BELOW)) #else -#define fLOADMML(EA, DST, ABOVE, BELOW) \ - do { HELPER(hlx_load_vec)(env, &(DST), (EA), (ABOVE), (BELOW)); } whil= e (0) +#define fLOADMML(EA, DST, ABOVE, BELOW) \ + do { \ + hlx_load_vec_ra(env, &(DST), (EA), (ABOVE), (BELOW), GETPC()); \ + } while (0) #endif =20 /* The helper logs the store for packet commit. */ @@ -748,8 +751,10 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val= , int shift) gen_helper_hlx_store_vec(tcg_env, EA, tcg_constant_ptr((intptr_t)&(SRC= )), \ tcg_constant_i32(ABOVE), tcg_constant_i32(BEL= OW)) #else -#define fSTOREMML(EA, SRC, ABOVE, BELOW) \ - do { HELPER(hlx_store_vec)(env, (EA), &(SRC), (ABOVE), (BELOW)); } whi= le (0) +#define fSTOREMML(EA, SRC, ABOVE, BELOW) \ + do { \ + hlx_store_vec_ra(env, (EA), &(SRC), (ABOVE), (BELOW), GETPC()); \ + } while (0) #endif =20 /* Helpers receive .new registers in future_LRegs. */ diff --git a/target/hexagon/hlx_helper.c b/target/hexagon/hlx_helper.c index c063706cfa..bc638f6403 100644 --- a/target/hexagon/hlx_helper.c +++ b/target/hexagon/hlx_helper.c @@ -7,6 +7,7 @@ #include "cpu.h" #include "accel/tcg/cpu-ldst.h" #include "exec/helper-proto.h" +#include "hlx_helper.h" #include "hlx/hlx.h" #include "hw/hexagon/hexagon_hlx.h" #include "accel/tcg/probe.h" @@ -15,40 +16,52 @@ #define HLX_MEM_ALIGN_MASK (~(HLX_VEC_SIZE_BYTES - 1)) =20 /* Align down to 2KB. Above and below are unused in V85. */ -void HELPER(hlx_load_vec)(CPUHexagonState *env, void *dst_void, - target_ulong ea, uint32_t above, uint32_t below) +void hlx_load_vec_ra(CPUHexagonState *env, void *dst_void, + target_ulong ea, uint32_t above, uint32_t below, + uintptr_t ra) { HLXVector *dst =3D (HLXVector *)dst_void; target_ulong aligned_ea =3D ea & HLX_MEM_ALIGN_MASK; - uintptr_t raddr =3D GETPC(); int mmu_idx =3D cpu_mmu_index(env_cpu(env), false); =20 /* A 2KB-aligned access stays within one page. */ - void *host =3D probe_read(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx, - raddr); + void *host =3D probe_read(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx= , ra); =20 if (host) { memcpy(dst, host, HLX_VEC_SIZE_BYTES); } else { for (int i =3D 0; i < HLX_VEC_SIZE_BYTES; i +=3D 8) { - uint64_t val =3D cpu_ldq_le_data_ra(env, aligned_ea + i, raddr= ); + uint64_t val =3D cpu_ldq_le_data_ra(env, aligned_ea + i, ra); memcpy(&dst->ub[i], &val, 8); } } } =20 -void HELPER(hlx_store_vec)(CPUHexagonState *env, target_ulong ea, - void *src_void, uint32_t above, uint32_t below) +void hlx_store_vec_ra(CPUHexagonState *env, target_ulong ea, + void *src_void, uint32_t above, uint32_t below, + uintptr_t ra) { target_ulong aligned_ea =3D ea & HLX_MEM_ALIGN_MASK; int mmu_idx =3D cpu_mmu_index(env_cpu(env), false); =20 - probe_write(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx, GETPC()); + probe_write(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx, ra); memcpy(&env->hlx_store_data, src_void, sizeof(HLXVector)); env->hlx_store_va =3D aligned_ea; env->hlx_store_pending =3D true; } =20 +void HELPER(hlx_load_vec)(CPUHexagonState *env, void *dst_void, + target_ulong ea, uint32_t above, uint32_t below) +{ + hlx_load_vec_ra(env, dst_void, ea, above, below, GETPC()); +} + +void HELPER(hlx_store_vec)(CPUHexagonState *env, target_ulong ea, + void *src_void, uint32_t above, uint32_t below) +{ + hlx_store_vec_ra(env, ea, src_void, above, below, GETPC()); +} + void HELPER(hlx_commit_store)(CPUHexagonState *env) { target_ulong va =3D env->hlx_store_va; --=20 2.52.0 From nobody Mon Nov 23 04:26:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793878896; cv=none; d=zohomail.com; s=zohoarc; b=m3+J4YD+6BA4gmENt+HaJSIH32GuIklCnvrrmS2R4Q9mfk3SDwK/XE1UChI2smuRhcoBDJvmUj2SYRc7MbiH2ZSO++6BdWw3Qqg+HMW/k/dWOqIaoRxZAcb4UdzeweXEUc7YcvDg8rAZ/MSVf2Lr+YXyTFNBMH86Ccsr7MzoVS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793878896; h=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:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=Dm7yRTs9+WTDMpbYYDlub46jSLGEtOdO/ql88BsjPWk=; b=nxGKbYG84moW3AcncoMzoMsEHL8EU1GDhcfFPYx2Siki+v+84lYDOv09/lfRpRlCZOk2iJESgmz4IYRVkIYYZBWHpbcfJY/UAvzc1AdiJIoueJCnC1F+Hh2pvgwnaKSVOx6K0YS6CMLeF2nzqnwCQgzZjm9dbuZSoVSfrp5ct5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1793878896660619.4389062388333; Thu, 5 Nov 2026 03:41:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOvqM-0002Lu-B4; Thu, 05 Nov 2026 06:41:22 -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 1xOvqE-0002Kh-KM for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:18 -0500 Received: from rev.ng ([94.130.142.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOvqC-0005ID-Nu for qemu-devel@nongnu.org; Thu, 05 Nov 2026 06:41:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive:List-Unsubscribe:List-Unsubscribe-Post: List-Help; bh=Dm7yRTs9+WTDMpbYYDlub46jSLGEtOdO/ql88BsjPWk=; b=jX6BJtKjlJh9kr1 yVFjaBl+faxg1zEcewd80o0PWRb9dplxvf+h/MFPHhhfNRlLuZez+k6PpKNF8CknJl6VDvgEHh9CL KHqtjN3evBlcLfW3DO1X8ThhhM1wOSSCyu3qGWqbXTHmh0SjwxWn6zKyyfXJF+pKRGKsEWnxa+0Ig bQ=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v2 4/4] linux-user/hexagon: Reset hlx_ctx pointer on cpu clone Date: Thu, 5 Nov 2026 12:46:33 +0100 Message-ID: <20261105114633.597-5-anjo@rev.ng> In-Reply-To: <20261105114633.597-1-anjo@rev.ng> References: <20261105114633.597-1-anjo@rev.ng> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=94.130.142.21; envelope-from=anjo@rev.ng; helo=rev.ng 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_PASS=-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: , Reply-to: Anton Johansson From: Anton Johansson via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1793878898351158500 Content-Type: text/plain; charset="utf-8" Currently hlx_ctx retains the pointer to the hlx_user_ctx of its parent. Another way to go is similar to hvx_ctx, which in user-mode, is just the struct itself rather than a pointer to the struct. Fixes: cf0bfbc338eaeef2b ("target/hexagon: manage HLX contexts through CCR") Signed-off-by: Anton Johansson Reviewed-by: Marco Liebel --- linux-user/hexagon/target_cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/hexagon/target_cpu.h b/linux-user/hexagon/target_cp= u.h index ecb76e9268..6c36b7166f 100644 --- a/linux-user/hexagon/target_cpu.h +++ b/linux-user/hexagon/target_cpu.h @@ -25,6 +25,7 @@ static inline void cpu_clone_regs_child(CPUHexagonState *= env, env->gpr[HEX_REG_SP] =3D newsp; } env->gpr[0] =3D 0; + env->hlx_ctx =3D &env->hlx_user_ctx; } =20 static inline void cpu_clone_regs_parent(CPUHexagonState *env, unsigned fl= ags) --=20 2.52.0