Hexagon: fix systests + migration
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.
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
Signature · 1 line
2.34.1
PATCH 1/14 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
@@ -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
@@ -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; + + asmvolatile ( +"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
@@ -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
PATCH 2/14 target/hexagon: bound packet lookahead to the current page
In reply to Brian CainFrom: 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
@@ -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
PATCH 3/14 target/hexagon: fix get_exe_mode assertion in hexagon_stop_thread
In reply to Brian CainWhen 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
@@ -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
PATCH 4/14 target/hexagon: deliver floating point exceptions after the packet
In reply to Brian CainAn 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 5/14 target/hexagon: report the faulting packet for stack limit exceptions
In reply to Brian CainThe 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 6/14 target/hexagon: take exceptions for cache operations
In reply to Brian CainThe 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
@@ -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
@@ -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
@@ -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
PATCH 7/14 target/hexagon: raise decode failures at the faulting packet
In reply to Brian CainA 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
@@ -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
@@ -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
PATCH 8/14 hw/hexagon: update the glob-reg vmstate ver
In reply to Brian CainSince 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
@@ -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
PATCH 9/14 tests/functional/hexagon: run the rest of the tests
In reply to Brian CainThe 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
@@ -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
PATCH 10/14 tests/tcg/hexagon: packet and COF corner cases
In reply to Brian CainAdd 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
@@ -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 ; + asmvolatile ("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
@@ -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 ; + asmvolatile ("{\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 ; + asmvolatile ("{\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
@@ -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; + + asmvolatile ("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
@@ -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
PATCH 11/14 hw/hexagon: honor configured RAM backends
In reply to Brian CainThe 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
@@ -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
@@ -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
PATCH 12/14 hw/hexagon: version the virt machine type
In reply to Brian CainMake 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
@@ -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
@@ -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
PATCH 13/14 tests/qtest/migration: add Hexagon to the migration framework
In reply to Brian CainAdd 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.
--- 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
MAINTAINERS +1 -0
@@ -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*
tests/qtest/migration/bootfile.h +6 -0
@@ -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)
tests/qtest/migration/hexagon/a-b-kernel.h new file +21 -0
@@ -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 +};
tests/qtest/migration/bootfile.c +4 -0
@@ -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);
tests/qtest/migration/framework.c +8 -0
@@ -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" ;
tests/qtest/meson.build +2 -1
@@ -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(
tests/qtest/migration/Makefile +1 -1
@@ -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 = ../../../..
tests/qtest/migration/hexagon/Makefile new file +30 -0
@@ -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
tests/qtest/migration/hexagon/a-b-kernel.S new file +37 -0
@@ -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
Signature · 1 line
2.34.1
PATCH 14/14 tests/qtest: add a Hexagon migration state test
In reply to Brian CainThe 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.
--- 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
MAINTAINERS +1 -0
@@ -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
tests/qtest/migration/hexagon/guest.h new file +47 -0
47 lines not on this page · raw message
tests/qtest/migration/hexagon/state.h new file +29 -0
@@ -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
tests/qtest/hexagon-migration-test.c new file +312 -0
312 lines not on this page · raw message
tests/qtest/meson.build +3 -1
@@ -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',
tests/qtest/migration/hexagon/Makefile +20 -2
@@ -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
tests/qtest/migration/hexagon/guest.S new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 68 lines · Brian Cain
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: fixget_exe_modeassertion inhexagon_stop_threadtarget/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 testMarco Liebel (2):
target/hexagon: read the old predicate value through C4 target/hexagon: bound packet lookahead to the current pageMAINTAINERS | 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
Quoted 8 lines
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.
Quoted 11 lines · Fabiano Rosas
Quoted 9 lines · Brian Cain
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.