[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/18] target/arm: add ARMv8.4-SEL2 system registers
From: |
remi . denis . courmont |
Subject: |
[PATCH 09/18] target/arm: add ARMv8.4-SEL2 system registers |
Date: |
Fri, 18 Dec 2020 12:37:50 +0200 |
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
---
target/arm/cpu.h | 7 +++++++
target/arm/helper.c | 24 ++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index ec96784bba..f6b59cb56b 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -168,6 +168,11 @@ typedef struct {
uint32_t base_mask;
} TCR;
+#define VTCR_NSW (1u << 29)
+#define VTCR_NSA (1u << 30)
+#define VSTCR_SW VTCR_NSW
+#define VSTCR_SA VTCR_NSA
+
/* Define a maximum sized vector register.
* For 32-bit, this is a 128-bit NEON/AdvSIMD register.
* For 64-bit, this is a 2048-bit SVE register.
@@ -323,9 +328,11 @@ typedef struct CPUARMState {
uint64_t ttbr1_el[4];
};
uint64_t vttbr_el2; /* Virtualization Translation Table Base. */
+ uint64_t vsttbr_el2; /* Secure Virtualization Translation Table. */
/* MMU translation table base control. */
TCR tcr_el[4];
TCR vtcr_el2; /* Virtualization Translation Control. */
+ TCR vstcr_el2; /* Secure Virtualization Translation Control. */
uint32_t c2_data; /* MPU data cacheable bits. */
uint32_t c2_insn; /* MPU instruction cacheable bits. */
union { /* MMU domain access control register
diff --git a/target/arm/helper.c b/target/arm/helper.c
index e92408229b..32469abf92 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -5721,6 +5721,27 @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
REGINFO_SENTINEL
};
+static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri,
+ bool isread)
+{
+ if (arm_current_el(env) == 3 || arm_is_secure_below_el3(env)) {
+ return CP_ACCESS_OK;
+ }
+ return CP_ACCESS_TRAP_UNCATEGORIZED;
+}
+
+static const ARMCPRegInfo el2_sec_cp_reginfo[] = {
+ { .name = "VSTTBR_EL2", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 0,
+ .access = PL2_RW, .accessfn = sel2_access,
+ .fieldoffset = offsetof(CPUARMState, cp15.vsttbr_el2) },
+ { .name = "VSTCR_EL2", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2,
+ .access = PL2_RW, .accessfn = sel2_access,
+ .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) },
+ REGINFO_SENTINEL
+};
+
static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
bool isread)
{
@@ -7733,6 +7754,9 @@ void register_cp_regs_for_features(ARMCPU *cpu)
if (arm_feature(env, ARM_FEATURE_V8)) {
define_arm_cp_regs(cpu, el2_v8_cp_reginfo);
}
+ if (cpu_isar_feature(aa64_sel2, cpu)) {
+ define_arm_cp_regs(cpu, el2_sec_cp_reginfo);
+ }
/* RVBAR_EL2 is only implemented if EL2 is the highest EL */
if (!arm_feature(env, ARM_FEATURE_EL3)) {
ARMCPRegInfo rvbar = {
--
2.29.2
- [PATCHv4 00/18] ARMv8.4-A Secure EL2, Rémi Denis-Courmont, 2020/12/18
- [PATCH 02/18] target/arm: add arm_is_el2_enabled() helper, remi . denis . courmont, 2020/12/18
- [PATCH 01/18] target/arm: remove redundant tests, remi . denis . courmont, 2020/12/18
- [PATCH 05/18] target/arm: factor MDCR_EL2 common handling, remi . denis . courmont, 2020/12/18
- [PATCH 04/18] target/arm: use arm_hcr_el2_eff() where applicable, remi . denis . courmont, 2020/12/18
- [PATCH 06/18] target/arm: declare new AA64PFR0 bit-fields, remi . denis . courmont, 2020/12/18
- [PATCH 07/18] target/arm: add 64-bit S-EL2 to EL exception table, remi . denis . courmont, 2020/12/18
- [PATCH 03/18] target/arm: use arm_is_el2_enabled() where applicable, remi . denis . courmont, 2020/12/18
- [PATCH 09/18] target/arm: add ARMv8.4-SEL2 system registers,
remi . denis . courmont <=
- [PATCH 10/18] target/arm: handle VMID change in secure state, remi . denis . courmont, 2020/12/18
- [PATCH 08/18] target/arm: add MMU stage 1 for Secure EL2, remi . denis . courmont, 2020/12/18
- [PATCH 13/18] target/arm: generalize 2-stage page-walk condition, remi . denis . courmont, 2020/12/18
- [PATCH 11/18] target/arm: do S1_ptw_translate() before address space lookup, remi . denis . courmont, 2020/12/18
- [PATCH 18/18] target/arm: refactor vae1_tlbmask(), remi . denis . courmont, 2020/12/18
- [PATCH 15/18] target/arm: set HPFAR_EL2.NS on secure stage 2 faults, remi . denis . courmont, 2020/12/18
- [PATCH 12/18] target/arm: translate NS bit in page-walks, remi . denis . courmont, 2020/12/18
- [PATCH 14/18] target/arm: secure stage 2 translation regime, remi . denis . courmont, 2020/12/18
- [PATCH 16/18] target/arm: add ARMv8.4-SEL2 extension, remi . denis . courmont, 2020/12/18
- [PATCH 17/18] target/arm: enable Secure EL2 in max CPU, remi . denis . courmont, 2020/12/18