target/arm: Reduce aa64_va_parameter overhead
cover target/arm: Reduce aa64_va_parameter overhead
Based-on: <[email protected]> ("target/arm: Implement ARMv8.1-VHE")
It's not really dependent on VHE, but there's a minor patch conflict which I've resolved in favor of the larger patch set.
r~
Richard Henderson (1):
target/arm: Split out aa64_va_parameter_tbi, aa64_va_parameter_tbid
target/arm/internals.h | 3 -- target/arm/helper.c | 68 +++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 34 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/1 target/arm: Split out aa64_va_parameter_tbi, aa64_va_parameter_tbid
For the purpose of rebuild_hflags_a64, we do not need to compute all of the va parameters, only tbi. Moreover, we can compute them in a form that is more useful to storing in hflags.
This eliminates the need for aa64_va_parameter_both, so fold that in to aa64_va_parameter. The remaining calls to aa64_va_parameter are in get_phys_addr_lpae and in pauth_helper.c.
This reduces the total cpu consumption of aa64_va_parameter in a kernel boot plus a kvm guest kernel boot from 3% to 0.5%.
--- target/arm/internals.h | 3 -- target/arm/helper.c | 68 +++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 34 deletions(-)
target/arm/internals.h +0 -3
@@ -1042,15 +1042,12 @@ typedef struct ARMVAParameters { unsigned tsz : 8; unsigned select : 1; bool tbi : 1; - bool tbid : 1; bool epd : 1; bool hpd : 1; bool using16k : 1; bool using64k : 1; } ARMVAParameters; -ARMVAParameters aa64_va_parameters_both (CPUARMState *env,uint64_t va, -ARMMMUIdx mmu_idx);ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va,ARMMMUIdx mmu_idx,bool data);
target/arm/helper.c +37 -31
124 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 1/1] target/arm: Split out aa64_va_parameter_tbi, aa64_va_parameter_tbid
Quoted 47 lines · Richard Henderson
For the purpose of
rebuild_hflags_a64, we do not need to compute all of the va parameters, only tbi. Moreover, we can compute them in a form that is more useful to storing in hflags.This eliminates the need for
aa64_va_parameter_both, so fold that in toaa64_va_parameter. The remaining calls toaa64_va_parameterare inget_phys_addr_lpaeand inpauth_helper.c.This reduces the total cpu consumption of
aa64_va_parameterin a kernel boot plus a kvm guest kernel boot from 3% to 0.5%.Signed-off-by Richard Henderson <[email protected]>--- target/arm/internals.h | 3 -- target/arm/helper.c | 68 +++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 34 deletions(-)target/arm/internals.h +0
-3@@ -1042,15 +1042,12 @@ typedef struct ARMVAParameters { unsigned tsz : 8; unsigned select : 1; bool tbi : 1; - bool tbid : 1; bool epd : 1; bool hpd : 1; bool using16k : 1; bool using64k : 1; } ARMVAParameters; -ARMVAParameters aa64_va_parameters_both (CPUARMState *env,uint64_t va, -ARMMMUIdx mmu_idx);ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va,ARMMMUIdx mmu_idx,bool data);target/arm/helper.c +0
-1@@ -10067,12 +10067,34 @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) }#endif /* !CONFIG_USER_ONLY */ -ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va,
target/arm/helper.c static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) · line 10078
Quoted 10 lines
target/arm/helper.c +9
-1- ARMMMUIdx mmu_idx) +static int aa64_va_parameter_tbi (uint64_t tcr,ARMMMUIdx mmu_idx) +{ +if (regime_has_2_ranges (mmu_idx)) { +return extract64 (tcr,37 ,2 ); + }else if (mmu_idx == ARMMMUIdx_Stage2) { +return 0 ;/* VTCR_EL2 */ + }else { +return extract32 (tcr,20 ,1 ); + }
So, this function returns either the two TBI bits, for the 2-ranges case, or a single TBI bit with bit 1 always zero, in the 1-range case...
target/arm/helper.c ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, · line 10138
Quoted 7 lines
target/arm/helper.c +6
-0+/* Present TBI as a composite with TBID. */ + tbi =aa64_va_parameter_tbi (tcr, mmu_idx); +if (!data) { + tbi &= ~aa64_va_parameter_tbid (tcr, mmu_idx); + } + tbi = (tbi >> select) &1 ;
...but aa64_va_parameters() always sets
select = extract64(va, 55, 1);
even for the 1-range case, and then we assume in this bit of code that we can pull the corresponding bit out of tbi.
Don't we need to either duplicate the bit returned by aa64_va_parameter_tbi() in the 1-range case, or else only shift tbi by 'select' in the 2-range case ?
thanks
-- PMM
Re: [PATCH 1/1] target/arm: Split out aa64_va_parameter_tbi, aa64_va_parameter_tbid
Quoted 8 lines · Peter Maydell
target/arm/helper.c ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, · line 10138
Quoted 7 lines
target/arm/helper.c +6
-0+/* Present TBI as a composite with TBID. */ + tbi =aa64_va_parameter_tbi (tcr, mmu_idx); +if (!data) { + tbi &= ~aa64_va_parameter_tbid (tcr, mmu_idx); + } + tbi = (tbi >> select) &1 ;
Quoted 8 lines
...but
aa64_va_parameters()always setsselect = extract64(va, 55, 1);even for the 1-range case, and then we assume in this bit of code that we can pull the corresponding bit out of tbi.
Don't we need to either duplicate the bit returned by
aa64_va_parameter_tbi()in the 1-range case, or else only shift tbi by 'select' in the 2-range case ?
I think we need to force select = 0 in the 1-range case, since "select == 1" makes no sense in that case.
r~