Re: [V4 PATCH 2/3] KVM: selftests: Add arch specific initialization

From: Vishal Annapurve
Date: Thu Nov 17 2022 - 13:24:41 EST


On Wed, Nov 16, 2022 at 9:46 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Tue, Nov 15, 2022, Vishal Annapurve wrote:
> > Introduce arch specific API: kvm_selftest_arch_init to allow each arch to
> > handle initialization before running any selftest logic.
> >
> > Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> > Reviewed-by: Andrew Jones <andrew.jones@xxxxxxxxx>
> > Reviewed-by: Peter Gonda <pgonda@xxxxxxxxxx>
> > Signed-off-by: Vishal Annapurve <vannapurve@xxxxxxxxxx>
> > ---
> > .../selftests/kvm/include/kvm_util_base.h | 5 +++++
> > .../selftests/kvm/lib/aarch64/processor.c | 18 +++++++++---------
> > tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++++
> > 3 files changed, 20 insertions(+), 9 deletions(-)
> >
> > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
> > index e42a09cd24a0..eec0e4898efe 100644
> > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h
> > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
> > @@ -838,4 +838,9 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)
> > return __vm_enable_cap(vm, KVM_CAP_VM_DISABLE_NX_HUGE_PAGES, 0);
> > }
> >
> > +/*
> > + * API to execute architecture specific setup before executing main().
> > + */
>
> I find the "API" blurb to be somewhat confusing. When I think of APIs, I think
> of functions that are provided by a library that are called by users of the
> library.
>
> An example might also help readers understand what types of setup can/should be
> done with this hook.
>
> Maybe something like this?
>
> /*
> * Arch hook that is invoked via a constructor, i.e. before exeucting main(),
> * to allow for arch-specific setup that is common to all tests, e.g. computing
> * the default guest "mode".
> */

Ack, that looks better.