qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v6 02/14] target/arm: Add ptw_idx to S1Translate
Date: Mon, 24 Oct 2022 15:09:32 +0100	[thread overview]
Message-ID: <87o7u19uo0.fsf@linaro.org> (raw)
In-Reply-To: <20221024051851.3074715-3-richard.henderson@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> Hoist the computation of the mmu_idx for the ptw up to
> get_phys_addr_with_struct and get_phys_addr_twostage.
> This removes the duplicate check for stage2 disabled
> from the middle of the walk, performing it only once.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/arm/ptw.c | 71 ++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 54 insertions(+), 17 deletions(-)
>
> diff --git a/target/arm/ptw.c b/target/arm/ptw.c
> index 004375e02b..161b7922e3 100644
> --- a/target/arm/ptw.c
> +++ b/target/arm/ptw.c
> @@ -17,6 +17,7 @@
>  
>  typedef struct S1Translate {
>      ARMMMUIdx in_mmu_idx;
> +    ARMMMUIdx in_ptw_idx;

I could use a comment here to explain the difference between mmu and ptr
indexes here because...

<snip>
> @@ -2527,10 +2536,32 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
>                                        ARMMMUFaultInfo *fi)
>  {
>      ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
> -    ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
>      bool is_secure = ptw->in_secure;
> +    ARMMMUIdx s1_mmu_idx;
>  
> -    if (mmu_idx != s1_mmu_idx) {
> +    switch (mmu_idx) {
> +    case ARMMMUIdx_Phys_S:
> +    case ARMMMUIdx_Phys_NS:
> +        /* Checking Phys early avoids special casing later vs regime_el. */
> +        return get_phys_addr_disabled(env, address, access_type, mmu_idx,
> +                                      is_secure, result, fi);
> +
> +    case ARMMMUIdx_Stage1_E0:
> +    case ARMMMUIdx_Stage1_E1:
> +    case ARMMMUIdx_Stage1_E1_PAN:
> +        /* First stage lookup uses second stage for ptw. */
> +        ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
> +        break;
> +
> +    case ARMMMUIdx_E10_0:
> +        s1_mmu_idx = ARMMMUIdx_Stage1_E0;
> +        goto do_twostage;
> +    case ARMMMUIdx_E10_1:
> +        s1_mmu_idx = ARMMMUIdx_Stage1_E1;
> +        goto do_twostage;
> +    case ARMMMUIdx_E10_1_PAN:
> +        s1_mmu_idx = ARMMMUIdx_Stage1_E1_PAN;
> +    do_twostage:
>          /*
>           * Call ourselves recursively to do the stage 1 and then stage 2
>           * translations if mmu_idx is a two-stage regime, and EL2 present.
> @@ -2541,6 +2572,12 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
>              return get_phys_addr_twostage(env, ptw, address, access_type,
>                                            result, fi);
>          }
> +        /* fall through */

following this I got confused as to what might be overwritten or
ignored. I assume for v8-A (ARM_FEATURE_EL2) we won't be falling through
anyway?

Anyway I think I understand it now:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>


> +
> +    default:
> +        /* Single stage and second stage uses physical for ptw. */
> +        ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
> +        break;
>      }
>  
>      /*


-- 
Alex Bennée


  reply	other threads:[~2022-10-24 14:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  5:18 [PATCH v6 00/14] target/arm: Implement FEAT_HAFDBS Richard Henderson
2022-10-24  5:18 ` [PATCH v6 01/14] target/arm: Introduce regime_is_stage2 Richard Henderson
2022-10-24  5:18 ` [PATCH v6 02/14] target/arm: Add ptw_idx to S1Translate Richard Henderson
2022-10-24 14:09   ` Alex Bennée [this message]
2022-10-24  5:18 ` [PATCH v6 03/14] target/arm: Add isar predicates for FEAT_HAFDBS Richard Henderson
2022-10-24  5:18 ` [PATCH v6 04/14] target/arm: Extract HA and HD in aa64_va_parameters Richard Henderson
2022-10-24 14:19   ` Alex Bennée
2022-10-24  5:18 ` [PATCH v6 05/14] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw Richard Henderson
2022-10-24  5:18 ` [PATCH v6 06/14] target/arm: Add ARMFault_UnsuppAtomicUpdate Richard Henderson
2022-10-24 14:53   ` Alex Bennée
2022-10-24  5:18 ` [PATCH v6 07/14] target/arm: Remove loop from get_phys_addr_lpae Richard Henderson
2022-10-24  5:18 ` [PATCH v6 08/14] target/arm: Fix fault reporting in get_phys_addr_lpae Richard Henderson
2022-10-24 14:55   ` Alex Bennée
2022-10-24  5:18 ` [PATCH v6 09/14] target/arm: Don't shift attrs " Richard Henderson
2022-10-24 11:52   ` Philippe Mathieu-Daudé
2022-10-24  5:18 ` [PATCH v6 10/14] target/arm: Consider GP an attribute " Richard Henderson
2022-10-24 15:06   ` Alex Bennée
2022-10-24  5:18 ` [PATCH v6 11/14] target/arm: Tidy merging of attributes from descriptor and table Richard Henderson
2022-10-24 15:20   ` Alex Bennée
2022-10-24  5:18 ` [PATCH v6 12/14] target/arm: Implement FEAT_HAFDBS, access flag portion Richard Henderson
2022-10-24  5:18 ` [PATCH v6 13/14] target/arm: Implement FEAT_HAFDBS, dirty bit portion Richard Henderson
2022-10-24  5:18 ` [PATCH v6 14/14] target/arm: Use the max page size in a 2-stage ptw Richard Henderson
2022-12-05 16:50   ` Peter Maydell
2022-12-05 19:06     ` Richard Henderson
2022-10-25 15:16 ` [PATCH v6 00/14] target/arm: Implement FEAT_HAFDBS Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o7u19uo0.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).