linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: Reiji Watanabe <reijiw@google.com>
Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/6] KVM: arm64: Remove internal accessor helpers for id regs
Date: Tue, 30 Aug 2022 12:45:12 -0500	[thread overview]
Message-ID: <Yw5MqMvqwPXBPE0a@google.com> (raw)
In-Reply-To: <CAAeT=FwxN=UtVGO+85iZNRkGEoZ7GQ_WB4FAhHBRnCKoPNXHVg@mail.gmail.com>

Hi Reiji,

On Mon, Aug 29, 2022 at 10:45:09PM -0700, Reiji Watanabe wrote:
> Hi Oliver,
> 
> On Wed, Aug 17, 2022 at 2:48 PM Oliver Upton <oliver.upton@linux.dev> wrote:
> >
> > The internal accessors are only ever called once. Dump out their
> > contents in the caller.
> >
> > No functional change intended.
> >
> > Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> > ---
> >  arch/arm64/kvm/sys_regs.c | 46 ++++++++++-----------------------------
> >  1 file changed, 12 insertions(+), 34 deletions(-)
> >
> > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > index e18efb9211f0..26210f3a0b27 100644
> > --- a/arch/arm64/kvm/sys_regs.c
> > +++ b/arch/arm64/kvm/sys_regs.c
> > @@ -1153,25 +1153,17 @@ static unsigned int raz_visibility(const struct kvm_vcpu *vcpu,
> >
> >  /* cpufeature ID register access trap handlers */
> >
> > -static bool __access_id_reg(struct kvm_vcpu *vcpu,
> > -                           struct sys_reg_params *p,
> > -                           const struct sys_reg_desc *r,
> > -                           bool raz)
> > -{
> > -       if (p->is_write)
> > -               return write_to_read_only(vcpu, p, r);
> > -
> > -       p->regval = read_id_reg(vcpu, r, raz);
> > -       return true;
> > -}
> > -
> >  static bool access_id_reg(struct kvm_vcpu *vcpu,
> >                           struct sys_reg_params *p,
> >                           const struct sys_reg_desc *r)
> >  {
> >         bool raz = sysreg_visible_as_raz(vcpu, r);
> >
> > -       return __access_id_reg(vcpu, p, r, raz);
> > +       if (p->is_write)
> > +               return write_to_read_only(vcpu, p, r);
> > +
> > +       p->regval = read_id_reg(vcpu, r, raz);
> > +       return true;
> >  }
> >
> >  /* Visibility overrides for SVE-specific control registers */
> > @@ -1226,31 +1218,13 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu,
> >   * are stored, and for set_id_reg() we don't allow the effective value
> >   * to be changed.
> >   */
> > -static int __get_id_reg(const struct kvm_vcpu *vcpu,
> > -                       const struct sys_reg_desc *rd, u64 *val,
> > -                       bool raz)
> > -{
> > -       *val = read_id_reg(vcpu, rd, raz);
> > -       return 0;
> > -}
> > -
> > -static int __set_id_reg(const struct kvm_vcpu *vcpu,
> > -                       const struct sys_reg_desc *rd, u64 val,
> > -                       bool raz)
> > -{
> > -       /* This is what we mean by invariant: you can't change it. */
> > -       if (val != read_id_reg(vcpu, rd, raz))
> > -               return -EINVAL;
> > -
> > -       return 0;
> > -}
> > -
> >  static int get_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> >                       u64 *val)
> >  {
> >         bool raz = sysreg_visible_as_raz(vcpu, rd);
> >
> > -       return __get_id_reg(vcpu, rd, val, raz);
> > +       *val = read_id_reg(vcpu, rd, raz);
> > +       return 0;
> >  }
> >
> >  static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> > @@ -1258,7 +1232,11 @@ static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> >  {
> >         bool raz = sysreg_visible_as_raz(vcpu, rd);
> >
> > -       return __set_id_reg(vcpu, rd, val, raz);
> > +       /* This is what we mean by invariant: you can't change it. */
> > +       if (val != read_id_reg(vcpu, rd, raz))
> > +               return -EINVAL;
> > +
> > +       return 0;
> >  }
> 
> I see no reason for read_id_reg() to take raz as an argument.
> Perhaps having read_id_reg() call sysreg_visible_as_raz() instead
> might make those functions even simpler?

Good point, as this patch has done away with caller-specified RAZ. I'll
incorporate that into v2.

--
Best,
Oliver

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-08-30 17:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 21:48 [PATCH 0/6] KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system Oliver Upton
2022-08-17 21:48 ` [PATCH 1/6] KVM: arm64: Use visibility hook to treat ID regs as RAZ Oliver Upton
2022-08-30  4:54   ` Reiji Watanabe
2022-08-17 21:48 ` [PATCH 2/6] KVM: arm64: Remove internal accessor helpers for id regs Oliver Upton
2022-08-30  5:45   ` Reiji Watanabe
2022-08-30 17:45     ` Oliver Upton [this message]
2022-08-17 21:48 ` [PATCH 3/6] KVM: arm64: Spin off helper for calling visibility hook Oliver Upton
2022-08-30  6:01   ` Reiji Watanabe
2022-08-17 21:48 ` [PATCH 4/6] KVM: arm64: Add a visibility bit to ignore user writes Oliver Upton
2022-08-31  3:29   ` Reiji Watanabe
2022-08-31 14:42     ` Oliver Upton
2022-09-01  4:57       ` Reiji Watanabe
2022-08-17 21:48 ` [PATCH 5/6] KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system Oliver Upton
2022-08-23 17:05   ` Marc Zyngier
2022-08-23 17:27     ` Oliver Upton
2022-08-17 21:48 ` [PATCH 6/6] KVM: selftests: Add test for RAZ/WI AArch32 ID registers Oliver Upton

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=Yw5MqMvqwPXBPE0a@google.com \
    --to=oliver.upton@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=reijiw@google.com \
    --cc=will@kernel.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).