qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/5] target/arm/ptw: Load stage-2 tables from realm physical space
Date: Thu, 20 Jul 2023 17:28:15 +0100	[thread overview]
Message-ID: <CAFEAcA-qPRSrLievcUZsCJQ3MO0AzdfrkMM6gs+PHK-mZq51fw@mail.gmail.com> (raw)
In-Reply-To: <20230719153018.1456180-3-jean-philippe@linaro.org>

On Wed, 19 Jul 2023 at 16:56, Jean-Philippe Brucker
<jean-philippe@linaro.org> wrote:
>
> In realm state, stage-2 translation tables are fetched from the realm
> physical address space (R_PGRQD).
>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
>  target/arm/ptw.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/target/arm/ptw.c b/target/arm/ptw.c
> index d1de934702..6318e13b98 100644
> --- a/target/arm/ptw.c
> +++ b/target/arm/ptw.c
> @@ -164,7 +164,11 @@ static ARMMMUIdx ptw_idx_for_stage_2(CPUARMState *env, ARMMMUIdx stage2idx)
>       * an NS stage 1+2 lookup while the NS bit is 0.)
>       */
>      if (!arm_is_secure_below_el3(env) || !arm_el_is_aa64(env, 3)) {
> -        return ARMMMUIdx_Phys_NS;
> +        if (arm_security_space_below_el3(env) == ARMSS_Realm) {
> +            return ARMMMUIdx_Phys_Realm;
> +        } else {
> +            return ARMMMUIdx_Phys_NS;
> +        }
>      }
>      if (stage2idx == ARMMMUIdx_Stage2_S) {
>          s2walk_secure = !(env->cp15.vstcr_el2 & VSTCR_SW);

This isn't wrong, but arm_is_secure_below_el3()
calls arm_security_space_below_el3(), so we kinda
duplicate work there. I think we should instead have:

    if (!arm_el_is_aa64(env, 3)) {
        return ARMMMUIdx_Phys_NS;
    }

    switch (arm_security_space_below_el3(env)) {
    case ARMSS_NonSecure:
        return ARMMUIdx_Phys_NS;
    case ARMSS_Realm:
        return ARMMMUIdx_Phys_Realm;
    case ARMSS_Secure:
        [existing code to look at the SW/NSW bits]
        return s2walk_secure ? ...;
    default:
        g_assert_not_reached();
    }

The comment above the function also needs tweaking
to say "SCR_EL3.NS or SCR_EL3.NSE bits" (we do already
do the TLB flush in scr_write).

thanks
-- PMM


  reply	other threads:[~2023-07-20 16:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 15:30 [PATCH 0/5] target/arm: Fixes for RME Jean-Philippe Brucker
2023-07-19 15:30 ` [PATCH 1/5] target/arm/ptw: Load stage-2 tables from realm physical space Jean-Philippe Brucker
2023-07-20 16:28   ` Peter Maydell [this message]
2023-07-19 15:30 ` [PATCH 2/5] target/arm/helper: Fix vae2_tlbmask() Jean-Philippe Brucker
2023-07-20 16:35   ` Peter Maydell
2023-07-21  9:06     ` Jean-Philippe Brucker
2023-07-19 15:30 ` [PATCH 3/5] target/arm: Skip granule protection checks for AT instructions Jean-Philippe Brucker
2023-07-20 16:39   ` Peter Maydell
2023-07-20 16:56     ` Peter Maydell
2023-07-21  9:08     ` Jean-Philippe Brucker
2023-07-19 15:30 ` [PATCH 4/5] target/arm: Pass security space rather than flag " Jean-Philippe Brucker
2023-07-20 17:09   ` Peter Maydell
2023-07-19 15:30 ` [PATCH 5/5] target/arm/helper: Implement CNTHCTL_EL2.CNT[VP]MASK Jean-Philippe Brucker
2023-07-20 17:13   ` Peter Maydell
2023-07-20 12:05 ` [PATCH 0/5] target/arm: Fixes for RME Peter Maydell
2023-07-20 12:53   ` Jean-Philippe Brucker

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=CAFEAcA-qPRSrLievcUZsCJQ3MO0AzdfrkMM6gs+PHK-mZq51fw@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=jean-philippe@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).