Skip to contentSkip to conversation

target/arm: Initialize SMCR_EL1.EZT0 for linux-user

PATCH Applied Philippe Mathieu-Daudé 3 participants 3 messages Oct 26 – Oct 29

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Initialize SMCR_EL1.EZT0 for linux-user

On SME2 systems, Linux sets SMCR_EL1.EZT0 in cpu_enable_sme2() to allow user space to access ZT0.

linux-user already initializes SMCR_EL1.LEN and FA64 to match the kernel's setup, but leaves EZT0 clear (see commit 3aad4bc8beb9 "target/arm: Add zt0_excp_el to DisasContext"). Set EZT0 when SME2 is present to keep the emulated EL1 state consistent with Linux.

This has no functional effect because CONFIG_USER_ONLY omits the ZT0 trap checks.

---
 target/arm/cpu.c | 4 ++++
 1 file changed, 4 insertions(+)
target/arm/cpu.c +4 -0
index 62262d742a27..851c9a81f3cb 100644
@@ -387,6 +387,10 @@ static void arm_cpu_reset_hold(Object *obj, ResetType type)
                 env->vfp.smcr_el[1] = FIELD_DP64(env->vfp.smcr_el[1],
                                                  SMCR, FA64, 1);
             }
+            if (cpu_isar_feature(aa64_sme2, cpu)) {
+                env->vfp.smcr_el[1] = FIELD_DP64(env->vfp.smcr_el[1],
+                                                 SMCR, EZT0, 1);
+            }
         }
         /*
          * Enable 48-bit address space (TODO: take reserved_va into account).
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé

On SME2 systems, Linux sets SMCR_EL1.EZT0 in cpu_enable_sme2() to allow user space to access ZT0.

linux-user already initializes SMCR_EL1.LEN and FA64 to match the kernel's setup, but leaves EZT0 clear (see commit 3aad4bc8beb9 "target/arm: Add zt0_excp_el to DisasContext"). Set EZT0 when SME2 is present to keep the emulated EL1 state consistent with Linux.

This has no functional effect because CONFIG_USER_ONLY omits the ZT0 trap checks.

Quoted 6 lines
---
  target/arm/cpu.c | 4 ++++
  1 file changed, 4 insertions(+)

r~

#2 lore raw
Quoted 13 lines · Richard Henderson
Quoted 11 lines · Philippe Mathieu-Daudé

On SME2 systems, Linux sets SMCR_EL1.EZT0 in cpu_enable_sme2() to allow user space to access ZT0.

linux-user already initializes SMCR_EL1.LEN and FA64 to match the kernel's setup, but leaves EZT0 clear (see commit 3aad4bc8beb9 "target/arm: Add zt0_excp_el to DisasContext"). Set EZT0 when SME2 is present to keep the emulated EL1 state consistent with Linux.

This has no functional effect because CONFIG_USER_ONLY omits the ZT0 trap checks.

Quoted 8 lines
Quoted 6 lines
---
  target/arm/cpu.c | 4 ++++
  1 file changed, 4 insertions(+)

Applied to target-arm.next, thanks.

-- PMM