[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 11/14] target/arm: Tidy merging of attributes from descriptor
From: |
Richard Henderson |
Subject: |
[PATCH v6 11/14] target/arm: Tidy merging of attributes from descriptor and table |
Date: |
Mon, 24 Oct 2022 15:18:48 +1000 |
Replace some gotos with some nested if statements.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/ptw.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 8004ca86df..282828992e 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -1341,27 +1341,25 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
page_size = (1ULL << ((stride * (4 - level)) + 3));
descaddr &= ~(hwaddr)(page_size - 1);
descaddr |= (address & (page_size - 1));
- /* Extract attributes from the descriptor */
- attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
- if (regime_is_stage2(mmu_idx)) {
- /* Stage 2 table descriptors do not include any attribute fields */
- goto skip_attrs;
- }
- /* Merge in attributes from table descriptors */
- attrs |= nstable << 5; /* NS */
- if (param.hpd) {
- /* HPD disables all the table attributes except NSTable. */
- goto skip_attrs;
- }
- attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
/*
- * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
- * means "force PL1 access only", which means forcing AP[1] to 0.
+ * Extract attributes from the descriptor, and apply table descriptors.
+ * Stage 2 table descriptors do not include any attribute fields.
+ * HPD disables all the table attributes except NSTable.
*/
- attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */
- attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */
- skip_attrs:
+ attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
+ if (!regime_is_stage2(mmu_idx)) {
+ attrs |= nstable << 5; /* NS */
+ if (!param.hpd) {
+ attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
+ /*
+ * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
+ * means "force PL1 access only", which means forcing AP[1] to 0.
+ */
+ attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1]
*/
+ attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */
+ }
+ }
/*
* Here descaddr is the final physical address, and attributes
--
2.34.1
- [PATCH v6 00/14] target/arm: Implement FEAT_HAFDBS, Richard Henderson, 2022/10/24
- [PATCH v6 01/14] target/arm: Introduce regime_is_stage2, Richard Henderson, 2022/10/24
- [PATCH v6 02/14] target/arm: Add ptw_idx to S1Translate, Richard Henderson, 2022/10/24
- [PATCH v6 04/14] target/arm: Extract HA and HD in aa64_va_parameters, Richard Henderson, 2022/10/24
- [PATCH v6 13/14] target/arm: Implement FEAT_HAFDBS, dirty bit portion, Richard Henderson, 2022/10/24
- [PATCH v6 11/14] target/arm: Tidy merging of attributes from descriptor and table,
Richard Henderson <=
- [PATCH v6 14/14] target/arm: Use the max page size in a 2-stage ptw, Richard Henderson, 2022/10/24
- [PATCH v6 06/14] target/arm: Add ARMFault_UnsuppAtomicUpdate, Richard Henderson, 2022/10/24
- [PATCH v6 05/14] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw, Richard Henderson, 2022/10/24
- [PATCH v6 07/14] target/arm: Remove loop from get_phys_addr_lpae, Richard Henderson, 2022/10/24
- [PATCH v6 03/14] target/arm: Add isar predicates for FEAT_HAFDBS, Richard Henderson, 2022/10/24
- [PATCH v6 10/14] target/arm: Consider GP an attribute in get_phys_addr_lpae, Richard Henderson, 2022/10/24
- [PATCH v6 12/14] target/arm: Implement FEAT_HAFDBS, access flag portion, Richard Henderson, 2022/10/24