[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 26/71] target/arm: Add SMCR_ELx
From: |
Richard Henderson |
Subject: |
[PATCH v2 26/71] target/arm: Add SMCR_ELx |
Date: |
Tue, 7 Jun 2022 13:32:21 -0700 |
These cpregs control the streaming vector length and whether the
full a64 instruction set is allowed while in streaming mode.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/cpu.h | 8 ++++++--
target/arm/helper.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index f1a459af8b..2f43b00843 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -669,8 +669,8 @@ typedef struct CPUArchState {
float_status standard_fp_status;
float_status standard_fp_status_f16;
- /* ZCR_EL[1-3] */
- uint64_t zcr_el[4];
+ uint64_t zcr_el[4]; /* ZCR_EL[1-3] */
+ uint64_t smcr_el[4]; /* SMCR_EL[1-3] */
} vfp;
uint64_t exclusive_addr;
uint64_t exclusive_val;
@@ -1434,6 +1434,10 @@ FIELD(CPTR_EL3, TCPAC, 31, 1)
FIELD(SVCR, SM, 0, 1)
FIELD(SVCR, ZA, 1, 1)
+/* Fields for SMCR_ELx. */
+FIELD(SMCR, LEN, 0, 4)
+FIELD(SMCR, FA64, 31, 1)
+
/* Write a new value to v7m.exception, thus transitioning into or out
* of Handler mode; this may result in a change of active stack pointer.
*/
diff --git a/target/arm/helper.c b/target/arm/helper.c
index e2d6d89a5d..46318515a8 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -5883,6 +5883,8 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU
*cpu)
*/
{ K(3, 0, 1, 2, 0), K(3, 4, 1, 2, 0), K(3, 5, 1, 2, 0),
"ZCR_EL1", "ZCR_EL2", "ZCR_EL12", isar_feature_aa64_sve },
+ { K(3, 0, 1, 2, 6), K(3, 4, 1, 2, 6), K(3, 5, 1, 2, 6),
+ "SMCR_EL1", "SMCR_EL2", "SMCR_EL12", isar_feature_aa64_sme },
{ K(3, 0, 5, 6, 0), K(3, 4, 5, 6, 0), K(3, 5, 5, 6, 0),
"TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte },
@@ -6361,6 +6363,30 @@ static void svcr_write(CPUARMState *env, const
ARMCPRegInfo *ri,
env->svcr = value;
}
+static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
+ uint64_t value)
+{
+ int cur_el = arm_current_el(env);
+ int old_len = sve_vqm1_for_el(env, cur_el);
+ int new_len;
+
+ QEMU_BUILD_BUG_ON(ARM_MAX_VQ > R_SMCR_LEN_MASK + 1);
+ value &= R_SMCR_LEN_MASK | R_SMCR_FA64_MASK;
+ raw_write(env, ri, value);
+
+ /*
+ * Note that it is CONSTRAINED UNPREDICTABLE what happens to ZA storage
+ * when SVL is widened (old values kept, or zeros). Choose to keep the
+ * current values for simplicity. But for QEMU internals, we must still
+ * apply the narrower SVL to the Zregs and Pregs -- see the comment
+ * above aarch64_sve_narrow_vq.
+ */
+ new_len = sve_vqm1_for_el(env, cur_el);
+ if (new_len < old_len) {
+ aarch64_sve_narrow_vq(env, new_len + 1);
+ }
+}
+
static const ARMCPRegInfo sme_reginfo[] = {
{ .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64,
.opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5,
@@ -6371,6 +6397,21 @@ static const ARMCPRegInfo sme_reginfo[] = {
.access = PL0_RW, .type = ARM_CP_SME,
.fieldoffset = offsetof(CPUARMState, svcr),
.writefn = svcr_write, .raw_writefn = raw_write },
+ { .name = "SMCR_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 6,
+ .access = PL1_RW, .type = ARM_CP_SME,
+ .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[1]),
+ .writefn = smcr_write, .raw_writefn = raw_write },
+ { .name = "SMCR_EL2", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 6,
+ .access = PL2_RW, .type = ARM_CP_SME,
+ .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[2]),
+ .writefn = smcr_write, .raw_writefn = raw_write },
+ { .name = "SMCR_EL3", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 6,
+ .access = PL3_RW, .type = ARM_CP_SME,
+ .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[3]),
+ .writefn = smcr_write, .raw_writefn = raw_write },
};
#endif /* TARGET_AARCH64 */
--
2.34.1
- [PATCH v2 04/71] target/arm: Remove fp checks from sve_exception_el, (continued)
- [PATCH v2 04/71] target/arm: Remove fp checks from sve_exception_el, Richard Henderson, 2022/06/07
- [PATCH v2 07/71] target/arm: Use el_is_in_host for sve_exception_el, Richard Henderson, 2022/06/07
- [PATCH v2 08/71] target/arm: Hoist arm_is_el2_enabled check in sve_exception_el, Richard Henderson, 2022/06/07
- [PATCH v2 11/71] target/arm: Use uint32_t instead of bitmap for sve vq's, Richard Henderson, 2022/06/07
- [PATCH v2 10/71] target/arm: Merge aarch64_sve_zcr_get_valid_len into caller, Richard Henderson, 2022/06/07
- [PATCH v2 13/71] target/arm: Split out load/store primitives to sve_ldst_internal.h, Richard Henderson, 2022/06/07
- [PATCH v2 17/71] target/arm: Move expand_pred_h to vec_internal.h, Richard Henderson, 2022/06/07
- [PATCH v2 18/71] target/arm: Export bfdotadd from vec_helper.c, Richard Henderson, 2022/06/07
- [PATCH v2 19/71] target/arm: Add isar_feature_aa64_sme, Richard Henderson, 2022/06/07
- [PATCH v2 15/71] target/arm: Move expand_pred_b to vec_internal.h, Richard Henderson, 2022/06/07
- [PATCH v2 26/71] target/arm: Add SMCR_ELx,
Richard Henderson <=
- [PATCH v2 12/71] target/arm: Rename sve_zcr_len_for_el to sve_vqm1_for_el, Richard Henderson, 2022/06/07
- [PATCH v2 14/71] target/arm: Export sve contiguous ldst support functions, Richard Henderson, 2022/06/07
- [PATCH v2 16/71] target/arm: Use expand_pred_b in mve_helper.c, Richard Henderson, 2022/06/07
- [PATCH v2 21/71] target/arm: Implement TPIDR2_EL0, Richard Henderson, 2022/06/07
- [PATCH v2 22/71] target/arm: Add SMEEXC_EL to TB flags, Richard Henderson, 2022/06/07
- [PATCH v2 23/71] target/arm: Add syn_smetrap, Richard Henderson, 2022/06/07
- [PATCH v2 24/71] target/arm: Add ARM_CP_SME, Richard Henderson, 2022/06/07
- [PATCH v2 25/71] target/arm: Add SVCR, Richard Henderson, 2022/06/07