All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Reiji Watanabe <reijiw@google.com>
Cc: Jing Zhang <jingzhangos@google.com>, KVM <kvm@vger.kernel.org>,
	KVMARM <kvmarm@lists.linux.dev>,
	ARMLinux <linux-arm-kernel@lists.infradead.org>,
	Oliver Upton <oupton@google.com>, Will Deacon <will@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Fuad Tabba <tabba@google.com>,
	Ricardo Koller <ricarkol@google.com>,
	Raghavendra Rao Ananta <rananta@google.com>
Subject: Re: [PATCH v2 1/6] KVM: arm64: Move CPU ID feature registers emulation into a separate file
Date: Fri, 24 Feb 2023 11:05:42 +0000	[thread overview]
Message-ID: <861qmfxr09.wl-maz@kernel.org> (raw)
In-Reply-To: <CAAeT=FwdjrPm9i6rxrGQKEuu+x5VU+mKEJER5C7RYtid6nmZWQ@mail.gmail.com>

On Fri, 24 Feb 2023 01:01:44 +0000,
Reiji Watanabe <reijiw@google.com> wrote:

[...]

> > +const struct sys_reg_desc *kvm_arm_find_id_reg(const struct sys_reg_params *params)
> > +{
> 
> You might want to check if the param indicates the ID register,
> before running the binary search for the ID register table.
> (I have the same comment to kvm_arm_get_id_reg() and
> kvm_arm_set_id_reg()).

It would be much better if the discrimination was done in
emulate_sys_reg(), just like we do for NV[1].

Save yourself pointless search on the critical path, and make the
decoding tree visible in one place.

> 
> > +       return find_reg(params, id_reg_descs, ARRAY_SIZE(id_reg_descs));
> > +}
> > +
> > +void kvm_arm_reset_id_regs(struct kvm_vcpu *vcpu)
> > +{
> > +       unsigned long i;
> > +
> > +       for (i = 0; i < ARRAY_SIZE(id_reg_descs); i++)
> > +               if (id_reg_descs[i].reset)
> > +                       id_reg_descs[i].reset(vcpu, &id_reg_descs[i]);
> > +}
> > +
> > +int kvm_arm_get_id_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> > +{
> > +       return kvm_sys_reg_get_user(vcpu, reg,
> > +                                   id_reg_descs, ARRAY_SIZE(id_reg_descs));
> > +}
> > +
> > +int kvm_arm_set_id_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> > +{
> > +       return kvm_sys_reg_set_user(vcpu, reg,
> > +                                   id_reg_descs, ARRAY_SIZE(id_reg_descs));
> > +}
> > +
> > +bool kvm_arm_check_idreg_table(void)
> > +{
> > +       return check_sysreg_table(id_reg_descs, ARRAY_SIZE(id_reg_descs), false);
> > +}
> > +
> > +/* Assumed ordered tables, see kvm_sys_reg_table_init. */
> 
> I don't think we need this comment, as the code doesn't seem to
> assume that.

Yeah, it only makes sense for the binary search.

Thanks,

	M.

[1] https://lore.kernel.org/linux-arm-kernel/20230131092504.2880505-1-maz@kernel.org/T/#mced7be0152816d3a1d02cf8c8b95d3ab3ef4e0c8

-- 
Without deviation from the norm, progress is not possible.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Reiji Watanabe <reijiw@google.com>
Cc: Jing Zhang <jingzhangos@google.com>, KVM <kvm@vger.kernel.org>,
	KVMARM <kvmarm@lists.linux.dev>,
	ARMLinux <linux-arm-kernel@lists.infradead.org>,
	Oliver Upton <oupton@google.com>, Will Deacon <will@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Fuad Tabba <tabba@google.com>,
	Ricardo Koller <ricarkol@google.com>,
	Raghavendra Rao Ananta <rananta@google.com>
Subject: Re: [PATCH v2 1/6] KVM: arm64: Move CPU ID feature registers emulation into a separate file
Date: Fri, 24 Feb 2023 11:05:42 +0000	[thread overview]
Message-ID: <861qmfxr09.wl-maz@kernel.org> (raw)
In-Reply-To: <CAAeT=FwdjrPm9i6rxrGQKEuu+x5VU+mKEJER5C7RYtid6nmZWQ@mail.gmail.com>

On Fri, 24 Feb 2023 01:01:44 +0000,
Reiji Watanabe <reijiw@google.com> wrote:

[...]

> > +const struct sys_reg_desc *kvm_arm_find_id_reg(const struct sys_reg_params *params)
> > +{
> 
> You might want to check if the param indicates the ID register,
> before running the binary search for the ID register table.
> (I have the same comment to kvm_arm_get_id_reg() and
> kvm_arm_set_id_reg()).

It would be much better if the discrimination was done in
emulate_sys_reg(), just like we do for NV[1].

Save yourself pointless search on the critical path, and make the
decoding tree visible in one place.

> 
> > +       return find_reg(params, id_reg_descs, ARRAY_SIZE(id_reg_descs));
> > +}
> > +
> > +void kvm_arm_reset_id_regs(struct kvm_vcpu *vcpu)
> > +{
> > +       unsigned long i;
> > +
> > +       for (i = 0; i < ARRAY_SIZE(id_reg_descs); i++)
> > +               if (id_reg_descs[i].reset)
> > +                       id_reg_descs[i].reset(vcpu, &id_reg_descs[i]);
> > +}
> > +
> > +int kvm_arm_get_id_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> > +{
> > +       return kvm_sys_reg_get_user(vcpu, reg,
> > +                                   id_reg_descs, ARRAY_SIZE(id_reg_descs));
> > +}
> > +
> > +int kvm_arm_set_id_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> > +{
> > +       return kvm_sys_reg_set_user(vcpu, reg,
> > +                                   id_reg_descs, ARRAY_SIZE(id_reg_descs));
> > +}
> > +
> > +bool kvm_arm_check_idreg_table(void)
> > +{
> > +       return check_sysreg_table(id_reg_descs, ARRAY_SIZE(id_reg_descs), false);
> > +}
> > +
> > +/* Assumed ordered tables, see kvm_sys_reg_table_init. */
> 
> I don't think we need this comment, as the code doesn't seem to
> assume that.

Yeah, it only makes sense for the binary search.

Thanks,

	M.

[1] https://lore.kernel.org/linux-arm-kernel/20230131092504.2880505-1-maz@kernel.org/T/#mced7be0152816d3a1d02cf8c8b95d3ab3ef4e0c8

-- 
Without deviation from the norm, progress is not possible.

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

  reply	other threads:[~2023-02-24 11:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-12 21:58 [PATCH v2 0/6] Support writable CPU ID registers from userspace Jing Zhang
2023-02-12 21:58 ` Jing Zhang
2023-02-12 21:58 ` [PATCH v2 1/6] KVM: arm64: Move CPU ID feature registers emulation into a separate file Jing Zhang
2023-02-12 21:58   ` Jing Zhang
2023-02-24  1:01   ` Reiji Watanabe
2023-02-24  1:01     ` Reiji Watanabe
2023-02-24 11:05     ` Marc Zyngier [this message]
2023-02-24 11:05       ` Marc Zyngier
2023-02-27  2:54     ` Jing Zhang
2023-02-27  2:54       ` Jing Zhang
2023-02-12 21:58 ` [PATCH v2 2/6] KVM: arm64: Save ID registers' sanitized value per guest Jing Zhang
2023-02-12 21:58   ` Jing Zhang
2023-02-12 21:58 ` [PATCH v2 3/6] KVM: arm64: Use per guest ID register for ID_AA64PFR0_EL1.[CSV2|CSV3] Jing Zhang
2023-02-12 21:58   ` Jing Zhang
2023-02-12 21:58 ` [PATCH v2 4/6] KVM: arm64: Use per guest ID register for ID_AA64DFR0_EL1.PMUVer Jing Zhang
2023-02-12 21:58   ` Jing Zhang
2023-02-25  2:35   ` Reiji Watanabe
2023-02-25  2:35     ` Reiji Watanabe
2023-02-27  2:57     ` Jing Zhang
2023-02-27  2:57       ` Jing Zhang
2023-02-12 21:58 ` [PATCH v2 5/6] KVM: arm64: Introduce ID register specific descriptor Jing Zhang
2023-02-12 21:58   ` Jing Zhang
2023-02-25  4:00   ` Reiji Watanabe
2023-02-25  4:00     ` Reiji Watanabe
2023-02-27  3:04     ` Jing Zhang
2023-02-27  3:04       ` Jing Zhang
2023-02-27 22:23       ` Reiji Watanabe
2023-02-27 22:23         ` Reiji Watanabe
2023-02-28  1:52         ` Jing Zhang
2023-02-28  1:52           ` Jing Zhang
2023-02-12 21:58 ` [PATCH v2 6/6] KVM: arm64: Refactor writings for PMUVer/CSV2/CSV3 Jing Zhang
2023-02-12 21:58   ` Jing Zhang

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=861qmfxr09.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=james.morse@arm.com \
    --cc=jingzhangos@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=rananta@google.com \
    --cc=reijiw@google.com \
    --cc=ricarkol@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@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 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.