target/arm: Split out ptw.c from helper.c
cover target/arm: Split out ptw.c from helper.c
The object here is to move 2500 lines out of helper.c. Yay!
r~
Richard Henderson (28):
target/arm: Move stage_1_mmu_idx decl to internals.h target/arm: Move get_phys_addr to ptw.c
target/arm: Move get_phys_addr_v5 to ptw.c
target/arm: Move get_phys_addr_v6 to ptw.c
target/arm: Move get_phys_addr_pmsav5 to ptw.c target/arm: Move get_phys_addr_pmsav7_default to ptw.c target/arm: Move get_phys_addr_pmsav7 to ptw.c target/arm: Move get_phys_addr_pmsav8 to ptw.c target/arm: Move pmsav8_mpu_lookup to ptw.c
target/arm: Move pmsav7_use_background_region to ptw.c target/arm: Move v8m_security_lookup to ptw.c target/arm: Move m_is_{ppb,system}_region to ptw.c target/arm: Move get_level1_table_address to ptw.c target/arm: Move combine_cacheattrs and subroutines to ptw.c target/arm: Move get_phys_addr_lpae to ptw.c
target/arm: Move arm_{ldl,ldq}_ptw to ptw.c
target/arm: Move {arm_s1_,}regime_using_lpae_format to tlb_helper.c target/arm: Move arm_pamax, pamax_map into ptw.c target/arm: Move get_S1prot, get_S2prot to ptw.c target/arm: Move check_s2_mmu_setup to ptw.c
target/arm: Move aa32_va_parameters to ptw.c
target/arm: Move ap_to_tw_prot etc to ptw.c
target/arm: Move regime_is_user to ptw.c
target/arm: Move regime_ttbr to ptw.c
target/arm: Move regime_translation_disabled to ptw.c target/arm: Move arm_cpu_get_phys_page_attrs_debug to ptw.c target/arm: Move stage_1_mmu_idx, arm_stage1_mmu_idx to ptw.c target/arm: Pass CPUARMState to arm_ld[lq]_ptw
target/arm/internals.h | 23 +- target/arm/helper.c | 2555 +-------------------------------------- target/arm/ptw.c | 2540 ++++++++++++++++++++++++++++++++++++++ target/arm/tlb_helper.c | 26 + target/arm/meson.build | 1 + 5 files changed, 2590 insertions(+), 2555 deletions(-) create mode 100644 target/arm/ptw.c
Signature · 1 line
2.34.1
PATCH 1/28 target/arm: Move stage_1_mmu_idx decl to internals.h
Move the decl from ptw.h to internals.h. Provide an inline version for user-only, just as we do for arm_stage1_mmu_idx. Move an endif down to make the definition in helper.c be system only.
--- target/arm/internals.h | 5 +++++ target/arm/helper.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-)
target/arm/internals.h +5 -0
@@ -979,11 +979,16 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env);* Return the ARMMMUIdx for the stage1 traversal for the current regime. */ #ifdef CONFIG_USER_ONLY +static inline ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) +{ +return ARMMMUIdx_Stage1_E0; +}static inline ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env) {return ARMMMUIdx_Stage1_E0; }#else +ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx);ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env);#endif
target/arm/helper.c +2 -3
@@ -10481,12 +10481,10 @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, } } -#endif /* !CONFIG_USER_ONLY */ -/* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */ -static inline ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) +ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) {switch (mmu_idx) {case ARMMMUIdx_SE10_0:
@@ -10505,6 +10503,7 @@ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) return mmu_idx; } } +#endif /* !CONFIG_USER_ONLY */ /* Return true if the translation regime is using LPAE format page tables */ static inline bool regime_using_lpae_format(CPUARMState *env,
Signature · 1 line
2.34.1
Re: [PATCH 01/28] target/arm: Move stage_1_mmu_idx decl to internals.h
Quoted 16 lines · Richard Henderson
Move the decl from
ptw.htointernals.h. Provide an inline version for user-only, just as we do forarm_stage1_mmu_idx. Move an endif down to make the definition inhelper.cbe system only.Signed-off-by Richard Henderson <[email protected]>--- target/arm/internals.h | 5 +++++ target/arm/helper.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-)target/arm/internals.h +0
-0
target/arm/internals.h ARMMMUIdx arm_mmu_idx(CPUARMState *env); · line 983
Quoted 5 lines
target/arm/internals.h +2
-0@@ -979,11 +979,16 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env);* Return the ARMMMUIdx for the stage1 traversal for the current regime. */ #ifdef CONFIG_USER_ONLY +static inline ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) +{
Should we assert(mmu_idx == ARMMMUIdx_Stage1_E0)?
Quoted 2 lines
target/arm/internals.h +2
-0+return ARMMMUIdx_Stage1_E0; +}
Re: [PATCH 01/28] target/arm: Move stage_1_mmu_idx decl to internals.h
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Richard Henderson
Move the decl from
ptw.hto internals.h. Provide an inline version for user-only, just as we do forarm_stage1_mmu_idx. Move an endif down to make the definition inhelper.cbe system only.Signed-off-by Richard Henderson <[email protected]>---
target/arm/internals.h| 5 +++++
target/arm/helper.c | 5 ++---2 files changed, 7 insertions(+), 3 deletions(-)
Quoted 12 lines
target/arm/internals.h ARMMMUIdx arm_mmu_idx(CPUARMState *env); · line 983
Quoted 10 lines
target/arm/internals.h +2
-0@@ -979,11 +979,16 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env);* Return the ARMMMUIdx for the stage1 traversal for the current regime. */ #ifdef CONFIG_USER_ONLY +static inline ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) +{Should we
assert(mmu_idx == ARMMMUIdx_Stage1_E0)?
You mean ARMMMUIdx_EL10_0, the stage2 idx, but no, I don't think that's useful considering the ifdef.
r~
PATCH 2/28 target/arm: Move get_phys_addr to ptw.c
In reply to Richard HendersonBegin moving all of the page table walking functions out of helper.c, starting with get_phys_addr().
Create a temporary header file, "ptw.h", in which to share declarations between the two C files while we are moving functions.
Move a few declarations to "internals.h", which will remain used by multiple C files.
--- target/arm/internals.h | 18 ++- target/arm/ptw.h | 51 ++++++ target/arm/helper.c | 344 +++++------------------------------------ target/arm/ptw.c | 267 ++++++++++++++++++++++++++++++++ target/arm/meson.build | 1 + 5 files changed, 372 insertions(+), 309 deletions(-) create mode 100644 target/arm/ptw.h create mode 100644 target/arm/ptw.c
target/arm/internals.h +16 -2
@@ -613,8 +613,13 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,/* Return the MMU index for a v7M CPU in the specified security state */ ARMMMUIdx arm_v7m_mmu_idx_for_secstate (CPUARMState *env,bool secstate); -/* Return true if the stage 1 translation regime is using LPAE format page -* tables */ +/* Return true if the translation regime is using LPAE format page tables */ +bool regime_using_lpae_format (CPUARMState *env,ARMMMUIdx mmu_idx); + +/* +* Return true if the stage 1 translation regime is using LPAE +* format page tables +*/ bool arm_s1_regime_using_lpae_format (CPUARMState *env,ARMMMUIdx mmu_idx);/* Raise a data fault alignment exception for the specified virtual address */
@@ -777,6 +782,12 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) } } +/* Return the SCTLR value which controls this address translation regime */ +static inline uint64_t regime_sctlr (CPUARMState *env,ARMMMUIdx mmu_idx) +{ +return env->cp15.sctlr_el[regime_el (env, mmu_idx)]; +} +/* Return the TCR controlling this translation regime */ static inline TCR *regime_tcr (CPUARMState *env,ARMMMUIdx mmu_idx) {
@@ -1095,6 +1106,9 @@ typedef struct ARMVAParameters {ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va,ARMMMUIdx mmu_idx,bool data); +int aa64_va_parameter_tbi (uint64_t tcr,ARMMMUIdx mmu_idx); +int aa64_va_parameter_tbid (uint64_t tcr,ARMMMUIdx mmu_idx); +static inline int exception_target_el (CPUARMState *env) {int target_el =MAX (1 ,arm_current_el (env));
target/arm/ptw.h new file +51 -0
51 lines not on this page · raw message
target/arm/helper.c +37 -307
441 lines not on this page · raw message
target/arm/ptw.c new file +267 -0
267 lines not on this page · raw message
target/arm/meson.build +1 -0
@@ -58,6 +58,7 @@ arm_softmmu_ss.add(files( 'machine.c', 'monitor.c', 'psci.c', + 'ptw.c', )) subdir('hvf')
Signature · 1 line
2.34.1
PATCH 3/28 target/arm: Move get_phys_addr_v5 to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 15 +++-- target/arm/helper.c | 137 +++----------------------------------------- target/arm/ptw.c | 123 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 135 deletions(-)
target/arm/ptw.h +10 -5
@@ -11,16 +11,21 @@#ifndef CONFIG_USER_ONLY +uint32_t arm_ldl_ptw (CPUState *cs,hwaddr addr,bool is_secure, +ARMMMUIdx mmu_idx,ARMMMUFaultInfo *fi); +uint64_t arm_ldq_ptw (CPUState *cs,hwaddr addr,bool is_secure, +ARMMMUIdx mmu_idx,ARMMMUFaultInfo *fi); +bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx);bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx);ARMCacheAttrs combine_cacheattrs (CPUARMState *env,ARMCacheAttrs s1,ARMCacheAttrs s2); -bool get_phys_addr_v5 (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -hwaddr *phys_ptr,int *prot, -target_ulong *page_size, -ARMMMUFaultInfo *fi); +bool get_level1_table_address (CPUARMState *env,ARMMMUIdx mmu_idx, +uint32_t *table,uint32_t address); +int ap_to_rw_prot (CPUARMState *env,ARMMMUIdx mmu_idx, +int ap,int domain_prot); + bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot,
target/arm/helper.c +7 -130
167 lines not on this page · raw message
target/arm/ptw.c +123 -0
129 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 4/28 target/arm: Move get_phys_addr_v6 to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 11 +-- target/arm/helper.c | 161 +------------------------------------------- target/arm/ptw.c | 153 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 164 deletions(-)
target/arm/ptw.h +7 -4
@@ -25,15 +25,18 @@ bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t *table, uint32_t address);int ap_to_rw_prot (CPUARMState *env,ARMMMUIdx mmu_idx,int ap,int domain_prot); +int simple_ap_to_rw_prot_is_user (int ap,bool is_user); + +static inline int +simple_ap_to_rw_prot (CPUARMState *env,ARMMMUIdx mmu_idx,int ap) +{ +return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); +}bool get_phys_addr_pmsav5 (CPUARMState *env,uint32_t address,MMUAccessType access_type,ARMMMUIdx mmu_idx,hwaddr *phys_ptr,int *prot,ARMMMUFaultInfo *fi); -bool get_phys_addr_v6 (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -hwaddr *phys_ptr,MemTxAttrs *attrs,int *prot, -target_ulong *page_size,ARMMMUFaultInfo *fi); bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot,
target/arm/helper.c +1 -160
179 lines not on this page · raw message
target/arm/ptw.c +153 -0
159 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 5/28 target/arm: Move get_phys_addr_pmsav5 to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 4 --- target/arm/helper.c | 85 --------------------------------------------- target/arm/ptw.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 89 deletions(-)
target/arm/ptw.h +0 -4
@@ -33,10 +33,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); } -bool get_phys_addr_pmsav5 (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -hwaddr *phys_ptr,int *prot, -ARMMMUFaultInfo *fi); bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot,
target/arm/helper.c +0 -85
91 lines not on this page · raw message
target/arm/ptw.c +85 -0
91 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 6/28 target/arm: Move get_phys_addr_pmsav7_default to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 3 +++ target/arm/helper.c | 41 ----------------------------------------- target/arm/ptw.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 41 deletions(-)
target/arm/ptw.h +3 -0
@@ -33,6 +33,9 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); } +void get_phys_addr_pmsav7_default (CPUARMState *env, +ARMMMUIdx mmu_idx, +int32_t address,int *prot); bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot,
target/arm/helper.c +0 -41
47 lines not on this page · raw message
target/arm/ptw.c +41 -0
47 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 7/28 target/arm: Move get_phys_addr_pmsav7 to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 10 +-- target/arm/helper.c | 194 +------------------------------------------- target/arm/ptw.c | 190 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+), 196 deletions(-)
target/arm/ptw.h +5 -5
@@ -33,14 +33,14 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); } +bool m_is_ppb_region (CPUARMState *env,uint32_t address); +bool m_is_system_region (CPUARMState *env,uint32_t address); +void get_phys_addr_pmsav7_default (CPUARMState *env,ARMMMUIdx mmu_idx,int32_t address,int *prot); -bool get_phys_addr_pmsav7 (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -hwaddr *phys_ptr,int *prot, -target_ulong *page_size, -ARMMMUFaultInfo *fi); +bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx,bool is_user); + bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *txattrs,
target/arm/helper.c +3 -191
218 lines not on this page · raw message
target/arm/ptw.c +190 -0
202 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 8/28 target/arm: Move get_phys_addr_pmsav8 to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 5 --- target/arm/helper.c | 75 ------------------------------------------- target/arm/ptw.c | 77 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 80 deletions(-)
target/arm/ptw.h +0 -5
@@ -41,11 +41,6 @@ void get_phys_addr_pmsav7_default(CPUARMState *env, int32_t address, int *prot);bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx,bool is_user); -bool get_phys_addr_pmsav8 (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -hwaddr *phys_ptr,MemTxAttrs *txattrs, -int *prot,target_ulong *page_size, -ARMMMUFaultInfo *fi); bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0,
target/arm/helper.c +0 -75
81 lines not on this page · raw message
target/arm/ptw.c +77 -0
83 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 9/28 target/arm: Move pmsav8_mpu_lookup to ptw.c
In reply to Richard HendersonThis is the final user of get_phys_addr_pmsav7_default within helper.c, so make it static within ptw.c.
--- target/arm/ptw.h | 3 - target/arm/helper.c | 136 ----------------------------------------- target/arm/ptw.c | 146 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 143 insertions(+), 142 deletions(-)
target/arm/ptw.h +0 -3
@@ -36,9 +36,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)bool m_is_ppb_region (CPUARMState *env,uint32_t address);bool m_is_system_region (CPUARMState *env,uint32_t address); -void get_phys_addr_pmsav7_default (CPUARMState *env, -ARMMMUIdx mmu_idx, -int32_t address,int *prot);bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx,bool is_user); bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
target/arm/helper.c +0 -136
142 lines not on this page · raw message
target/arm/ptw.c +143 -3
158 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 10/28 target/arm: Move pmsav7_use_background_region to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 2 -- target/arm/helper.c | 19 ------------------- target/arm/ptw.c | 21 +++++++++++++++++++++ 3 files changed, 21 insertions(+), 21 deletions(-)
target/arm/ptw.h +0 -2
@@ -36,8 +36,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)bool m_is_ppb_region (CPUARMState *env,uint32_t address);bool m_is_system_region (CPUARMState *env,uint32_t address); -bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx,bool is_user); - bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0,
target/arm/helper.c +0 -19
@@ -11642,25 +11642,6 @@ do_fault:return true; } -bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx,bool is_user) -{ -/* Return true if we should use the default memory map as a -* "background" region if there are no hits against any MPU regions. -*/ -CPUARMState *env = &cpu->env; - -if (is_user) { -return false; - } - -if (arm_feature (env,ARM_FEATURE_M )) { -return env->v7m.mpu_ctrl[regime_is_secure (env, mmu_idx)] - &R_V7M_MPU_CTRL_PRIVDEFENA_MASK ; - }else { -return regime_sctlr (env, mmu_idx) &SCTLR_BR ; - } -} -bool m_is_ppb_region (CPUARMState *env,uint32_t address) {/* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */
target/arm/ptw.c +21 -0
@@ -415,6 +415,27 @@ static void get_phys_addr_pmsav7_default(CPUARMState *env, ARMMMUIdx mmu_idx, } } +static bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx, +bool is_user) +{ +/* +* Return true if we should use the default memory map as a +* "background" region if there are no hits against any MPU regions. +*/ +CPUARMState *env = &cpu->env; + +if (is_user) { +return false; + } + +if (arm_feature (env,ARM_FEATURE_M )) { +return env->v7m.mpu_ctrl[regime_is_secure (env, mmu_idx)] + &R_V7M_MPU_CTRL_PRIVDEFENA_MASK ; + }else { +return regime_sctlr (env, mmu_idx) &SCTLR_BR ; + } +} + static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot,
Signature · 1 line
2.34.1
PATCH 11/28 target/arm: Move v8m_security_lookup to ptw.c
In reply to Richard HendersonThis function has one private helper, v8m_is_sau_exempt, so move that at the same time.
--- target/arm/helper.c | 123 ------------------------------------------ target/arm/ptw.c | 126 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 123 deletions(-)
target/arm/helper.c +0 -123
@@ -9,7 +9,6 @@#include "qemu/osdep.h" #include "qemu/units.h" #include "qemu/log.h" -#include "target/arm/idau.h" #include "trace.h" #include "cpu.h" #include "internals.h"
@@ -11657,128 +11656,6 @@ bool m_is_system_region(CPUARMState *env, uint32_t address)return arm_feature (env,ARM_FEATURE_M ) &&extract32 (address,29 ,3 ) ==0x7 ; } -static bool v8m_is_sau_exempt (CPUARMState *env, -uint32_t address,MMUAccessType access_type) -{ -/* The architecture specifies that certain address ranges are -* exempt from v8M SAU/IDAU checks. -*/ -return - (access_type ==MMU_INST_FETCH &&m_is_system_region (env, address)) || - (address >=0xe0000000 && address <=0xe0002fff ) || - (address >=0xe000e000 && address <=0xe000efff ) || - (address >=0xe002e000 && address <=0xe002efff ) || - (address >=0xe0040000 && address <=0xe0041fff ) || - (address >=0xe00ff000 && address <=0xe00fffff ); -} - -void v8m_security_lookup (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -V8M_SAttributes *sattrs) -{ -/* Look up the security attributes for this address. Compare the -* pseudocode SecurityCheck() function. -* We assume the caller has zero-initialized *sattrs. -*/ -ARMCPU *cpu =env_archcpu (env); -int r; -bool idau_exempt = false, idau_ns = true, idau_nsc = true; -int idau_region =IREGION_NOTVALID ; -uint32_t addr_page_base = address &TARGET_PAGE_MASK ; -uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE -1 ); - -if (cpu->idau) { -IDAUInterfaceClass *iic =IDAU_INTERFACE_GET_CLASS (cpu->idau); -IDAUInterface *ii =IDAU_INTERFACE (cpu->idau); - - iic->check (ii, address, &idau_region, &idau_exempt, &idau_ns, - &idau_nsc); - } - -if (access_type ==MMU_INST_FETCH &&extract32 (address,28 ,4 ) ==0xf ) { -/* 0xf0000000..0xffffffff is always S for insn fetches */ -return ; - } - -if (idau_exempt ||v8m_is_sau_exempt (env, address, access_type)) { - sattrs->ns = !regime_is_secure (env, mmu_idx); -return ; - } - -if (idau_region !=IREGION_NOTVALID ) { - sattrs->irvalid = true; - sattrs->iregion = idau_region; - } - -switch (env->sau.ctrl &3 ) { -case 0 :/* SAU.ENABLE == 0, SAU.ALLNS == 0 */ -break ; -case 2 :/* SAU.ENABLE == 0, SAU.ALLNS == 1 */ - sattrs->ns = true; -break ; -default :/* SAU.ENABLE == 1 */ -for (r =0 ; r < cpu->sau_sregion; r++) { -if (env->sau.rlar[r] &1 ) { -uint32_t base = env->sau.rbar[r] & ~0x1f ; -uint32_t limit = env->sau.rlar[r] |0x1f ; - -if (base <= address && limit >= address) { -if (base > addr_page_base || limit < addr_page_limit) { - sattrs->subpage = true; - } -if (sattrs->srvalid) { -/* If we hit in more than one region then we must report -* as Secure, not NS-Callable, with no valid region -* number info. -*/ - sattrs->ns = false; - sattrs->nsc = false; - sattrs->sregion =0 ; - sattrs->srvalid = false; -break ; - }else { -if (env->sau.rlar[r] &2 ) { - sattrs->nsc = true; - }else { - sattrs->ns = true; - } - sattrs->srvalid = true; - sattrs->sregion = r; - } - }else { -/* -* Address not in this region. We must check whether the -* region covers addresses in the same page as our address. -* In that case we must not report a size that covers the -* whole page for a subsequent hit against a different MPU -* region or the background region, because it would result -* in incorrect TLB hits for subsequent accesses to -* addresses that are in this MPU region. -*/ -if (limit >= base && -ranges_overlap (base, limit - base +1 , - addr_page_base, -TARGET_PAGE_SIZE )) { - sattrs->subpage = true; - } - } - } - } -break ; - } - -/* -* The IDAU will override the SAU lookup results if it specifies -* higher security than the SAU does. -*/ -if (!idau_ns) { -if (sattrs->ns || (!idau_nsc && sattrs->nsc)) { - sattrs->ns = false; - sattrs->nsc = idau_nsc; - } - } -} -/* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM).
target/arm/ptw.c +126 -0
138 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 12/28 target/arm: Move m_is_{ppb,system}_region to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 3 --- target/arm/helper.c | 15 --------------- target/arm/ptw.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 18 deletions(-)
target/arm/ptw.h +0 -3
@@ -33,9 +33,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); } -bool m_is_ppb_region (CPUARMState *env,uint32_t address); -bool m_is_system_region (CPUARMState *env,uint32_t address); - bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0,
target/arm/helper.c +0 -15
@@ -11641,21 +11641,6 @@ do_fault:return true; } -bool m_is_ppb_region (CPUARMState *env,uint32_t address) -{ -/* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */ -return arm_feature (env,ARM_FEATURE_M ) && -extract32 (address,20 ,12 ) ==0xe00 ; -} - -bool m_is_system_region (CPUARMState *env,uint32_t address) -{ -/* True if address is in the M profile system region -* 0xe0000000 - 0xffffffff -*/ -return arm_feature (env,ARM_FEATURE_M ) &&extract32 (address,29 ,3 ) ==0x7 ; -} -/* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM).
target/arm/ptw.c +16 -0
@@ -416,6 +416,22 @@ static void get_phys_addr_pmsav7_default(CPUARMState *env, ARMMMUIdx mmu_idx, } } +static bool m_is_ppb_region (CPUARMState *env,uint32_t address) +{ +/* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */ +return arm_feature (env,ARM_FEATURE_M ) && +extract32 (address,20 ,12 ) ==0xe00 ; +} + +static bool m_is_system_region (CPUARMState *env,uint32_t address) +{ +/* +* True if address is in the M profile system region +* 0xe0000000 - 0xffffffff +*/ +return arm_feature (env,ARM_FEATURE_M ) &&extract32 (address,29 ,3 ) ==0x7 ; +} +static bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx,bool is_user) {
Signature · 1 line
2.34.1
PATCH 13/28 target/arm: Move get_level1_table_address to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 4 ++-- target/arm/helper.c | 26 +------------------------- target/arm/ptw.c | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 27 deletions(-)
target/arm/ptw.h +2 -2
@@ -18,11 +18,11 @@ uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx);bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx); +uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn); +ARMCacheAttrs combine_cacheattrs (CPUARMState *env,ARMCacheAttrs s1,ARMCacheAttrs s2); -bool get_level1_table_address (CPUARMState *env,ARMMMUIdx mmu_idx, -uint32_t *table,uint32_t address);int ap_to_rw_prot (CPUARMState *env,ARMMMUIdx mmu_idx,int ap,int domain_prot);int simple_ap_to_rw_prot_is_user (int ap,bool is_user);
target/arm/helper.c +1 -25
@@ -10446,8 +10446,7 @@ static inline bool regime_translation_big_endian(CPUARMState *env, }/* Return the TTBR associated with this translation regime */ -static inline uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx, -int ttbrn) +uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn) {if (mmu_idx == ARMMMUIdx_Stage2) {return env->cp15.vttbr_el2;
@@ -10738,29 +10737,6 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,return prot_rw |PAGE_EXEC ; } -bool get_level1_table_address (CPUARMState *env,ARMMMUIdx mmu_idx, -uint32_t *table,uint32_t address) -{ -/* Note that we can only get here for an AArch32 PL0/PL1 lookup */ -TCR *tcr =regime_tcr (env, mmu_idx); - -if (address & tcr->mask) { -if (tcr->raw_tcr &TTBCR_PD1 ) { -/* Translation table walk disabled for TTBR1 */ -return false; - } - *table =regime_ttbr (env, mmu_idx,1 ) &0xffffc000 ; - }else { -if (tcr->raw_tcr &TTBCR_PD0 ) { -/* Translation table walk disabled for TTBR0 */ -return false; - } - *table =regime_ttbr (env, mmu_idx,0 ) & tcr->base_mask; - } - *table |= (address >>18 ) &0x3ffc ; -return true; -} -static bool ptw_attrs_are_device (CPUARMState *env,ARMCacheAttrs cacheattrs) {/*
target/arm/ptw.c +23 -0
@@ -15,6 +15,29 @@#include "ptw.h" +static bool get_level1_table_address (CPUARMState *env,ARMMMUIdx mmu_idx, +uint32_t *table,uint32_t address) +{ +/* Note that we can only get here for an AArch32 PL0/PL1 lookup */ +TCR *tcr =regime_tcr (env, mmu_idx); + +if (address & tcr->mask) { +if (tcr->raw_tcr &TTBCR_PD1 ) { +/* Translation table walk disabled for TTBR1 */ +return false; + } + *table =regime_ttbr (env, mmu_idx,1 ) &0xffffc000 ; + }else { +if (tcr->raw_tcr &TTBCR_PD0 ) { +/* Translation table walk disabled for TTBR0 */ +return false; + } + *table =regime_ttbr (env, mmu_idx,0 ) & tcr->base_mask; + } + *table |= (address >>18 ) &0x3ffc ; +return true; +} + static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot,
Signature · 1 line
2.34.1
PATCH 14/28 target/arm: Move combine_cacheattrs and subroutines to ptw.c
In reply to Richard HendersonThere are a handful of helpers for combine_cacheattrs that we can move at the same time as the main entry point.
--- target/arm/ptw.h | 3 - target/arm/helper.c | 218 ------------------------------------------- target/arm/ptw.c | 221 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 221 insertions(+), 221 deletions(-)
target/arm/ptw.h +0 -3
@@ -20,9 +20,6 @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx);bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx);uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn); -ARMCacheAttrs combine_cacheattrs (CPUARMState *env, -ARMCacheAttrs s1,ARMCacheAttrs s2); -int ap_to_rw_prot (CPUARMState *env,ARMMMUIdx mmu_idx,int ap,int domain_prot);int simple_ap_to_rw_prot_is_user (int ap,bool is_user);
target/arm/helper.c +0 -218
230 lines not on this page · raw message
target/arm/ptw.c +221 -0
227 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 15/28 target/arm: Move get_phys_addr_lpae to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 10 ++ target/arm/helper.c | 416 +------------------------------------------- target/arm/ptw.c | 411 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 429 insertions(+), 408 deletions(-)
target/arm/ptw.h +10 -0
@@ -11,6 +11,8 @@#ifndef CONFIG_USER_ONLY +extern const uint8_t pamax_map[7 ]; +uint32_t arm_ldl_ptw (CPUState *cs,hwaddr addr,bool is_secure,ARMMMUIdx mmu_idx,ARMMMUFaultInfo *fi); uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
@@ -30,6 +32,14 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); } +ARMVAParameters aa32_va_parameters (CPUARMState *env,uint32_t va, +ARMMMUIdx mmu_idx); +bool check_s2_mmu_setup (ARMCPU *cpu,bool is_aa64,int level, +int inputsize,int stride,int outputsize); +int get_S2prot (CPUARMState *env,int s2ap,int xn,bool s1_is_el0); +int get_S1prot (CPUARMState *env,ARMMMUIdx mmu_idx,bool is_aa64, +int ap,int ns,int xn,int pxn); + bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0,
target/arm/helper.c +8 -408
452 lines not on this page · raw message
target/arm/ptw.c +411 -0
417 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 16/28 target/arm: Move arm_{ldl,ldq}_ptw to ptw.c
In reply to Richard HendersonMove the ptw load functions, plus 3 common subroutines:S1_ptw_translate, ptw_attrs_are_device, and regime_translation_big_endian. This also allows get_phys_addr_lpae to become static again.
--- target/arm/ptw.h | 13 ---- target/arm/helper.c | 141 -------------------------------------- target/arm/ptw.c | 160 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 154 insertions(+), 160 deletions(-)
target/arm/ptw.h +0 -13
@@ -13,11 +13,6 @@extern const uint8_t pamax_map[7 ]; -uint32_t arm_ldl_ptw (CPUState *cs,hwaddr addr,bool is_secure, -ARMMMUIdx mmu_idx,ARMMMUFaultInfo *fi); -uint64_t arm_ldq_ptw (CPUState *cs,hwaddr addr,bool is_secure, -ARMMMUIdx mmu_idx,ARMMMUFaultInfo *fi); -bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx);bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx);uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn);
@@ -40,13 +35,5 @@ int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0);int get_S1prot (CPUARMState *env,ARMMMUIdx mmu_idx,bool is_aa64,int ap,int ns,int xn,int pxn); -bool get_phys_addr_lpae (CPUARMState *env,uint64_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -bool s1_is_el0, -hwaddr *phys_ptr,MemTxAttrs *txattrs,int *prot, -target_ulong *page_size_ptr, -ARMMMUFaultInfo *fi,ARMCacheAttrs *cacheattrs) - __attribute__((nonnull)); -#endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */
target/arm/helper.c +0 -141
153 lines not on this page · raw message
target/arm/ptw.c +154 -6
172 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 17/28 target/arm: Move {arm_s1_, }regime_using_lpae_format to tlb_helper.c
In reply to Richard HendersonThese functions are used for both page table walking and for deciding what format in which to deliver exception results. Since ptw.c is only present for system mode, put the functions into tlb_helper.c.
--- target/arm/helper.c | 24 ------------------------ target/arm/tlb_helper.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 24 deletions(-)
target/arm/helper.c +0 -24
@@ -10479,30 +10479,6 @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) }#endif /* !CONFIG_USER_ONLY */ -/* Return true if the translation regime is using LPAE format page tables */ -bool regime_using_lpae_format (CPUARMState *env,ARMMMUIdx mmu_idx) -{ -int el =regime_el (env, mmu_idx); -if (el ==2 ||arm_el_is_aa64 (env, el)) { -return true; - } -if (arm_feature (env,ARM_FEATURE_LPAE ) - && (regime_tcr (env, mmu_idx)->raw_tcr &TTBCR_EAE )) { -return true; - } -return false; -} - -/* Returns true if the stage 1 translation regime is using LPAE format page -* tables. Used when raising alignment exceptions, whose FSR changes depending -* on whether the long or short descriptor format is in use. */ -bool arm_s1_regime_using_lpae_format (CPUARMState *env,ARMMMUIdx mmu_idx) -{ - mmu_idx =stage_1_mmu_idx (mmu_idx); - -return regime_using_lpae_format (env, mmu_idx); -} -#ifndef CONFIG_USER_ONLY bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx) {
target/arm/tlb_helper.c +26 -0
@@ -11,6 +11,32 @@#include "exec/exec-all.h" #include "exec/helper-proto.h" + +/* Return true if the translation regime is using LPAE format page tables */ +bool regime_using_lpae_format (CPUARMState *env,ARMMMUIdx mmu_idx) +{ +int el =regime_el (env, mmu_idx); +if (el ==2 ||arm_el_is_aa64 (env, el)) { +return true; + } +if (arm_feature (env,ARM_FEATURE_LPAE ) + && (regime_tcr (env, mmu_idx)->raw_tcr &TTBCR_EAE )) { +return true; + } +return false; +} + +/* +* Returns true if the stage 1 translation regime is using LPAE format page +* tables. Used when raising alignment exceptions, whose FSR changes depending +* on whether the long or short descriptor format is in use. +*/ +bool arm_s1_regime_using_lpae_format (CPUARMState *env,ARMMMUIdx mmu_idx) +{ + mmu_idx =stage_1_mmu_idx (mmu_idx); +return regime_using_lpae_format (env, mmu_idx); +} + static inline uint32_t merge_syn_data_abort(uint32_t template_syn, unsigned int target_el, bool same_el, bool ea,
Signature · 1 line
2.34.1
PATCH 18/28 target/arm: Move arm_pamax, pamax_map into ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 2 -- target/arm/helper.c | 25 ------------------------- target/arm/ptw.c | 25 +++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 27 deletions(-)
target/arm/ptw.h +0 -2
@@ -11,8 +11,6 @@#ifndef CONFIG_USER_ONLY -extern const uint8_t pamax_map[7 ]; -bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx);bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx);uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn);
target/arm/helper.c +0 -25
@@ -10778,31 +10778,6 @@ bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, }#endif /* !CONFIG_USER_ONLY */ -/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ -const uint8_t pamax_map[] = { - [0 ] =32 , - [1 ] =36 , - [2 ] =40 , - [3 ] =42 , - [4 ] =44 , - [5 ] =48 , - [6 ] =52 , -}; - -/* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ -unsigned int arm_pamax (ARMCPU *cpu) -{ -unsigned int parange = -FIELD_EX64 (cpu->isar.id_aa64mmfr0,ID_AA64MMFR0 ,PARANGE ); - -/* -* id_aa64mmfr0 is a read-only register so values outside of the -* supported mappings can be considered an implementation error. -*/ -assert (parange <ARRAY_SIZE (pamax_map)); -return pamax_map[parange]; -} -int aa64_va_parameter_tbi (uint64_t tcr,ARMMMUIdx mmu_idx) {if (regime_has_2_ranges (mmu_idx)) {
target/arm/ptw.c +25 -0
@@ -23,6 +23,31 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) __attribute__((nonnull)); +/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ +static const uint8_t pamax_map[] = { + [0 ] =32 , + [1 ] =36 , + [2 ] =40 , + [3 ] =42 , + [4 ] =44 , + [5 ] =48 , + [6 ] =52 , +}; + +/* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ +unsigned int arm_pamax (ARMCPU *cpu) +{ +unsigned int parange = +FIELD_EX64 (cpu->isar.id_aa64mmfr0,ID_AA64MMFR0 ,PARANGE ); + +/* +* id_aa64mmfr0 is a read-only register so values outside of the +* supported mappings can be considered an implementation error. +*/ +assert (parange <ARRAY_SIZE (pamax_map)); +return pamax_map[parange]; +} +static bool regime_translation_big_endian (CPUARMState *env,ARMMMUIdx mmu_idx) {return (regime_sctlr (env, mmu_idx) &SCTLR_EE ) !=0 ;
Signature · 1 line
2.34.1
PATCH 19/28 target/arm: Move get_S1prot, get_S2prot to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 3 -- target/arm/helper.c | 128 -------------------------------------------- target/arm/ptw.c | 128 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 131 deletions(-)
target/arm/ptw.h +0 -3
@@ -29,9 +29,6 @@ ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, ARMMMUIdx mmu_idx);bool check_s2_mmu_setup (ARMCPU *cpu,bool is_aa64,int level,int inputsize,int stride,int outputsize); -int get_S2prot (CPUARMState *env,int s2ap,int xn,bool s1_is_el0); -int get_S1prot (CPUARMState *env,ARMMMUIdx mmu_idx,bool is_aa64, -int ap,int ns,int xn,int pxn);#endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */
target/arm/helper.c +0 -128
134 lines not on this page · raw message
target/arm/ptw.c +128 -0
134 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 20/28 target/arm: Move check_s2_mmu_setup to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 2 -- target/arm/helper.c | 70 --------------------------------------------- target/arm/ptw.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 72 deletions(-)
target/arm/ptw.h +0 -2
@@ -27,8 +27,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)ARMVAParameters aa32_va_parameters (CPUARMState *env,uint32_t va,ARMMMUIdx mmu_idx); -bool check_s2_mmu_setup (ARMCPU *cpu,bool is_aa64,int level, -int inputsize,int stride,int outputsize);#endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */
target/arm/helper.c +0 -70
76 lines not on this page · raw message
target/arm/ptw.c +70 -0
76 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 21/28 target/arm: Move aa32_va_parameters to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 3 --- target/arm/helper.c | 64 --------------------------------------------- target/arm/ptw.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 67 deletions(-)
target/arm/ptw.h +0 -3
@@ -25,8 +25,5 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); } -ARMVAParameters aa32_va_parameters (CPUARMState *env,uint32_t va, -ARMMMUIdx mmu_idx); -#endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */
target/arm/helper.c +0 -64
70 lines not on this page · raw message
target/arm/ptw.c +64 -0
70 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 22/28 target/arm: Move ap_to_tw_prot etc to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 10 ------ target/arm/helper.c | 77 ------------------------------------------ target/arm/ptw.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 87 deletions(-)
target/arm/ptw.h +0 -10
@@ -15,15 +15,5 @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx);bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx);uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn); -int ap_to_rw_prot (CPUARMState *env,ARMMMUIdx mmu_idx, -int ap,int domain_prot); -int simple_ap_to_rw_prot_is_user (int ap,bool is_user); - -static inline int -simple_ap_to_rw_prot (CPUARMState *env,ARMMMUIdx mmu_idx,int ap) -{ -return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); -} -#endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */
target/arm/helper.c +0 -77
83 lines not on this page · raw message
target/arm/ptw.c +81 -0
87 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 23/28 target/arm: Move regime_is_user to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 1 - target/arm/helper.c | 24 ------------------------ target/arm/ptw.c | 22 ++++++++++++++++++++++ 3 files changed, 22 insertions(+), 25 deletions(-)
target/arm/ptw.h +0 -1
@@ -11,7 +11,6 @@#ifndef CONFIG_USER_ONLY -bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx);bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx);uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn);
target/arm/helper.c +0 -24
@@ -10479,30 +10479,6 @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) }#endif /* !CONFIG_USER_ONLY */ -#ifndef CONFIG_USER_ONLY -bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx) -{ -switch (mmu_idx) { -case ARMMMUIdx_SE10_0: -case ARMMMUIdx_E20_0: -case ARMMMUIdx_SE20_0: -case ARMMMUIdx_Stage1_E0: -case ARMMMUIdx_Stage1_SE0: -case ARMMMUIdx_MUser: -case ARMMMUIdx_MSUser: -case ARMMMUIdx_MUserNegPri: -case ARMMMUIdx_MSUserNegPri: -return true; -default : -return false; -case ARMMMUIdx_E10_0: -case ARMMMUIdx_E10_1: -case ARMMMUIdx_E10_1_PAN: -g_assert_not_reached (); - } -} -#endif /* !CONFIG_USER_ONLY */ -int aa64_va_parameter_tbi (uint64_t tcr,ARMMMUIdx mmu_idx) {if (regime_has_2_ranges (mmu_idx)) {
target/arm/ptw.c +22 -0
@@ -53,6 +53,28 @@ static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx)return (regime_sctlr (env, mmu_idx) &SCTLR_EE ) !=0 ; } +static bool regime_is_user (CPUARMState *env,ARMMMUIdx mmu_idx) +{ +switch (mmu_idx) { +case ARMMMUIdx_SE10_0: +case ARMMMUIdx_E20_0: +case ARMMMUIdx_SE20_0: +case ARMMMUIdx_Stage1_E0: +case ARMMMUIdx_Stage1_SE0: +case ARMMMUIdx_MUser: +case ARMMMUIdx_MSUser: +case ARMMMUIdx_MUserNegPri: +case ARMMMUIdx_MSUserNegPri: +return true; +default : +return false; +case ARMMMUIdx_E10_0: +case ARMMMUIdx_E10_1: +case ARMMMUIdx_E10_1_PAN: +g_assert_not_reached (); + } +} +static bool ptw_attrs_are_device (CPUARMState *env,ARMCacheAttrs cacheattrs) {/*
Signature · 1 line
2.34.1
PATCH 24/28 target/arm: Move regime_ttbr to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 1 - target/arm/helper.c | 16 ---------------- target/arm/ptw.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 17 deletions(-)
target/arm/ptw.h +0 -1
@@ -12,7 +12,6 @@#ifndef CONFIG_USER_ONLY bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx); -uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn);#endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */
target/arm/helper.c +0 -16
@@ -10439,22 +10439,6 @@ bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx)return (regime_sctlr (env, mmu_idx) &SCTLR_M ) ==0 ; } -/* Return the TTBR associated with this translation regime */ -uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn) -{ -if (mmu_idx == ARMMMUIdx_Stage2) { -return env->cp15.vttbr_el2; - } -if (mmu_idx == ARMMMUIdx_Stage2_S) { -return env->cp15.vsttbr_el2; - } -if (ttbrn ==0 ) { -return env->cp15.ttbr0_el[regime_el (env, mmu_idx)]; - }else { -return env->cp15.ttbr1_el[regime_el (env, mmu_idx)]; - } -} -/* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */
target/arm/ptw.c +16 -0
@@ -75,6 +75,22 @@ static bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) } } +/* Return the TTBR associated with this translation regime */ +static uint64_t regime_ttbr (CPUARMState *env,ARMMMUIdx mmu_idx,int ttbrn) +{ +if (mmu_idx == ARMMMUIdx_Stage2) { +return env->cp15.vttbr_el2; + } +if (mmu_idx == ARMMMUIdx_Stage2_S) { +return env->cp15.vsttbr_el2; + } +if (ttbrn ==0 ) { +return env->cp15.ttbr0_el[regime_el (env, mmu_idx)]; + }else { +return env->cp15.ttbr1_el[regime_el (env, mmu_idx)]; + } +} +static bool ptw_attrs_are_device (CPUARMState *env,ARMCacheAttrs cacheattrs) {/*
Signature · 1 line
2.34.1
PATCH 25/28 target/arm: Move regime_translation_disabled to ptw.c
In reply to Richard Henderson--- target/arm/ptw.h | 17 ---------------- target/arm/helper.c | 47 --------------------------------------------- target/arm/ptw.c | 47 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 65 deletions(-) delete mode 100644 target/arm/ptw.h
target/arm/ptw.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* -* ARM page table walking. -* -* This code is licensed under the GNU GPL v2 or later. -* -* SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#ifndef TARGET_ARM_PTW_H -#define TARGET_ARM_PTW_H - -#ifndef CONFIG_USER_ONLY - -bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx); - -#endif /* !CONFIG_USER_ONLY */ -#endif /* TARGET_ARM_PTW_H */
target/arm/helper.c +0 -47
59 lines not on this page · raw message
target/arm/ptw.c +46 -1
59 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 26/28 target/arm: Move arm_cpu_get_phys_page_attrs_debug to ptw.c
In reply to Richard Henderson--- target/arm/helper.c | 26 -------------------------- target/arm/ptw.c | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 26 deletions(-)
target/arm/helper.c +0 -26
@@ -10570,32 +10570,6 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, }; } -#ifndef CONFIG_USER_ONLY -hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cs,vaddr addr, -MemTxAttrs *attrs) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; -hwaddr phys_addr; -target_ulong page_size; -int prot; -bool ret; -ARMMMUFaultInfo fi = {}; -ARMMMUIdx mmu_idx =arm_mmu_idx (env); -ARMCacheAttrs cacheattrs = {}; - - *attrs = (MemTxAttrs ) {}; - - ret =get_phys_addr (env, addr,MMU_DATA_LOAD , mmu_idx, &phys_addr, - attrs, &prot, &page_size, &fi, &cacheattrs); - -if (ret) { -return -1 ; - } -return phys_addr; -} -#endif -/* Note that signed overflow is undefined in C. The following routines are careful to use unsigned types where modulo arithmetic is required. Failure to do so _will_ break on newer gcc. */
target/arm/ptw.c +24 -0
@@ -2491,3 +2491,27 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, phys_ptr, prot, page_size, fi); } } + +hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cs,vaddr addr, +MemTxAttrs *attrs) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +hwaddr phys_addr; +target_ulong page_size; +int prot; +bool ret; +ARMMMUFaultInfo fi = {}; +ARMMMUIdx mmu_idx =arm_mmu_idx (env); +ARMCacheAttrs cacheattrs = {}; + + *attrs = (MemTxAttrs ) {}; + + ret =get_phys_addr (env, addr,MMU_DATA_LOAD , mmu_idx, &phys_addr, + attrs, &prot, &page_size, &fi, &cacheattrs); + +if (ret) { +return -1 ; + } +return phys_addr; +}
Signature · 1 line
2.34.1
PATCH 27/28 target/arm: Move stage_1_mmu_idx, arm_stage1_mmu_idx to ptw.c
In reply to Richard Henderson--- target/arm/helper.c | 32 -------------------------------- target/arm/ptw.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 32 deletions(-)
target/arm/helper.c +0 -32
@@ -10391,31 +10391,6 @@ uint64_t arm_sctlr(CPUARMState *env, int el)return env->cp15.sctlr_el[el]; } -#ifndef CONFIG_USER_ONLY -/* Convert a possible stage1+2 MMU index into the appropriate -* stage 1 MMU index -*/ -ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) -{ -switch (mmu_idx) { -case ARMMMUIdx_SE10_0: -return ARMMMUIdx_Stage1_SE0; -case ARMMMUIdx_SE10_1: -return ARMMMUIdx_Stage1_SE1; -case ARMMMUIdx_SE10_1_PAN: -return ARMMMUIdx_Stage1_SE1_PAN; -case ARMMMUIdx_E10_0: -return ARMMMUIdx_Stage1_E0; -case ARMMMUIdx_E10_1: -return ARMMMUIdx_Stage1_E1; -case ARMMMUIdx_E10_1_PAN: -return ARMMMUIdx_Stage1_E1_PAN; -default : -return mmu_idx; - } -} -#endif /* !CONFIG_USER_ONLY */ -int aa64_va_parameter_tbi (uint64_t tcr,ARMMMUIdx mmu_idx) {if (regime_has_2_ranges (mmu_idx)) {
@@ -11045,13 +11020,6 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env)return arm_mmu_idx_el (env,arm_current_el (env)); } -#ifndef CONFIG_USER_ONLY -ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env) -{ -return stage_1_mmu_idx (arm_mmu_idx (env)); -} -#endif -static CPUARMTBFlags rebuild_hflags_common (CPUARMState *env,int fp_el,ARMMMUIdx mmu_idx,CPUARMTBFlags flags)
target/arm/ptw.c +28 -0
@@ -47,6 +47,34 @@ unsigned int arm_pamax(ARMCPU *cpu)return pamax_map[parange]; } +/* +* Convert a possible stage1+2 MMU index into the appropriate stage 1 MMU index +*/ +ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) +{ +switch (mmu_idx) { +case ARMMMUIdx_SE10_0: +return ARMMMUIdx_Stage1_SE0; +case ARMMMUIdx_SE10_1: +return ARMMMUIdx_Stage1_SE1; +case ARMMMUIdx_SE10_1_PAN: +return ARMMMUIdx_Stage1_SE1_PAN; +case ARMMMUIdx_E10_0: +return ARMMMUIdx_Stage1_E0; +case ARMMMUIdx_E10_1: +return ARMMMUIdx_Stage1_E1; +case ARMMMUIdx_E10_1_PAN: +return ARMMMUIdx_Stage1_E1_PAN; +default : +return mmu_idx; + } +} + +ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env) +{ +return stage_1_mmu_idx (arm_mmu_idx (env)); +} +static bool regime_translation_big_endian (CPUARMState *env,ARMMMUIdx mmu_idx) {return (regime_sctlr (env, mmu_idx) &SCTLR_EE ) !=0 ;
Signature · 1 line
2.34.1
PATCH 28/28 target/arm: Pass CPUARMState to arm_ld[lq]_ptw
In reply to Richard HendersonThe use of ARM_CPU to recover env from cs calls object_class_dynamic_cast, which shows up on the profile. This is pointless, because all callers already have env, and the reverse operation, env_cpu, is only pointer arithmetic.
--- target/arm/ptw.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
target/arm/ptw.c +9 -14
@@ -241,11 +241,10 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, }/* All loads done in the course of a page table walk go through here. */ -static uint32_t arm_ldl_ptw (CPUState *cs,hwaddr addr,bool is_secure, +static uint32_t arm_ldl_ptw (CPUARMState *env,hwaddr addr,bool is_secure,ARMMMUIdx mmu_idx,ARMMMUFaultInfo *fi) { -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; +CPUState *cs =env_cpu (env);MemTxAttrs attrs = {};MemTxResult result =MEMTX_OK ;AddressSpace *as;
@@ -270,11 +269,10 @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure,return 0 ; } -static uint64_t arm_ldq_ptw (CPUState *cs,hwaddr addr,bool is_secure, +static uint64_t arm_ldq_ptw (CPUARMState *env,hwaddr addr,bool is_secure,ARMMMUIdx mmu_idx,ARMMMUFaultInfo *fi) { -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; +CPUState *cs =env_cpu (env);MemTxAttrs attrs = {};MemTxResult result =MEMTX_OK ;AddressSpace *as;
@@ -409,7 +407,6 @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, target_ulong *page_size, ARMMMUFaultInfo *fi) { -CPUState *cs =env_cpu (env);int level =1 ;uint32_t table;uint32_t desc;
@@ -427,7 +424,7 @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, fi->type = ARMFault_Translation; goto do_fault; } - desc =arm_ldl_ptw (cs, table,regime_is_secure (env, mmu_idx), + desc =arm_ldl_ptw (env, table,regime_is_secure (env, mmu_idx), mmu_idx, fi);if (fi->type != ARMFault_None) { goto do_fault;
@@ -466,7 +463,7 @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,/* Fine pagetable. */ table = (desc &0xfffff000 ) | ((address >>8 ) &0xffc ); } - desc =arm_ldl_ptw (cs, table,regime_is_secure (env, mmu_idx), + desc =arm_ldl_ptw (env, table,regime_is_secure (env, mmu_idx), mmu_idx, fi);if (fi->type != ARMFault_None) { goto do_fault;
@@ -531,7 +528,6 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, target_ulong *page_size, ARMMMUFaultInfo *fi) { -CPUState *cs =env_cpu (env);ARMCPU *cpu =env_archcpu (env);int level =1 ;uint32_t table;
@@ -553,7 +549,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, fi->type = ARMFault_Translation; goto do_fault; } - desc =arm_ldl_ptw (cs, table,regime_is_secure (env, mmu_idx), + desc =arm_ldl_ptw (env, table,regime_is_secure (env, mmu_idx), mmu_idx, fi);if (fi->type != ARMFault_None) { goto do_fault;
@@ -607,7 +603,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, ns =extract32 (desc,3 ,1 );/* Lookup l2 entry. */ table = (desc &0xfffffc00 ) | ((address >>10 ) &0x3fc ); - desc =arm_ldl_ptw (cs, table,regime_is_secure (env, mmu_idx), + desc =arm_ldl_ptw (env, table,regime_is_secure (env, mmu_idx), mmu_idx, fi);if (fi->type != ARMFault_None) { goto do_fault;
@@ -973,7 +969,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) {ARMCPU *cpu =env_archcpu (env); -CPUState *cs =CPU (cpu);/* Read an LPAE long-descriptor translation table. */ ARMFaultType fault_type = ARMFault_Translation;uint32_t level;
@@ -1196,7 +1191,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, descaddr |= (address >> (stride * (4 - level))) & indexmask; descaddr &= ~7ULL ; nstable =extract32 (tableattrs,4 ,1 ); - descriptor =arm_ldq_ptw (cs, descaddr, !nstable, mmu_idx, fi); + descriptor =arm_ldq_ptw (env, descaddr, !nstable, mmu_idx, fi);if (fi->type != ARMFault_None) { goto do_fault; }
Signature · 1 line
2.34.1
Peter Maydell
AppliedQuoted 3 lines · Richard Henderson
The object here is to move 2500 lines out of
helper.c. Yay!
Applied to target-arm.next, thanks.
-- PMM