From: David Matlack <dmatlack@google.com>
To: Vishal Annapurve <vannapurve@google.com>
Cc: x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
pbonzini@redhat.com, shuah@kernel.org, bgardon@google.com,
seanjc@google.com, oupton@google.com, peterx@redhat.com,
vkuznets@redhat.com
Subject: Re: [V2 PATCH 2/8] KVM: selftests: Add arch specific initialization
Date: Wed, 21 Sep 2022 13:50:56 -0700 [thread overview]
Message-ID: <Yyt5MHc1bwPfvBq/@google.com> (raw)
In-Reply-To: <20220915000448.1674802-3-vannapurve@google.com>
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@google.com>
> Signed-off-by: Vishal Annapurve <vannapurve@google.com>
> ---
> .../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()/
("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.
> diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c
> index 604478151212..26660dd2ba78 100644
> --- a/tools/testing/selftests/kvm/lib/riscv/processor.c
> +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c
> @@ -362,3 +362,7 @@ void vcpu_args_set(struct kvm_vcpu *vcpu, unsigned int num, ...)
> void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
> {
> }
> +
> +void kvm_selftest_arch_init(void)
> +{
> +}
> diff --git a/tools/testing/selftests/kvm/lib/s390x/processor.c b/tools/testing/selftests/kvm/lib/s390x/processor.c
> index 89d7340d9cbd..8654ec74009a 100644
> --- a/tools/testing/selftests/kvm/lib/s390x/processor.c
> +++ b/tools/testing/selftests/kvm/lib/s390x/processor.c
> @@ -218,3 +218,7 @@ void vcpu_arch_dump(FILE *stream, struct kvm_vcpu *vcpu, uint8_t indent)
> void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
> {
> }
> +
> +void kvm_selftest_arch_init(void)
> +{
> +}
> diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> index 2e6e61bbe81b..20bf125f9363 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> @@ -1311,3 +1311,7 @@ bool vm_is_unrestricted_guest(struct kvm_vm *vm)
>
> return val == 'Y';
> }
> +
> +void kvm_selftest_arch_init(void)
> +{
> +}
> --
> 2.37.2.789.g6183377224-goog
>
next prev parent reply other threads:[~2022-09-21 20:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 0:04 [V2 PATCH 0/8] Execute hypercalls from guests according to cpu type Vishal Annapurve
2022-09-15 0:04 ` [V2 PATCH 1/8] KVM: selftests: move common startup logic to kvm_util.c Vishal Annapurve
2022-09-15 9:45 ` Andrew Jones
2022-09-15 0:04 ` [V2 PATCH 2/8] KVM: selftests: Add arch specific initialization Vishal Annapurve
2022-09-15 9:44 ` Andrew Jones
2022-09-26 23:18 ` Vishal Annapurve
2022-09-21 20:50 ` David Matlack [this message]
2022-09-26 23:18 ` Vishal Annapurve
2022-09-15 0:04 ` [V2 PATCH 3/8] KVM: selftests: Add arch specific post vm load setup Vishal Annapurve
2022-09-21 20:54 ` David Matlack
2022-09-26 23:18 ` Vishal Annapurve
2022-10-03 15:42 ` Sean Christopherson
2022-10-04 0:02 ` Vishal Annapurve
2022-10-04 20:10 ` Sean Christopherson
2022-10-13 11:36 ` Vishal Annapurve
2022-09-15 0:04 ` [V2 PATCH 4/8] KVM: selftests: x86: Precompute the result for is_{intel,amd}_cpu() Vishal Annapurve
2022-09-21 21:19 ` David Matlack
2022-09-26 23:27 ` Vishal Annapurve
2022-09-26 23:34 ` David Matlack
2022-09-26 23:40 ` Vishal Annapurve
2022-09-21 21:39 ` David Matlack
2022-09-26 23:48 ` Vishal Annapurve
2022-09-26 23:53 ` David Matlack
2022-09-15 0:04 ` [V2 PATCH 5/8] KVM: selftests: x86: delete svm_vmcall_test Vishal Annapurve
2022-09-21 21:34 ` David Matlack
2022-09-26 23:32 ` Vishal Annapurve
2022-09-15 0:04 ` [V2 PATCH 6/8] KVM: selftests: x86: Execute cpu specific hypercall from nested guests Vishal Annapurve
2022-09-15 0:04 ` [V2 PATCH 7/8] Kvm: selftests: x86: Execute cpu specific vmcall instruction Vishal Annapurve
2022-09-21 21:43 ` David Matlack
2022-09-26 23:35 ` Vishal Annapurve
2022-09-15 0:04 ` [V2 PATCH 8/8] KVM: selftests: x86: xen: " Vishal Annapurve
2022-09-21 21:47 ` David Matlack
2022-09-26 23:37 ` Vishal Annapurve
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=Yyt5MHc1bwPfvBq/@google.com \
--to=dmatlack@google.com \
--cc=bgardon@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=vannapurve@google.com \
--cc=vkuznets@redhat.com \
--cc=x86@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.