[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/8] target/arm: Check addresses for disabled regimes
From: |
Richard Henderson |
Subject: |
[PATCH 7/8] target/arm: Check addresses for disabled regimes |
Date: |
Mon, 24 Feb 2020 19:14:13 -0800 |
We fail to validate the upper bits of a virtual address on a
translation disabled regime, as per AArch64.TranslateAddressS1Off.
Signed-off-by: Richard Henderson <address@hidden>
---
target/arm/helper.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 7cf6642210..2867adea29 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -11615,7 +11615,38 @@ bool get_phys_addr(CPUARMState *env, target_ulong
address,
/* Definitely a real MMU, not an MPU */
if (regime_translation_disabled(env, mmu_idx)) {
- /* MMU disabled. */
+ /*
+ * MMU disabled. S1 addresses are still checked for bounds.
+ * C.f. AArch64.TranslateAddressS1Off.
+ */
+ if (is_a64(env) && mmu_idx != ARMMMUIdx_Stage2) {
+ int pamax = arm_pamax(env_archcpu(env));
+ uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr;
+ int addrtop, tbi;
+
+ tbi = aa64_va_parameter_tbi(tcr, mmu_idx);
+ if (access_type == MMU_INST_FETCH) {
+ tbi &= ~aa64_va_parameter_tbid(tcr, mmu_idx);
+ }
+ tbi = (tbi >> extract64(address, 55, 1)) & 1;
+ addrtop = (tbi ? 55 : 63);
+
+ if (extract64(address, pamax, addrtop - pamax + 1) != 0) {
+ fi->type = ARMFault_AddressSize;
+ fi->level = 0;
+ fi->stage2 = false;
+ return 1;
+ }
+
+ /*
+ * The ARM pseudocode copies bits [51:0] to addrdesc.paddress.
+ * Except for TBI, we've just validated everything above PAMax
+ * is zero. So we only need to drop TBI.
+ */
+ if (tbi) {
+ address = extract64(address, 0, 56);
+ }
+ }
*phys_ptr = address;
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
*page_size = TARGET_PAGE_SIZE;
--
2.20.1
- [PATCH 0/8] target/arm: Misc cleanups surrounding TBI, Richard Henderson, 2020/02/24
- [PATCH 1/8] target/arm: Replicate TBI/TBID bits for single range regimes, Richard Henderson, 2020/02/24
- [PATCH 2/8] target/arm: Optimize cpu_mmu_index, Richard Henderson, 2020/02/24
- [PATCH 3/8] target/arm: Apply TBI to ESR_ELx in helper_exception_return, Richard Henderson, 2020/02/24
- [PATCH 5/8] target/arm: Use DEF_HELPER_FLAGS for helper_dc_zva, Richard Henderson, 2020/02/24
- [PATCH 4/8] target/arm: Move helper_dc_zva to helper-a64.c, Richard Henderson, 2020/02/24
- [PATCH 6/8] target/arm: Clean address for DC ZVA, Richard Henderson, 2020/02/24
- [PATCH 7/8] target/arm: Check addresses for disabled regimes,
Richard Henderson <=
- [PATCH 8/8] target/arm: Disable clean_data_tbi for system mode, Richard Henderson, 2020/02/24