On Wed, Sep 21, 2022 at 1:51 PM David Matlack <dmatlack@xxxxxxxxxx> wrote: > > On Thu, Sep 15, 2022 at 12:04:42AM +0000, 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> > > 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 | 2 ++ > > .../selftests/kvm/lib/riscv/processor.c | 4 ++++ > > .../selftests/kvm/lib/s390x/processor.c | 4 ++++ > > .../selftests/kvm/lib/x86_64/processor.c | 4 ++++ > > 6 files changed, 28 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 24fde97f6121..98edbbda9f97 100644 > > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > > @@ -834,4 +834,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 selftest logic. > > nit: s/before executing selftest logic/before main()/ > Ack, will fix this in the next series. > ("selftest logic" is vague) > > > + */ > > +void kvm_selftest_arch_init(void); > > + > > #endif /* SELFTEST_KVM_UTIL_BASE_H */ > > diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > index 6f5551368944..2281d6c5d02f 100644 > > --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c > > +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > @@ -495,15 +495,6 @@ void aarch64_get_supported_page_sizes(uint32_t ipa, > > close(kvm_fd); > > } > > > > -/* > > - * arm64 doesn't have a true default mode, so start by computing the > > - * available IPA space and page sizes early. > > - */ > > -void __attribute__((constructor)) init_guest_modes(void) > > -{ > > - guest_modes_append_default(); > > -} > > - > > void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1, > > uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, > > uint64_t arg6, struct arm_smccc_res *res) > > @@ -528,3 +519,12 @@ void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1, > > [arg4] "r"(arg4), [arg5] "r"(arg5), [arg6] "r"(arg6) > > : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"); > > } > > + > > +/* > > + * arm64 doesn't have a true default mode, so start by computing the > > + * available IPA space and page sizes early. > > + */ > > +void kvm_selftest_arch_init(void) > > +{ > > + guest_modes_append_default(); > > +} > > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > > index 3c83838999f5..dafe4471a6c7 100644 > > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > > @@ -1984,4 +1984,6 @@ void __attribute((constructor)) kvm_selftest_init(void) > > { > > /* Tell stdout not to buffer its content. */ > > setbuf(stdout, NULL); > > + > > + kvm_selftest_arch_init(); > > } > > Suggest defining a default no-op implementation of > kvm_selftest_arch_init() using __weak since most architectures do not > actually need an implementation. > Ack, will update this in the next series. > > ... > >