[PATCH v2 7/8] KVM: riscv: selftest: Change vcpu_has_ext to a common function
Haibo Xu
xiaobo55x at gmail.com
Thu Sep 7 02:18:25 PDT 2023
On Thu, Sep 7, 2023 at 5:01 PM Andrew Jones <ajones at ventanamicro.com> wrote:
>
> On Thu, Sep 07, 2023 at 11:57:00AM +0800, Haibo Xu wrote:
> > On Wed, Sep 6, 2023 at 6:10 PM Haibo Xu <xiaobo55x at gmail.com> wrote:
> > >
> > > On Mon, Sep 4, 2023 at 10:04 PM Andrew Jones <ajones at ventanamicro.com> wrote:
> > > >
> > > > On Sat, Sep 02, 2023 at 08:59:29PM +0800, Haibo Xu wrote:
> > > > > diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c b/tools/testing/selftests/kvm/riscv/get-reg-list.c
> > > > > index d8ecacd03ecf..c4028bf32e3f 100644
> > > > > --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c
> > > > > +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c
> > > > > @@ -44,20 +44,6 @@ bool check_reject_set(int err)
> > > > > return err == EINVAL;
> > > > > }
> > > > >
> > > > > -static inline bool vcpu_has_ext(struct kvm_vcpu *vcpu, int ext)
> > > > > -{
> > > > > - int ret;
> > > > > - unsigned long value;
> > > > > -
> > > > > - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value);
> > > > > - if (ret) {
> > > > > - printf("Failed to get ext %d", ext);
> > > > > - return false;
> > > > > - }
> > > > > -
> > > > > - return !!value;
> > > >
> > > > get-reg-list will now assert on get-reg when an extension isn't present,
> > > > rather than failing the __TEST_REQUIRE(), which would do a skip instead.
> > > > We need both the return false version and the assert version.
> > > >
> > >
> > > Ok, Will keep this one for get-reg-list and add another one for
> > > arch-timer specific usage.
> > >
> >
> > Just thought about it again, maybe we only need the "return false"
> > version for both get-reg-list
> > and arch-timer tests since if an extension was not available, the test
> > can be skipped with a message.
> >
> > bool vcpu_has_ext(struct kvm_vcpu *vcpu, int ext)
> > {
> > unsigned long value = 0;
> >
> > __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value);
> >
> > return !!value;
> > }
>
> Yup, I had actually seen that when reviewing a later patch in this series,
> but I wasn't concerned if we added the assert type anyway, since we
> frequently end up with the two function types for KVM queries. If we don't
> have a need for an assert type yet, then we don't need to introduce it.
> However, we should introduce the non-assert type as __vcpu_has_ext(),
> reserving the vcpu_has_ext() name for the assert type, per the kvm
> selftests naming convention.
>
Sure, thanks!
> Thanks,
> drew
More information about the linux-arm-kernel
mailing list