Skip to contentSkip to conversation

Hexagon: fix systests + migration

PATCH Superseded Brian Cain 3 participants 26 messages Nov 20 – Nov 23 Arm/Amlogic Meson SoC support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Brian Cain

author
#0 lore raw

v2 cover Hexagon: fix systests + migration

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.

In v2:
- dropped the 'add Hexagon to the migration framework', 'add a Hexagon migration state test' commits. Will target these for 12.0 instead.

v1: https://lore.kernel.org/qemu-devel/[email protected]/

Brian Cain (10):
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

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

 docs/system/hexagon/machines.rst            |   3 +
 target/hexagon/gen_tcg.h                    |  18 +-
 target/hexagon/helper.h                     |   4 +-
 target/hexagon/translate.h                  |   6 +-
 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/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/tcg/hexagon/meson.build               |   1 +
 tests/tcg/hexagon/test_dotnew.S             |  34 ++-
 tests/tcg/hexagon/test_packet.S             |  46 +++-
 29 files changed, 1057 insertions(+), 40 deletions(-)
 create mode 100644 tests/tcg/hexagon/packet_user.c
 create mode 100755 tests/functional/hexagon/test_linux.py
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/12 target/hexagon: read the old predicate value through C4

From: Marco Liebel <[email protected]>

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.

---
 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
target/hexagon/translate.h +5 -1
index bc3b49ab06d..c988c85f33b 100644
@@ -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;
     }
 }
tests/tcg/hexagon/packet_user.c new file +38 -0
new file mode 100644
index 00000000000..acc77202ef3
@@ -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;
+}
tests/tcg/hexagon/meson.build +1 -0
index 70f6475656c..b3635be3fcb 100644
@@ -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},
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v2 2/12 target/hexagon: bound packet lookahead to the current page

In reply to Brian Cain

From: Marco Liebel <[email protected]>

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.

---
 target/hexagon/translate.c | 5 +++++
 1 file changed, 5 insertions(+)
target/hexagon/translate.c +5 -0
index ec1d79e31f6..41a0f2b0852 100644
@@ -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),
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH v2 3/12 target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread

In reply to Brian Cain

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.

---
 target/hexagon/cpu_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/hexagon/cpu_helper.c +1 -0
index f53d377ab14..680dcf56803 100644
@@ -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);
Signature · 1 line
2.34.1
Reviewed-by on v2 3/12
#4 lore raw

Re: [PATCH-for-11.2 v2 03/12] target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread

Quoted 7 lines · Brian Cain

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.

Quoted 5 lines
---
 target/hexagon/cpu_helper.c | 1 +
 1 file changed, 1 insertion(+)
author
#5 lore raw

PATCH v2 4/12 target/hexagon: deliver floating point exceptions after the packet

In reply to Brian Cain

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.

---
 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(-)
target/hexagon/arch.c +5 -4
index 5ee87b320b6..ddbcba9cdd0 100644
@@ -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
 
target/hexagon/hexswi.c +1 -0
index acc68aa6c23..96d4a783ed4 100644
@@ -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);
target/hexagon/translate.c +8 -2
index 41a0f2b0852..eef392b1e9c 100644
@@ -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);
tests/functional/hexagon/test_systests.py +5 -0
index 76e2480c1d3..606567230b9 100755
@@ -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")
Signature · 1 line
2.34.1
Reviewed-by on v2 4/12
#6 lore raw

Re: [PATCH-for-11.2 v2 04/12] target/hexagon: deliver floating point exceptions after the packet

Quoted 9 lines · Brian Cain

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.

Quoted 8 lines
---
 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(-)
author
#7 lore raw

PATCH v2 5/12 target/hexagon: report the faulting packet for stack limit exceptions

In reply to Brian Cain

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.

---
 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(-)
target/hexagon/helper.h +1 -1
index 292ca8eb7c5..e658f8068f4 100644
@@ -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)
target/hexagon/genptr.c +2 -1
index 52615628e3f..90b71ebc016 100644
@@ -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
 }
target/hexagon/op_helper.c +3 -1
index 71b27ef07f1..cdb731160eb 100644
@@ -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;
tests/functional/hexagon/test_systests.py +5 -0
index 606567230b9..f997563baca 100755
@@ -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")
Signature · 1 line
2.34.1
Reviewed-by on v2 5/12
#8 lore raw

Re: [PATCH-for-11.2 v2 05/12] target/hexagon: report the faulting packet for stack limit exceptions

Quoted 8 lines · Brian Cain

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.

Quoted 8 lines
---
 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(-)
author
#9 lore raw

PATCH v2 6/12 target/hexagon: take exceptions for cache operations

In reply to Brian Cain

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.

---
 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(-)
target/hexagon/gen_tcg.h +14 -4
index e82f89aee42..40f35eb8199 100644
@@ -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) \
target/hexagon/helper.h +2 -0
index e658f8068f4..e7e7ab2c02e 100644
@@ -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)
target/hexagon/op_helper.c +42 -0

54 lines not on this page · raw message

tests/functional/hexagon/test_systests.py +4 -0
index f997563baca..5dc05256aae 100755
@@ -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")
Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH-for-11.2 v2 06/12] target/hexagon: take exceptions for cache operations

Quoted 11 lines · Brian Cain

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.

Quoted 9 lines
---
 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(-)

This looks like new feature more than a bug fix.

Regards,
Pierrick

author
#11 lore raw

Re: [PATCH-for-11.2 v2 06/12] target/hexagon: take exceptions for cache operations

Quoted 21 lines · Pierrick Bouvier
Quoted 11 lines · Brian Cain

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.

Quoted 9 lines
---
  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(-)
Quoted 1 line

This looks like new feature more than a bug fix.

Ok - seemed like incomplete buggy behavior from sysemu but I will concede that it's more new code so makes sense to re-target this for 12.0.

Quoted 3 lines

Regards,
Pierrick

author
#12 lore raw

PATCH v2 7/12 target/hexagon: raise decode failures at the faulting packet

In reply to Brian Cain

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.

---
 target/hexagon/translate.c                | 13 +++++++++++--
 tests/functional/hexagon/test_systests.py |  5 +++++
 2 files changed, 16 insertions(+), 2 deletions(-)
target/hexagon/translate.c +11 -2
index eef392b1e9c..126d7b29a9d 100644
@@ -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,
tests/functional/hexagon/test_systests.py +5 -0
index 5dc05256aae..ac2071795fb 100755
@@ -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")
Signature · 1 line
2.34.1
Reviewed-by on v2 7/12
#13 lore raw

Re: [PATCH-for-11.2 v2 07/12] target/hexagon: raise decode failures at the faulting packet

Quoted 7 lines · Brian Cain

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.

Quoted 8 lines

This enables the llsc_on_excp systest.

---
 target/hexagon/translate.c                | 13 +++++++++++--
 tests/functional/hexagon/test_systests.py |  5 +++++
 2 files changed, 16 insertions(+), 2 deletions(-)
author
#14 lore raw

PATCH v2 8/12 hw/hexagon: update the glob-reg vmstate ver

In reply to Brian Cain

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.

---
 hw/hexagon/hexagon_globalreg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/hexagon/hexagon_globalreg.c +2 -2
index 8b50fec770a..dd373dec9fe 100644
@@ -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[]){
Signature · 1 line
2.34.1
#15 lore raw

Re: [PATCH-for-11.2 v2 08/12] hw/hexagon: update the glob-reg vmstate ver

Quoted 10 lines · Brian Cain

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.

---
 hw/hexagon/hexagon_globalreg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Is migration correctly supported at this point? If not, we might also simply leave it as it is.

Regards,
Pierrick

author
#16 lore raw

PATCH v2 9/12 tests/functional/hexagon: run the rest of the tests

In reply to Brian Cain

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.

---
 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
tests/functional/hexagon/meson.build +2 -0
index 3dd40ed0463..565a056a951 100644
@@ -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,
 }
tests/functional/hexagon/test_arch_tests.py +110 -4

150 lines not on this page · raw message

tests/functional/hexagon/test_linux.py new file +62 -0

62 lines not on this page · raw message

tests/functional/hexagon/test_systests.py +238 -2

263 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#17 lore raw

PATCH v2 10/12 tests/tcg/hexagon: packet and COF corner cases

In reply to Brian Cain

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.

---
 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(-)
tests/tcg/hexagon/brev.c +25 -0
index 1473e309ee0..192107d4f30 100644
@@ -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;
 }
tests/tcg/hexagon/circ.c +42 -0

54 lines not on this page · raw message

tests/tcg/hexagon/dual_stores.c +34 -0
index 775458e0fc8..e6fae7fe9b2 100644
@@ -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;
 }
tests/tcg/hexagon/mem_noshuf.c +47 -11

95 lines not on this page · raw message

tests/tcg/hexagon/preg_alias.c +58 -0

70 lines not on this page · raw message

tests/tcg/hexagon/test_cond_branch.c +95 -0

106 lines not on this page · raw message

tests/tcg/hexagon/usr.c +33 -0
index ef1787c64c6..129e249da66 100644
@@ -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;
 }
tests/tcg/hexagon/test_dotnew.S +33 -1
index b18b6a72e2e..1c2eeebc052 100644
@@ -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 }
tests/tcg/hexagon/test_packet.S +45 -1

51 lines not on this page · raw message

Signature · 1 line
2.34.1
#18 lore raw

Re: [PATCH-for-11.2 v2 10/12] tests/tcg/hexagon: packet and COF corner cases

Quoted 14 lines · Brian Cain

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.

Quoted 12 lines
---
 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(-)

Should be split, ideally in its own series, with details per patch to explain what each new test does.

Regards,
Pierrick

author
#19 lore raw

Re: [PATCH-for-11.2 v2 10/12] tests/tcg/hexagon: packet and COF corner cases

Quoted 27 lines · Pierrick Bouvier
Quoted 14 lines · Brian Cain

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.

Quoted 12 lines
---
  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(-)
Quoted 3 lines

Should be split, ideally in its own series, with details per patch to explain what each new test does.

Makes sense - these are not critical for 11.2 so I'll omit them and include in a future 12.0 series.  Thanks.

Quoted 2 lines

Regards,
Pierrick

author
#20 lore raw

PATCH v2 11/12 hw/hexagon: honor configured RAM backends

In reply to Brian Cain

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.

---
 hw/hexagon/hex-subsys.c           | 10 +++++++---
 tests/qtest/hexagon-config-test.c | 26 ++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)
hw/hexagon/hex-subsys.c +7 -3
index 52ec0cadacc..1103d2b556c 100644
@@ -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",
tests/qtest/hexagon-config-test.c +26 -0
index 9554fce57ca..d4dc9a2d3f0 100644
@@ -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();
 }
Signature · 1 line
2.34.1
Reviewed-by on v2 11/12
#21 lore raw

Re: [PATCH-for-11.2 v2 11/12] hw/hexagon: honor configured RAM backends

Quoted 7 lines · Brian Cain

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.

Quoted 9 lines

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

---
 hw/hexagon/hex-subsys.c           | 10 +++++++---
 tests/qtest/hexagon-config-test.c | 26 ++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)
author
#22 lore raw

PATCH v2 12/12 hw/hexagon: version the virt machine type

In reply to Brian Cain

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

---
 docs/system/hexagon/machines.rst |  3 +++
 hw/hexagon/virt.c                | 37 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
docs/system/hexagon/machines.rst +3 -0
index a4760b7a5b1..3bdf5eac26e 100644
@@ -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
 ------------------------------------
 
hw/hexagon/virt.c +37 -0
index 3327e28d121..7c798222ba6 100644
@@ -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)
Signature · 1 line
2.34.1
#23 lore raw

Re: [PATCH-for-11.2 v2 12/12] hw/hexagon: version the virt machine type

Quoted 9 lines · Brian Cain

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

---
 docs/system/hexagon/machines.rst |  3 +++
 hw/hexagon/virt.c                | 37 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

Introducing this mean we'll provide backward compatibility for any future release, which is a huge one promise. Are we ready for this yet?

Regards,
Pierrick

#24 lore raw

Re: [PATCH-for-11.2 v2 12/12] hw/hexagon: version the virt machine type

Quoted 11 lines · Pierrick Bouvier
Quoted 9 lines · Brian Cain

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

---
 docs/system/hexagon/machines.rst |  3 +++
 hw/hexagon/virt.c                | 37 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
Quoted 2 lines

Introducing this mean we'll provide backward compatibility for any future release, which is a huge one promise. Are we ready for this yet?

Aside from that, we're well past soft freeze, and IMHO introducing versioned machine types is a feature, so would have to wait until 12.0 opens up.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
author
#25 lore raw

Re: [PATCH-for-11.2 v2 12/12] hw/hexagon: version the virt machine type

Quoted 11 lines · Daniel P. Berrangé
Quoted 10 lines · Pierrick Bouvier
Quoted 9 lines · Brian Cain

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

---
  docs/system/hexagon/machines.rst |  3 +++
  hw/hexagon/virt.c                | 37 ++++++++++++++++++++++++++++++++
  2 files changed, 40 insertions(+)
Quoted 5 lines
Quoted 2 lines

Introducing this mean we'll provide backward compatibility for any future release, which is a huge one promise. Are we ready for this yet?

Aside from that, we're well past soft freeze, and IMHO introducing versioned machine types is a feature, so would have to wait until 12.0 opens up.

Okay - my mistake -- I'll drop this patch.