All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Cain via qemu development <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org
Cc: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	Brian Cain <brian.cain@oss.qualcomm.com>,
	Laurent Vivier <laurent@vivier.eu>, Helge Deller <deller@gmx.de>
Subject: [PATCH v2 10/11] target/hexagon: fix iassign{r, w} to cover all threads
Date: Tue,  1 Sep 2026 10:33:52 -0700	[thread overview]
Message-ID: <20260901173353.200474-11-brian.cain@oss.qualcomm.com> (raw)
In-Reply-To: <20260901173353.200474-1-brian.cain@oss.qualcomm.com>

iassignw/iassignr were filtering CPU_FOREACH by MODECTL_E, the
thread-enabled mask. That mask reflects whether a thread has been
started, not whether it exists, so IMASK writes/reads never reached
threads that hadn't been started yet, leaving their IMASK stale or
unreadable. Drop the MODECTL_E filtering and operate on every thread.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/op_helper.c | 42 +++++++++-----------------------------
 1 file changed, 10 insertions(+), 32 deletions(-)

diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
index df31ed2488a..e19c3c91085 100644
--- a/target/hexagon/op_helper.c
+++ b/target/hexagon/op_helper.c
@@ -1637,61 +1637,39 @@ void HELPER(cswi)(CPUHexagonState *env, uint32_t mask)
 
 void HELPER(iassignw)(CPUHexagonState *env, uint32_t src)
 {
-    uint32_t modectl;
-    uint32_t thread_enabled_mask;
     CPUState *cpu;
-    HexagonCPU *hex_cpu;
 
     BQL_LOCK_GUARD();
-    hex_cpu = env_archcpu(env);
-    modectl = hex_cpu->globalregs ?
-        hexagon_globalreg_read(hex_cpu->globalregs, HEX_SREG_MODECTL,
-                               env->threadId) : 0;
-    thread_enabled_mask = GET_FIELD(MODECTL_E, modectl);
 
     CPU_FOREACH(cpu) {
         CPUHexagonState *thread_env = &(HEXAGON_CPU(cpu)->env);
-        uint32_t thread_id_mask = 0x1 << thread_env->threadId;
-        if (thread_enabled_mask & thread_id_mask) {
-            uint32_t imask = thread_env->t_sreg[HEX_SREG_IMASK];
-            uint32_t intbitpos = (src >> 16) & 0xF;
-            uint32_t val = (src >> thread_env->threadId) & 0x1;
-            imask = deposit32(imask, intbitpos, 1, val);
-            thread_env->t_sreg[HEX_SREG_IMASK] = imask;
+        uint32_t imask = thread_env->t_sreg[HEX_SREG_IMASK];
+        uint32_t intbitpos = (src >> 16) & 0xF;
+        uint32_t val = (src >> thread_env->threadId) & 0x1;
+        imask = deposit32(imask, intbitpos, 1, val);
+        thread_env->t_sreg[HEX_SREG_IMASK] = imask;
 
-            qemu_log_mask(CPU_LOG_INT, "%s: thread " TARGET_FMT_ld
-               ", new imask 0x%" PRIx32 "\n", __func__,
-               thread_env->threadId, imask);
-        }
+        qemu_log_mask(CPU_LOG_INT, "%s: thread " TARGET_FMT_ld
+           ", new imask 0x%" PRIx32 "\n", __func__,
+           thread_env->threadId, imask);
     }
     hex_interrupt_update(env);
 }
 
 uint32_t HELPER(iassignr)(CPUHexagonState *env, uint32_t src)
 {
-    uint32_t modectl;
-    uint32_t thread_enabled_mask;
     uint32_t intbitpos;
     uint32_t dest_reg;
     CPUState *cpu;
-    HexagonCPU *hex_cpu;
 
     BQL_LOCK_GUARD();
-    hex_cpu = env_archcpu(env);
-    modectl = hex_cpu->globalregs ?
-        hexagon_globalreg_read(hex_cpu->globalregs, HEX_SREG_MODECTL,
-                               env->threadId) : 0;
-    thread_enabled_mask = GET_FIELD(MODECTL_E, modectl);
     /* src fields are in same position as modectl, but mean different things */
     intbitpos = GET_FIELD(MODECTL_W, src);
     dest_reg = 0;
     CPU_FOREACH(cpu) {
         CPUHexagonState *thread_env = &(HEXAGON_CPU(cpu)->env);
-        uint32_t thread_id_mask = 0x1 << thread_env->threadId;
-        if (thread_enabled_mask & thread_id_mask) {
-            uint32_t imask = thread_env->t_sreg[HEX_SREG_IMASK];
-            dest_reg |= ((imask >> intbitpos) & 0x1) << thread_env->threadId;
-        }
+        uint32_t imask = thread_env->t_sreg[HEX_SREG_IMASK];
+        dest_reg |= ((imask >> intbitpos) & 0x1) << thread_env->threadId;
     }
 
     return dest_reg;
-- 
2.34.1


  parent reply	other threads:[~2026-09-01 17:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 17:33 [PATCH v2 00/11] Hexagon: exception, interrupt, system reg fixes Brian Cain
2026-09-01 17:33 ` [PATCH v2 01/11] target/hexagon: align exceptions for user/sysemu Brian Cain
2026-09-01 17:33 ` [PATCH v2 02/11] tests/tcg/hexagon: check priv instructions raise SIGILL Brian Cain
2026-09-01 17:33 ` [PATCH v2 03/11] hw/intc: clear pending bit on l2vic de-assertion Brian Cain
2026-09-02 21:30   ` Philippe Mathieu-Daudé
2026-09-03 19:33     ` Brian Cain
2026-09-01 17:33 ` [PATCH v2 04/11] target/hexagon: guard writes to unimplemented guest registers Brian Cain
2026-09-01 18:25   ` Pierrick Bouvier
2026-09-01 17:33 ` [PATCH v2 05/11] target/hexagon: take BQL when reading the system pcycle count Brian Cain
2026-09-01 17:33 ` [PATCH v2 06/11] target/hexagon: gate GPCYCLE guest register reads on SSR:CE Brian Cain
2026-09-02 21:16   ` Philippe Mathieu-Daudé
2026-09-03 19:36     ` Brian Cain
2026-09-04 13:19       ` Philippe Mathieu-Daudé
2026-09-01 17:33 ` [PATCH v2 07/11] target/hexagon: read UTIMERLO/UTIMERHI from the global timer Brian Cain
2026-09-02 21:21   ` Philippe Mathieu-Daudé
2026-09-01 17:33 ` [PATCH v2 08/11] target/hexagon: raise imprecise exception on multi-TLB match Brian Cain
2026-09-01 17:33 ` [PATCH v2 09/11] target/hexagon: implement direct-to-guest interrupt delivery Brian Cain
2026-09-01 18:26   ` Pierrick Bouvier
2026-09-01 17:33 ` Brian Cain via qemu development [this message]
2026-09-01 17:33 ` [PATCH v2 11/11] tests/functional/hexagon: update to v0.2.12, +test_{interrupts, sys_regs} Brian Cain via qemu development

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260901173353.200474-11-brian.cain@oss.qualcomm.com \
    --to=qemu-devel@nongnu.org \
    --cc=brian.cain@oss.qualcomm.com \
    --cc=deller@gmx.de \
    --cc=laurent@vivier.eu \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.