[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 15/45] target/arm: Add SME enablement checks
From: |
Richard Henderson |
Subject: |
[PATCH v6 15/45] target/arm: Add SME enablement checks |
Date: |
Fri, 8 Jul 2022 20:45:10 +0530 |
These functions will be used to verify that the cpu
is in the correct state for a given instruction.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/translate-a64.h | 21 +++++++++++++++++++++
target/arm/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
index 789b6e8e78..02fb95e019 100644
--- a/target/arm/translate-a64.h
+++ b/target/arm/translate-a64.h
@@ -29,6 +29,27 @@ void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v);
bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn,
unsigned int imms, unsigned int immr);
bool sve_access_check(DisasContext *s);
+bool sme_enabled_check(DisasContext *s);
+bool sme_enabled_check_with_svcr(DisasContext *s, unsigned);
+
+/* This function corresponds to CheckStreamingSVEEnabled. */
+static inline bool sme_sm_enabled_check(DisasContext *s)
+{
+ return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK);
+}
+
+/* This function corresponds to CheckSMEAndZAEnabled. */
+static inline bool sme_za_enabled_check(DisasContext *s)
+{
+ return sme_enabled_check_with_svcr(s, R_SVCR_ZA_MASK);
+}
+
+/* Note that this function corresponds to CheckStreamingSVEAndZAEnabled. */
+static inline bool sme_smza_enabled_check(DisasContext *s)
+{
+ return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
+}
+
TCGv_i64 clean_data_tbi(DisasContext *s, TCGv_i64 addr);
TCGv_i64 gen_mte_check1(DisasContext *s, TCGv_i64 addr, bool is_write,
bool tag_checked, int log2_size);
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index 7fab7f64f8..b16d81bf19 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -1216,6 +1216,40 @@ static bool sme_access_check(DisasContext *s)
return true;
}
+/* This function corresponds to CheckSMEEnabled. */
+bool sme_enabled_check(DisasContext *s)
+{
+ /*
+ * Note that unlike sve_excp_el, we have not constrained sme_excp_el
+ * to be zero when fp_excp_el has priority. This is because we need
+ * sme_excp_el by itself for cpregs access checks.
+ */
+ if (!s->fp_excp_el || s->sme_excp_el < s->fp_excp_el) {
+ s->fp_access_checked = true;
+ return sme_access_check(s);
+ }
+ return fp_access_check_only(s);
+}
+
+/* Common subroutine for CheckSMEAnd*Enabled. */
+bool sme_enabled_check_with_svcr(DisasContext *s, unsigned req)
+{
+ if (!sme_enabled_check(s)) {
+ return false;
+ }
+ if (FIELD_EX64(req, SVCR, SM) && !s->pstate_sm) {
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
+ syn_smetrap(SME_ET_NotStreaming, false));
+ return false;
+ }
+ if (FIELD_EX64(req, SVCR, ZA) && !s->pstate_za) {
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
+ syn_smetrap(SME_ET_InactiveZA, false));
+ return false;
+ }
+ return true;
+}
+
/*
* This utility function is for doing register extension with an
* optional shift. You will likely want to pass a temporary for the
--
2.34.1
- [PATCH v6 03/45] target/arm: Trap non-streaming usage when Streaming SVE is active, (continued)
- [PATCH v6 03/45] target/arm: Trap non-streaming usage when Streaming SVE is active, Richard Henderson, 2022/07/08
- [PATCH v6 05/45] target/arm: Mark RDFFR, WRFFR, SETFFR as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 09/45] target/arm: Mark SMMLA, UMMLA, USMMLA as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 08/45] target/arm: Mark FTSMUL, FTMAD, FADDA as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 10/45] target/arm: Mark string/histo/crypto as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 06/45] target/arm: Mark BDEP, BEXT, BGRP, COMPACT, FEXPA, FTSSEL as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 07/45] target/arm: Mark PMULL, FMMLA as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 11/45] target/arm: Mark gather/scatter load/store as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 12/45] target/arm: Mark gather prefetch as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 14/45] target/arm: Mark LD1RO as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 15/45] target/arm: Add SME enablement checks,
Richard Henderson <=
- [PATCH v6 13/45] target/arm: Mark LDFF1 and LDNF1 as non-streaming, Richard Henderson, 2022/07/08
- [PATCH v6 16/45] target/arm: Handle SME in sve_access_check, Richard Henderson, 2022/07/08
- [PATCH v6 17/45] target/arm: Implement SME RDSVL, ADDSVL, ADDSPL, Richard Henderson, 2022/07/08
- [PATCH v6 18/45] target/arm: Implement SME ZERO, Richard Henderson, 2022/07/08
- [PATCH v6 19/45] target/arm: Implement SME MOVA, Richard Henderson, 2022/07/08
- [PATCH v6 20/45] target/arm: Implement SME LD1, ST1, Richard Henderson, 2022/07/08
- [PATCH v6 21/45] target/arm: Export unpredicated ld/st from translate-sve.c, Richard Henderson, 2022/07/08
- [PATCH v6 22/45] target/arm: Implement SME LDR, STR, Richard Henderson, 2022/07/08
- [PATCH v6 23/45] target/arm: Implement SME ADDHA, ADDVA, Richard Henderson, 2022/07/08
- [PATCH v6 24/45] target/arm: Implement FMOPA, FMOPS (non-widening), Richard Henderson, 2022/07/08