[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/28] target/arm: Fix cacheattr in get_phys_addr_disabled
From: |
Peter Maydell |
Subject: |
[PULL 23/28] target/arm: Fix cacheattr in get_phys_addr_disabled |
Date: |
Mon, 10 Oct 2022 15:27:25 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
Do not apply memattr or shareability for Stage2 translations.
Make sure to apply HCR_{DC,DCT} only to Regime_EL10, per the
pseudocode in AArch64.S1DisabledOutput.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20221001162318.153420-20-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/ptw.c | 48 +++++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 96ab99c7b6f..15c37b52c97 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -2282,11 +2282,12 @@ static bool get_phys_addr_disabled(CPUARMState *env,
target_ulong address,
GetPhysAddrResult *result,
ARMMMUFaultInfo *fi)
{
- uint64_t hcr;
- uint8_t memattr;
+ uint8_t memattr = 0x00; /* Device nGnRnE */
+ uint8_t shareability = 0; /* non-sharable */
if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
int r_el = regime_el(env, mmu_idx);
+
if (arm_el_is_aa64(env, r_el)) {
int pamax = arm_pamax(env_archcpu(env));
uint64_t tcr = env->cp15.tcr_el[r_el];
@@ -2314,32 +2315,33 @@ static bool get_phys_addr_disabled(CPUARMState *env,
target_ulong address,
*/
address = extract64(address, 0, 52);
}
+
+ /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */
+ if (r_el == 1) {
+ uint64_t hcr = arm_hcr_el2_eff_secstate(env, is_secure);
+ if (hcr & HCR_DC) {
+ if (hcr & HCR_DCT) {
+ memattr = 0xf0; /* Tagged, Normal, WB, RWA */
+ } else {
+ memattr = 0xff; /* Normal, WB, RWA */
+ }
+ }
+ }
+ if (memattr == 0 && access_type == MMU_INST_FETCH) {
+ if (regime_sctlr(env, mmu_idx) & SCTLR_I) {
+ memattr = 0xee; /* Normal, WT, RA, NT */
+ } else {
+ memattr = 0x44; /* Normal, NC, No */
+ }
+ shareability = 2; /* outer sharable */
+ }
+ result->cacheattrs.is_s2_format = false;
}
result->phys = address;
result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
result->page_size = TARGET_PAGE_SIZE;
-
- /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */
- hcr = arm_hcr_el2_eff_secstate(env, is_secure);
- result->cacheattrs.shareability = 0;
- result->cacheattrs.is_s2_format = false;
- if (hcr & HCR_DC) {
- if (hcr & HCR_DCT) {
- memattr = 0xf0; /* Tagged, Normal, WB, RWA */
- } else {
- memattr = 0xff; /* Normal, WB, RWA */
- }
- } else if (access_type == MMU_INST_FETCH) {
- if (regime_sctlr(env, mmu_idx) & SCTLR_I) {
- memattr = 0xee; /* Normal, WT, RA, NT */
- } else {
- memattr = 0x44; /* Normal, NC, No */
- }
- result->cacheattrs.shareability = 2; /* outer sharable */
- } else {
- memattr = 0x00; /* Device, nGnRnE */
- }
+ result->cacheattrs.shareability = shareability;
result->cacheattrs.attrs = memattr;
return 0;
}
--
2.25.1
- [PULL 03/28] docs/nuvoton: Update URL for images, (continued)
- [PULL 03/28] docs/nuvoton: Update URL for images, Peter Maydell, 2022/10/10
- [PULL 04/28] target/arm: Split s2walk_secure from ipa_secure in get_phys_addr, Peter Maydell, 2022/10/10
- [PULL 05/28] target/arm: Make the final stage1+2 write to secure be unconditional, Peter Maydell, 2022/10/10
- [PULL 06/28] target/arm: Add is_secure parameter to get_phys_addr_lpae, Peter Maydell, 2022/10/10
- [PULL 07/28] target/arm: Fix S2 disabled check in S1_ptw_translate, Peter Maydell, 2022/10/10
- [PULL 08/28] target/arm: Add is_secure parameter to regime_translation_disabled, Peter Maydell, 2022/10/10
- [PULL 09/28] target/arm: Split out get_phys_addr_with_secure, Peter Maydell, 2022/10/10
- [PULL 10/28] target/arm: Add is_secure parameter to v7m_read_half_insn, Peter Maydell, 2022/10/10
- [PULL 11/28] target/arm: Add TBFLAG_M32.SECURE, Peter Maydell, 2022/10/10
- [PULL 16/28] target/arm: Drop secure check for HCR.TGE vs SCTLR_EL1.M, Peter Maydell, 2022/10/10
- [PULL 23/28] target/arm: Fix cacheattr in get_phys_addr_disabled,
Peter Maydell <=
- [PULL 12/28] target/arm: Merge regime_is_secure into get_phys_addr, Peter Maydell, 2022/10/10
- [PULL 13/28] target/arm: Add is_secure parameter to do_ats_write, Peter Maydell, 2022/10/10
- [PULL 14/28] target/arm: Fold secure and non-secure a-profile mmu indexes, Peter Maydell, 2022/10/10
- [PULL 15/28] target/arm: Reorg regime_translation_disabled, Peter Maydell, 2022/10/10
- [PULL 17/28] target/arm: Introduce arm_hcr_el2_eff_secstate, Peter Maydell, 2022/10/10
- [PULL 19/28] target/arm: Remove env argument from combined_attrs_fwb, Peter Maydell, 2022/10/10
- [PULL 18/28] target/arm: Hoist read of *is_secure in S1_ptw_translate, Peter Maydell, 2022/10/10
- [PULL 21/28] target/arm: Fix ATS12NSO* from S PL1, Peter Maydell, 2022/10/10
- [PULL 20/28] target/arm: Pass HCR to attribute subroutines., Peter Maydell, 2022/10/10
- [PULL 22/28] target/arm: Split out get_phys_addr_disabled, Peter Maydell, 2022/10/10