target/arm: Tidy merging of attributes from descriptor and table

Replace some gotos with some nested if statements.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20221024051851.3074715-12-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2022-10-24 15:18:48 +10:00 committed by Peter Maydell
parent 0e8df0fe24
commit 34a57faeab

View File

@ -1322,19 +1322,16 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
page_size = (1ULL << ((stride * (4 - level)) + 3)); page_size = (1ULL << ((stride * (4 - level)) + 3));
descaddr &= ~(hwaddr)(page_size - 1); descaddr &= ~(hwaddr)(page_size - 1);
descaddr |= (address & (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 */ * Extract attributes from the descriptor, and apply table descriptors.
goto skip_attrs; * Stage 2 table descriptors do not include any attribute fields.
} * HPD disables all the table attributes except NSTable.
/* Merge in attributes from table descriptors */ */
attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
if (!regime_is_stage2(mmu_idx)) {
attrs |= nstable << 5; /* NS */ attrs |= nstable << 5; /* NS */
if (param.hpd) { if (!param.hpd) {
/* HPD disables all the table attributes except NSTable. */
goto skip_attrs;
}
attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
/* /*
* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
@ -1342,7 +1339,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
*/ */
attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */ attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */
attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */ attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */
skip_attrs: }
}
/* /*
* Here descaddr is the final physical address, and attributes * Here descaddr is the final physical address, and attributes