From: "Rémi Denis-Courmont" <remi.denis.courmont@huawei.com>
To: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 08/14] target/arm: add MMU stage 1 for Secure EL2
Date: Tue, 03 Nov 2020 20:49:00 +0200 [thread overview]
Message-ID: <1674144.VLH7GnMWUR@basile.remlab.net> (raw)
In-Reply-To: <e1bca2e0-d926-02cb-c462-5e9d64a51999@linaro.org>
Le tiistaina 3. marraskuuta 2020, 20.32.21 EET Richard Henderson a écrit :
> On 11/2/20 2:57 AM, remi.denis.courmont@huawei.com wrote:
> > From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
> >
> > This adds the MMU indices for EL2 stage 1 in secure mode.
> >
> > To keep code contained, which is largelly identical between secure and
> > non-secure modes, this patch introduces a secure bit for all new and
> > existing stage 1 translation regimes.
> >
> > Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
> > ---
> >
> > target/arm/cpu-param.h | 2 +-
> > target/arm/cpu.h | 22 ++++--
> > target/arm/helper.c | 143 ++++++++++++++++++++++++-------------
> > target/arm/internals.h | 12 ++++
> > target/arm/translate-a64.c | 4 ++
> > 5 files changed, 127 insertions(+), 56 deletions(-)
> >
> > diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h
> > index 6321385b46..0db5e37c17 100644
> > --- a/target/arm/cpu-param.h
> > +++ b/target/arm/cpu-param.h
> > @@ -29,6 +29,6 @@
> >
> > # define TARGET_PAGE_BITS_MIN 10
> > #endif
> >
> > -#define NB_MMU_MODES 11
> > +#define NB_MMU_MODES 16
> >
> > #endif
> >
> > diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> > index 724b11ee57..3fbb70e273 100644
> > --- a/target/arm/cpu.h
> > +++ b/target/arm/cpu.h
> > @@ -2944,6 +2944,9 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool
> > kvm_sync);>
> > #define ARM_MMU_IDX_NOTLB 0x20 /* does not have a TLB */
> > #define ARM_MMU_IDX_M 0x40 /* M profile */
> >
> > +/* Meanings of the bits for A profile mmu idx values */
> > +#define ARM_MMU_IDX_A_S 0x8
> > +
> >
> > /* Meanings of the bits for M profile mmu idx values */
> > #define ARM_MMU_IDX_M_PRIV 0x1
> > #define ARM_MMU_IDX_M_NEGPRI 0x2
> >
> > @@ -2967,10 +2970,17 @@ typedef enum ARMMMUIdx {
> >
> > ARMMMUIdx_E20_2 = 5 | ARM_MMU_IDX_A,
> > ARMMMUIdx_E20_2_PAN = 6 | ARM_MMU_IDX_A,
> >
> > - ARMMMUIdx_SE10_0 = 7 | ARM_MMU_IDX_A,
> > - ARMMMUIdx_SE10_1 = 8 | ARM_MMU_IDX_A,
> > - ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A,
> > - ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A,
> > + ARMMMUIdx_SE10_0 = ARMMMUIdx_E10_0 | ARM_MMU_IDX_A_S,
> > + ARMMMUIdx_SE20_0 = ARMMMUIdx_E20_0 | ARM_MMU_IDX_A_S,
> > +
> > + ARMMMUIdx_SE10_1 = ARMMMUIdx_E10_1 | ARM_MMU_IDX_A_S,
> > + ARMMMUIdx_SE10_1_PAN = ARMMMUIdx_E10_1_PAN | ARM_MMU_IDX_A_S,
> > +
> > + ARMMMUIdx_SE2 = ARMMMUIdx_E2 | ARM_MMU_IDX_A_S,
> > + ARMMMUIdx_SE20_2 = ARMMMUIdx_E20_2 | ARM_MMU_IDX_A_S,
> > + ARMMMUIdx_SE20_2_PAN = ARMMMUIdx_E20_2_PAN | ARM_MMU_IDX_A_S,
> > +
> > + ARMMMUIdx_SE3 = 15 | ARM_MMU_IDX_A,
>
> Hum. So, we're adding 4 new mmu_idx, and increasing the mmu_idx count by 5.
> The unused index would be 7 -- no non-secure el3.
>
> Is it worth reversing the S bit to NS, so that index 15 becomes the one that
> is unused, and so we don't actually have to add it to NB_MMU_MODES?
Possible. It would save a few hundred bytes from a quick glance.
It could also be argued that E2 and E20_2 should be one and the same. The
regimes are distinct but they cannot coexist. The mode's TLB mode could be
flushed when HCR.E2H is flipped, I guess.
--
Rémi Denis-Courmont
next prev parent reply other threads:[~2020-11-03 18:49 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2172054.ElGaqSPkdT@basile.remlab.net>
2020-11-02 10:57 ` [PATCH 01/14] target/arm: add arm_is_el2_enabled() helper remi.denis.courmont
2020-11-02 11:06 ` Peter Maydell
2020-11-02 11:27 ` Peter Maydell
2020-11-02 13:35 ` Remi Denis Courmont
2020-11-03 16:42 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 02/14] target/arm: use arm_is_el2_enabled() where applicable remi.denis.courmont
2020-11-03 16:53 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 03/14] target/arm: use arm_hcr_el2_eff() " remi.denis.courmont
2020-11-03 16:56 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 04/14] target/arm: factor MDCR_EL2 common handling remi.denis.courmont
2020-11-03 17:00 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 05/14] target/arm: declare new AA64PFR0 bit-fields remi.denis.courmont
2020-11-03 17:02 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 06/14] target/arm: add 64-bit S-EL2 to EL exception table remi.denis.courmont
2020-11-02 10:57 ` [PATCH 07/14] target/arm: return the stage 2 index for stage 1 remi.denis.courmont
2020-11-03 17:04 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 08/14] target/arm: add MMU stage 1 for Secure EL2 remi.denis.courmont
2020-11-03 18:32 ` Richard Henderson
2020-11-03 18:49 ` Rémi Denis-Courmont [this message]
2020-11-03 19:41 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 09/14] target/arm: add ARMv8.4-SEL2 system registers remi.denis.courmont
2020-11-03 19:49 ` Richard Henderson
2020-11-03 21:09 ` Peter Maydell
2020-11-03 21:40 ` Richard Henderson
2020-11-02 10:57 ` [PATCH 10/14] target/arm: do S1_ptw_translate() before address space lookup remi.denis.courmont
2020-11-03 19:54 ` Richard Henderson
2020-11-03 21:21 ` Rémi Denis-Courmont
2020-11-02 10:57 ` [PATCH 11/14] target/arm: secure stage 2 translation regime remi.denis.courmont
2020-11-02 10:58 ` [PATCH 12/14] target/arm: set HPFAR_EL2.NS on secure stage 2 faults remi.denis.courmont
2020-11-02 10:58 ` [PATCH 13/14] target/arm: add ARMv8.4-SEL2 extension remi.denis.courmont
2020-11-03 20:14 ` Richard Henderson
2020-11-02 10:58 ` [PATCH 14/14] target/arm: enable Secure EL2 in max CPU remi.denis.courmont
2020-11-03 7:38 ` Rémi Denis-Courmont
2020-11-03 16:38 ` Richard Henderson
2020-11-03 20:15 ` Richard Henderson
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=1674144.VLH7GnMWUR@basile.remlab.net \
--to=remi.denis.courmont@huawei.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.