[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 25/32] target/arm: Install asids for E2&0 transla
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v2 25/32] target/arm: Install asids for E2&0 translation regime |
Date: |
Wed, 31 Jul 2019 13:38:06 -0700 |
When clearing HCR_E2H, this involves re-installing the EL1&0 asid.
Signed-off-by: Richard Henderson <address@hidden>
---
target/arm/helper.c | 38 ++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 2883d6e568..30f93f4792 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -3518,10 +3518,29 @@ static void vmsa_ttbr_el1_write(CPUARMState *env, const
ARMCPRegInfo *ri,
}
}
+static void update_el2_asid(CPUARMState *env)
+{
+ CPUState *cs = env_cpu(env);
+ uint64_t ttbr0, ttbr1, ttcr;
+ int asid, idxmask;
+
+ ttbr0 = env->cp15.ttbr0_el[2];
+ ttbr1 = env->cp15.ttbr1_el[2];
+ ttcr = env->cp15.tcr_el[2].raw_tcr;
+ idxmask = ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0;
+ asid = extract64(ttcr & TTBCR_A1 ? ttbr1 : ttbr0, 48, 16);
+
+ tlb_set_asid_for_mmuidx(cs, asid, idxmask, 0);
+}
+
static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
raw_write(env, ri, value);
+ if (arm_hcr_el2_eff(env) & HCR_E2H) {
+ /* We are running with EL2&0 regime and the ASID is active. */
+ update_el2_asid(env);
+ }
}
static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
@@ -4654,6 +4673,7 @@ static void hcr_write(CPUARMState *env, const
ARMCPRegInfo *ri, uint64_t value)
ARMCPU *cpu = env_archcpu(env);
/* Begin with bits defined in base ARMv8.0. */
uint64_t valid_mask = MAKE_64BIT_MASK(0, 34);
+ uint64_t old_value;
if (arm_feature(env, ARM_FEATURE_EL3)) {
valid_mask &= ~HCR_HCD;
@@ -4680,15 +4700,25 @@ static void hcr_write(CPUARMState *env, const
ARMCPRegInfo *ri, uint64_t value)
/* Clear RES0 bits. */
value &= valid_mask;
- /* These bits change the MMU setup:
+ old_value = env->cp15.hcr_el2;
+ env->cp15.hcr_el2 = value;
+
+ /*
+ * These bits change the MMU setup:
* HCR_VM enables stage 2 translation
* HCR_PTW forbids certain page-table setups
- * HCR_DC Disables stage1 and enables stage2 translation
+ * HCR_DC disables stage1 and enables stage2 translation
+ * HCR_E2H enables E2&0 translation regime.
*/
- if ((env->cp15.hcr_el2 ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) {
+ if ((old_value ^ value) & (HCR_VM | HCR_PTW | HCR_DC | HCR_E2H)) {
tlb_flush(CPU(cpu));
+ /* Also install the correct ASID for the regime. */
+ if (value & HCR_E2H) {
+ update_el2_asid(env);
+ } else {
+ update_lpae_el1_asid(env, false);
+ }
}
- env->cp15.hcr_el2 = value;
/*
* Updates to VI and VF require us to update the status of
--
2.17.1
- [Qemu-devel] [PATCH v2 14/32] target/arm: Simplify tlb_force_broadcast alternatives, (continued)
- [Qemu-devel] [PATCH v2 14/32] target/arm: Simplify tlb_force_broadcast alternatives, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 15/32] target/arm: Rename ARMMMUIdx*_S12NSE* to ARMMMUIdx*_E10_*, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 16/32] target/arm: Rename ARMMMUIdx_S2NS to ARMMMUIdx_Stage2, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 17/32] target/arm: Rename ARMMMUIdx_S1NSE* to ARMMMUIdx_Stage1_E*, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 18/32] target/arm: Rename ARMMMUIdx_S1SE* to ARMMMUIdx_SE*, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 19/32] target/arm: Rename ARMMMUIdx*_S1E3 to ARMMMUIdx*_SE3, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 20/32] target/arm: Rename ARMMMUIdx_S1E2 to ARMMMUIdx_E2, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 22/32] target/arm: Add regime_has_2_ranges, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 23/32] target/arm: Update arm_mmu_idx for VHE, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 21/32] target/arm: Reorganize ARMMMUIdx, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 25/32] target/arm: Install asids for E2&0 translation regime,
Richard Henderson <=
- [Qemu-devel] [PATCH v2 24/32] target/arm: Update arm_sctlr for VHE, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 27/32] target/arm: Update arm_phys_excp_target_el for TGE, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 30/32] target/arm: Enable ARMv8.1-VHE in -cpu max, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 28/32] target/arm: Update regime_is_user for EL2&0, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 26/32] target/arm: Flush tlbs for E2&0 translation regime, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 29/32] target/arm: Update {fp, sve}_exception_el for VHE, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 31/32] target/arm: check TGE and E2H flags for EL0 pauth traps, Richard Henderson, 2019/07/31
- [Qemu-devel] [PATCH v2 32/32] target/arm: generate a custom MIDR for -cpu max, Richard Henderson, 2019/07/31