mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 18:23:57 -06:00
target/arm: Introduce regime_is_stage2
Reduce the amount of typing required for this check. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20221024051851.3074715-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
7719419deb
commit
edc05dd43a
3 changed files with 16 additions and 17 deletions
|
@ -10352,7 +10352,7 @@ int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx)
|
||||||
{
|
{
|
||||||
if (regime_has_2_ranges(mmu_idx)) {
|
if (regime_has_2_ranges(mmu_idx)) {
|
||||||
return extract64(tcr, 37, 2);
|
return extract64(tcr, 37, 2);
|
||||||
} else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
|
} else if (regime_is_stage2(mmu_idx)) {
|
||||||
return 0; /* VTCR_EL2 */
|
return 0; /* VTCR_EL2 */
|
||||||
} else {
|
} else {
|
||||||
/* Replicate the single TBI bit so we always have 2 bits. */
|
/* Replicate the single TBI bit so we always have 2 bits. */
|
||||||
|
@ -10364,7 +10364,7 @@ int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx)
|
||||||
{
|
{
|
||||||
if (regime_has_2_ranges(mmu_idx)) {
|
if (regime_has_2_ranges(mmu_idx)) {
|
||||||
return extract64(tcr, 51, 2);
|
return extract64(tcr, 51, 2);
|
||||||
} else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
|
} else if (regime_is_stage2(mmu_idx)) {
|
||||||
return 0; /* VTCR_EL2 */
|
return 0; /* VTCR_EL2 */
|
||||||
} else {
|
} else {
|
||||||
/* Replicate the single TBID bit so we always have 2 bits. */
|
/* Replicate the single TBID bit so we always have 2 bits. */
|
||||||
|
@ -10474,7 +10474,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
|
||||||
int select, tsz, tbi, max_tsz, min_tsz, ps, sh;
|
int select, tsz, tbi, max_tsz, min_tsz, ps, sh;
|
||||||
ARMGranuleSize gran;
|
ARMGranuleSize gran;
|
||||||
ARMCPU *cpu = env_archcpu(env);
|
ARMCPU *cpu = env_archcpu(env);
|
||||||
bool stage2 = mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S;
|
bool stage2 = regime_is_stage2(mmu_idx);
|
||||||
|
|
||||||
if (!regime_has_2_ranges(mmu_idx)) {
|
if (!regime_has_2_ranges(mmu_idx)) {
|
||||||
select = 0;
|
select = 0;
|
||||||
|
@ -10541,22 +10541,18 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
|
||||||
}
|
}
|
||||||
ds = false;
|
ds = false;
|
||||||
} else if (ds) {
|
} else if (ds) {
|
||||||
switch (mmu_idx) {
|
if (regime_is_stage2(mmu_idx)) {
|
||||||
case ARMMMUIdx_Stage2:
|
|
||||||
case ARMMMUIdx_Stage2_S:
|
|
||||||
if (gran == Gran16K) {
|
if (gran == Gran16K) {
|
||||||
ds = cpu_isar_feature(aa64_tgran16_2_lpa2, cpu);
|
ds = cpu_isar_feature(aa64_tgran16_2_lpa2, cpu);
|
||||||
} else {
|
} else {
|
||||||
ds = cpu_isar_feature(aa64_tgran4_2_lpa2, cpu);
|
ds = cpu_isar_feature(aa64_tgran4_2_lpa2, cpu);
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
if (gran == Gran16K) {
|
if (gran == Gran16K) {
|
||||||
ds = cpu_isar_feature(aa64_tgran16_lpa2, cpu);
|
ds = cpu_isar_feature(aa64_tgran16_lpa2, cpu);
|
||||||
} else {
|
} else {
|
||||||
ds = cpu_isar_feature(aa64_tgran4_lpa2, cpu);
|
ds = cpu_isar_feature(aa64_tgran4_lpa2, cpu);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (ds) {
|
if (ds) {
|
||||||
min_tsz = 12;
|
min_tsz = 12;
|
||||||
|
|
|
@ -673,6 +673,11 @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool regime_is_stage2(ARMMMUIdx mmu_idx)
|
||||||
|
{
|
||||||
|
return mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the exception level which controls this address translation regime */
|
/* Return the exception level which controls this address translation regime */
|
||||||
static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
|
static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
|
||||||
{
|
{
|
||||||
|
|
|
@ -823,8 +823,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,
|
||||||
bool have_wxn;
|
bool have_wxn;
|
||||||
int wxn = 0;
|
int wxn = 0;
|
||||||
|
|
||||||
assert(mmu_idx != ARMMMUIdx_Stage2);
|
assert(!regime_is_stage2(mmu_idx));
|
||||||
assert(mmu_idx != ARMMMUIdx_Stage2_S);
|
|
||||||
|
|
||||||
user_rw = simple_ap_to_rw_prot_is_user(ap, true);
|
user_rw = simple_ap_to_rw_prot_is_user(ap, true);
|
||||||
if (is_user) {
|
if (is_user) {
|
||||||
|
@ -1152,7 +1151,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
|
||||||
goto do_fault;
|
goto do_fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
|
if (!regime_is_stage2(mmu_idx)) {
|
||||||
/*
|
/*
|
||||||
* The starting level depends on the virtual address size (which can
|
* The starting level depends on the virtual address size (which can
|
||||||
* be up to 48 bits) and the translation granule size. It indicates
|
* be up to 48 bits) and the translation granule size. It indicates
|
||||||
|
@ -1323,7 +1322,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
|
||||||
attrs = extract64(descriptor, 2, 10)
|
attrs = extract64(descriptor, 2, 10)
|
||||||
| (extract64(descriptor, 52, 12) << 10);
|
| (extract64(descriptor, 52, 12) << 10);
|
||||||
|
|
||||||
if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
|
if (regime_is_stage2(mmu_idx)) {
|
||||||
/* Stage 2 table descriptors do not include any attribute fields */
|
/* Stage 2 table descriptors do not include any attribute fields */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1355,7 +1354,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
|
||||||
|
|
||||||
ap = extract32(attrs, 4, 2);
|
ap = extract32(attrs, 4, 2);
|
||||||
|
|
||||||
if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
|
if (regime_is_stage2(mmu_idx)) {
|
||||||
ns = mmu_idx == ARMMMUIdx_Stage2;
|
ns = mmu_idx == ARMMMUIdx_Stage2;
|
||||||
xn = extract32(attrs, 11, 2);
|
xn = extract32(attrs, 11, 2);
|
||||||
result->f.prot = get_S2prot(env, ap, xn, s1_is_el0);
|
result->f.prot = get_S2prot(env, ap, xn, s1_is_el0);
|
||||||
|
@ -1385,7 +1384,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
|
||||||
result->f.guarded = guarded;
|
result->f.guarded = guarded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
|
if (regime_is_stage2(mmu_idx)) {
|
||||||
result->cacheattrs.is_s2_format = true;
|
result->cacheattrs.is_s2_format = true;
|
||||||
result->cacheattrs.attrs = extract32(attrs, 0, 4);
|
result->cacheattrs.attrs = extract32(attrs, 0, 4);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1416,8 +1415,7 @@ do_fault:
|
||||||
fi->type = fault_type;
|
fi->type = fault_type;
|
||||||
fi->level = level;
|
fi->level = level;
|
||||||
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
|
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
|
||||||
fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 ||
|
fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx);
|
||||||
mmu_idx == ARMMMUIdx_Stage2_S);
|
|
||||||
fi->s1ns = mmu_idx == ARMMMUIdx_Stage2;
|
fi->s1ns = mmu_idx == ARMMMUIdx_Stage2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue