On 9/10/2026 6:44 PM, Marco Liebel wrote:
On Thu, Sep 10, 2026 at 10:32 AM Brian Cain <[email protected]> wrote:
Assign env->hvx to the right context when SSR:XA changes.
Signed-off-by: Brian Cain <[email protected]>
---
target/hexagon/cpu_helper.h | 1 +
target/hexagon/cpu.c | 5 +++
target/hexagon/cpu_helper.c | 72 +++++++++++++++++++++++++++++++++++++
target/hexagon/machine.c | 12 +++++++
4 files changed, 90 insertions(+)
+static unsigned hexagon_hvx_context_index(HexagonCPU *cpu, uint8_t xa)
+{
+ unsigned n = hexagon_hvx_context_count(cpu);
+
+ if (n == 0) {
+ return 0;
+ }
+ return xa % n;
+}
Why is `xa` wrapped with `% n` instead of being used directly?
The behavior for an out-of-range SSR.XA value is unspecified.
Empirically I can see that the reference simulator happens to map these
values to some in-range context number, but the behavior varies from
arch rev to rev. So - a modulus seems reasonable/appropriate to me.
But in v5 I'll add a GUEST_ERROR when it's out of range here so that
users have a way to find out what went wrong.