qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 2/5] target-arm: enable get_rw_prot to take simple AP
Date: Tue, 10 Mar 2015 17:32:33 +0100	[thread overview]
Message-ID: <20150310163233.GB6320@hawk.usersys.redhat.com> (raw)
In-Reply-To: <CAFEAcA-OjE2dudpzhppkjD0cpjgABG41ueJCrzxJ26N6_-1r9A@mail.gmail.com>

On Tue, Mar 10, 2015 at 03:22:55PM +0000, Peter Maydell wrote:
> On 12 February 2015 at 15:05, Andrew Jones <drjones@redhat.com> wrote:
> > Teach get_rw_prot about the simple AP format AP[2:1]. An additional
> > switch was added, as opposed to converting ap := AP[2:1] to AP[2:0]
> > with a simple shift - and then modifying cases 0,2,4,6, because the
> > resulting code is easier to read with the switch.
> >
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> >  target-arm/helper.c | 22 +++++++++++++++++++++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/target-arm/helper.c b/target-arm/helper.c
> > index 610f305c4d661..b63ec7b7979f9 100644
> > --- a/target-arm/helper.c
> > +++ b/target-arm/helper.c
> > @@ -4698,12 +4698,32 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
> >  static inline int get_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx,
> >                                int ap, int domain_prot)
> >  {
> > +    bool simple_ap = regime_using_lpae_format(env, mmu_idx)
> > +                         || (regime_sctlr(env, mmu_idx) & SCTLR_AFE);
> 
> We should check arm_feature(env, ARM_FEATURE_V6K) && (SCTLR.AFE is set);
> that bit isn't defined til v6K.

Indeed. Will send v2 for that.

> 
> > +    bool domain_prot_valid = !regime_using_lpae_format(env, mmu_idx);
> 
> Given that the lpae code path is totally separate (and not even
> calling this function yet), can't you just have it pass in a
> zero domain_prot ? Or have the callers do the domain protection
> check themselves...

domain_prot=0 is a valid access permission (no access), so I didn't
want to overload the meaning with 'not used'. I can move the check to
the callers that need it though. It would actually be nice to remove
the need for a 0 place holder from the other callers.

> 
> >      bool is_user = regime_is_user(env, mmu_idx);
> >
> > -    if (domain_prot == 3) {
> > +    if (domain_prot_valid && domain_prot == 3) {
> >          return PAGE_READ | PAGE_WRITE;
> >      }
> >
> > +    /* ap is AP[2:1] */
> > +    if (simple_ap) {
> > +        switch (ap) {
> > +        case 0:
> > +            return is_user ? 0 : PAGE_READ | PAGE_WRITE;
> > +        case 1:
> > +            return PAGE_READ | PAGE_WRITE;
> > +        case 2:
> > +            return is_user ? 0 : PAGE_READ;
> > +        case 3:
> > +            return PAGE_READ;
> > +        default:
> > +            g_assert_not_reached();
> > +        }
> > +    }
> 
> I'm confused. Even if we're using the simple-permissions
> model, the ap parameter is still AP[2:0]. Shouldn't this
> switch be for cases 0, 2, 4, 6 ?

Depends on how we choose to implement the callers. Currently
I only require the caller to send in 2 bits for the simple
model. If we want to require them to send in 3, then we'll
need to shift a zero in for the lpae caller, rather than
shift a zero out for the v6 caller.

> 
> > +
> > +    /* ap is AP[2:0] */
> >      switch (ap) {
> >      case 0:
> >          if (arm_feature(env, ARM_FEATURE_V7)) {
> > --
> > 1.9.3
> >
> 
> -- PMM

  reply	other threads:[~2015-03-10 16:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12 15:05 [Qemu-devel] [PATCH 0/5] tcg-arm: LPAE: fix and extend xn control Andrew Jones
2015-02-12 15:05 ` [Qemu-devel] [PATCH 1/5] target-arm: convert check_ap to get_rw_prot Andrew Jones
2015-03-10 15:07   ` Peter Maydell
2015-03-10 15:17     ` Peter Maydell
2015-03-10 15:12   ` Peter Maydell
2015-03-10 15:52     ` Andrew Jones
2015-02-12 15:05 ` [Qemu-devel] [PATCH 2/5] target-arm: enable get_rw_prot to take simple AP Andrew Jones
2015-03-10 15:22   ` Peter Maydell
2015-03-10 16:32     ` Andrew Jones [this message]
2015-03-10 16:41       ` Peter Maydell
2015-03-10 16:57         ` Andrew Jones
2015-02-12 15:05 ` [Qemu-devel] [PATCH 3/5] target-arm: add an is_user param to get_rw_prot Andrew Jones
2015-02-12 15:05 ` [Qemu-devel] [PATCH 4/5] target-arm: get_phys_addr_lpae: more xn control Andrew Jones
2015-02-12 17:44   ` Andrew Jones
2015-03-10 15:56   ` Peter Maydell
2015-03-10 16:48     ` Andrew Jones
2015-03-10 16:55       ` Peter Maydell
2015-03-10 17:02         ` Andrew Jones
2015-03-10 17:14           ` Peter Maydell
2015-03-10 17:28             ` Andrew Jones
2015-03-10 17:38               ` Peter Maydell
2015-03-11 10:37   ` Andrew Jones
2015-02-12 15:05 ` [Qemu-devel] [PATCH 5/5] target-arm: apply get_S1prot to get_phys_addr_v6 Andrew Jones
2015-02-12 17:08   ` Andrew Jones
2015-03-10 15:57     ` Peter Maydell
2015-03-10 16:54       ` Andrew Jones
2015-03-10 17:03         ` Peter Maydell
2015-03-10 17:08           ` Andrew Jones
2015-02-24 15:06 ` [Qemu-devel] [PATCH 0/5] tcg-arm: LPAE: fix and extend xn control Andrew Jones
2015-02-24 15:08   ` Peter Maydell
2015-02-24 15:14     ` Andrew Jones

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=20150310163233.GB6320@hawk.usersys.redhat.com \
    --to=drjones@redhat.com \
    --cc=peter.maydell@linaro.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 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).