From nobody Mon Nov 23 04:27:58 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=1794525463; cv=none; d=zohomail.com; s=zohoarc; b=YKsLz6N93cpr1P2RiBUi4qotHYgCZ39R7iLrpM1UzGZzFYxWv4ZOujuWoGHGt/1XRH53xWKu10pDs5PO41OOrHUS8hJoNHGVj3nJR8gwSU2Xs794WTtdPPc03hWjW6EWXoVWFzmbTXzxuJQAj69EEzgv+ya/GwLQtnN0mUVERs4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794525463; 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=xIvqupr19xUTXm40pMHZbgPcROBIpc7vo1h8khhUxvo=; b=ErSiwg90x0ArteYsZU8VVdV6orBt1o/bJ1yAEhLtx/qrtk/wkT0NQHvJoWoSBKDUzzxRH0LKL8jEW6m/a5WvMZAs28atc9n7U9xtV88dVlD+MgXam48hpXTDrqxt10XfkapISwnedC9gSDt4ENUH1+bMFmS9WUr9036G41eXD48= 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 1794525463643882.7761619662491; Thu, 12 Nov 2026 15:17:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRe2M-00076b-3T; Thu, 12 Nov 2026 18:16:58 -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 1xRe2I-00075x-Uj for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:55 -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 1xRe2H-0001Tl-AI for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:54 -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=xIvqupr19xUTXm40pMHZbgPcROBIpc7vo1h8khhUxvo=; b=TdkxRJ5z5vIYaj5 n5Cz8Y6L8uEnCl2V0bY+pmLcxwOoIyWvZE1wcpaEQP8OcHGaxpBycuhu9RhfztDya37pUTSgFxUMx PK9ujqbz3KBjkEtmFft2zbGkvSjPmqSkRFdrAGxTFf9rUOYXCA8B/rSBT9FdjH6yPmVZ3ZixqsZ79 Ik=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v3 1/4] target/hexagon: HLX, preserve scalar :mem_noshuf ordering Date: Fri, 13 Nov 2026 00:20:29 +0100 Message-ID: <20261112232032.396-2-anjo@rev.ng> In-Reply-To: <20261112232032.396-1-anjo@rev.ng> References: <20261112232032.396-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: 1794525464705158500 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..c0844646a0 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(%[ptr]) =3D %[val]\n" + " %[ret] =3D memw(%[ptr])\n" + "}:mem_noshuf\n" + : [ret] "=3Dr"(ret) + : [ptr] "r"(&ptr), [val] "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:27:58 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=1794525478; cv=none; d=zohomail.com; s=zohoarc; b=nBTdv+DKrHleMlSpsOUTq0s7ehHQGpoK+ubGkR4ILCjTxf9UVt2GgANah92Eb3U90qD03nGOnBUVMLjPk6aqHtR2zBwk4Ses6Yb2HyA+WbihM2MscrRAlKHrLfq6A+cYBWG9fdioGYQtGGa9Q4TjeWEnLcR3r/jW6F/nYuUUY5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794525478; 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=5S1OizVelwL+bqSVutpwpAknO5FjBS0yU0F8ElER32o=; b=QjZlNT3eKDQLyfCmbtUzRTdRkh7PK++RzjfJdD4mePohFKLpWXeU36gVQIGLWZyHOd6+Hf58mCESTUdKjwcFaDsNP46UeA+OSwXKFmzKb11aNjm8hMxgi7RE6k7zOM9L5hwcWvt6gTf1k49o5OdvQEO5gRdGp/oHmN3ANmiV+Kc= 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 1794525478032350.85639657806655; Thu, 12 Nov 2026 15:17:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRe2R-00077i-IS; Thu, 12 Nov 2026 18:17:03 -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 1xRe2M-00076e-5Z for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:58 -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 1xRe2K-0001Tv-71 for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:57 -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=5S1OizVelwL+bqSVutpwpAknO5FjBS0yU0F8ElER32o=; b=nuGbPPIQFm3ULsi svnKXW6A37UJ48kya0sCRgodmdfbFQrDugf9t2r6CAEG6aun44ShSWk7c1KEywCqaGyzSnkijWArU QwpPyAN/uSz2AEyDNMCyKMpZpIt9Jkdbi8iJ+XZ7o6QWJA51o0Y/nWYUF6ztFfplPjincMDBm7f2a vI=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v3 2/4] target/hexagon: HLX, search for .new values in pair high register Date: Fri, 13 Nov 2026 00:20:30 +0100 Message-ID: <20261112232032.396-3-anjo@rev.ng> In-Reply-To: <20261112232032.396-1-anjo@rev.ng> References: <20261112232032.396-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: 1794525478689158500 Content-Type: text/plain; charset="utf-8" Otherwise, the following packet { L7:6 =3D combine(L0, L2) mem(R7) =3D L7.new } results in mem(R7) being zero-initialized, compared to L6.new which would correctly write the lower bytes of the pair. Compared to scalar and HVX .new instructions, HLX encodes the register number rather than an offset to the producing instruction + an odd/even bit. In order to find possible producers which write to register pairs without the odd/even bit, a Instruction::has_pair_dest field is added for scalar, HVX, and HLX registers. Lastly, we move the new-regno patching in decode_fill_newvalue_regno() to the non-HLX scalar path to avoid overwriting the consumer L7 with the base register L6 of the producer destination L7:6. This is safe as the patching is only required for replacing the scalar offset+odd/even bit with the actual producer. Fixes: ef81d1b047337e81 ("target/hexagon: decode HLX packets and add load a= nd store") Signed-off-by: Anton Johansson Reviewed-by: Brian Cain Reviewed-by: Marco Liebel --- target/hexagon/insn.h | 1 + target/hexagon/decode.c | 29 +++++++++++++++++++----- tests/tcg/hexagon/hlx_assign_conv.c | 35 +++++++++++++++++++++++++++++ target/hexagon/gen_trans_funcs.py | 5 +++++ target/hexagon/hex_common.py | 2 ++ 5 files changed, 66 insertions(+), 6 deletions(-) diff --git a/target/hexagon/insn.h b/target/hexagon/insn.h index 0dd36d2931..37a3111374 100644 --- a/target/hexagon/insn.h +++ b/target/hexagon/insn.h @@ -42,6 +42,7 @@ struct Instruction { int32_t new_read_idx; int32_t dest_idx; bool has_pred_dest; + bool has_pair_dest; =20 bool part1; /* * cmp-jumps are split into two insns. diff --git a/target/hexagon/decode.c b/target/hexagon/decode.c index d48630da87..08fa9aee2a 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 || + (insn->has_pair_dest && regno + 1 =3D=3D lreg)) { return i; } } @@ -172,12 +188,13 @@ decode_fill_newvalue_regno(Packet *packet) if (def_idx < 0 || packet->insn[def_idx].dest_idx =3D=3D -= 1) { return false; } + + /* Now patch up the consumer with the register number */ + dst_idx =3D packet->insn[def_idx].dest_idx; + packet->insn[i].regno[use_regidx] =3D + packet->insn[def_idx].regno[dst_idx]; } =20 - /* Now patch up the consumer with the register number */ - dst_idx =3D packet->insn[def_idx].dest_idx; - packet->insn[i].regno[use_regidx] =3D - packet->insn[def_idx].regno[dst_idx]; /* * We need to remember who produces this value to later * check if it was dynamically cancelled diff --git a/tests/tcg/hexagon/hlx_assign_conv.c b/tests/tcg/hexagon/hlx_as= sign_conv.c index 8192882b8e..bca902a6e5 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, L2) + * mem(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_B; + } + 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(); diff --git a/target/hexagon/gen_trans_funcs.py b/target/hexagon/gen_trans_f= uncs.py index 93125bdfe4..7e65438565 100755 --- a/target/hexagon/gen_trans_funcs.py +++ b/target/hexagon/gen_trans_funcs.py @@ -74,6 +74,7 @@ def mark_which_imm_extended(f, tag): ## insn->new_read_idx =3D -1; ## insn->dest_idx =3D 0; ## insn->has_pred_dest =3D false; +## insn->has_pair_dest =3D false; ## return true; ## } ## @@ -94,6 +95,7 @@ def gen_trans_funcs(f): dest_idx =3D -1 dest_idx_reg_id =3D None has_pred_dest =3D "false" + has_pair_dest =3D "false" for regno, (reg_type, reg_id, *_) in enumerate(regs): reg =3D hex_common.get_register(tag, reg_type, reg_id) f.write(code_fmt(f"""\ @@ -108,6 +110,8 @@ def gen_trans_funcs(f): dest_idx_reg_id =3D reg_id if reg_type =3D=3D "P" and reg.is_written() and not reg.is_rea= d(): has_pred_dest =3D "true" + if reg.is_written() and reg.is_pair(): + has_pair_dest =3D "true" =20 if len(imms) !=3D 0: mark_which_imm_extended(f, tag) @@ -132,6 +136,7 @@ def gen_trans_funcs(f): insn->new_read_idx =3D {new_read_idx}; insn->dest_idx =3D {dest_idx}; insn->has_pred_dest =3D {has_pred_dest}; + insn->has_pair_dest =3D {has_pair_dest}; """)) f.write(textwrap.dedent(f"""\ return true; diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index f85f063f52..8d68d8dad9 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -805,6 +805,8 @@ def is_hvx_reg(self): return True def is_hlx_reg(self): return False + def is_pair(self): + return len(self.regid) =3D=3D 2 def hvx_off(self): return f"{self.reg_tcg()}_off" def hvx_base(self): --=20 2.52.0 From nobody Mon Nov 23 04:27:58 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=1794525481; cv=none; d=zohomail.com; s=zohoarc; b=fh4DPt9uzA1ipAWqSwOAObMz3adMhRzrCigEUduKALMM1NH8gcR7o9tvdP3A/KisZzrZE2egs0BuUpwUGxHNwUKh/nd91qnwWjRLnxtbdKbTPCJhqiF7LMn7aMDfRC92+P8L5Y6fy6VFPF/9cvG0jl7vRGMk0iAJtWpWayYUbpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794525481; 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=9irHMgZ9xnAb96XhcwIPDB9gNKGWCcYEIqFeIoCp164=; b=g4ss6Ks7vWfk6+dx7VJVlf/hKhm2g9c+HnqQ4V6L2394UDBmWwb1d1Zd9bgJckbMKtBWYI9K/lroJGshVYllt4yy0Rj5RtLhyM12Es6XQK7OPdkttKe35Vsz22Ub+5GK7SFfC1VzSq0dkVF1RQtB2By0HbOhYLgYR8Y3W661jV8= 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 1794525481010721.8141897410981; Thu, 12 Nov 2026 15:18:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRe2O-00076u-NO; Thu, 12 Nov 2026 18:17:00 -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 1xRe2I-00075y-Sq for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:55 -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 1xRe2H-0001U4-3l for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:54 -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=9irHMgZ9xnAb96XhcwIPDB9gNKGWCcYEIqFeIoCp164=; b=Z445TOlTDA6aJtT EM1x33g+ODJmGnQFEZ1H6iTxdVt43P2KA6np7V1MsTLq2+aomaFTzOjP1qOreEWD5iJSP0ElmPVau TYUHns+bGrY9mXmJaiOBFC8XenHUWnfb4WWDnnA8DR86tZgcFvb6o031dX9hrI/mEVxPSnILHihgQ 20=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v3 3/4] target/hexagon: Forward return address to HLX load/store helpers Date: Fri, 13 Nov 2026 00:20:31 +0100 Message-ID: <20261112232032.396-4-anjo@rev.ng> In-Reply-To: <20261112232032.396-1-anjo@rev.ng> References: <20261112232032.396-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: 1794525482603158500 Content-Type: text/plain; charset="utf-8" Fixes: 2db29a3615a5ad2a3 ("target/hexagon: add HLX helper support") Signed-off-by: Anton Johansson Reviewed-by: Marco Liebel Reviewed-by: Brian Cain --- 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:27:58 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=1794525461; cv=none; d=zohomail.com; s=zohoarc; b=c5O5h4ig2xMWxOxpTl3n68IxIAVxPg90HAHLpgM8hRnWFdu7wUB3u9DFyj+x8tfFcbH1j7PKwIwE1sdJJ673FljrFSsiqaHhLfGLtq/6f7vZY6YOcR9OqqlGvbyA6N6J6fFZAbUEq/CSqHwB8Zv1AlIdx74lFHhAY38zeoYJ6LU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794525461; 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=eBYJbjVF0YLZiSBfeYvWiwi2LgyBsdccQo6pCjwxG5vszJnjDKABCS2brulLhNgdQVcow34v93xgO7ScxuOfWGp3Mjy3YVPKVGtGd/dOK4PQ3ewThqUQ7JeQ0toLOyPPOa5v2AFTT3FTduEcBGcrbSCy5x95vI/1ja3KrijDf/0= 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 1794525461626588.4316477370852; Thu, 12 Nov 2026 15:17:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRe2S-00077n-Ab; Thu, 12 Nov 2026 18:17:04 -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 1xRe2M-00076d-4t for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:58 -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 1xRe2K-0001UN-GO for qemu-devel@nongnu.org; Thu, 12 Nov 2026 18:16:57 -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=nR7DHXJ/wvan0nw JYnAMeZBwPtUP5qt6MgXvbqJ4aiaU8RkgcHK4G4gH2s5oBRNYwoHYfIDoFz+klhEsxOMgWb5teDqj m1qsid5vGu5BMHts2FgB8ZwRC+ZmoKYOBPu7r8OUd4wG7RplGHpNAa+UzggkGVjiZ8CtPsBcpiQ80 Io=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH v3 4/4] linux-user/hexagon: Reset hlx_ctx pointer on cpu clone Date: Fri, 13 Nov 2026 00:20:32 +0100 Message-ID: <20261112232032.396-5-anjo@rev.ng> In-Reply-To: <20261112232032.396-1-anjo@rev.ng> References: <20261112232032.396-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: 1794525464811158500 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 Reviewed-by: Brian Cain --- 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