[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 19/24] target/arm: Fix fault reporting in get_phys_addr_lpae
From: |
Richard Henderson |
Subject: |
[PATCH v4 19/24] target/arm: Fix fault reporting in get_phys_addr_lpae |
Date: |
Mon, 10 Oct 2022 20:19:06 -0700 |
Always overriding fi->type was incorrect, as we would not properly
propagate the fault type from S1_ptw_translate, or arm_ldq_ptw.
Simplify things by providing a new label for a translation fault.
For other faults, store into fi directly.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/ptw.c | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 9b767f8236..acbf09cce8 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -1065,8 +1065,6 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
ARMCPU *cpu = env_archcpu(env);
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
bool is_secure = ptw->in_secure;
- /* Read an LPAE long-descriptor translation table. */
- ARMFaultType fault_type = ARMFault_Translation;
uint32_t level;
ARMVAParameters param;
uint64_t ttbr;
@@ -1103,8 +1101,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
* so our choice is to always raise the fault.
*/
if (param.tsz_oob) {
- fault_type = ARMFault_Translation;
- goto do_fault;
+ goto do_translation_fault;
}
addrsize = 64 - 8 * param.tbi;
@@ -1141,8 +1138,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
addrsize - inputsize);
if (-top_bits != param.select) {
/* The gap between the two regions is a Translation fault */
- fault_type = ARMFault_Translation;
- goto do_fault;
+ goto do_translation_fault;
}
}
@@ -1168,7 +1164,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
* Translation table walk disabled => Translation fault on TLB miss
* Note: This is always 0 on 64-bit EL2 and EL3.
*/
- goto do_fault;
+ goto do_translation_fault;
}
if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
@@ -1199,8 +1195,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
if (param.ds && stride == 9 && sl2) {
if (sl0 != 0) {
level = 0;
- fault_type = ARMFault_Translation;
- goto do_fault;
+ goto do_translation_fault;
}
startlevel = -1;
} else if (!aarch64 || stride == 9) {
@@ -1219,8 +1214,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
ok = check_s2_mmu_setup(cpu, aarch64, startlevel,
inputsize, stride, outputsize);
if (!ok) {
- fault_type = ARMFault_Translation;
- goto do_fault;
+ goto do_translation_fault;
}
level = startlevel;
}
@@ -1242,7 +1236,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
descaddr |= extract64(ttbr, 2, 4) << 48;
} else if (descaddr >> outputsize) {
level = 0;
- fault_type = ARMFault_AddressSize;
+ fi->type = ARMFault_AddressSize;
goto do_fault;
}
@@ -1296,7 +1290,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) {
/* Invalid, or the Reserved level 3 encoding */
- goto do_fault;
+ goto do_translation_fault;
}
descaddr = descriptor & descaddrmask;
@@ -1314,7 +1308,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
descaddr |= extract64(descriptor, 12, 4) << 48;
}
} else if (descaddr >> outputsize) {
- fault_type = ARMFault_AddressSize;
+ fi->type = ARMFault_AddressSize;
goto do_fault;
}
@@ -1371,9 +1365,9 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
* Here descaddr is the final physical address, and attributes
* are all in attrs.
*/
- fault_type = ARMFault_AccessFlag;
if ((attrs & (1 << 8)) == 0) {
/* Access flag */
+ fi->type = ARMFault_AccessFlag;
goto do_fault;
}
@@ -1390,8 +1384,8 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
}
- fault_type = ARMFault_Permission;
if (!(result->f.prot & (1 << access_type))) {
+ fi->type = ARMFault_Permission;
goto do_fault;
}
@@ -1436,8 +1430,9 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
result->f.lg_page_size = ctz64(page_size);
return false;
-do_fault:
- fi->type = fault_type;
+ do_translation_fault:
+ fi->type = ARMFault_Translation;
+ do_fault:
fi->level = level;
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 ||
--
2.34.1
- [PATCH v4 12/24] target/arm: Use bool consistently for get_phys_addr subroutines, (continued)
- [PATCH v4 12/24] target/arm: Use bool consistently for get_phys_addr subroutines, Richard Henderson, 2022/10/10
- [PATCH v4 13/24] target/arm: Add ptw_idx to S1Translate, Richard Henderson, 2022/10/10
- [PATCH v4 11/24] target/arm: Split out get_phys_addr_twostage, Richard Henderson, 2022/10/10
- [PATCH v4 07/24] target/arm: Split out S1Translate type, Richard Henderson, 2022/10/10
- [PATCH v4 01/24] target/arm: Enable TARGET_PAGE_ENTRY_EXTRA, Richard Henderson, 2022/10/10
- [PATCH v4 14/24] target/arm: Add isar predicates for FEAT_HAFDBS, Richard Henderson, 2022/10/10
- [PATCH v4 18/24] target/arm: Remove loop from get_phys_addr_lpae, Richard Henderson, 2022/10/10
- [PATCH v4 19/24] target/arm: Fix fault reporting in get_phys_addr_lpae,
Richard Henderson <=
- [PATCH v4 09/24] target/arm: Move be test for regime into S1TranslateResult, Richard Henderson, 2022/10/10
- [PATCH v4 10/24] target/arm: Use softmmu tlbs for page table walking, Richard Henderson, 2022/10/10
- [PATCH v4 16/24] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw, Richard Henderson, 2022/10/10
- [PATCH v4 17/24] target/arm: Add ARMFault_UnsuppAtomicUpdate, Richard Henderson, 2022/10/10
- [PATCH v4 08/24] target/arm: Plumb debug into S1Translate, Richard Henderson, 2022/10/10
- [PATCH v4 20/24] target/arm: Don't shift attrs in get_phys_addr_lpae, Richard Henderson, 2022/10/10
- [PATCH v4 15/24] target/arm: Extract HA and HD in aa64_va_parameters, Richard Henderson, 2022/10/10
- [PATCH v4 22/24] target/arm: Implement FEAT_HAFDBS, access flag portion, Richard Henderson, 2022/10/10
- [PATCH v4 23/24] target/arm: Implement FEAT_HAFDBS, dirty bit portion, Richard Henderson, 2022/10/10