All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH-for-11.2 00/14] Hexagon: fix systests + migration
@ 2026-11-19 20:15 Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 01/14] target/hexagon: read the old predicate value through C4 Brian Cain
                   ` (14 more replies)
  0 siblings, 15 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

The systests/arch tarballs were crafted while testing a downstream fork.

Enabling the omitted tests revealed a few remaining bugs in 11.2.  Add
those tests and the associated fixes, plus a couple of fixes from Marco's
recent series.

Brian Cain (12):
  target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread
  target/hexagon: deliver floating point exceptions after the packet
  target/hexagon: report the faulting packet for stack limit exceptions
  target/hexagon: take exceptions for cache operations
  target/hexagon: raise decode failures at the faulting packet
  hw/hexagon: update the glob-reg vmstate ver
  tests/functional/hexagon: run the rest of the tests
  tests/tcg/hexagon: packet and COF corner cases
  hw/hexagon: honor configured RAM backends
  hw/hexagon: version the virt machine type
  tests/qtest/migration: add Hexagon to the migration framework
  tests/qtest: add a Hexagon migration state test

Marco Liebel (2):
  target/hexagon: read the old predicate value through C4
  target/hexagon: bound packet lookahead to the current page

 MAINTAINERS                                 |   2 +
 docs/system/hexagon/machines.rst            |   3 +
 target/hexagon/gen_tcg.h                    |  18 +-
 target/hexagon/helper.h                     |   4 +-
 target/hexagon/translate.h                  |   6 +-
 tests/qtest/migration/bootfile.h            |   6 +
 tests/qtest/migration/hexagon/a-b-kernel.h  |  21 ++
 tests/qtest/migration/hexagon/guest.h       |  47 +++
 tests/qtest/migration/hexagon/state.h       |  29 ++
 hw/hexagon/hex-subsys.c                     |  10 +-
 hw/hexagon/hexagon_globalreg.c              |   4 +-
 hw/hexagon/virt.c                           |  37 +++
 target/hexagon/arch.c                       |   9 +-
 target/hexagon/cpu_helper.c                 |   1 +
 target/hexagon/genptr.c                     |   3 +-
 target/hexagon/hexswi.c                     |   1 +
 target/hexagon/op_helper.c                  |  46 ++-
 target/hexagon/translate.c                  |  28 +-
 tests/qtest/hexagon-config-test.c           |  26 ++
 tests/qtest/hexagon-migration-test.c        | 312 ++++++++++++++++++++
 tests/qtest/migration/bootfile.c            |   4 +
 tests/qtest/migration/framework.c           |   8 +
 tests/tcg/hexagon/brev.c                    |  25 ++
 tests/tcg/hexagon/circ.c                    |  42 +++
 tests/tcg/hexagon/dual_stores.c             |  34 +++
 tests/tcg/hexagon/mem_noshuf.c              |  58 +++-
 tests/tcg/hexagon/packet_user.c             |  38 +++
 tests/tcg/hexagon/preg_alias.c              |  58 ++++
 tests/tcg/hexagon/test_cond_branch.c        |  95 ++++++
 tests/tcg/hexagon/usr.c                     |  33 +++
 tests/functional/hexagon/meson.build        |   2 +
 tests/functional/hexagon/test_arch_tests.py | 114 ++++++-
 tests/functional/hexagon/test_linux.py      |  62 ++++
 tests/functional/hexagon/test_systests.py   | 259 +++++++++++++++-
 tests/qtest/meson.build                     |   5 +-
 tests/qtest/migration/Makefile              |   2 +-
 tests/qtest/migration/hexagon/Makefile      |  48 +++
 tests/qtest/migration/hexagon/a-b-kernel.S  |  37 +++
 tests/qtest/migration/hexagon/guest.S       | 124 ++++++++
 tests/tcg/hexagon/meson.build               |   1 +
 tests/tcg/hexagon/test_dotnew.S             |  34 ++-
 tests/tcg/hexagon/test_packet.S             |  46 ++-
 42 files changed, 1700 insertions(+), 42 deletions(-)
 create mode 100644 tests/qtest/migration/hexagon/a-b-kernel.h
 create mode 100644 tests/qtest/migration/hexagon/guest.h
 create mode 100644 tests/qtest/migration/hexagon/state.h
 create mode 100644 tests/qtest/hexagon-migration-test.c
 create mode 100644 tests/tcg/hexagon/packet_user.c
 create mode 100755 tests/functional/hexagon/test_linux.py
 create mode 100644 tests/qtest/migration/hexagon/Makefile
 create mode 100644 tests/qtest/migration/hexagon/a-b-kernel.S
 create mode 100644 tests/qtest/migration/hexagon/guest.S

-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 01/14] target/hexagon: read the old predicate value through C4
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 02/14] target/hexagon: bound packet lookahead to the current page Brian Cain
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu, Marco Liebel

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>
---
 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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 02/14] target/hexagon: bound packet lookahead to the current page
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 01/14] target/hexagon: read the old predicate value through C4 Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 03/14] target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread Brian Cain
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu, Marco Liebel

From: Marco Liebel <marco.liebel@oss.qualcomm.com>

Do not fetch an unmapped page while deciding where to end a TB.
This lets complete packets retire before a straddling packet faults,
and preserves the correct packet restart address.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
 target/hexagon/translate.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index ec1d79e31f6..41a0f2b0852 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -1620,6 +1620,11 @@ static bool pkt_crosses_page(CPUHexagonState *env, DisasContext *ctx)
     int nwords;
 
     for (nwords = 0; !found_end && nwords < PACKET_WORDS_MAX; nwords++) {
+        /* Look ahead only on this page; a fault must not discard this TB. */
+        if (ctx->base.pc_next + nwords * sizeof(uint32_t) - page_start >=
+            TARGET_PAGE_SIZE) {
+            return true;
+        }
         uint32_t word = translator_ldl_end(env, &ctx->base,
                                            ctx->base.pc_next
                                            + nwords * sizeof(uint32_t),
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 03/14] target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 01/14] target/hexagon: read the old predicate value through C4 Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 02/14] target/hexagon: bound packet lookahead to the current page Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 04/14] target/hexagon: deliver floating point exceptions after the packet Brian Cain
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

When a thread in WAIT mode (W=1, E=1) executes a STOP instruction,
hexagon_stop_thread must clear the wait-mode bit before clearing
the enable bit.  Without this, clear_enable_mask creates a transient
(W=1, E=0) state in MODECTL that triggers g_assert_not_reached() in
get_exe_mode() when another thread iterates all CPUs via
hex_interrupt_update.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/cpu_helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/hexagon/cpu_helper.c b/target/hexagon/cpu_helper.c
index f53d377ab14..680dcf56803 100644
--- a/target/hexagon/cpu_helper.c
+++ b/target/hexagon/cpu_helper.c
@@ -441,6 +441,7 @@ void hexagon_stop_thread(CPUHexagonState *env)
 
     BQL_LOCK_GUARD();
 
+    clear_wait_mode(env);
     thread_enabled_mask = clear_enable_mask(env);
     cs = env_cpu(env);
     cpu_interrupt(cs, CPU_INTERRUPT_HALT);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 04/14] target/hexagon: deliver floating point exceptions after the packet
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (2 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 03/14] target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 05/14] target/hexagon: report the faulting packet for stack limit exceptions Brian Cain
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

An unmasked floating point exception used to take the exception in the
middle of the packet, with whatever PC was last written.  The
architecture takes it after the packet commits, like trap0, so pend it
the way the TLB pends an imprecise exception and raise it at the end of
the packet.  Report ELR as the last word of the packet so that a handler
resumes at the next packet by advancing ELR by one word.

This enables the float_excp systest.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/arch.c                     |  9 +++++----
 target/hexagon/hexswi.c                   |  1 +
 target/hexagon/translate.c                | 10 ++++++++--
 tests/functional/hexagon/test_systests.py |  5 +++++
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/target/hexagon/arch.c b/target/hexagon/arch.c
index 5ee87b320b6..ddbcba9cdd0 100644
--- a/target/hexagon/arch.c
+++ b/target/hexagon/arch.c
@@ -214,13 +214,14 @@ void arch_fpop_start(CPUHexagonState *env)
  */
 #define RAISE_FP_EXCEPTION   do {} while (0)
 #else
+/*
+ * Floating point exceptions are taken after the packet that caused them
+ * commits, so pend this one for check_imprecise_exception().
+ */
 #define RAISE_FP_EXCEPTION \
     do { \
-        CPUState *cs = env_cpu(env); \
-        cs->exception_index = HEX_EVENT_FPTRAP; \
+        env->imprecise_exception = HEX_EVENT_FPTRAP; \
         env->cause_code = HEX_CAUSE_FPTRAP_CAUSE_BADFLOAT; \
-        do_raise_exception(env, cs->exception_index, \
-                           env->gpr[HEX_REG_PC], 0); \
     } while (0)
 #endif
 
diff --git a/target/hexagon/hexswi.c b/target/hexagon/hexswi.c
index acc68aa6c23..96d4a783ed4 100644
--- a/target/hexagon/hexswi.c
+++ b/target/hexagon/hexswi.c
@@ -972,6 +972,7 @@ void hexagon_cpu_do_interrupt(CPUState *cs)
         break;
 
     case HEX_EVENT_FPTRAP:
+        env->imprecise_exception = 0;
         if (event_to_guest(env, CCR_GEE)) {
             guest_event_entry(env, env->cause_code, env->gpr[HEX_REG_PC],
                               HEX_GEVB_HW_FPTRAP, false);
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index 41a0f2b0852..eef392b1e9c 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -1345,11 +1345,17 @@ static void update_exec_counters(DisasContext *ctx)
 #ifndef CONFIG_USER_ONLY
 /*
  * A tlbp instruction may detect multiple TLB matches and set a pending
- * imprecise exception.  Raise it after the packet that ran the tlbp.
+ * imprecise exception, and a floating point instruction may set a pending
+ * floating point exception.  Raise them after the packet that caused them.
+ *
+ * A floating point exception establishes the exception point after the
+ * packet, like trap0.  ELR is the last word of the packet, so a handler
+ * resumes at the next packet by advancing ELR by one word.
  */
 static void check_imprecise_exception(DisasContext *ctx)
 {
-    TCGv PC = tcg_constant_tl(ctx->pkt.pc);
+    TCGv PC = tcg_constant_tl(check_for_attrib(&ctx->pkt, A_FPOP) ?
+                              ctx->next_PC - 4 : ctx->pkt.pc);
     TCGLabel *label = gen_new_label();
 
     tcg_gen_brcondi_tl(TCG_COND_EQ, hex_imprecise_exception, 0, label);
diff --git a/tests/functional/hexagon/test_systests.py b/tests/functional/hexagon/test_systests.py
index 76e2480c1d3..606567230b9 100755
--- a/tests/functional/hexagon/test_systests.py
+++ b/tests/functional/hexagon/test_systests.py
@@ -82,6 +82,11 @@ def test_ftrunc(self):
         self.assertEqual(os.path.getsize(ftrunc_path), 1,
                          "_testfile_ftrunc should be 1 byte after ftrunc")
 
+    def test_float_excp(self):
+        """Unmasked floating point exceptions are taken after the packet
+        that caused them commits."""
+        self.run_exit_zero("float_excp")
+
     def test_access(self):
         """access checks R_OK|W_OK on _testfile_access."""
         testfile = self.scratch_file("_testfile_access")
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 05/14] target/hexagon: report the faulting packet for stack limit exceptions
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (3 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 04/14] target/hexagon: deliver floating point exceptions after the packet Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 06/14] target/hexagon: take exceptions for cache operations Brian Cain
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

The stack limit check raised the exception from a helper without
updating the PC register, which is not kept current while a packet runs.
The exception's ELR was whatever PC was last written, so a handler that
skipped the faulting allocframe resumed at an earlier packet and took
the same exception forever.  Pass the packet's PC to the helper.

This enables the framelimit systest.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/helper.h                   | 2 +-
 target/hexagon/genptr.c                   | 3 ++-
 target/hexagon/op_helper.c                | 4 +++-
 tests/functional/hexagon/test_systests.py | 5 +++++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h
index 292ca8eb7c5..e658f8068f4 100644
--- a/target/hexagon/helper.h
+++ b/target/hexagon/helper.h
@@ -158,7 +158,7 @@ DEF_HELPER_5(insn_cache_op, void, env, i32, int, int, i32)
 #endif
 
 #if !defined(CONFIG_USER_ONLY)
-DEF_HELPER_3(raise_stack_overflow, void, env, i32, i32)
+DEF_HELPER_4(raise_stack_overflow, void, env, i32, i32, i32)
 DEF_HELPER_2(swi, void, env, i32)
 DEF_HELPER_2(cswi, void, env, i32)
 DEF_HELPER_2(ciad, void, env, i32)
diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c
index 52615628e3f..90b71ebc016 100644
--- a/target/hexagon/genptr.c
+++ b/target/hexagon/genptr.c
@@ -1156,7 +1156,8 @@ void gen_framecheck(DisasContext *ctx, TCGv_i32 addr, TCGv_i32 ea)
     TCGLabel *ok = gen_new_label();
     tcg_gen_brcond_i32(TCG_COND_GEU, addr, hex_gpr[HEX_REG_FRAMELIMIT], ok);
     gen_helper_raise_stack_overflow(tcg_env,
-                                   tcg_constant_i32(ctx->insn->slot), ea);
+                                    tcg_constant_i32(ctx->insn->slot), ea,
+                                    tcg_constant_i32(ctx->pkt.pc));
     gen_set_label(ok);
 #endif
 }
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
index 71b27ef07f1..cdb731160eb 100644
--- a/target/hexagon/op_helper.c
+++ b/target/hexagon/op_helper.c
@@ -1660,7 +1660,7 @@ void HELPER(vwhist128qm)(CPUHexagonState *env, int32_t uiV)
 
 #ifndef CONFIG_USER_ONLY
 void HELPER(raise_stack_overflow)(CPUHexagonState *env, uint32_t slot,
-                                  uint32_t badva)
+                                  uint32_t badva, uint32_t pc)
 {
     /*
      * Per section 7.3.1 of the V67 Programmer's Reference,
@@ -1677,6 +1677,8 @@ void HELPER(raise_stack_overflow)(CPUHexagonState *env, uint32_t slot,
     cs = env_cpu(env);
     cs->exception_index = HEX_EVENT_PRECISE;
     env->cause_code = HEX_CAUSE_STACK_LIMIT;
+    /* The PC register is not kept current, ELR is the faulting packet */
+    env->gpr[HEX_REG_PC] = pc;
 
     if (slot == 0) {
         env->t_sreg[HEX_SREG_BADVA0] = badva;
diff --git a/tests/functional/hexagon/test_systests.py b/tests/functional/hexagon/test_systests.py
index 606567230b9..f997563baca 100755
--- a/tests/functional/hexagon/test_systests.py
+++ b/tests/functional/hexagon/test_systests.py
@@ -87,6 +87,11 @@ def test_float_excp(self):
         that caused them commits."""
         self.run_exit_zero("float_excp")
 
+    def test_framelimit(self):
+        """allocframe past FRAMELIMIT in user mode raises the stack limit
+        exception at the allocframe packet."""
+        self.run_exit_zero("framelimit")
+
     def test_access(self):
         """access checks R_OK|W_OK on _testfile_access."""
         testfile = self.scratch_file("_testfile_access")
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 06/14] target/hexagon: take exceptions for cache operations
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (4 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 05/14] target/hexagon: report the faulting packet for stack limit exceptions Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 07/14] target/hexagon: raise decode failures at the faulting packet Brian Cain
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

The dcinva, dccleaninva, dccleana and icinva instructions did nothing
in system mode, but the hardware translates their address.  A data cache
operation takes a TLB miss exception if the address is unmapped, and a
privilege exception if the mapping can be neither read nor written.  An
instruction cache operation only takes the TLB miss exception.

Probe the address through the normal TLB fill path, which also reports
the packet that faulted.

This enables the mmu_cacheops systest.

Link: https://lore.kernel.org/qemu-devel/20261117183629.2002840-7-marco.liebel@oss.qualcomm.com/
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/gen_tcg.h                  | 18 +++++++---
 target/hexagon/helper.h                   |  2 ++
 target/hexagon/op_helper.c                | 42 +++++++++++++++++++++++
 tests/functional/hexagon/test_systests.py |  4 +++
 4 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h
index e82f89aee42..40f35eb8199 100644
--- a/target/hexagon/gen_tcg.h
+++ b/target/hexagon/gen_tcg.h
@@ -512,23 +512,33 @@
 #define fGEN_TCG_Y2_dczeroa(SHORTCODE) SHORTCODE
 #define fGEN_TCG_Y2_dczeroa_nt(SHORTCODE) SHORTCODE
 
-/* In linux-user mode, these are not modelled, suppress compiler warning */
+#ifdef CONFIG_USER_ONLY
+/* In linux-user mode, the data cache is not modelled */
 #define fGEN_TCG_Y2_dcinva(SHORTCODE) \
     do { RsV = RsV; } while (0)
 #define fGEN_TCG_Y2_dccleaninva(SHORTCODE) \
     do { RsV = RsV; } while (0)
 #define fGEN_TCG_Y2_dccleana(SHORTCODE) \
     do { RsV = RsV; } while (0)
-
-#ifdef CONFIG_USER_ONLY
 #define fGEN_TCG_Y2_icinva(SHORTCODE) \
     gen_helper_insn_cache_op(tcg_env, RsV, \
                              tcg_constant_tl(insn->slot), \
                              tcg_constant_tl(ctx->mem_idx), \
                              tcg_constant_tl(ctx->pkt.pc))
 #else
+/*
+ * In system mode the caches are not modelled either, but the operations
+ * translate their address so they can take TLB miss and privilege exceptions.
+ */
+#define fGEN_TCG_Y2_dcinva(SHORTCODE) \
+    gen_helper_data_cache_op(tcg_env, RsV, tcg_constant_tl(ctx->mem_idx))
+#define fGEN_TCG_Y2_dccleaninva(SHORTCODE) \
+    gen_helper_data_cache_op(tcg_env, RsV, tcg_constant_tl(ctx->mem_idx))
+#define fGEN_TCG_Y2_dccleana(SHORTCODE) \
+    gen_helper_data_cache_op(tcg_env, RsV, tcg_constant_tl(ctx->mem_idx))
 #define fGEN_TCG_Y2_icinva(SHORTCODE) \
-    do { RsV = RsV; } while (0)
+    gen_helper_insn_cache_op_check(tcg_env, RsV, \
+                                   tcg_constant_tl(ctx->mem_idx))
 #endif
 
 #define fGEN_TCG_V2_CHECK_AND_WRITE_VSP(VSP) \
diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h
index e658f8068f4..e7e7ab2c02e 100644
--- a/target/hexagon/helper.h
+++ b/target/hexagon/helper.h
@@ -159,6 +159,8 @@ DEF_HELPER_5(insn_cache_op, void, env, i32, int, int, i32)
 
 #if !defined(CONFIG_USER_ONLY)
 DEF_HELPER_4(raise_stack_overflow, void, env, i32, i32, i32)
+DEF_HELPER_3(data_cache_op, void, env, i32, i32)
+DEF_HELPER_3(insn_cache_op_check, void, env, i32, i32)
 DEF_HELPER_2(swi, void, env, i32)
 DEF_HELPER_2(cswi, void, env, i32)
 DEF_HELPER_2(ciad, void, env, i32)
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
index cdb731160eb..bdd5defc9ec 100644
--- a/target/hexagon/op_helper.c
+++ b/target/hexagon/op_helper.c
@@ -25,6 +25,7 @@
 #include "exec/helper-proto.h"
 #include "exec/mmap-lock.h"
 #include "exec/target_page.h"
+#include "exec/tlb-flags.h"
 #include "exec/translation-block.h"
 #include "fpu/softfloat.h"
 #include "exec/cpu-interrupt.h"
@@ -1659,6 +1660,47 @@ void HELPER(vwhist128qm)(CPUHexagonState *env, int32_t uiV)
 }
 
 #ifndef CONFIG_USER_ONLY
+/*
+ * The data cache operations translate their address.  They take a TLB miss
+ * exception if the address is not mapped, and a privilege exception if the
+ * mapping allows neither reads nor writes.
+ */
+void HELPER(data_cache_op)(CPUHexagonState *env, target_ulong RsV,
+                           uint32_t mmu_idx)
+{
+    uintptr_t ra = GETPC();
+    void *host;
+
+    if ((probe_access_flags(env, RsV, 1, MMU_DATA_LOAD, mmu_idx, true,
+                            &host, ra) & TLB_INVALID_MASK) &&
+        (probe_access_flags(env, RsV, 1, MMU_DATA_STORE, mmu_idx, true,
+                            &host, ra) & TLB_INVALID_MASK)) {
+        /* Not accessible at all, take the exception for a read */
+        probe_read(env, RsV, 1, mmu_idx, ra);
+    }
+}
+
+/*
+ * The instruction cache operations only take a TLB miss exception, whether
+ * or not the mapping can be executed.
+ */
+void HELPER(insn_cache_op_check)(CPUHexagonState *env, target_ulong RsV,
+                                 uint32_t mmu_idx)
+{
+    hwaddr phys;
+    int prot;
+    uint64_t size;
+    int32_t excp;
+
+    if (!hexagon_cpu_mmu_enabled(env)) {
+        return;
+    }
+    if (!hex_tlb_find_match(env, RsV, MMU_INST_FETCH, &phys, &prot, &size,
+                            &excp, mmu_idx)) {
+        probe_access(env, RsV, 1, MMU_INST_FETCH, mmu_idx, GETPC());
+    }
+}
+
 void HELPER(raise_stack_overflow)(CPUHexagonState *env, uint32_t slot,
                                   uint32_t badva, uint32_t pc)
 {
diff --git a/tests/functional/hexagon/test_systests.py b/tests/functional/hexagon/test_systests.py
index f997563baca..5dc05256aae 100755
--- a/tests/functional/hexagon/test_systests.py
+++ b/tests/functional/hexagon/test_systests.py
@@ -92,6 +92,10 @@ def test_framelimit(self):
         exception at the allocframe packet."""
         self.run_exit_zero("framelimit")
 
+    def test_mmu_cacheops(self):
+        """Cache operations raise TLB miss and privilege exceptions."""
+        self.run_exit_zero("mmu_cacheops")
+
     def test_access(self):
         """access checks R_OK|W_OK on _testfile_access."""
         testfile = self.scratch_file("_testfile_access")
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 07/14] target/hexagon: raise decode failures at the faulting packet
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (5 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 06/14] target/hexagon: take exceptions for cache operations Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 08/14] hw/hexagon: update the glob-reg vmstate ver Brian Cain
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

A guest handler for an invalid packet or opcode skips the packet by
advancing ELR past it.  gen_exception_decode_fail() raised the exception
at the address after the packet words, so the handler stepped over the
packet that followed as well.  In system mode report the address of the
faulting packet.  linux-user keeps reporting the address after the words,
which is where the invalid encoding tests resume.

This enables the llsc_on_excp systest.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/translate.c                | 13 +++++++++++--
 tests/functional/hexagon/test_systests.py |  5 +++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index eef392b1e9c..126d7b29a9d 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -271,13 +271,22 @@ void hex_gen_exception_end_tb(DisasContext *ctx, int cause)
  */
 static void gen_exception_decode_fail(DisasContext *ctx, int nwords, int cause)
 {
-    target_ulong fail_pc = ctx->base.pc_next + nwords * sizeof(uint32_t);
+    target_ulong next_pc = ctx->base.pc_next + nwords * sizeof(uint32_t);
+#ifdef CONFIG_USER_ONLY
+    target_ulong fail_pc = next_pc;
+#else
+    /*
+     * A guest handler skips the packet by advancing ELR, so it must be the
+     * address of the faulting packet and not the one after it.
+     */
+    target_ulong fail_pc = ctx->base.pc_next;
+#endif
 
     gen_exec_counters(ctx);
     tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], fail_pc);
     gen_precise_exception(cause, fail_pc);
     ctx->base.is_jmp = DISAS_NORETURN;
-    ctx->base.pc_next = fail_pc;
+    ctx->base.pc_next = next_pc;
 }
 
 static int read_packet_words(CPUHexagonState *env, DisasContext *ctx,
diff --git a/tests/functional/hexagon/test_systests.py b/tests/functional/hexagon/test_systests.py
index 5dc05256aae..ac2071795fb 100755
--- a/tests/functional/hexagon/test_systests.py
+++ b/tests/functional/hexagon/test_systests.py
@@ -96,6 +96,11 @@ def test_mmu_cacheops(self):
         """Cache operations raise TLB miss and privilege exceptions."""
         self.run_exit_zero("mmu_cacheops")
 
+    def test_llsc_on_excp(self):
+        """An exception between a load-locked and the store-conditional
+        clears the reservation."""
+        self.run_exit_zero("llsc_on_excp")
+
     def test_access(self):
         """access checks R_OK|W_OK on _testfile_access."""
         testfile = self.scratch_file("_testfile_access")
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 08/14] hw/hexagon: update the glob-reg vmstate ver
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (6 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 07/14] target/hexagon: raise decode failures at the faulting packet Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 09/14] tests/functional/hexagon: run the rest of the tests Brian Cain
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

Since 11.1 the layout of the migrated global register state has changed.
Several regs were added when the v81 interrupt/commit/cycle count update.

Raise the version, and the minimum version that is accepted.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 hw/hexagon/hexagon_globalreg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/hexagon/hexagon_globalreg.c b/hw/hexagon/hexagon_globalreg.c
index 8b50fec770a..dd373dec9fe 100644
--- a/hw/hexagon/hexagon_globalreg.c
+++ b/hw/hexagon/hexagon_globalreg.c
@@ -450,8 +450,8 @@ static int hexagon_globalreg_post_load(void *opaque,
 
 static const VMStateDescription vmstate_hexagon_globalreg = {
     .name = "hexagon_globalreg",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .pre_save = hexagon_globalreg_pre_save,
     .post_load = hexagon_globalreg_post_load,
     .fields = (const VMStateField[]){
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 09/14] tests/functional/hexagon: run the rest of the tests
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (7 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 08/14] hw/hexagon: update the glob-reg vmstate ver Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:15 ` [PATCH-for-11.2 10/14] tests/tcg/hexagon: packet and COF corner cases Brian Cain
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

The arch and systest tarballs carry more binaries than were being run.
Run the missing test cases, and add a Linux boot test for the QCS6490
CDSP machine.

With this many tests in the one file, a busy host sometimes stalled the
whole file until the test timeout.  The guest starts to print to the
console as soon as it is launched, and does so with the BQL held.  If the
test has not started to read the console by the time the socket is full,
the guest blocks holding the BQL.  QMP is answered by the main loop, which
needs the BQL, so the test cannot get a reply to a QMP command until it
reads the console, and it cannot read the console while it waits for the
reply.  Start the guest paused, and read the console while it is resumed.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 tests/functional/hexagon/meson.build        |   2 +
 tests/functional/hexagon/test_arch_tests.py | 114 +++++++++-
 tests/functional/hexagon/test_linux.py      |  62 +++++
 tests/functional/hexagon/test_systests.py   | 240 +++++++++++++++++++-
 4 files changed, 412 insertions(+), 6 deletions(-)
 create mode 100755 tests/functional/hexagon/test_linux.py

diff --git a/tests/functional/hexagon/meson.build b/tests/functional/hexagon/meson.build
index 3dd40ed0463..565a056a951 100644
--- a/tests/functional/hexagon/meson.build
+++ b/tests/functional/hexagon/meson.build
@@ -5,6 +5,7 @@ tests_hexagon_system_thorough = [
   'qcom_dsp_firmware',
   'systests',
   'hlx',
+  'linux',
   'minivm',
 ]
 
@@ -13,4 +14,5 @@ test_hexagon_timeouts = {
   'qcom_dsp_firmware': 240,
   'systests': 180,
   'hlx': 180,
+  'linux': 240,
 }
diff --git a/tests/functional/hexagon/test_arch_tests.py b/tests/functional/hexagon/test_arch_tests.py
index a437e4d4aac..08ebdc72477 100755
--- a/tests/functional/hexagon/test_arch_tests.py
+++ b/tests/functional/hexagon/test_arch_tests.py
@@ -4,6 +4,9 @@
 #
 # SPDX-License-Identifier: GPL-2.0-or-later
 
+import threading
+import unittest
+
 from qemu_test import QemuSystemTest, Asset
 from qemu_test.cmd import wait_for_console_pattern
 
@@ -32,6 +35,23 @@ class ArchTestsUart(QemuSystemTest):
         "64053b31e8e3acf7c97e7e82209b6bda",
     )
 
+    def launch_and_wait_for_pass(self) -> None:
+        """
+        Run the guest until it prints PASS on the console.
+
+        Start the guest paused and read the console while resuming it, so
+        that a guest blocked on a full console socket cannot deadlock QMP.
+        """
+        self.vm.add_args("-S")
+        self.vm.launch()
+        resume = threading.Thread(target=self.vm.cmd, args=("cont",),
+                                  daemon=True)
+        resume.start()
+        try:
+            wait_for_console_pattern(self, "PASS")
+        finally:
+            resume.join(timeout=30)
+
     def run_uart_test(self, test_name: str,
                       machine: str = "virt") -> None:
         """
@@ -44,8 +64,7 @@ def run_uart_test(self, test_name: str,
         self.vm.set_console()
         self.set_vm_arg("-display", "none")
         self.set_vm_arg("-kernel", target_bin)
-        self.vm.launch()
-        wait_for_console_pattern(self, "PASS")
+        self.launch_and_wait_for_pass()
 
     def run_semihosting_test(self, test_name: str,
                              machine: str = "V81QA_1") -> None:
@@ -56,8 +75,7 @@ def run_semihosting_test(self, test_name: str,
         self.vm.set_console(semihosting=True)
         self.set_vm_arg("-display", "none")
         self.set_vm_arg("-kernel", target_bin)
-        self.vm.launch()
-        wait_for_console_pattern(self, "PASS")
+        self.launch_and_wait_for_pass()
 
     def test_exceptions(self) -> None:
         """Tests exception delivery for trap instructions, privilege
@@ -101,6 +119,65 @@ def test_sys_regs_v81(self) -> None:
         """Tests V81-specific system register masks."""
         self.run_semihosting_test("test_sys_regs")
 
+    def test_cache_v81(self) -> None:
+        """Tests cache operations on the V81 machine."""
+        self.run_semihosting_test("test_cache")
+
+    def test_exceptions_v81(self) -> None:
+        """Tests exception delivery on the V81 machine."""
+        self.run_semihosting_test("test_exceptions")
+
+    def test_guest_mode_v81(self) -> None:
+        """Tests guest mode on the V81 machine."""
+        self.run_semihosting_test("test_guest_mode")
+
+    def test_hvx_context_v81(self) -> None:
+        """Tests the HVX coprocessor context on the V81 machine."""
+        self.run_semihosting_test("test_hvx_context")
+
+    def test_int_steering_v81(self) -> None:
+        """Tests interrupt steering on the V81 machine."""
+        self.run_semihosting_test("test_int_steering")
+
+    def test_interrupts_v81(self) -> None:
+        """Tests interrupt delivery on the V81 machine."""
+        self.run_semihosting_test("test_interrupts")
+
+    @unittest.skip("test_isr_stress in v0.3.1 gives another hardware "
+                   "thread a fixed polling budget, so it fails when the "
+                   "host delays that vCPU thread")
+    def test_isr_stress_v81(self) -> None:
+        """Tests interrupt service routine stress on the V81 machine."""
+        self.run_semihosting_test("test_isr_stress")
+
+    def test_l2vic_v81(self) -> None:
+        """Tests the L2VIC on the V81 machine."""
+        self.run_semihosting_test("test_l2vic")
+
+    def test_pagecross_tlbmissx_v81(self) -> None:
+        """Tests page-crossing instruction TLB misses on the V81 machine."""
+        self.run_semihosting_test("test_pagecross_tlbmissx")
+
+    def test_pmu_v81(self) -> None:
+        """Tests the performance counters on the V81 machine."""
+        self.run_semihosting_test("test_pmu")
+
+    def test_threads_v81(self) -> None:
+        """Tests hardware thread management on the V81 machine."""
+        self.run_semihosting_test("test_threads")
+
+    def test_timer_v81(self) -> None:
+        """Tests the system timer on the V81 machine."""
+        self.run_semihosting_test("test_timer")
+
+    def test_tlb_mmu_v81(self) -> None:
+        """Tests TLB/MMU operations on the V81 machine."""
+        self.run_semihosting_test("test_tlb_mmu")
+
+    def test_user_mode_v81(self) -> None:
+        """Tests user mode transitions on the V81 machine."""
+        self.run_semihosting_test("test_user_mode")
+
     def test_threads(self) -> None:
         """Tests hardware thread management: start/stop, MODECTL state,
         per-thread HTID, shared memory, wait/resume, STID priority, and
@@ -115,6 +192,35 @@ def test_tlb_mmu(self) -> None:
         """
         self.run_uart_test("test_tlb_mmu")
 
+    @unittest.skip("test_isr_stress in v0.3.1 gives another hardware "
+                   "thread a fixed polling budget, so it fails when the "
+                   "host delays that vCPU thread")
+    def test_isr_stress(self) -> None:
+        """Tests interrupt service routine stress: bursts of interrupts,
+        simultaneous software interrupts, rapid refire, nesting, and
+        interrupts while threads start, spin, and wait.
+        """
+        self.run_uart_test("test_isr_stress")
+
+    def test_pagecross_tlbmissx(self) -> None:
+        """Tests instruction TLB misses for packets that cross a page
+        boundary: the next page missing, both pages missing, and the
+        default handler.
+        """
+        self.run_uart_test("test_pagecross_tlbmissx")
+
+    def test_pmu(self) -> None:
+        """Tests the performance counters: PCYCLE incrementing, its high
+        and low halves, enabling and disabling it, and UPCYCLE.
+        """
+        self.run_uart_test("test_pmu")
+
+    def test_timer(self) -> None:
+        """Tests the system timer: QTimer reads, monotonicity, version, and
+        using PCYCLE as a timer.
+        """
+        self.run_uart_test("test_timer")
+
     def test_user_mode(self) -> None:
         """Tests user mode / privilege transitions: supervisor mode,
         SSR UM/IE/XE/CE/PE bits, and the trap0 user-mode exit handler.
diff --git a/tests/functional/hexagon/test_linux.py b/tests/functional/hexagon/test_linux.py
new file mode 100755
index 00000000000..68b08eeff71
--- /dev/null
+++ b/tests/functional/hexagon/test_linux.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+#
+# Boot Linux on the QCS6490 CDSP machine, using H2 as the Hexagon VM host
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import QemuSystemTest, Asset
+from qemu_test import exec_command_and_wait_for_pattern
+from qemu_test import wait_for_console_pattern
+
+
+class HexagonLinuxQcs6490Cdsp(QemuSystemTest):
+    """
+    Boot a Hexagon Linux kernel with an initramfs.  The H2 "loadlinux"
+    firmware runs the kernel as a guest of the Hexagon VM interface and
+    hands it the device tree that QEMU generated.
+    """
+
+    timeout = 240
+
+    ASSET_KERNEL = Asset(
+        'https://artifacts.codelinaro.org/artifactory/'
+        'codelinaro-toolchain-for-hexagon/23.1.2/qcs6490-cdsp/vmlinux',
+        '1908e9c684df4eb44d700c4096e1b2f73af6652a874e377cd8c6af0f5760d66a')
+    ASSET_INITRD = Asset(
+        'https://artifacts.codelinaro.org/artifactory/'
+        'codelinaro-toolchain-for-hexagon/23.1.2/qcs6490-cdsp/initrd',
+        '2b958945b38db54145051f76b886f42dd5dee70db399f6222ccc54808d6bdd6b')
+
+    # The H2 hypervisor and its loadlinux, built for this machine's DDR
+    # carve-out; it hands the device tree in r1:r0 on to the kernel.
+    ASSET_H2 = Asset(
+        'https://github.com/qualcomm/qemu-hexagon-testing/releases/'
+        'download/v0.2.17b-h2/loadlinux_qcs6490-cdsp',
+        'ad667005c7ae286de5a79f79613341f6e928da74cea31ced14772d5a94cb1716')
+
+    def test_linux_boot(self):
+        self.set_machine('qcs6490-cdsp')
+
+        self.vm.set_console()
+        self.vm.add_args(
+            '-bios', self.ASSET_H2.fetch(),
+            '-kernel', self.ASSET_KERNEL.fetch(),
+            '-initrd', self.ASSET_INITRD.fetch(),
+            '-append', 'console=ttyAMA0 mem=240M lpj=89124080 rdinit=/init',
+        )
+        self.vm.launch()
+
+        # The initramfs has no login: init prints this and starts a root shell
+        wait_for_console_pattern(self, 'Please press Enter to activate this '
+                                 'console.', failure_message='Kernel panic')
+        exec_command_and_wait_for_pattern(self, '', '# ')
+
+        # All six hardware threads are Linux CPUs
+        exec_command_and_wait_for_pattern(self, 'nproc', '6')
+        exec_command_and_wait_for_pattern(self, 'uname -m', 'hexagon')
+
+
+if __name__ == '__main__':
+    QemuSystemTest.main()
diff --git a/tests/functional/hexagon/test_systests.py b/tests/functional/hexagon/test_systests.py
index ac2071795fb..bd444a1f831 100755
--- a/tests/functional/hexagon/test_systests.py
+++ b/tests/functional/hexagon/test_systests.py
@@ -36,14 +36,15 @@ def binary(self, name):
         self.assertTrue(os.path.exists(path))
         return path
 
-    def run_exit_zero(self, binary_name, *extra_args, machine="sim"):
+    def run_exit_zero(self, binary_name, *extra_args, machine="sim",
+                      timeout=60.0):
         self.set_machine(machine)
         self.set_vm_arg("-display", "none")
         self.set_vm_arg("-kernel", self.binary(binary_name))
         for flag, value in zip(extra_args[::2], extra_args[1::2]):
             self.set_vm_arg(flag, value)
         self.vm.launch()
-        self.vm.wait(timeout=60.0)
+        self.vm.wait(timeout=timeout)
         self.assertEqual(self.vm.exitcode(), 0,
                          f"Test {binary_name} exited with "
                          f"code {self.vm.exitcode()}, expected 0")
@@ -62,6 +63,52 @@ def run_console_pattern(self, binary_name, pattern, *extra_args,
         finally:
             self.vm.kill()
 
+    def run_expect_crash(self, binary_name, log_pattern, *extra_args,
+                         machine="sim"):
+        """Run a test that is meant to crash.
+
+        The standalone CRT exits with 255 from its unhandled-exception
+        handler, which also reports the cause in the log.
+        """
+        self.set_machine(machine)
+        self.set_vm_arg("-display", "none")
+        self.set_vm_arg("-kernel", self.binary(binary_name))
+        for flag, value in zip(extra_args[::2], extra_args[1::2]):
+            self.set_vm_arg(flag, value)
+        self.vm.launch()
+        self.vm.wait(timeout=60.0)
+        self.assertEqual(self.vm.exitcode(), 255,
+                         f"{binary_name} exited with {self.vm.exitcode()}, "
+                         "expected 255")
+        log = self.vm.get_log() or ""
+        self.assertTrue(re.search(log_pattern, log),
+                        f"{log_pattern!r} not in the log of {binary_name}:"
+                        f"\n{log}")
+
+    def wait_for_log_pattern(self, pattern, count=1, timeout=30.0):
+        """Wait until the log of the running VM has @pattern @count times."""
+        deadline = time.monotonic() + timeout
+        log_path = self.vm._qemu_log_path
+        while time.monotonic() < deadline:
+            with open(log_path, "r", encoding="utf-8",
+                      errors="replace") as f:
+                if f.read().count(pattern) >= count:
+                    return
+            time.sleep(0.1)
+        self.fail(f"Timed out waiting for {count} of {pattern!r} in the log")
+
+    def run_hang_log_pattern(self, binary_name, pattern):
+        """Run a test that is meant to hang, and expect @pattern logged."""
+        self.set_machine("sim")
+        self.set_vm_arg("-display", "none")
+        self.set_vm_arg("-kernel", self.binary(binary_name))
+        self.set_vm_arg("-d", "guest_errors")
+        self.vm.launch()
+        try:
+            self.wait_for_log_pattern(pattern)
+        finally:
+            self.vm.kill()
+
     def test_fopen(self):
         """fopen reads a file passed via --append and verifies its contents."""
         import tempfile
@@ -144,5 +191,194 @@ def test_lock_verify(self):
     def test_single_step(self):
         self.run_exit_zero("single_step")
 
+    def test_start(self):
+        """The start instruction resets the threads it names but not the
+        thread executing it."""
+        self.run_exit_zero("start")
+
+    def test_test_thread(self):
+        """Eight threads start, record their ids, and exit."""
+        self.run_exit_zero("test-thread", "-smp", "cpus=8")
+
+    def test_test_thread_single_threaded_tcg(self):
+        """test_thread with the vCPUs sharing one host thread."""
+        self.run_exit_zero("test-thread", "-smp", "cpus=8",
+                           "-accel", "tcg,thread=single")
+
+    def test_k0locklock(self):
+        """Locking k0 twice in a row hangs the thread, and is reported."""
+        self.run_hang_log_pattern("k0locklock", "Double k0lock at PC")
+
+    def test_tlblocklock(self):
+        """Locking the TLB twice in a row hangs the thread, and is reported."""
+        self.run_hang_log_pattern("tlblocklock", "Double tlblock at PC")
+
+    def test_inf_loop(self):
+        """Four threads start, spin forever, and start again after a
+        system reset."""
+        self.set_machine("sim")
+        self.set_vm_arg("-display", "none")
+        self.set_vm_arg("-kernel", self.binary("inf-loop"))
+        self.vm.launch()
+        try:
+            for i in range(4):
+                self.wait_for_log_pattern(f"Starting thread {i}")
+            self.vm.qmp("system_reset")
+            for i in range(4):
+                self.wait_for_log_pattern(f"Starting thread {i}", count=2)
+        finally:
+            self.vm.kill()
+
+    def test_unaligned(self):
+        """A misaligned load raises the misaligned load exception."""
+        self.run_expect_crash("unaligned", "Misaligned Load")
+
+    def test_hvx_nocoproc(self):
+        """An HVX instruction with SSR:XE clear raises the coprocessor
+        exception."""
+        self.run_expect_crash("hvx_nocoproc",
+                              "Illegal Execution of Coprocessor Instruction")
+
+    def test_neg_no_hmx(self):
+        """HMX instructions are invalid on a machine without HMX."""
+        self.run_expect_crash("neg-no-hmx", "Invalid packet",
+                              machine="V68N_1024")
+
+    def test_badva(self):
+        """Dual memory operations and TLB exceptions record the right BADVA."""
+        self.run_exit_zero("badva")
+
+    def test_checkforpriv(self):
+        """Privileged instructions raise a privilege exception in user mode."""
+        self.run_exit_zero("checkforpriv")
+
+    def test_ciad_siad(self):
+        """The ciad and siad instructions clear and set interrupt state."""
+        self.run_exit_zero("ciad-siad")
+
+    def test_fastint(self):
+        """The fast L2VIC interface handles a large number of interrupts."""
+        self.run_exit_zero("fastint")
+
+    def test_fastl2vic(self):
+        """The fast L2VIC interface sets and clears interrupt enables."""
+        self.run_exit_zero("fastl2vic")
+
+    def test_getcwd(self):
+        """The getcwd semihosting call fills a buffer with a valid path."""
+        self.run_exit_zero("getcwd")
+
+    def test_gregs(self):
+        """Guest registers g0-g31 keep or reject written values."""
+        self.run_exit_zero("gregs")
+
+    def test_hvx_64b(self):
+        """HVX 64-byte mode accesses raise the expected exceptions."""
+        self.run_exit_zero("hvx_64b")
+
+    def test_hvx_ext(self):
+        """HVX extension bits and qfloat operations across revisions."""
+        self.run_exit_zero("hvx_ext")
+
+    def test_int_range(self):
+        """The L2VIC interrupt range 1-1024 can be enabled and cleared."""
+        self.run_exit_zero("int_range")
+
+    def test_invalid_insn_for_rev(self):
+        """Instructions invalid for the revision raise an exception."""
+        self.run_exit_zero("invalid_insn_for_rev")
+
+    def test_invalid_opcode(self):
+        """Invalid opcodes raise an exception."""
+        self.run_exit_zero("invalid_opcode")
+
+    def test_k0lock(self):
+        """k0lock and k0unlock serialize several threads."""
+        self.run_exit_zero("k0lock")
+
+    def test_k0lock_syscfg(self):
+        """k0lock interacts correctly with SYSCFG changes."""
+        self.run_exit_zero("k0lock-syscfg")
+
+    def test_levelint(self):
+        """Level-triggered interrupts are delivered and cleared."""
+        self.run_exit_zero("levelint")
+
+    def test_mmu_asids(self):
+        """TLB entries with different ASIDs translate independently."""
+        self.run_exit_zero("mmu_asids")
+
+    def test_mmu_overlap(self):
+        """Overlapping TLB entries are rejected by the TLB write."""
+        self.run_exit_zero("mmu_overlap")
+
+    def test_mmu_page_size(self):
+        """Every page size from 4KB to 1GB translates data and code."""
+        self.run_exit_zero("mmu_page_size")
+
+    def test_mmu_permissions(self):
+        """TLB permission bits raise miss and permission exceptions."""
+        self.run_exit_zero("mmu_permissions")
+
+    def test_nmi_cross_thread(self):
+        """An NMI sent to another thread is delivered there."""
+        self.run_exit_zero("nmi_cross_thread")
+
+    def test_pendalot(self):
+        """1023 interrupts are pended, taken, and logged."""
+        self.run_exit_zero("pendalot")
+
+    def test_pend_wake_wait(self):
+        """Worker threads wait while software interrupts cycle."""
+        self.run_exit_zero("pend_wake_wait")
+
+    def test_qfloat_test(self):
+        """HVX qfloat arithmetic, comparisons, min/max, and conversions."""
+        self.run_exit_zero("qfloat_test")
+
+    def test_reg_reads(self):
+        """Reading the PMU registers and counting HVX packets."""
+        self.run_exit_zero("reg-reads")
+
+    def test_standalone_hw(self):
+        """The hardware thread and monitor instructions work."""
+        self.run_exit_zero("standalone_hw")
+
+    def test_swi(self):
+        """Software interrupts are delivered to the expected threads."""
+        self.run_exit_zero("swi")
+
+    def test_swi2(self):
+        """Software interrupts under load while masks and priorities change."""
+        self.run_exit_zero("swi2")
+
+    def test_swi_wait(self):
+        """Software interrupts wake threads in wait mode."""
+        self.run_exit_zero("swi_wait")
+
+    def test_sys_atomics(self):
+        """Load-linked/store-conditional increments across threads."""
+        self.run_exit_zero("sys_atomics")
+
+    def test_thread_scheduling(self):
+        """Threads are scheduled and make progress."""
+        self.run_exit_zero("thread_scheduling")
+
+    def test_tlblock(self):
+        """tlblock and tlbunlock serialize several threads."""
+        self.run_exit_zero("tlblock")
+
+    def test_vid_reg(self):
+        """The VID register accepts valid values and rejects invalid ones."""
+        self.run_exit_zero("vid_reg")
+
+    def test_vtcm_error(self):
+        """VTCM accesses outside the window raise an error."""
+        self.run_exit_zero("vtcm_error")
+
+    def test_rev(self):
+        """The revision register reports the V81 of the machine."""
+        self.run_console_pattern("rev", "0x81", machine="V81QA_1")
+
 if __name__ == "__main__":
     QemuSystemTest.main()
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 10/14] tests/tcg/hexagon: packet and COF corner cases
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (8 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 09/14] tests/functional/hexagon: run the rest of the tests Brian Cain
@ 2026-11-19 20:15 ` Brian Cain
  2026-11-19 20:16 ` [PATCH-for-11.2 11/14] hw/hexagon: honor configured RAM backends Brian Cain
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

Add tests for subtle packet semantics not yet covered:

- Register, pair and half-register writes commit together, so parallel
  reads see the old values; .new store data may come from an extended
  or load producer.
- Packed pred reads see the old bytes, auto-and before .new
- Aliasing stores, cancelled ld/st does not postinc
- Dual jumps, callr through LR, an overwritten jumpr target, and short
  sp3loop0 loops
- M0, CS0 and M1 updates in a circ/brev packet apply to later packets
  only, and a saturating add reads the old USR.OVF before setting it.

Link: https://lore.kernel.org/qemu-devel/20261117183629.2002840-4-marco.liebel@oss.qualcomm.com/
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 tests/tcg/hexagon/brev.c             | 25 ++++++++
 tests/tcg/hexagon/circ.c             | 42 ++++++++++++
 tests/tcg/hexagon/dual_stores.c      | 34 ++++++++++
 tests/tcg/hexagon/mem_noshuf.c       | 58 +++++++++++++----
 tests/tcg/hexagon/preg_alias.c       | 58 +++++++++++++++++
 tests/tcg/hexagon/test_cond_branch.c | 95 ++++++++++++++++++++++++++++
 tests/tcg/hexagon/usr.c              | 33 ++++++++++
 tests/tcg/hexagon/test_dotnew.S      | 34 +++++++++-
 tests/tcg/hexagon/test_packet.S      | 46 +++++++++++++-
 9 files changed, 412 insertions(+), 13 deletions(-)

diff --git a/tests/tcg/hexagon/brev.c b/tests/tcg/hexagon/brev.c
index 1473e309ee0..192107d4f30 100644
--- a/tests/tcg/hexagon/brev.c
+++ b/tests/tcg/hexagon/brev.c
@@ -149,6 +149,29 @@ int32_t sext8(int32_t x)
  */
 int high_half[SIZE];
 
+/* The first access uses old M1; the following access uses the new M1. */
+static void brev_test_packet(void)
+{
+    uintptr_t ptr = (uintptr_t)wbuf;
+    uint32_t first, second;
+
+    wbuf[0] = 0x11223344;
+    wbuf[1] = 0x55667788;
+    asm volatile("m1 = %[old_inc]\n\t"
+                 "{\n\t"
+                 "    m1 = %[new_inc]\n\t"
+                 "    %[first] = memw(%[ptr]++m1:brev)\n\t"
+                 "}\n\t"
+                 "%[second] = memw(%[ptr]++m1:brev)\n\t"
+                 : [ptr] "+r"(ptr), [first] "=&r"(first),
+                   [second] "=r"(second)
+                 : [old_inc] "r"(0x2000), [new_inc] "r"(0x4000)
+                 : "m1", "memory");
+    check32(first, 0x11223344);
+    check32(second, 0x55667788);
+    check32(ptr - (uintptr_t)wbuf, 0x6000);
+}
+
 int main()
 {
     void *p;
@@ -178,6 +201,8 @@ int main()
     TEST_BREV_STORE_NEW(hnew, hbuf, 15);
     TEST_BREV_STORE_NEW(wnew, wbuf, 14);
 
+    brev_test_packet();
+
     puts(err ? "FAIL" : "PASS");
     return err ? 1 : 0;
 }
diff --git a/tests/tcg/hexagon/circ.c b/tests/tcg/hexagon/circ.c
index 2a15c324242..a0d1500f5aa 100644
--- a/tests/tcg/hexagon/circ.c
+++ b/tests/tcg/hexagon/circ.c
@@ -423,6 +423,46 @@ static void circ_test_v3(void)
     }
 }
 
+/* Updating a modifier in the packet must not change that packet's wrap. */
+static void circ_test_packet(void)
+{
+    int32_t *ptr = &wbuf[3];
+    int32_t result, modifier;
+
+    init_wbuf();
+    asm volatile("m0 = %[old_len]\n\t"
+                 "cs0 = %[start]\n\t"
+                 "{\n\t"
+                 "    m0 = %[new_len]\n\t"
+                 "    %[result] = memw(%[ptr]++#4:circ(m0))\n\t"
+                 "}\n\t"
+                 "%[modifier] = m0\n\t"
+                 : [ptr] "+r"(ptr), [result] "=r"(result),
+                   [modifier] "=r"(modifier)
+                 : [start] "r"(wbuf), [old_len] "r"(16), [new_len] "r"(8)
+                 : "m0", "cs0", "memory");
+    check32(result, 3);
+    checkp(ptr, wbuf);
+    check32(modifier, 8);
+
+    /* A same-packet CS0 write must likewise leave this wrap unchanged. */
+    ptr = &wbuf[3];
+    asm volatile("m0 = %[len]\n\t"
+                 "cs0 = %[start]\n\t"
+                 "{\n\t"
+                 "    cs0 = %[next]\n\t"
+                 "    %[result] = memw(%[ptr]++#4:circ(m0))\n\t"
+                 "}\n\t"
+                 "%[modifier] = cs0\n\t"
+                 : [ptr] "+r"(ptr), [result] "=r"(result),
+                   [modifier] "=r"(modifier)
+                 : [start] "r"(wbuf), [len] "r"(16), [next] "r"(&wbuf[8])
+                 : "m0", "cs0", "memory");
+    check32(result, 3);
+    checkp(ptr, wbuf);
+    check32(modifier, (uintptr_t)&wbuf[8]);
+}
+
 int main()
 {
     init_bbuf();
@@ -470,6 +510,8 @@ int main()
 
     circ_test_v3();
 
+    circ_test_packet();
+
     puts(err ? "FAIL" : "PASS");
     return err ? 1 : 0;
 }
diff --git a/tests/tcg/hexagon/dual_stores.c b/tests/tcg/hexagon/dual_stores.c
index 775458e0fc8..e6fae7fe9b2 100644
--- a/tests/tcg/hexagon/dual_stores.c
+++ b/tests/tcg/hexagon/dual_stores.c
@@ -42,6 +42,38 @@ typedef union {
     int8_t byte;
 } Dual;
 
+/* Cover partial overlap in both directions, retaining untouched guard bytes. */
+static void test_partial_overlap(void)
+{
+    union {
+        uint64_t d;
+        uint32_t w[2];
+        uint16_t h[4];
+    } data;
+
+    data.d = 0x8877665544332211ULL;
+    asm volatile("{\n\t"
+                 "    memw(%[word]) = %[wide]\n\t"
+                 "    memh(%[half]) = %[narrow]\n\t"
+                 "}\n\t"
+                 :
+                 : [word] "r"(&data.w[0]), [half] "r"(&data.h[1]),
+                   [wide] "r"(0xaabbccdd), [narrow] "r"(0x1234)
+                 : "memory");
+    check64(data.d, 0x887766551234ccddULL);
+
+    data.d = 0x8877665544332211ULL;
+    asm volatile("{\n\t"
+                 "    memh(%[half]) = %[narrow]\n\t"
+                 "    memw(%[word]) = %[wide]\n\t"
+                 "}\n\t"
+                 :
+                 : [word] "r"(&data.w[0]), [half] "r"(&data.h[1]),
+                   [wide] "r"(0xaabbccdd), [narrow] "r"(0x1234)
+                 : "memory");
+    check64(data.d, 0x88776655aabbccddULL);
+}
+
 int main()
 {
     Dual d;
@@ -50,6 +82,8 @@ int main()
     dual_stores(&d.word, &d.byte, 0x12345678, 0xff);
     check32(d.word, 0x123456ff);
 
+    test_partial_overlap();
+
     puts(err ? "FAIL" : "PASS");
     return err;
 }
diff --git a/tests/tcg/hexagon/mem_noshuf.c b/tests/tcg/hexagon/mem_noshuf.c
index 6263d5ef8e0..e4db6511d35 100644
--- a/tests/tcg/hexagon/mem_noshuf.c
+++ b/tests/tcg/hexagon/mem_noshuf.c
@@ -107,19 +107,23 @@ static inline int pred_lw_sw(bool pred, int32_t *p, int32_t *q,
 }
 
 static inline int pred_lw_sw_pi(bool pred, int32_t *p, int32_t *q,
-                                int32_t x, int32_t y)
+                                int32_t x, int32_t y, int32_t **q_after)
 {
     int ret;
-    asm volatile("p0 = cmp.eq(%5, #0)\n\t"
-                 "%0 = %3\n\t"
-                 "r7 = %2\n\t"
+    int32_t *after;
+    asm volatile("p0 = cmp.eq(%[pred], #0)\n\t"
+                 "%[ret] = %[x]\n\t"
+                 "r7 = %[q]\n\t"
                  "{\n\t"
-                 "    memw(%1) = %4\n\t"
-                 "    if (!p0) %0 = memw(r7++#4)\n\t"
-                 "}:mem_noshuf\n"
-                 : "=&r"(ret)
-                 : "r"(p), "r"(q), "r"(x), "r"(y), "r"(pred)
+                 "    memw(%[p]) = %[y]\n\t"
+                 "    if (!p0) %[ret] = memw(r7++#4)\n\t"
+                 "}:mem_noshuf\n\t"
+                 "%[after] = r7\n"
+                 : [ret] "=&r"(ret), [after] "=r"(after)
+                 : [p] "r"(p), [q] "r"(q), [x] "r"(x), [y] "r"(y),
+                   [pred] "r"(pred)
                  : "r7", "p0", "memory");
+    *q_after = after;
     return ret;
 }
 
@@ -195,10 +199,35 @@ typedef union {
     uint8_t ub[16];
 } Memory;
 
+/* A cancelled store must also cancel its post-increment. */
+static void test_cancelled_postinc(void)
+{
+    for (int enabled = 0; enabled < 2; enabled++) {
+        uint32_t data[2] = { 0x55aa55aa, 0xabcdef01 };
+        uint32_t *store_ptr = data;
+        uint32_t loaded;
+
+        asm volatile("p0 = cmp.eq(%[enabled], #1)\n\t"
+                     "{\n\t"
+                     "    if (p0) memw(%[ptr]++#4) = %[value]\n\t"
+                     "    %[loaded] = memw(%[base])\n\t"
+                     "}:mem_noshuf\n\t"
+                     : [loaded] "=r"(loaded), [ptr] "+r"(store_ptr)
+                     : [enabled] "r"(enabled), [base] "r"(data),
+                       [value] "r"(0x11223344)
+                     : "p0", "memory");
+        check32(loaded, enabled ? 0x11223344 : 0x55aa55aa);
+        checkp(store_ptr, data + enabled);
+        check32(data[0], loaded);
+        check32(data[1], 0xabcdef01);
+    }
+}
+
 int main()
 {
     Memory n;
     uint32_t res32;
+    int32_t *pi_after;
     uint64_t res64;
 
     /*
@@ -387,13 +416,18 @@ int main()
     check32(n.w[0], 0xc0ffeeda);
 
     n.w[0] = ~0;
-    res32 = pred_lw_sw_pi(false, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda);
+    res32 = pred_lw_sw_pi(false, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda,
+                          &pi_after);
     check32(res32, 0x12345678);
+    /* The cancelled load must not post-increment its base. */
+    checkp(pi_after, &n.w[0]);
     check32(n.w[0], 0xc0ffeeda);
 
     n.w[0] = ~0;
-    res32 = pred_lw_sw_pi(true, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda);
+    res32 = pred_lw_sw_pi(true, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda,
+                          &pi_after);
     check32(res32, 0xc0ffeeda);
+    checkp(pi_after, &n.w[1]);
     check32(n.w[0], 0xc0ffeeda);
 
     n.d[0] = ~0LL;
@@ -420,6 +454,8 @@ int main()
     check64(res64, 0xc0ffeedac0ffeedaLL);
     check64(n.d[0], 0xc0ffeedac0ffeedaLL);
 
+    test_cancelled_postinc();
+
     puts(err ? "FAIL" : "PASS");
     return err;
 }
diff --git a/tests/tcg/hexagon/preg_alias.c b/tests/tcg/hexagon/preg_alias.c
index 892ecbbdbf7..ed3413ab687 100644
--- a/tests/tcg/hexagon/preg_alias.c
+++ b/tests/tcg/hexagon/preg_alias.c
@@ -128,6 +128,61 @@ static void test_packet(void)
     check32(result, 0x0);
 }
 
+/* Packed predicate reads see the old bytes, not booleanized new values. */
+static void test_packet_alias(void)
+{
+    static const uint32_t inputs[] = {
+        0x81421200, 0x81421212, 0x81421281, 0x814212ff,
+    };
+
+    for (int i = 0; i < ARRAY_SIZE(inputs); i++) {
+        uint32_t before, after, taken = 0;
+
+        asm volatile("p3:0 = %[input]\n\t"
+                     "{\n\t"
+                     "    p0 = cmp.eq(%[input], %[input])\n\t"
+                     "    %[before] = p3:0\n\t"
+                     "}\n\t"
+                     "%[after] = p3:0\n\t"
+                     : [before] "=&r"(before), [after] "=r"(after)
+                     : [input] "r"(inputs[i])
+                     : "p0", "p1", "p2", "p3");
+        check32(before, inputs[i]);
+        check32(after, inputs[i] | 0xff);
+        /* Also check an ordinary predicate consumer, independently of C4. */
+        asm volatile("p3:0 = %[input]\n\t"
+                     "{\n\t"
+                     "    p0 = cmp.eq(%[input], %[input])\n\t"
+                     "    if (p0) %[taken] = #1\n\t"
+                     "}\n\t"
+                     : [taken] "+r"(taken)
+                     : [input] "r"(inputs[i])
+                     : "p0", "p1", "p2", "p3");
+        check32(taken, inputs[i] & 1);
+    }
+}
+
+/* All writes to a predicate are ANDed before a .new consumer uses it. */
+static void test_packet_auto_and(void)
+{
+    for (int a = 0; a < 2; a++) {
+        for (int b = 0; b < 2; b++) {
+            uint32_t taken = 0;
+
+            asm volatile("p0 = cmp.gt(%[a], %[a])\n\t"
+                         "{\n\t"
+                         "    p0 = cmp.eq(%[a], #0)\n\t"
+                         "    p0 = cmp.eq(%[b], #0)\n\t"
+                         "    if (p0.new) %[taken] = #1\n\t"
+                         "}\n\t"
+                         : [taken] "+r"(taken)
+                         : [a] "r"(a), [b] "r"(b)
+                         : "p0");
+            check32(taken, !a && !b);
+        }
+    }
+}
+
 int main()
 {
     uint32_t c4;
@@ -195,6 +250,9 @@ int main()
 
     test_packet();
 
+    test_packet_alias();
+    test_packet_auto_and();
+
     puts(err ? "FAIL" : "PASS");
     return err;
 }
diff --git a/tests/tcg/hexagon/test_cond_branch.c b/tests/tcg/hexagon/test_cond_branch.c
index 73be8fbb43c..372f1dec8d9 100644
--- a/tests/tcg/hexagon/test_cond_branch.c
+++ b/tests/tcg/hexagon/test_cond_branch.c
@@ -151,11 +151,106 @@ static void check_endloop01(void)
     check32(count, 12);
 }
 
+/* The first taken branch wins, but a parallel store still commits. */
+static void check_dual_jump(void)
+{
+    for (int a = 0; a < 2; a++) {
+        for (int b = 0; b < 2; b++) {
+            uint32_t path, stored = 0;
+
+            asm volatile("p0 = cmp.eq(%[a], #1)\n\t"
+                         "p1 = cmp.eq(%[b], #1)\n\t"
+                         "{\n\t"
+                         "    if (p0) jump:t 1f\n\t"
+                         "    if (p1) jump:nt 2f\n\t"
+                         "    memw(%[stored]) = #7\n\t"
+                         "}\n\t"
+                         "{ %[path] = #0; jump 3f }\n\t"
+                         "1: { %[path] = #1; jump 3f }\n\t"
+                         "2: { %[path] = #2 }\n\t"
+                         "3:\n\t"
+                         : [path] "=r"(path)
+                         : [a] "r"(a), [b] "r"(b), [stored] "r"(&stored)
+                         : "p0", "p1", "memory");
+            check32(path, a ? 1 : b ? 2 : 0);
+            check32(stored, 7);
+        }
+    }
+}
+
+/* callr r31 reads the old LR before installing the return address in LR. */
+static void check_callr_lr(void)
+{
+    uint32_t path, delta;
+
+    asm volatile("r31 = ##1f\n\t"
+                 "{ callr r31; r6 = ##2f }\n\t"
+                 "2: { %[path] = #0; %[delta] = #1; jump 3f }\n\t"
+                 "1: { %[path] = #1; %[delta] = sub(r31, r6) }\n\t"
+                 "3:\n\t"
+                 : [path] "=r"(path), [delta] "=r"(delta)
+                 :
+                 : "r6", "r31");
+    check32(path, 1);
+    check32(delta, 0);
+}
+
+/* An explicit target-register write also commits after the branch reads it. */
+static void check_jumpr_old_target(void)
+{
+    uint32_t path;
+
+    asm volatile("{ r5 = ##1f; r6 = ##2f }\n\t"
+                 "{ r5 = r6; jumpr r5 }\n\t"
+                 "{ %[path] = #0; jump 3f }\n\t"
+                 "1: { %[path] = #1; jump 3f }\n\t"
+                 "2: { %[path] = #2 }\n\t"
+                 "3:\n\t"
+                 : [path] "=r"(path)
+                 :
+                 : "r5", "r6");
+    check32(path, 1);
+}
+
+/* Short software-pipelined loops exercise the LPCFG/P3 transition boundary. */
+static void check_sp_loop(void)
+{
+    static const unsigned counts[] = { 1, 3, 4 };
+
+    for (int i = 0; i < ARRAY_SIZE(counts); i++) {
+        uint32_t iterations, active, pred, usr;
+        unsigned count = counts[i];
+
+        asm volatile("%[iterations] = #0\n\t"
+                     "%[active] = #0\n\t"
+                     "p3 = sp3loop0(1f, %[count])\n\t"
+                     "1: {\n\t"
+                     "    if (p3) %[active] = add(%[active], #1)\n\t"
+                     "    %[iterations] = add(%[iterations], #1)\n\t"
+                     "}:endloop0\n\t"
+                     "%[pred] = p3\n\t"
+                     "%[usr] = usr\n\t"
+                     : [iterations] "=&r"(iterations), [active] "=&r"(active),
+                       [pred] "=r"(pred), [usr] "=r"(usr)
+                     : [count] "r"(count)
+                     : "p3", "sa0", "lc0", "usr");
+        check32(iterations, count);
+        check32(active, count > 3 ? count - 3 : 0);
+        check32(pred, count >= 3 ? 0xff : 0);
+        check32((usr >> 8) & 3, count < 3 ? 3 - count : 0);
+    }
+}
+
 int main(void)
 {
     check_cond_call();
     check_tstbit0_jump();
     check_endloop01();
+    check_sp_loop();
+
+    check_dual_jump();
+    check_callr_lr();
+    check_jumpr_old_target();
 
     puts(err ? "FAIL" : "PASS");
     return err ? 1 : 0;
diff --git a/tests/tcg/hexagon/usr.c b/tests/tcg/hexagon/usr.c
index ef1787c64c6..129e249da66 100644
--- a/tests/tcg/hexagon/usr.c
+++ b/tests/tcg/hexagon/usr.c
@@ -660,6 +660,37 @@ static void test_usr_packets(void)
     check32(usr_out & 0x3f, USR_OVF | USR_FPINPF);
 }
 
+/* A packet reads the old sticky OVF, then commits any new saturation. */
+static void test_usr_read_before_write(void)
+{
+    static const struct {
+        uint32_t initial, x, result, final;
+    } cases[] = {
+        { 0,       0x7fffffff, 0x7fffffff, USR_OVF },
+        { USR_OVF, 1,          2,          USR_OVF },
+        { 0,       1,          2,          0       },
+    };
+
+    for (int i = 0; i < ARRAY_SIZE(cases); i++) {
+        uint32_t result, before, after;
+
+        asm volatile("usr = %[initial]\n\t"
+                     "{\n\t"
+                     "    %[result] = add(%[x], %[one]):sat\n\t"
+                     "    %[before] = usr\n\t"
+                     "}\n\t"
+                     "%[after] = usr\n\t"
+                     : [result] "=r"(result), [before] "=r"(before),
+                       [after] "=r"(after)
+                     : [initial] "r"(cases[i].initial), [x] "r"(cases[i].x),
+                       [one] "r"(1)
+                     : "usr");
+        check32(result, cases[i].result);
+        check32(before & USR_OVF, cases[i].initial);
+        check32(after & USR_OVF, cases[i].final);
+    }
+}
+
 int main()
 {
     TEST_R_OP_R(satub,       0,         0,         USR_CLEAR);
@@ -1151,6 +1182,8 @@ int main()
 
     test_usr_packets();
 
+    test_usr_read_before_write();
+
     puts(err ? "FAIL" : "PASS");
     return err;
 }
diff --git a/tests/tcg/hexagon/test_dotnew.S b/tests/tcg/hexagon/test_dotnew.S
index b18b6a72e2e..1c2eeebc052 100644
--- a/tests/tcg/hexagon/test_dotnew.S
+++ b/tests/tcg/hexagon/test_dotnew.S
@@ -33,6 +33,38 @@ _start:
     }
     {
         deallocframe
-        p0 = cmp.eq(r3, #2); if (p0.new) jump:t pass
+        p0 = cmp.eq(r3, #2); if (p0.new) jump:t .Lcorner_cases
         jump fail
     }
+
+/*
+ * .new selects a producer through an unrelated instruction and an extender.
+ * The parallel ordinary read still sees the producer's input value.
+ */
+.Lcorner_cases:
+    { allocframe(#16) }
+    { r0 = #7; r1 = #11 }
+    {
+        r0 = ##0x12345678
+        r3 = r0
+        memw(sp+#0) = r0.new
+    }
+    { r4 = memw(sp+#0); r5 = ##0x12345678 }
+    { p0 = cmp.eq(r4, r5); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r3, #7); if (!p0.new) jump:nt fail }
+
+/* A load producer must forward the loaded value, not its old destination. */
+    { r0 = #37 }
+    { r0 = memw(sp+#0); memw(sp+#4) = r0.new }
+    { r4 = memw(sp+#4) }
+    { p0 = cmp.eq(r4, r5); if (!p0.new) jump:nt fail }
+
+/* Predicate.new gates the store independently of the data.new forwarding. */
+    { r0 = #13; r1 = #0; memw(sp+#8) = #19 }
+    { p0 = cmp.eq(r1, #0); r0 = #23; if (p0.new) memw(sp+#8) = r0.new }
+    { r4 = memw(sp+#8) }
+    { p0 = cmp.eq(r4, #23); if (!p0.new) jump:nt fail }
+    { p0 = cmp.gt(r1, #0); r0 = #31; if (p0.new) memw(sp+#8) = r0.new }
+    { r4 = memw(sp+#8) }
+    { p0 = cmp.eq(r4, #23); if (!p0.new) jump:nt fail }
+    { deallocframe; jump pass }
diff --git a/tests/tcg/hexagon/test_packet.S b/tests/tcg/hexagon/test_packet.S
index 9ec9d8d6fb7..7dfaaf9c3ca 100644
--- a/tests/tcg/hexagon/test_packet.S
+++ b/tests/tcg/hexagon/test_packet.S
@@ -24,6 +24,50 @@ _start:
     {
         deallocframe
         p0 = cmp.eq(r3, #4)
-        p0 = cmp.eq(r0, #10); if (p0.new) jump:t pass
+        p0 = cmp.eq(r0, #10); if (p0.new) jump:t .Lcorner_cases
         jump fail
     }
+
+/* Scalar and pair writes commit together, including reads of pair halves. */
+.Lcorner_cases:
+    { r0 = #11; r1 = #22; r2 = #33; r3 = #44 }
+    { r0 = r1; r1 = r2; r2 = r0 }
+    { p0 = cmp.eq(r0, #22); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r1, #33); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r2, #11); if (!p0.new) jump:nt fail }
+    { r1:0 = r3:2; r3:2 = r1:0 }
+    { p0 = cmp.eq(r0, #11); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r1, #44); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r2, #22); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r3, #33); if (!p0.new) jump:nt fail }
+
+    { r0.h = #0x1234; r5:4 = r1:0 }
+    { p0 = cmp.eq(r4, #11); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r5, #44); if (!p0.new) jump:nt fail }
+    { r6 = ##0x1234000b }
+    { p0 = cmp.eq(r0, r6); if (!p0.new) jump:nt fail }
+
+/* An accumulator reads its old destination, as does a parallel copy. */
+    { r0 = #5; r1 = #3; r2 = #7 }
+    { r0 += mpyi(r1, r2); r3 = r0 }
+    { p0 = cmp.eq(r0, #26); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r3, #5); if (!p0.new) jump:nt fail }
+
+/* A load does not forward to an ordinary store's data or base operands. */
+    { allocframe(#16) }
+    { r0 = #17; r1 = #29; r20 = sp }
+    { memw(sp+#0) = r1 }
+    { r0 = memw(r20+#0); memw(r20+#4) = r0 }
+    { r2 = memw(sp+#4) }
+    { p0 = cmp.eq(r0, #29); if (!p0.new) jump:nt fail }
+    { p0 = cmp.eq(r2, #17); if (!p0.new) jump:nt fail }
+/* Without :mem_noshuf, an aliasing load sees memory before the store. */
+    { r0 = memw(r20+#0); memw(r20+#0) = r2 }
+    { p0 = cmp.eq(r0, #29); if (!p0.new) jump:nt fail }
+    { r4 = memw(r20+#0) }
+    { p0 = cmp.eq(r4, #17); if (!p0.new) jump:nt fail }
+    { r0 = memw(r20++#4); r3 = r20 }
+    { p0 = cmp.eq(r3, sp); if (!p0.new) jump:nt fail }
+    { r4 = sub(r20, sp) }
+    { p0 = cmp.eq(r4, #4); if (!p0.new) jump:nt fail }
+    { deallocframe; jump pass }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 11/14] hw/hexagon: honor configured RAM backends
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (9 preceding siblings ...)
  2026-11-19 20:15 ` [PATCH-for-11.2 10/14] tests/tcg/hexagon: packet and COF corner cases Brian Cain
@ 2026-11-19 20:16 ` Brian Cain
  2026-11-19 20:16 ` [PATCH-for-11.2 12/14] hw/hexagon: version the virt machine type Brian Cain
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

The Hexagon machines consumed the MachineState memory-backend
configuration but always created and mapped a separate DDR region, so
a memory backend given with -machine memory-backend= was never used as
guest memory.  Map the machine's configured RAM when present, so that
file-backed and shared memory (as used by the migration tests) is
actually guest memory.  Keep the board-allocated RAM as the fallback.

Add a regression test that writes guest DDR and verifies the bytes
through the backing file.  It fails without this change.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 hw/hexagon/hex-subsys.c           | 10 +++++++---
 tests/qtest/hexagon-config-test.c | 26 ++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c
index 52ec0cadacc..1103d2b556c 100644
--- a/hw/hexagon/hex-subsys.c
+++ b/hw/hexagon/hex-subsys.c
@@ -163,12 +163,16 @@ void hex_subsys_create(HexagonCommonMachineState *hms,
 {
     MachineState *machine = MACHINE(hms);
     MemoryRegion *sysmem = get_system_memory();
+    MemoryRegion *ram = machine->ram;
     size_t i;
 
     /* Main DDR. */
-    memory_region_init_ram(&hms->ram, NULL, "ddr.ram", machine->ram_size,
-                           &error_fatal);
-    memory_region_add_subregion(sysmem, m_cfg->ddr_base, &hms->ram);
+    if (!ram) {
+        memory_region_init_ram(&hms->ram, NULL, "ddr.ram", machine->ram_size,
+                               &error_fatal);
+        ram = &hms->ram;
+    }
+    memory_region_add_subregion(sysmem, m_cfg->ddr_base, ram);
 
     /* Config-table ROM and the blob that backs it. */
     memory_region_init_rom(&hms->cfgtable_rom, NULL, "config_table.rom",
diff --git a/tests/qtest/hexagon-config-test.c b/tests/qtest/hexagon-config-test.c
index 9554fce57ca..d4dc9a2d3f0 100644
--- a/tests/qtest/hexagon-config-test.c
+++ b/tests/qtest/hexagon-config-test.c
@@ -60,6 +60,31 @@ static void test_config_table(gconstpointer data)
     qtest_end();
 }
 
+/* The virt machine maps DDR at guest physical address 0. */
+static void test_memory_backend(void)
+{
+    g_autofree char *path = NULL;
+    g_autofree char *args = NULL;
+    const uint8_t expected[] = { 0x12, 0x34, 0x56, 0x78 };
+    uint8_t actual[4];
+    int fd = g_file_open_tmp("hexagon-ram-XXXXXX", &path, NULL);
+
+    g_assert_cmpint(fd, >=, 0);
+    g_assert_cmpint(ftruncate(fd, 16 * 1024 * 1024), ==, 0);
+    args = g_strdup_printf("-machine virt,memory-backend=ram -m 16M "
+                           "-object memory-backend-file,id=ram,size=16M,"
+                           "share=on,mem-path=%s", path);
+    qtest_start(args);
+    /* QEMU has the file open now, so nothing is left behind on failure. */
+    unlink(path);
+    writel(0x1000, 0x78563412);
+    g_assert_cmpint(lseek(fd, 0x1000, SEEK_SET), ==, 0x1000);
+    g_assert_cmpint(read(fd, actual, sizeof(actual)), ==, sizeof(actual));
+    g_assert_cmpmem(actual, sizeof(actual), expected, sizeof(expected));
+    qtest_end();
+    close(fd);
+}
+
 int main(int argc, char **argv)
 {
     size_t i;
@@ -74,5 +99,6 @@ int main(int argc, char **argv)
         qtest_add_data_func(path, mc, test_config_table);
     }
 
+    qtest_add_func("/config/memory-backend", test_memory_backend);
     return g_test_run();
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 12/14] hw/hexagon: version the virt machine type
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (10 preceding siblings ...)
  2026-11-19 20:16 ` [PATCH-for-11.2 11/14] hw/hexagon: honor configured RAM backends Brian Cain
@ 2026-11-19 20:16 ` Brian Cain
  2026-11-19 20:16 ` [PATCH-for-11.2 13/14] tests/qtest/migration: add Hexagon to the migration framework Brian Cain
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

Make the existing virt type abstract and add virt-11.2 as its only
concrete type, aliased as "virt".

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 docs/system/hexagon/machines.rst |  3 +++
 hw/hexagon/virt.c                | 37 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/docs/system/hexagon/machines.rst b/docs/system/hexagon/machines.rst
index a4760b7a5b1..3bdf5eac26e 100644
--- a/docs/system/hexagon/machines.rst
+++ b/docs/system/hexagon/machines.rst
@@ -29,6 +29,9 @@ hardware available to the guest, including CPUs, interrupt controller,
 console, virtio devices, and accelerator capabilities. See :doc:`boot` for
 its boot protocol.
 
+``virt`` is an alias for the latest versioned machine type, currently
+``virt-11.2``.
+
 Board-specific CDSP and NSP machines
 ------------------------------------
 
diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c
index 3327e28d121..7c798222ba6 100644
--- a/hw/hexagon/virt.c
+++ b/hw/hexagon/virt.c
@@ -161,7 +161,44 @@ static const TypeInfo virt_machine_types[] = { {
     .parent = TYPE_HEXAGON_COMMON_MACHINE,
     .instance_size = sizeof(HexagonVirtMachineState),
     .class_init = virt_class_init,
+    .abstract = true,
     .is_available = target_hexagon,
 } };
 
 DEFINE_TYPES(virt_machine_types)
+
+#define DEFINE_VIRT_MACHINE_IMPL(latest, ...) \
+    static void MACHINE_VER_SYM(class_init, virt, __VA_ARGS__)( \
+        ObjectClass *oc, \
+        const void *data) \
+    { \
+        MachineClass *mc = MACHINE_CLASS(oc); \
+        MACHINE_VER_SYM(options, virt, __VA_ARGS__)(mc); \
+        mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) \
+                   " Hexagon Virtual Machine"; \
+        MACHINE_VER_DEPRECATION(__VA_ARGS__); \
+        if (latest) { \
+            mc->alias = "virt"; \
+        } \
+    } \
+    static const TypeInfo MACHINE_VER_SYM(info, virt, __VA_ARGS__) = \
+    { \
+        .name = MACHINE_VER_TYPE_NAME("virt", __VA_ARGS__), \
+        .parent = TYPE_HEXAGON_VIRT_MACHINE, \
+        .class_init = MACHINE_VER_SYM(class_init, virt, __VA_ARGS__), \
+        .is_available = target_hexagon, \
+    }; \
+    static void MACHINE_VER_SYM(register, virt, __VA_ARGS__)(void) \
+    { \
+        MACHINE_VER_DELETION(__VA_ARGS__); \
+        type_register_static(&MACHINE_VER_SYM(info, virt, __VA_ARGS__)); \
+    } \
+    type_init(MACHINE_VER_SYM(register, virt, __VA_ARGS__));
+
+#define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \
+    DEFINE_VIRT_MACHINE_IMPL(true, major, minor)
+
+static void virt_machine_11_2_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(11, 2)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 13/14] tests/qtest/migration: add Hexagon to the migration framework
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (11 preceding siblings ...)
  2026-11-19 20:16 ` [PATCH-for-11.2 12/14] hw/hexagon: version the virt machine type Brian Cain
@ 2026-11-19 20:16 ` Brian Cain
  2026-11-19 20:16 ` [PATCH-for-11.2 14/14] tests/qtest: add a Hexagon migration state test Brian Cain
  2026-11-20 12:40 ` [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Fabiano Rosas
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

Add a conventional dirty-page guest for the Hexagon virt machine, in the
same form as the other architectures: it touches the first byte of each
page of the test range in order and reports progress on the UART.  Wire
it into bootfile.c and framework.c, register migration-test for the
Hexagon target, and add the new directory to the regeneration Makefile
and to MAINTAINERS.

The guest is checked in as generated instruction bytes, so running the
test needs neither a cross compiler nor downloaded firmware.  The guest
link address comes from bootfile.h, so it is defined only once.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 MAINTAINERS                                |  1 +
 tests/qtest/migration/bootfile.h           |  6 ++++
 tests/qtest/migration/hexagon/a-b-kernel.h | 21 ++++++++++++
 tests/qtest/migration/bootfile.c           |  4 +++
 tests/qtest/migration/framework.c          |  8 +++++
 tests/qtest/meson.build                    |  3 +-
 tests/qtest/migration/Makefile             |  2 +-
 tests/qtest/migration/hexagon/Makefile     | 30 ++++++++++++++++++
 tests/qtest/migration/hexagon/a-b-kernel.S | 37 ++++++++++++++++++++++
 9 files changed, 110 insertions(+), 2 deletions(-)
 create mode 100644 tests/qtest/migration/hexagon/a-b-kernel.h
 create mode 100644 tests/qtest/migration/hexagon/Makefile
 create mode 100644 tests/qtest/migration/hexagon/a-b-kernel.S

diff --git a/MAINTAINERS b/MAINTAINERS
index 15942aaba3a..5baf78faa55 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1396,6 +1396,7 @@ F: configs/devices/hexagon-softmmu/default.mak
 F: docs/system/hexagon/
 F: tests/functional/hexagon/
 F: tests/qtest/hexagon-config-test.c
+F: tests/qtest/migration/hexagon/
 F: tests/qtest/qcom-dsp-test.c
 F: docs/devel/hexagon-sys.rst
 F: pc-bios/hexagon*
diff --git a/tests/qtest/migration/bootfile.h b/tests/qtest/migration/bootfile.h
index a4060ea4f72..717de0b07e7 100644
--- a/tests/qtest/migration/bootfile.h
+++ b/tests/qtest/migration/bootfile.h
@@ -42,6 +42,12 @@
  */
 #define ARM_TEST_MAX_KERNEL_SIZE (512 * 1024)
 
+/* Hexagon virt: keep the guest code below the test memory range. */
+#define HEXAGON_TEST_MEM_START (1 * 1024 * 1024)
+#define HEXAGON_TEST_MEM_END (100 * 1024 * 1024)
+#define HEXAGON_MACH_VIRT_UART 0x10000000
+#define HEXAGON_TEST_KERNEL_ADDR 0x10000
+
 /* LoongArch64 */
 #define LOONGARCH_TEST_MEM_START (32 * 1024 * 1024)
 #define LOONGARCH_TEST_MEM_END   (100 * 1024 * 1024)
diff --git a/tests/qtest/migration/hexagon/a-b-kernel.h b/tests/qtest/migration/hexagon/a-b-kernel.h
new file mode 100644
index 00000000000..35ce5286ed1
--- /dev/null
+++ b/tests/qtest/migration/hexagon/a-b-kernel.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/*
+ * This file is automatically generated from the assembly file in
+ * tests/qtest/migration/hexagon. Edit that file and then run "make"
+ * inside tests/qtest/migration to update, and then remember to send both
+ * the header and the assembler differences in your patch submission.
+ */
+unsigned char hexagon_kernel[] = {
+  0x00, 0x40, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x78, 0x00, 0x40, 0x64, 0x00,
+  0x01, 0xc0, 0x00, 0x78, 0x00, 0x40, 0x00, 0x01, 0x02, 0xc0, 0x00, 0x78,
+  0x03, 0xc0, 0x00, 0x78, 0x04, 0xc0, 0x60, 0x70, 0x00, 0xc3, 0x04, 0xa1,
+  0x40, 0x40, 0x00, 0x00, 0x04, 0xc0, 0x04, 0xb0, 0x00, 0xc1, 0x04, 0xf2,
+  0xf8, 0xe0, 0xff, 0x5c, 0x23, 0xc8, 0x00, 0x78, 0x00, 0xc3, 0x02, 0xa1,
+  0x05, 0xc0, 0x00, 0x78, 0x04, 0xc0, 0x60, 0x70, 0x03, 0xc0, 0x04, 0x91,
+  0x23, 0xc0, 0x03, 0xb0, 0x00, 0xc3, 0x04, 0xa1, 0x40, 0x40, 0x00, 0x00,
+  0x04, 0xc0, 0x04, 0xb0, 0x00, 0xc1, 0x04, 0xf2, 0xf4, 0xe0, 0xff, 0x5c,
+  0x25, 0xc0, 0x05, 0xb0, 0xe5, 0xc3, 0x05, 0x76, 0x00, 0xc0, 0x05, 0x75,
+  0xea, 0xe0, 0xff, 0x5c, 0x43, 0xc8, 0x00, 0x78, 0x00, 0xc3, 0x02, 0xa1,
+  0x04, 0xc0, 0x40, 0x54, 0xe2, 0xff, 0xff, 0x59
+};
diff --git a/tests/qtest/migration/bootfile.c b/tests/qtest/migration/bootfile.c
index e46ad09de76..af3f1c23712 100644
--- a/tests/qtest/migration/bootfile.c
+++ b/tests/qtest/migration/bootfile.c
@@ -19,6 +19,7 @@
 #include "bootfile.h"
 #include "i386/a-b-bootblock.h"
 #include "aarch64/a-b-kernel.h"
+#include "hexagon/a-b-kernel.h"
 #include "loongarch64/a-b-kernel.h"
 #include "ppc64/a-b-kernel.h"
 #include "s390x/a-b-bios.h"
@@ -58,6 +59,9 @@ char *bootfile_create(const char *arch, const char *dir, bool suspend_me)
         content = aarch64_kernel;
         len = sizeof(aarch64_kernel);
         g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
+    } else if (strcmp(arch, "hexagon") == 0) {
+        content = hexagon_kernel;
+        len = sizeof(hexagon_kernel);
     } else if (strcmp(arch, "loongarch64") == 0) {
         content = loongarch64_kernel;
         len = sizeof(loongarch64_kernel);
diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
index b7aef6b21cb..e4b1b105267 100644
--- a/tests/qtest/migration/framework.c
+++ b/tests/qtest/migration/framework.c
@@ -367,6 +367,14 @@ int migrate_args(char **from, char **to, MigrateStart *args)
         arch_opts = g_strdup_printf("-cpu max -kernel %s", bootpath);
         start_address = ARM_TEST_MEM_START;
         end_address = ARM_TEST_MEM_END;
+    } else if (strcmp(arch, "hexagon") == 0) {
+        memory_size = "150M";
+        machine_alias = "virt";
+        start_address = HEXAGON_TEST_MEM_START;
+        end_address = HEXAGON_TEST_MEM_END;
+        arch_opts = g_strdup_printf(
+            "-smp 1 -device loader,file=%s,addr=0x%x,cpu-num=0,force-raw=on",
+            bootpath, HEXAGON_TEST_KERNEL_ADDR);
     } else if (strcmp(arch, "loongarch64") == 0) {
         memory_size = "256M";
         machine_alias = "virt";
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 6e2938d913e..67410b3778f 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -330,7 +330,8 @@ qtests_riscv64 = ['riscv-csr-test'] + \
 
 qtests_hexagon = ['boot-serial-test', 'hexagon-config-test', 'l2vic-test',
                   'qcom-dsp-test',
-                  'qct-qtimer-test']
+                  'qct-qtimer-test',
+                  'migration-test']
 
 qos_test_ss = ss.source_set()
 qos_test_ss.add(
diff --git a/tests/qtest/migration/Makefile b/tests/qtest/migration/Makefile
index 626e3974f7b..0cf7d528ca4 100644
--- a/tests/qtest/migration/Makefile
+++ b/tests/qtest/migration/Makefile
@@ -5,7 +5,7 @@
 # See the COPYING file in the top-level directory.
 #
 
-TARGET_LIST = i386 aarch64 s390x ppc64 loongarch64
+TARGET_LIST = i386 aarch64 s390x ppc64 loongarch64 hexagon
 
 SRC_PATH = ../../../..
 
diff --git a/tests/qtest/migration/hexagon/Makefile b/tests/qtest/migration/hexagon/Makefile
new file mode 100644
index 00000000000..5000de63044
--- /dev/null
+++ b/tests/qtest/migration/hexagon/Makefile
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# To specify cross compiler prefix, use CROSS_PREFIX=
+#   $ make CROSS_PREFIX=hexagon-unknown-linux-musl-
+# The tools can also be overridden individually: CC, OBJCOPY and NM.
+CC = $(or $(CROSS_PREFIX),hexagon-unknown-linux-musl-)clang
+OBJCOPY = llvm-objcopy
+NM = llvm-nm
+
+# $(call define-value,NAME,header) is the value of "#define NAME" in header,
+# so that load addresses are defined only once.
+define-value = $(shell awk '$$2 == "$(1)" { print $$3 }' $(2))
+
+.PHONY: all clean
+all: a-b-kernel.h
+
+a-b-kernel.h: hexagon.kernel
+	echo "$$__note" > $@
+	xxd -i $< | sed -e '/.*int.*/d' >> $@
+
+hexagon.kernel: hexagon.elf
+	$(OBJCOPY) -O binary --only-section=.text $< $@
+
+hexagon.elf: a-b-kernel.S ../bootfile.h
+	$(CC) -mcpu=hexagonv68 -nostdlib -static -fno-pie -Wl,--build-id=none \
+	    -Wl,-Ttext=$(call define-value,HEXAGON_TEST_KERNEL_ADDR,../bootfile.h) \
+	    -Wl,-e,_start $< -o $@
+
+clean:
+	$(RM) *.kernel *.elf
diff --git a/tests/qtest/migration/hexagon/a-b-kernel.S b/tests/qtest/migration/hexagon/a-b-kernel.S
new file mode 100644
index 00000000000..c54b82dfea1
--- /dev/null
+++ b/tests/qtest/migration/hexagon/a-b-kernel.S
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Dirty one byte per page in order, reporting progress on the virt UART. */
+#include "../bootfile.h"
+
+.text
+.globl _start
+_start:
+    r0 = ##HEXAGON_TEST_MEM_START
+    r1 = ##HEXAGON_TEST_MEM_END
+    r2 = ##HEXAGON_MACH_VIRT_UART
+    r3 = #0
+    r4 = r0
+clean:
+    memb(r4) = r3
+    r4 = add(r4, ##TEST_MEM_PAGE_SIZE)
+    p0 = cmp.eq(r4, r1)
+    if (!p0) jump clean
+    r3 = #'A'
+    memb(r2) = r3
+    r5 = #0
+mainloop:
+    r4 = r0
+innerloop:
+    r3 = memb(r4)
+    r3 = add(r3, #1)
+    memb(r4) = r3
+    r4 = add(r4, ##TEST_MEM_PAGE_SIZE)
+    p0 = cmp.eq(r4, r1)
+    if (!p0) jump innerloop
+    r5 = add(r5, #1)
+    r5 = and(r5, #31)
+    p0 = cmp.eq(r5, #0)
+    if (!p0) jump mainloop
+    r3 = #'B'
+    memb(r2) = r3
+    pause(#1)
+    jump mainloop
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH-for-11.2 14/14] tests/qtest: add a Hexagon migration state test
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (12 preceding siblings ...)
  2026-11-19 20:16 ` [PATCH-for-11.2 13/14] tests/qtest/migration: add Hexagon to the migration framework Brian Cain
@ 2026-11-19 20:16 ` Brian Cain
  2026-11-20 12:40 ` [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Fabiano Rosas
  14 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-19 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Laurent Vivier, Pierrick Bouvier, Paolo Bonzini,
	Brian Cain, Peter Xu

The shared migration test only checks that RAM migrates.  Add a Hexagon
specific qtest on the sm8975-nsp machine, with two hardware threads,
that checks the architectural state a migration must carry: scalar and
predicate registers, SSR and CCR context selection, distinct HVX and
HLX register contents in two contexts, QTimer and L2VIC state, and a
thread blocked on the K0 lock.  It runs the same checkpoint through a
stopped migration, a precopy migration paused before switchover, and
an internal qcow2 snapshot (savevm/loadvm) in an already used VM.

The guest uses raw HLX encodings, each annotated with its mnemonic, so
that it can be regenerated with toolchains whose assembler lacks HLX
support.  The host test and the guest share the mailbox layout in
state.h.  The test waits for the second thread's PC with 'info
registers' because QMP has no structured query for a CPU's PC or lock
wait state.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 MAINTAINERS                            |   1 +
 tests/qtest/migration/hexagon/guest.h  |  47 ++++
 tests/qtest/migration/hexagon/state.h  |  29 +++
 tests/qtest/hexagon-migration-test.c   | 312 +++++++++++++++++++++++++
 tests/qtest/meson.build                |   4 +-
 tests/qtest/migration/hexagon/Makefile |  22 +-
 tests/qtest/migration/hexagon/guest.S  | 124 ++++++++++
 7 files changed, 536 insertions(+), 3 deletions(-)
 create mode 100644 tests/qtest/migration/hexagon/guest.h
 create mode 100644 tests/qtest/migration/hexagon/state.h
 create mode 100644 tests/qtest/hexagon-migration-test.c
 create mode 100644 tests/qtest/migration/hexagon/guest.S

diff --git a/MAINTAINERS b/MAINTAINERS
index 5baf78faa55..b3d0d1b4cbb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1396,6 +1396,7 @@ F: configs/devices/hexagon-softmmu/default.mak
 F: docs/system/hexagon/
 F: tests/functional/hexagon/
 F: tests/qtest/hexagon-config-test.c
+F: tests/qtest/hexagon-migration-test.c
 F: tests/qtest/migration/hexagon/
 F: tests/qtest/qcom-dsp-test.c
 F: docs/devel/hexagon-sys.rst
diff --git a/tests/qtest/migration/hexagon/guest.h b/tests/qtest/migration/hexagon/guest.h
new file mode 100644
index 00000000000..c647274d733
--- /dev/null
+++ b/tests/qtest/migration/hexagon/guest.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/*
+ * This file is automatically generated from the assembly file in
+ * tests/qtest/migration/hexagon. Edit that file and then run "make"
+ * inside tests/qtest/migration to update, and then remember to send both
+ * the header and the assembler differences in your patch submission.
+ */
+#define HEXAGON_PEER_LOCK_PC 0x80010198
+static const uint8_t guest_bin[] = {
+  0x00, 0x48, 0x00, 0x08, 0x10, 0xc0, 0x00, 0x78, 0x00, 0xc0, 0x88, 0x6e,
+  0x00, 0xc0, 0x00, 0x75, 0xbe, 0xc0, 0x20, 0x5c, 0x00, 0x44, 0x00, 0x08,
+  0x00, 0xc0, 0x00, 0x78, 0x10, 0xc0, 0x00, 0x67, 0x00, 0xc0, 0x86, 0x6e,
+  0x00, 0xdf, 0xc0, 0x8c, 0x06, 0xc0, 0x00, 0x67, 0xa0, 0xc6, 0x00, 0x78,
+  0x40, 0xc0, 0xc0, 0x19, 0xe0, 0xca, 0x00, 0x78, 0x5f, 0xc0, 0xc0, 0x19,
+  0x03, 0xc0, 0x80, 0x1f, 0x00, 0xc0, 0x86, 0x6e, 0x00, 0xdb, 0xc0, 0x8c,
+  0x06, 0xc0, 0x00, 0x67, 0xc0, 0xc8, 0x00, 0x78, 0x40, 0xc0, 0xc0, 0x19,
+  0x00, 0xcd, 0x00, 0x78, 0x5f, 0xc0, 0xc0, 0x19, 0x03, 0xc0, 0x9f, 0x1f,
+  0x00, 0x40, 0x00, 0x01, 0x00, 0xc0, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x67,
+  0x48, 0x40, 0x00, 0x00, 0x8a, 0xc6, 0x00, 0x78, 0x2c, 0xe4, 0x2a, 0xe5,
+  0x00, 0x40, 0x02, 0x01, 0x00, 0xc0, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x67,
+  0x59, 0x41, 0x00, 0x00, 0x0a, 0xc7, 0x00, 0x78, 0x2c, 0xe4, 0x2a, 0xe5,
+  0x60, 0xc0, 0x20, 0x6c, 0x40, 0xc0, 0x00, 0x78, 0x20, 0xc0, 0x60, 0x64,
+  0xfb, 0x76, 0xea, 0x0d, 0xf4, 0xc5, 0x00, 0x78, 0xc8, 0x50, 0x65, 0x07,
+  0x15, 0xc2, 0x00, 0x78, 0xfc, 0x6b, 0x55, 0x0a, 0x00, 0xc0, 0x00, 0x78,
+  0x04, 0xc0, 0x20, 0x62, 0x64, 0x45, 0x14, 0x03, 0xc0, 0xc4, 0x00, 0x78,
+  0x00, 0xc0, 0x00, 0x67, 0x0b, 0xd4, 0x90, 0xa1, 0x81, 0xc0, 0x50, 0x3c,
+  0x81, 0xc1, 0x90, 0x91, 0x21, 0xc0, 0x01, 0xb0, 0x0c, 0xc1, 0x90, 0xa1,
+  0x00, 0xc0, 0x90, 0x91, 0x00, 0xc0, 0x00, 0x75, 0x06, 0xc0, 0x20, 0x5c,
+  0x04, 0xc0, 0x40, 0x54, 0xf2, 0xff, 0xff, 0x59, 0x05, 0xd4, 0x90, 0xa1,
+  0x06, 0xd5, 0x90, 0xa1, 0x00, 0xc0, 0x04, 0x6a, 0x07, 0xc0, 0x90, 0xa1,
+  0x00, 0xc0, 0x86, 0x6e, 0x08, 0xc0, 0x90, 0xa1, 0x00, 0xc0, 0x87, 0x6e,
+  0x09, 0xc0, 0x90, 0xa1, 0x00, 0xc0, 0x80, 0x6e, 0x0a, 0xc0, 0x90, 0xa1,
+  0x40, 0x48, 0x00, 0x08, 0x00, 0xc0, 0x00, 0x78, 0x00, 0xc0, 0x20, 0x28,
+  0x1f, 0xc1, 0x20, 0x28, 0x61, 0xe0, 0xff, 0x1e, 0x01, 0xc2, 0x20, 0x28,
+  0x80, 0x48, 0x00, 0x08, 0x06, 0xc0, 0x00, 0x78, 0xac, 0x79, 0x00, 0xe5,
+  0x06, 0xc0, 0x86, 0xa4, 0x00, 0xc0, 0x86, 0x6e, 0x20, 0xdb, 0xc0, 0x8c,
+  0x06, 0xc0, 0x00, 0x67, 0x60, 0x48, 0x00, 0x08, 0x00, 0xc0, 0x00, 0x78,
+  0x00, 0xc0, 0x20, 0x28, 0x1f, 0xc1, 0x20, 0x28, 0x61, 0xe0, 0xff, 0x1e,
+  0x01, 0xc2, 0x20, 0x28, 0x00, 0x40, 0x00, 0x01, 0x00, 0xc0, 0x00, 0x78,
+  0x07, 0xc0, 0x00, 0x67, 0xa0, 0x48, 0x00, 0x08, 0x06, 0xc0, 0x00, 0x78,
+  0xac, 0x79, 0x00, 0xe5, 0x06, 0xc0, 0x86, 0xa4, 0x80, 0xc0, 0x20, 0x6c,
+  0x01, 0xc2, 0x50, 0x3c, 0x04, 0xc0, 0x40, 0x54, 0xfe, 0xff, 0xff, 0x59,
+  0xc0, 0x7b, 0xaf, 0x0c, 0xb6, 0xc1, 0x00, 0x78, 0x01, 0xc1, 0x50, 0x3c,
+  0x60, 0xc0, 0x20, 0x6c, 0x0d, 0xd6, 0x90, 0xa1, 0x80, 0xc0, 0x20, 0x6c,
+  0x81, 0xc1, 0x50, 0x3c, 0xee, 0xff, 0xff, 0x59
+};
diff --git a/tests/qtest/migration/hexagon/state.h b/tests/qtest/migration/hexagon/state.h
new file mode 100644
index 00000000000..6a4c05bd9d8
--- /dev/null
+++ b/tests/qtest/migration/hexagon/state.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef HEXAGON_MIGRATION_STATE_H
+#define HEXAGON_MIGRATION_STATE_H
+
+/* SM8975 NSP DDR and device map; mailbox fields are byte offsets. */
+#define STATE_KERNEL_ADDR 0x80010000
+#define STATE_MAILBOX 0x80020000
+#define STATE_RELEASE 0
+#define STATE_READY 4
+#define STATE_PEER_READY 8
+#define STATE_PEER_DONE 12
+#define STATE_DONE 16
+#define STATE_R20 20
+#define STATE_R21 24
+#define STATE_PREDICATES 28
+#define STATE_SSR 32
+#define STATE_CCR 36
+#define STATE_SGP0 40
+#define STATE_MEMORY 44
+#define STATE_HEARTBEAT 48
+#define STATE_PEER_R22 52
+#define STATE_HVX1 0x80021000
+#define STATE_HVX0 0x80021800
+#define STATE_HLX1 0x80022000
+#define STATE_HLX0 0x80022800
+#define STATE_QTIMER 0x263a1000
+#define STATE_L2VIC 0x26390000
+
+#endif
diff --git a/tests/qtest/hexagon-migration-test.c b/tests/qtest/hexagon-migration-test.c
new file mode 100644
index 00000000000..b9a774aa6a8
--- /dev/null
+++ b/tests/qtest/hexagon-migration-test.c
@@ -0,0 +1,312 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Same-build Hexagon migration and internal snapshot regression tests. */
+
+#include "qemu/osdep.h"
+#include "libqtest.h"
+#include "qobject/qdict.h"
+#include "migration/hexagon/guest.h"
+#include "migration/hexagon/state.h"
+#include "migration/migration-qmp.h"
+
+#define TIMEOUT_US (30 * G_USEC_PER_SEC)
+
+/* QTimer registers; each frame is 0x1000 bytes after the previous one. */
+#define QTIMER_CNTPCT_LO        0x000
+#define QTIMER_CNTP_CVAL_LO(f)  (0x020 + (f) * 0x1000)
+#define QTIMER_CNTP_CTL(f)      (0x02c + (f) * 0x1000)
+#define QTIMER_CTL_ENABLE       1
+#define QTIMER_CTL_EXPIRED      5       /* enabled, IMASK clear, ISTATUS set */
+
+/* L2VIC registers and the interrupt lines this test looks at. */
+#define L2VIC_INT_TYPEn         0x280
+#define L2VIC_SOFT_INTn         0x480
+#define L2VIC_INT_PENDINGn      0x500
+#define L2VIC_QTIMER0_IRQ       2
+#define L2VIC_QTIMER1_IRQ       3
+#define L2VIC_SOFT_IRQ          10
+#define PENDING_TIMER0_SOFT \
+    ((1 << L2VIC_QTIMER0_IRQ) | (1 << L2VIC_SOFT_IRQ))
+#define PENDING_ALL (PENDING_TIMER0_SOFT | (1 << L2VIC_QTIMER1_IRQ))
+
+static char *tmpdir;
+static char *guest_path;
+
+static uint32_t mailbox_read(QTestState *vm, unsigned offset)
+{
+    return qtest_readl(vm, STATE_MAILBOX + offset);
+}
+
+static void wait_word(QTestState *vm, uint64_t addr, uint32_t value)
+{
+    int64_t deadline = g_get_monotonic_time() + TIMEOUT_US;
+
+    while (qtest_readl(vm, addr) != value) {
+        g_assert_cmpint(g_get_monotonic_time(), <, deadline);
+        g_usleep(1000);
+    }
+}
+
+static uint32_t qtimer_ctl(QTestState *vm, unsigned frame)
+{
+    return qtest_readl(vm, STATE_QTIMER + QTIMER_CNTP_CTL(frame));
+}
+
+static uint32_t l2vic_pending(QTestState *vm, uint32_t mask)
+{
+    return qtest_readl(vm, STATE_L2VIC + L2VIC_INT_PENDINGn) & mask;
+}
+
+static uint64_t qtimer_deadline(QTestState *vm)
+{
+    return qtest_readq(vm, STATE_QTIMER + QTIMER_CNTP_CVAL_LO(1));
+}
+
+static uint64_t qtimer_count(QTestState *vm)
+{
+    return qtest_readq(vm, STATE_QTIMER + QTIMER_CNTPCT_LO);
+}
+
+static void stop_vm(QTestState *vm)
+{
+    qtest_qmp_assert_success(vm, "{'execute':'stop'}");
+    qtest_qmp_eventwait(vm, "STOP");
+}
+
+static QTestState *start_vm(const char *extra)
+{
+    return qtest_initf("-machine sm8975-nsp -m 16M -smp 2 "
+                       "-accel tcg,thread=single -icount shift=0,sleep=off "
+                       "-device loader,file=%s,addr=0x%x,cpu-num=0,"
+                       "force-raw=on %s", guest_path, STATE_KERNEL_ADDR, extra);
+}
+
+static void wait_checkpoint(QTestState *vm)
+{
+    int64_t deadline = g_get_monotonic_time() + TIMEOUT_US;
+    g_autofree char *pc = g_strdup_printf("pc = 0x%08x",
+                                         HEXAGON_PEER_LOCK_PC);
+
+    wait_word(vm, STATE_MAILBOX + STATE_READY, 1);
+    wait_word(vm, STATE_MAILBOX + STATE_PEER_READY, 1);
+    /* Wait until the second CPU has reached the blocking lock instruction. */
+    while (true) {
+        QDict *reply = qtest_qmp(vm,
+            "{'execute':'human-monitor-command','arguments':"
+            "{'command-line':'info registers','cpu-index':1}}");
+        const char *output;
+        bool found;
+
+        g_assert_true(qdict_haskey(reply, "return"));
+        output = qdict_get_str(reply, "return");
+        found = strstr(output, pc) != NULL;
+
+        if (!found && g_get_monotonic_time() >= deadline) {
+            g_error("Expected %s in registers: %s", pc, output);
+        }
+        qobject_unref(reply);
+        if (found) {
+            break;
+        }
+        g_usleep(1000);
+    }
+    g_assert_cmphex(mailbox_read(vm, STATE_PEER_DONE), ==, 0);
+}
+
+static void arm_future_timer(QTestState *vm)
+{
+    uint64_t now = qtimer_count(vm);
+
+    /* Frame 1 has a deadline still in the future at the checkpoint. */
+    qtest_writel(vm, STATE_QTIMER + QTIMER_CNTP_CTL(1), 0);
+    qtest_writeq(vm, STATE_QTIMER + QTIMER_CNTP_CVAL_LO(1), now + 1024);
+    qtest_writel(vm, STATE_QTIMER + QTIMER_CNTP_CTL(1), QTIMER_CTL_ENABLE);
+    g_assert_cmphex(qtimer_ctl(vm, 1), ==, QTIMER_CTL_ENABLE);
+}
+
+static void prepare_devices(QTestState *vm)
+{
+    /* Dispatch frame 0's expiry callback before freezing the clock. */
+    qtest_writeq(vm, STATE_QTIMER + QTIMER_CNTP_CVAL_LO(0), 0);
+    qtest_writel(vm, STATE_QTIMER + QTIMER_CNTP_CTL(0), QTIMER_CTL_ENABLE);
+    qtest_qmp_assert_success(vm, "{'execute':'cont'}");
+    wait_word(vm, STATE_QTIMER + QTIMER_CNTP_CTL(0), QTIMER_CTL_EXPIRED);
+    stop_vm(vm);
+    arm_future_timer(vm);
+    /* Keep an independent software interrupt pending alongside the timer. */
+    qtest_writel(vm, STATE_L2VIC + L2VIC_INT_TYPEn, 1 << L2VIC_SOFT_IRQ);
+    qtest_writel(vm, STATE_L2VIC + L2VIC_SOFT_INTn, 1 << L2VIC_SOFT_IRQ);
+    g_assert_cmphex(qtimer_ctl(vm, 0), ==, QTIMER_CTL_EXPIRED);
+    g_assert_cmphex(l2vic_pending(vm, PENDING_TIMER0_SOFT), ==,
+                    PENDING_TIMER0_SOFT);
+}
+
+static void check_devices(QTestState *vm, uint64_t now, uint64_t compare)
+{
+    g_assert_cmphex(qtest_readl(vm, STATE_L2VIC + L2VIC_INT_TYPEn), ==,
+                    1 << L2VIC_SOFT_IRQ);
+    g_assert_cmphex(qtimer_count(vm), ==, now);
+    g_assert_cmphex(qtimer_deadline(vm), ==, compare);
+    g_assert_cmphex(qtimer_ctl(vm, 0), ==, QTIMER_CTL_EXPIRED);
+    g_assert_cmphex(qtimer_ctl(vm, 1), ==, QTIMER_CTL_ENABLE);
+    g_assert_cmphex(l2vic_pending(vm, PENDING_TIMER0_SOFT), ==,
+                    PENDING_TIMER0_SOFT);
+}
+
+static void check_bytes(QTestState *vm, uint64_t addr, size_t size,
+                        uint16_t pattern)
+{
+    g_autofree uint8_t *data = g_malloc(size);
+
+    qtest_memread(vm, addr, data, size);
+    for (size_t i = 0; i < size; i++) {
+        g_assert_cmphex(data[i], ==, (pattern >> (8 * (i & 1))) & 0xff);
+    }
+}
+
+static void check_guest(QTestState *vm)
+{
+    qtest_writel(vm, STATE_MAILBOX + STATE_RELEASE, 1);
+    qtest_qmp_assert_success(vm, "{'execute':'cont'}");
+    wait_word(vm, STATE_MAILBOX + STATE_DONE, 1);
+    wait_word(vm, STATE_MAILBOX + STATE_PEER_DONE, 1);
+    /* Check that the migrated deadline fires after resuming. */
+    wait_word(vm, STATE_QTIMER + QTIMER_CNTP_CTL(1), QTIMER_CTL_EXPIRED);
+    stop_vm(vm);
+    g_assert_cmphex(mailbox_read(vm, STATE_R20), ==, 0xdeadbeef);
+    g_assert_cmphex(mailbox_read(vm, STATE_R21), ==, 0x76543210);
+    g_assert_cmphex(mailbox_read(vm, STATE_PREDICATES), ==, 0xa55aff00);
+    g_assert_cmphex(mailbox_read(vm, STATE_SSR), ==, 0x88020000);
+    g_assert_cmphex(mailbox_read(vm, STATE_CCR), ==, 0x10200000);
+    g_assert_cmphex(mailbox_read(vm, STATE_SGP0), ==, 0x31415926);
+    g_assert_cmphex(mailbox_read(vm, STATE_MEMORY), ==, 0xdeadbeef);
+    g_assert_cmphex(mailbox_read(vm, STATE_PEER_R22), ==, 0xcafef00d);
+    check_bytes(vm, STATE_HVX1, 128, 0x4646);
+    check_bytes(vm, STATE_HVX1 + 128, 128, 0x6868);
+    check_bytes(vm, STATE_HVX1 + 256, 128, 0x6868);
+    check_bytes(vm, STATE_HVX0, 128, 0x3535);
+    check_bytes(vm, STATE_HVX0 + 128, 128, 0x5757);
+    check_bytes(vm, STATE_HVX0 + 256, 128, 0x3535);
+    check_bytes(vm, STATE_HLX1, 2048, 0x5678);
+    check_bytes(vm, STATE_HLX0, 2048, 0x1234);
+    g_assert_cmphex(l2vic_pending(vm, PENDING_ALL), ==, PENDING_ALL);
+}
+
+static void test_migration(gconstpointer opaque)
+{
+    g_autofree char *uri = g_strdup_printf("unix:%s/migrate.sock", tmpdir);
+    QTestState *source = start_vm("");
+    QTestState *dest;
+    bool live = GPOINTER_TO_UINT(opaque);
+    uint64_t now, compare;
+    uint32_t heartbeat;
+
+    wait_checkpoint(source);
+    stop_vm(source);
+    prepare_devices(source);
+    now = qtimer_count(source);
+    compare = qtimer_deadline(source);
+    heartbeat = mailbox_read(source, STATE_HEARTBEAT);
+    if (live) {
+        migrate_set_capability(source, "pause-before-switchover", true);
+        qtest_qmp_assert_success(source, "{'execute':'cont'}");
+    }
+    dest = start_vm("-incoming defer -S");
+    migrate_incoming_qmp(dest, uri, NULL, "{}");
+    migrate_qmp(source, dest, uri, NULL, "{}");
+    if (live) {
+        QDict *status;
+
+        wait_for_migration_status(source, "pre-switchover", NULL);
+        status = qtest_qmp_assert_success_ref(source,
+                                             "{'execute':'query-status'}");
+        g_assert_false(qdict_get_bool(status, "running"));
+        qobject_unref(status);
+        qtest_qmp_eventwait(source, "STOP");
+        g_assert_cmpuint(mailbox_read(source, STATE_HEARTBEAT), >, heartbeat);
+        arm_future_timer(source);
+        now = qtimer_count(source);
+        compare = qtimer_deadline(source);
+        heartbeat = mailbox_read(source, STATE_HEARTBEAT);
+        migrate_continue(source, "pre-switchover");
+    }
+    wait_for_migration_complete(source);
+    wait_for_migration_complete(dest);
+    /* Kill the source before checking state or allowing the guest to finish. */
+    qtest_quit(source);
+    check_devices(dest, now, compare);
+    g_assert_cmphex(mailbox_read(dest, STATE_HEARTBEAT), ==, heartbeat);
+    check_guest(dest);
+    qtest_quit(dest);
+}
+
+static void snapshot_command(QTestState *vm, const char *command)
+{
+    g_autofree char *output = qtest_hmp(vm, "%s checkpoint", command);
+
+    g_assert_cmpstr(output, ==, "");
+}
+
+static void test_snapshot(void)
+{
+    g_autofree char *disk = g_strdup_printf("%s/state.qcow2", tmpdir);
+    g_autofree char *args = g_strdup_printf(
+        "-drive if=none,id=state,file=%s,format=qcow2", disk);
+    QTestState *vm;
+    uint64_t now, compare;
+    uint32_t heartbeat;
+
+    if (!have_qemu_img()) {
+        g_test_skip("qemu-img is required for qcow2 snapshot testing");
+        return;
+    }
+    g_assert_true(mkimg(disk, "qcow2", 8));
+    vm = start_vm(args);
+    wait_checkpoint(vm);
+    stop_vm(vm);
+    prepare_devices(vm);
+    now = qtimer_count(vm);
+    compare = qtimer_deadline(vm);
+    heartbeat = mailbox_read(vm, STATE_HEARTBEAT);
+    snapshot_command(vm, "savevm");
+    /* Change registers, memory, context selection and lock state. */
+    check_guest(vm);
+    qtest_writel(vm, STATE_MAILBOX + STATE_MEMORY, 0);
+    snapshot_command(vm, "loadvm");
+    g_assert_cmphex(qtest_readl(vm, STATE_MAILBOX), ==, 0);
+    g_assert_cmphex(mailbox_read(vm, STATE_PEER_DONE), ==, 0);
+    g_assert_cmphex(mailbox_read(vm, STATE_DONE), ==, 0);
+    g_assert_cmphex(mailbox_read(vm, STATE_MEMORY), ==, 0xdeadbeef);
+    g_assert_cmphex(mailbox_read(vm, STATE_HEARTBEAT), ==, heartbeat);
+    check_devices(vm, now, compare);
+    check_guest(vm);
+    snapshot_command(vm, "delvm");
+    qtest_quit(vm);
+    unlink(disk);
+}
+
+int main(int argc, char **argv)
+{
+    int result;
+
+    g_test_init(&argc, &argv, NULL);
+    if (qtest_has_accel("tcg")) {
+        tmpdir = g_dir_make_tmp("hexagon-migration-XXXXXX", NULL);
+        g_assert_nonnull(tmpdir);
+        guest_path = g_strdup_printf("%s/guest.bin", tmpdir);
+        g_assert_true(g_file_set_contents(guest_path, (const char *)guest_bin,
+                                          sizeof(guest_bin), NULL));
+        qtest_add_data_func("/migration/stopped", GUINT_TO_POINTER(false),
+                            test_migration);
+        qtest_add_data_func("/migration/precopy", GUINT_TO_POINTER(true),
+                            test_migration);
+        qtest_add_func("/migration/snapshot", test_snapshot);
+    }
+    result = g_test_run();
+    if (tmpdir) {
+        unlink(guest_path);
+        g_free(guest_path);
+        g_assert_cmpint(rmdir(tmpdir), ==, 0);
+        g_free(tmpdir);
+    }
+    return result;
+}
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 67410b3778f..2a987fcb49d 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -331,7 +331,7 @@ qtests_riscv64 = ['riscv-csr-test'] + \
 qtests_hexagon = ['boot-serial-test', 'hexagon-config-test', 'l2vic-test',
                   'qcom-dsp-test',
                   'qct-qtimer-test',
-                  'migration-test']
+                  'hexagon-migration-test', 'migration-test']
 
 qos_test_ss = ss.source_set()
 qos_test_ss.add(
@@ -442,6 +442,8 @@ qtests = {
                        [gio],
   'erst-test': files('erst-test.c'),
   'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
+  'hexagon-migration-test': files('migration/migration-qmp.c',
+                                  'migration/migration-util.c'),
   'migration-test': test_migration_files + migration_tls_files + migration_colo_files,
   'pxe-test': files('boot-sector.c'),
   'pnv-xive2-test': files('pnv-xive2-common.c', 'pnv-xive2-flush-sync.c',
diff --git a/tests/qtest/migration/hexagon/Makefile b/tests/qtest/migration/hexagon/Makefile
index 5000de63044..f9025ccb1a0 100644
--- a/tests/qtest/migration/hexagon/Makefile
+++ b/tests/qtest/migration/hexagon/Makefile
@@ -12,7 +12,7 @@ NM = llvm-nm
 define-value = $(shell awk '$$2 == "$(1)" { print $$3 }' $(2))
 
 .PHONY: all clean
-all: a-b-kernel.h
+all: a-b-kernel.h guest.h
 
 a-b-kernel.h: hexagon.kernel
 	echo "$$__note" > $@
@@ -26,5 +26,23 @@ hexagon.elf: a-b-kernel.S ../bootfile.h
 	    -Wl,-Ttext=$(call define-value,HEXAGON_TEST_KERNEL_ADDR,../bootfile.h) \
 	    -Wl,-e,_start $< -o $@
 
+# The state guest uses the HVX and HLX extensions of the SM8975 NSP and is
+# linked where state.h says the host test loads it.
+guest.h: guest.bin guest.elf
+	echo "$$__note" > $@
+	$(NM) guest.elf | awk '$$3 == "peer_lock" \
+	    { print "#define HEXAGON_PEER_LOCK_PC 0x"$$1 }' >> $@
+	xxd -i guest.bin | sed -e 's/^unsigned char/static const uint8_t/' \
+	    -e '/unsigned int guest_bin_len/d' >> $@
+
+guest.bin: guest.elf
+	$(OBJCOPY) -O binary --only-section=.text $< $@
+
+guest.elf: guest.S state.h
+	$(CC) -mcpu=hexagonv81 -mhvx -mhvx-length=128b -nostdlib -static \
+	    -fno-pie -Wl,--build-id=none \
+	    -Wl,-Ttext=$(call define-value,STATE_KERNEL_ADDR,state.h) \
+	    -Wl,-e,_start $< -o $@
+
 clean:
-	$(RM) *.kernel *.elf
+	$(RM) *.kernel *.elf *.bin
diff --git a/tests/qtest/migration/hexagon/guest.S b/tests/qtest/migration/hexagon/guest.S
new file mode 100644
index 00000000000..74300d30367
--- /dev/null
+++ b/tests/qtest/migration/hexagon/guest.S
@@ -0,0 +1,124 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Migration checkpoint guest, loaded at 0x80010000 on sm8975-nsp.
+ * r16 points to the host/guest mailbox at 0x80020000. The host releases
+ * the checkpoint by writing 1 to mailbox[0]. No stack or runtime is used.
+ */
+#include "state.h"
+
+.text
+.globl _start
+_start:
+    r16 = ##STATE_MAILBOX
+    r0 = htid
+    p0 = cmp.eq(r0, #0)
+    if (!p0) jump peer
+    r0 = ##STATE_KERNEL_ADDR
+    evb = r0
+
+    /* Distinct state in two shared HVX contexts. */
+    r0 = ssr
+    r0 = setbit(r0, #31)
+    ssr = r0
+    r0 = #0x35
+    v0.b = vsplat(r0)
+    r0 = #0x57
+    v31.b = vsplat(r0)
+    q3 = vcmp.eq(v0.b, v0.b)
+    r0 = ssr
+    r0 = setbit(r0, #27)
+    ssr = r0
+    r0 = #0x46
+    v0.b = vsplat(r0)
+    r0 = #0x68
+    v31.b = vsplat(r0)
+    q3 = vcmp.eq(v0.b, v31.b)
+
+    /*
+     * Distinct patterns in the two shared HLX contexts. Raw encodings allow
+     * regeneration with assemblers that do not support HLX mnemonics.
+     */
+    r0 = ##0x10000000
+    ccr = r0
+    r10 = ##0x1234
+    .word 0xe52ae42c /* L6.h = r10.h */
+    r0 = ##0x10200000
+    ccr = r0
+    r10 = ##0x5678
+    .word 0xe52ae42c /* L6.h = r10.h */
+
+    /* Keep both an owner and a blocked waiter across the checkpoint. */
+    k0lock
+    r0 = #2
+    start(r0)
+    r20 = ##0xdeadbeef
+    r21 = ##0x76543210
+    r0 = ##0xa55aff00
+    p3:0 = r0
+    r0 = ##0x31415926
+    sgp0 = r0
+    memw(r16 + #STATE_MEMORY) = r20
+    memw(r16 + #STATE_READY) = #1
+checkpoint:
+    r1 = memw(r16 + #STATE_HEARTBEAT)
+    r1 = add(r1, #1)
+    memw(r16 + #STATE_HEARTBEAT) = r1
+    r0 = memw(r16 + #STATE_RELEASE)
+    p0 = cmp.eq(r0, #0)
+    if (!p0) jump released
+    pause(#1)
+    jump checkpoint
+released:
+    memw(r16 + #STATE_R20) = r20
+    memw(r16 + #STATE_R21) = r21
+    r0 = p3:0
+    memw(r16 + #STATE_PREDICATES) = r0
+    r0 = ssr
+    memw(r16 + #STATE_SSR) = r0
+    r0 = ccr
+    memw(r16 + #STATE_CCR) = r0
+    r0 = sgp0
+    memw(r16 + #STATE_SGP0) = r0
+
+    /* Read the active contexts before changing the selection. */
+    r0 = ##STATE_HVX1
+    vmem(r0) = v0
+    vmem(r0 + #1) = v31
+    v1 = vmux(q3, v0, v31)
+    vmem(r0 + #2) = v1
+    r6 = ##STATE_HLX1
+    /* The producer and .new store form one packet. */
+    .word 0xe50079ac /* L6.h = L6.h */
+    .word 0xa486c006 /* mem(r6) = L6.new */
+
+    r0 = ssr
+    r0 = clrbit(r0, #27)
+    ssr = r0
+    r0 = ##STATE_HVX0
+    vmem(r0) = v0
+    vmem(r0 + #1) = v31
+    v1 = vmux(q3, v0, v31)
+    vmem(r0 + #2) = v1
+    r0 = ##0x10000000
+    ccr = r0
+    r6 = ##STATE_HLX0
+    /* The producer and .new store form one packet. */
+    .word 0xe50079ac /* L6.h = L6.h */
+    .word 0xa486c006 /* mem(r6) = L6.new */
+
+    k0unlock
+    memw(r16 + #STATE_DONE) = #1
+done:
+    pause(#1)
+    jump done
+
+peer:
+    r22 = ##0xcafef00d
+    memw(r16 + #STATE_PEER_READY) = #1
+.globl peer_lock
+peer_lock:
+    k0lock
+    memw(r16 + #STATE_PEER_R22) = r22
+    k0unlock
+    memw(r16 + #STATE_PEER_DONE) = #1
+    jump done
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH-for-11.2 00/14] Hexagon: fix systests + migration
  2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
                   ` (13 preceding siblings ...)
  2026-11-19 20:16 ` [PATCH-for-11.2 14/14] tests/qtest: add a Hexagon migration state test Brian Cain
@ 2026-11-20 12:40 ` Fabiano Rosas
  2026-11-20 19:13   ` Brian Cain
  14 siblings, 1 reply; 17+ messages in thread
From: Fabiano Rosas @ 2026-11-20 12:40 UTC (permalink / raw)
  To: Brian Cain, qemu-devel
  Cc: Laurent Vivier, Pierrick Bouvier, Paolo Bonzini, Brian Cain,
	Peter Xu

Brian Cain <brian.cain@oss.qualcomm.com> writes:

> The systests/arch tarballs were crafted while testing a downstream fork.
>
> Enabling the omitted tests revealed a few remaining bugs in 11.2.  Add
> those tests and the associated fixes, plus a couple of fixes from Marco's
> recent series.
>
> Brian Cain (12):
>   target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread
>   target/hexagon: deliver floating point exceptions after the packet
>   target/hexagon: report the faulting packet for stack limit exceptions
>   target/hexagon: take exceptions for cache operations
>   target/hexagon: raise decode failures at the faulting packet
>   hw/hexagon: update the glob-reg vmstate ver
>   tests/functional/hexagon: run the rest of the tests
>   tests/tcg/hexagon: packet and COF corner cases
>   hw/hexagon: honor configured RAM backends
>   hw/hexagon: version the virt machine type
>   tests/qtest/migration: add Hexagon to the migration framework
>   tests/qtest: add a Hexagon migration state test
>
> Marco Liebel (2):
>   target/hexagon: read the old predicate value through C4
>   target/hexagon: bound packet lookahead to the current page
>
>  MAINTAINERS                                 |   2 +
>  docs/system/hexagon/machines.rst            |   3 +
>  target/hexagon/gen_tcg.h                    |  18 +-
>  target/hexagon/helper.h                     |   4 +-
>  target/hexagon/translate.h                  |   6 +-
>  tests/qtest/migration/bootfile.h            |   6 +
>  tests/qtest/migration/hexagon/a-b-kernel.h  |  21 ++
>  tests/qtest/migration/hexagon/guest.h       |  47 +++
>  tests/qtest/migration/hexagon/state.h       |  29 ++
>  hw/hexagon/hex-subsys.c                     |  10 +-
>  hw/hexagon/hexagon_globalreg.c              |   4 +-
>  hw/hexagon/virt.c                           |  37 +++
>  target/hexagon/arch.c                       |   9 +-
>  target/hexagon/cpu_helper.c                 |   1 +
>  target/hexagon/genptr.c                     |   3 +-
>  target/hexagon/hexswi.c                     |   1 +
>  target/hexagon/op_helper.c                  |  46 ++-
>  target/hexagon/translate.c                  |  28 +-
>  tests/qtest/hexagon-config-test.c           |  26 ++
>  tests/qtest/hexagon-migration-test.c        | 312 ++++++++++++++++++++
>  tests/qtest/migration/bootfile.c            |   4 +
>  tests/qtest/migration/framework.c           |   8 +
>  tests/tcg/hexagon/brev.c                    |  25 ++
>  tests/tcg/hexagon/circ.c                    |  42 +++
>  tests/tcg/hexagon/dual_stores.c             |  34 +++
>  tests/tcg/hexagon/mem_noshuf.c              |  58 +++-
>  tests/tcg/hexagon/packet_user.c             |  38 +++
>  tests/tcg/hexagon/preg_alias.c              |  58 ++++
>  tests/tcg/hexagon/test_cond_branch.c        |  95 ++++++
>  tests/tcg/hexagon/usr.c                     |  33 +++
>  tests/functional/hexagon/meson.build        |   2 +
>  tests/functional/hexagon/test_arch_tests.py | 114 ++++++-
>  tests/functional/hexagon/test_linux.py      |  62 ++++
>  tests/functional/hexagon/test_systests.py   | 259 +++++++++++++++-
>  tests/qtest/meson.build                     |   5 +-
>  tests/qtest/migration/Makefile              |   2 +-
>  tests/qtest/migration/hexagon/Makefile      |  48 +++
>  tests/qtest/migration/hexagon/a-b-kernel.S  |  37 +++
>  tests/qtest/migration/hexagon/guest.S       | 124 ++++++++
>  tests/tcg/hexagon/meson.build               |   1 +
>  tests/tcg/hexagon/test_dotnew.S             |  34 ++-
>  tests/tcg/hexagon/test_packet.S             |  46 ++-
>  42 files changed, 1700 insertions(+), 42 deletions(-)
>  create mode 100644 tests/qtest/migration/hexagon/a-b-kernel.h
>  create mode 100644 tests/qtest/migration/hexagon/guest.h
>  create mode 100644 tests/qtest/migration/hexagon/state.h
>  create mode 100644 tests/qtest/hexagon-migration-test.c
>  create mode 100644 tests/tcg/hexagon/packet_user.c
>  create mode 100755 tests/functional/hexagon/test_linux.py
>  create mode 100644 tests/qtest/migration/hexagon/Makefile
>  create mode 100644 tests/qtest/migration/hexagon/a-b-kernel.S
>  create mode 100644 tests/qtest/migration/hexagon/guest.S

Let's leave the migration tests for the next cycle, please.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH-for-11.2 00/14] Hexagon: fix systests + migration
  2026-11-20 12:40 ` [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Fabiano Rosas
@ 2026-11-20 19:13   ` Brian Cain
  0 siblings, 0 replies; 17+ messages in thread
From: Brian Cain @ 2026-11-20 19:13 UTC (permalink / raw)
  To: Fabiano Rosas, qemu-devel
  Cc: Laurent Vivier, Pierrick Bouvier, Paolo Bonzini, Peter Xu


On 11/20/2026 6:40 AM, Fabiano Rosas wrote:
> Brian Cain <brian.cain@oss.qualcomm.com> writes:
>
>> The systests/arch tarballs were crafted while testing a downstream fork.
>>
>> Enabling the omitted tests revealed a few remaining bugs in 11.2.  Add
>> those tests and the associated fixes, plus a couple of fixes from Marco's
>> recent series.

>> ...

>> Let's leave the migration tests for the next cycle, please.

ok - omitted from v2.



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-11-20 19:14 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 20:15 [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 01/14] target/hexagon: read the old predicate value through C4 Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 02/14] target/hexagon: bound packet lookahead to the current page Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 03/14] target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 04/14] target/hexagon: deliver floating point exceptions after the packet Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 05/14] target/hexagon: report the faulting packet for stack limit exceptions Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 06/14] target/hexagon: take exceptions for cache operations Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 07/14] target/hexagon: raise decode failures at the faulting packet Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 08/14] hw/hexagon: update the glob-reg vmstate ver Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 09/14] tests/functional/hexagon: run the rest of the tests Brian Cain
2026-11-19 20:15 ` [PATCH-for-11.2 10/14] tests/tcg/hexagon: packet and COF corner cases Brian Cain
2026-11-19 20:16 ` [PATCH-for-11.2 11/14] hw/hexagon: honor configured RAM backends Brian Cain
2026-11-19 20:16 ` [PATCH-for-11.2 12/14] hw/hexagon: version the virt machine type Brian Cain
2026-11-19 20:16 ` [PATCH-for-11.2 13/14] tests/qtest/migration: add Hexagon to the migration framework Brian Cain
2026-11-19 20:16 ` [PATCH-for-11.2 14/14] tests/qtest: add a Hexagon migration state test Brian Cain
2026-11-20 12:40 ` [PATCH-for-11.2 00/14] Hexagon: fix systests + migration Fabiano Rosas
2026-11-20 19:13   ` Brian Cain

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.