> -----Original Message-----
> From: Brian Cain <brian.c...@oss.qualcomm.com>
> Sent: Friday, February 28, 2025 11:28 PM
> To: qemu-devel@nongnu.org
> Cc: brian.c...@oss.qualcomm.com; richard.hender...@linaro.org;
> phi...@linaro.org; quic_mathb...@quicinc.com; a...@rev.ng; a...@rev.ng;
> quic_mlie...@quicinc.com; ltaylorsimp...@gmail.com;
> alex.ben...@linaro.org; quic_mbur...@quicinc.com;
> sidn...@quicinc.com; Brian Cain <bc...@quicinc.com>
> Subject: [PATCH 06/39] target/hexagon: Implement {g,s}etimask helpers
>
> From: Brian Cain <bc...@quicinc.com>
>
> Signed-off-by: Brian Cain <brian.c...@oss.qualcomm.com>
> ---
> target/hexagon/op_helper.c | 31 +++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
> index 9f79b1a20c..83088cfaa3 100644
> --- a/target/hexagon/op_helper.c
> +++ b/target/hexagon/op_helper.c
> @@ -1468,12 +1468,39 @@ void HELPER(resume)(CPUHexagonState *env,
> uint32_t mask)
>
> uint32_t HELPER(getimask)(CPUHexagonState *env, uint32_t tid) {
> - g_assert_not_reached();
> + CPUState *cs;
> + CPU_FOREACH(cs) {
> + HexagonCPU *found_cpu = HEXAGON_CPU(cs);
> + CPUHexagonState *found_env = &found_cpu->env;
> + if (found_env->threadId == tid) {
> + target_ulong imask = arch_get_system_reg(found_env,
> HEX_SREG_IMASK);
> + qemu_log_mask(CPU_LOG_INT, "%s: tid %d imask = 0x%x\n",
> + __func__, env->threadId,
> + (unsigned)GET_FIELD(IMASK_MASK, imask));
> + return GET_FIELD(IMASK_MASK, imask);
> + }
> + }
> + return 0;
> }
>
> void HELPER(setimask)(CPUHexagonState *env, uint32_t pred, uint32_t
> imask) {
The name pred sounds like a predicate register. Use tid instead.
> - g_assert_not_reached();
> + CPUState *cs;
> +
> + BQL_LOCK_GUARD();
> + CPU_FOREACH(cs) {
> + HexagonCPU *found_cpu = HEXAGON_CPU(cs);
> + CPUHexagonState *found_env = &found_cpu->env;
> +
> + if (pred == found_env->threadId) {
> + SET_SYSTEM_FIELD(found_env, HEX_SREG_IMASK, IMASK_MASK,
> imask);
> + qemu_log_mask(CPU_LOG_INT, "%s: tid %d imask 0x%x\n",
> + __func__, found_env->threadId, imask);
> + hex_interrupt_update(env);
Shouldn't this be found_env?
> + return;
> + }
> + }
> + hex_interrupt_update(env);
Do you need to update if the thread wasn't found?
> }
>
> static bool handle_pmu_sreg_write(CPUHexagonState *env, uint32_t reg,
> --
> 2.34.1