From: Brian Cain <brian.cain@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: Fabiano Rosas <farosas@suse.de>,
Brian Cain <brian.cain@oss.qualcomm.com>,
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
Laurent Vivier <lvivier@redhat.com>, Peter Xu <peterx@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Marco Liebel <marco.liebel@oss.qualcomm.com>
Subject: [PATCH-for-11.2 v2 01/12] target/hexagon: read the old predicate value through C4
Date: Fri, 20 Nov 2026 10:20:20 -0800 [thread overview]
Message-ID: <20261120182031.560481-2-brian.cain@oss.qualcomm.com> (raw)
In-Reply-To: <20261120182031.560481-1-brian.cain@oss.qualcomm.com>
From: Marco Liebel <marco.liebel@oss.qualcomm.com>
Track C4 reads as reads of all four predicates. This prevents the
packet short circuit from exposing a predicate result to an old-value
control register read.
Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
target/hexagon/translate.h | 6 +++++-
tests/tcg/hexagon/packet_user.c | 38 +++++++++++++++++++++++++++++++++
tests/tcg/hexagon/meson.build | 1 +
3 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644 tests/tcg/hexagon/packet_user.c
diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h
index bc3b49ab06d..c988c85f33b 100644
--- a/target/hexagon/translate.h
+++ b/target/hexagon/translate.h
@@ -248,7 +248,11 @@ static inline void ctx_log_reg_write_pair(DisasContext *ctx, int rnum,
static inline void ctx_log_reg_read(DisasContext *ctx, int rnum)
{
- if (test_bit(rnum, ctx->regs_written)) {
+ if (rnum == HEX_REG_P3_0_ALIASED) {
+ for (int i = 0; i < NUM_PREGS; i++) {
+ ctx_log_pred_read(ctx, i);
+ }
+ } else if (test_bit(rnum, ctx->regs_written)) {
ctx->read_after_write = true;
}
}
diff --git a/tests/tcg/hexagon/packet_user.c b/tests/tcg/hexagon/packet_user.c
new file mode 100644
index 00000000000..acc77202ef3
--- /dev/null
+++ b/tests/tcg/hexagon/packet_user.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+static int err;
+
+#include "hex_test.h"
+
+static void test_predicate_read(void)
+{
+ unsigned old, new;
+
+ asm volatile(
+ "r0 = #0x12\n"
+ "p3:0 = r0\n"
+ "{\n"
+ " p0 = cmp.eq(r0,r0)\n"
+ " %[old] = p3:0\n"
+ "}\n"
+ "%[new] = p3:0\n"
+ : [old] "=r"(old), [new] "=r"(new)
+ : : "r0", "p0", "p1", "p2", "p3"
+ );
+ /* Packet reads old C4, then commits P0. */
+ check32(old, 0x12);
+ check32(new, 0xff);
+}
+
+int main(void)
+{
+ test_predicate_read();
+ puts(err ? "FAIL" : "PASS");
+ return err != 0;
+}
diff --git a/tests/tcg/hexagon/meson.build b/tests/tcg/hexagon/meson.build
index 70f6475656c..b3635be3fcb 100644
--- a/tests/tcg/hexagon/meson.build
+++ b/tests/tcg/hexagon/meson.build
@@ -96,6 +96,7 @@ tests += {
'misc.c': {'cflags': [cflags, '-mv71', '-O2']},
'multiple-writes.c': {'cflags': [cflags, '-mhvx']},
'overflow.c': {'cflags': cflags, 'exe_name': 'hex-overflow'},
+ 'packet_user.c': {'cflags': [cflags, '-O2']},
'preg_alias.c': {'cflags': cflags},
'dual_stores.c': {'cflags': cflags},
'framekey.c': {'cflags': cflags},
--
2.34.1
next prev parent reply other threads:[~2026-11-20 18:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 18:20 [PATCH-for-11.2 v2 00/12] Hexagon: fix systests + migration Brian Cain
2026-11-20 18:20 ` Brian Cain [this message]
2026-11-20 18:20 ` [PATCH-for-11.2 v2 02/12] target/hexagon: bound packet lookahead to the current page Brian Cain
2026-11-20 18:20 ` [PATCH-for-11.2 v2 03/12] target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread Brian Cain
2026-11-23 17:51 ` Pierrick Bouvier
2026-11-20 18:20 ` [PATCH-for-11.2 v2 04/12] target/hexagon: deliver floating point exceptions after the packet Brian Cain
2026-11-23 17:52 ` Pierrick Bouvier
2026-11-20 18:20 ` [PATCH-for-11.2 v2 05/12] target/hexagon: report the faulting packet for stack limit exceptions Brian Cain
2026-11-23 18:01 ` Pierrick Bouvier
2026-11-20 18:20 ` [PATCH-for-11.2 v2 06/12] target/hexagon: take exceptions for cache operations Brian Cain
2026-11-23 18:02 ` Pierrick Bouvier
2026-11-23 19:11 ` Brian Cain
2026-11-20 18:20 ` [PATCH-for-11.2 v2 07/12] target/hexagon: raise decode failures at the faulting packet Brian Cain
2026-11-23 18:03 ` Pierrick Bouvier
2026-11-20 18:20 ` [PATCH-for-11.2 v2 08/12] hw/hexagon: update the glob-reg vmstate ver Brian Cain
2026-11-23 18:04 ` Pierrick Bouvier
2026-11-20 18:20 ` [PATCH-for-11.2 v2 09/12] tests/functional/hexagon: run the rest of the tests Brian Cain
2026-11-20 18:20 ` [PATCH-for-11.2 v2 10/12] tests/tcg/hexagon: packet and COF corner cases Brian Cain
2026-11-23 18:06 ` Pierrick Bouvier
2026-11-23 19:08 ` Brian Cain
2026-11-20 18:20 ` [PATCH-for-11.2 v2 11/12] hw/hexagon: honor configured RAM backends Brian Cain
2026-11-23 18:08 ` Pierrick Bouvier
2026-11-20 18:20 ` [PATCH-for-11.2 v2 12/12] hw/hexagon: version the virt machine type Brian Cain
2026-11-23 17:37 ` Pierrick Bouvier
2026-11-23 17:47 ` Daniel P. Berrangé
2026-11-23 19:03 ` Brian Cain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120182031.560481-2-brian.cain@oss.qualcomm.com \
--to=brian.cain@oss.qualcomm.com \
--cc=farosas@suse.de \
--cc=lvivier@redhat.com \
--cc=marco.liebel@oss.qualcomm.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.