From: Andrew Jones <drjones@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ben Gardon <bgardon@google.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Cannon Matthews <cannonmatthews@google.com>,
Peter Xu <peterx@redhat.com>, Peter Shier <pshier@google.com>,
Oliver Upton <oupton@google.com>
Subject: Re: [PATCH v4 06/10] KVM: selftests: Add support for vcpu_args_set to aarch64 and s390x
Date: Mon, 27 Jan 2020 09:38:38 +0100 [thread overview]
Message-ID: <20200127083838.u32bylca2n4om6zx@kamzik.brq.redhat.com> (raw)
In-Reply-To: <6061cd22-59bb-c191-bd98-f14d7cd274ae@redhat.com>
On Sat, Jan 25, 2020 at 10:34:16AM +0100, Paolo Bonzini wrote:
> On 23/01/20 19:04, Ben Gardon wrote:
> > Currently vcpu_args_set is only implemented for x86. This makes writing
> > tests with multiple vCPUs difficult as each guest vCPU must either a.)
> > do the same thing or b.) derive some kind of unique token from it's
> > registers or the architecture. To simplify the process of writing tests
> > with multiple vCPUs for s390 and aarch64, add set args functions for
> > those architectures.
> >
> > Signed-off-by: Ben Gardon <bgardon@google.com>
> > ---
> > .../selftests/kvm/lib/aarch64/processor.c | 33 +++++++++++++++++
> > .../selftests/kvm/lib/s390x/processor.c | 35 +++++++++++++++++++
> > 2 files changed, 68 insertions(+)
> >
> > diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c
> > index 86036a59a668e..a2ff90a75f326 100644
> > --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c
> > +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c
> > @@ -333,3 +333,36 @@ void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code)
> > {
> > aarch64_vcpu_add_default(vm, vcpuid, NULL, guest_code);
> > }
> > +
> > +/* VM VCPU Args Set
> > + *
> > + * Input Args:
> > + * vm - Virtual Machine
> > + * vcpuid - VCPU ID
> > + * num - number of arguments
> > + * ... - arguments, each of type uint64_t
> > + *
> > + * Output Args: None
> > + *
> > + * Return: None
> > + *
> > + * Sets the first num function input arguments to the values
> > + * given as variable args. Each of the variable args is expected to
> > + * be of type uint64_t. The registers set by this function are r0-r7.
> > + */
> > +void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...)
> > +{
> > + va_list ap;
> > +
> > + TEST_ASSERT(num >= 1 && num <= 8, "Unsupported number of args,\n"
> > + " num: %u\n",
> > + num);
> > +
> > + va_start(ap, num);
> > +
> > + for (i = 0; i < num; i++)
> > + set_reg(vm, vcpuid, ARM64_CORE_REG(regs.regs[num]),
For AArch64 you also need to squash s/num/i/ for this line.
(Plus I'm still not that pleased with adding this big header to this
file for this function, or the weird line breaks in the assert.)
> > + va_arg(ap, uint64_t));
> > +
> > + va_end(ap);
> > +}
> > diff --git a/tools/testing/selftests/kvm/lib/s390x/processor.c b/tools/testing/selftests/kvm/lib/s390x/processor.c
> > index 32a02360b1eb0..680f37be9dbc9 100644
> > --- a/tools/testing/selftests/kvm/lib/s390x/processor.c
> > +++ b/tools/testing/selftests/kvm/lib/s390x/processor.c
> > @@ -269,6 +269,41 @@ void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code)
> > run->psw_addr = (uintptr_t)guest_code;
> > }
> >
> > +/* VM VCPU Args Set
> > + *
> > + * Input Args:
> > + * vm - Virtual Machine
> > + * vcpuid - VCPU ID
> > + * num - number of arguments
> > + * ... - arguments, each of type uint64_t
> > + *
> > + * Output Args: None
> > + *
> > + * Return: None
> > + *
> > + * Sets the first num function input arguments to the values
> > + * given as variable args. Each of the variable args is expected to
> > + * be of type uint64_t. The registers set by this function are r2-r6.
> > + */
> > +void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...)
> > +{
> > + va_list ap;
> > + struct kvm_regs regs;
> > +
> > + TEST_ASSERT(num >= 1 && num <= 5, "Unsupported number of args,\n"
> > + " num: %u\n",
> > + num);
> > +
> > + va_start(ap, num);
> > + vcpu_regs_get(vm, vcpuid, ®s);
> > +
> > + for (i = 0; i < num; i++)
> > + regs.gprs[i + 2] = va_arg(ap, uint64_t);
> > +
> > + vcpu_regs_set(vm, vcpuid, ®s);
> > + va_end(ap);
> > +}
> > +
> > void vcpu_dump(FILE *stream, struct kvm_vm *vm, uint32_t vcpuid, uint8_t indent)
> > {
> > struct vcpu *vcpu = vm->vcpu_head;
> >
>
> Squashing this:
>
> diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c
> index a2ff90a75f32..839a76c96f01 100644
> --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c
> @@ -353,6 +353,7 @@ void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code)
> void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...)
> {
> va_list ap;
> + int i;
>
> TEST_ASSERT(num >= 1 && num <= 8, "Unsupported number of args,\n"
> " num: %u\n",
> diff --git a/tools/testing/selftests/kvm/lib/s390x/processor.c b/tools/testing/selftests/kvm/lib/s390x/processor.c
> index 680f37be9dbc..a0b84235c848 100644
> --- a/tools/testing/selftests/kvm/lib/s390x/processor.c
> +++ b/tools/testing/selftests/kvm/lib/s390x/processor.c
> @@ -289,6 +289,7 @@ void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...)
> {
> va_list ap;
> struct kvm_regs regs;
> + int i;
>
> TEST_ASSERT(num >= 1 && num <= 5, "Unsupported number of args,\n"
> " num: %u\n",
>
> Paolo
>
next prev parent reply other threads:[~2020-01-27 8:38 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-23 18:04 [PATCH v4 00/10] Create a userfaultfd demand paging test Ben Gardon
2020-01-23 18:04 ` [PATCH v4 01/10] KVM: selftests: Create a " Ben Gardon
2020-01-24 9:49 ` Andrew Jones
2020-01-27 9:18 ` Thomas Huth
2020-01-23 18:04 ` [PATCH v4 02/10] KVM: selftests: Add demand paging content to the " Ben Gardon
2020-01-23 18:04 ` [PATCH v4 03/10] KVM: selftests: Add configurable demand paging delay Ben Gardon
2020-01-23 18:04 ` [PATCH v4 04/10] KVM: selftests: Add memory size parameter to the demand paging test Ben Gardon
2020-01-24 10:01 ` Andrew Jones
2020-01-23 18:04 ` [PATCH v4 05/10] KVM: selftests: Pass args to vCPU in global vCPU args struct Ben Gardon
2020-01-23 18:04 ` [PATCH v4 06/10] KVM: selftests: Add support for vcpu_args_set to aarch64 and s390x Ben Gardon
2020-01-24 9:03 ` Paolo Bonzini
2020-01-24 9:35 ` Andrew Jones
2020-01-24 9:44 ` Paolo Bonzini
2020-01-24 10:45 ` Andrew Jones
2020-01-24 18:33 ` Christian Borntraeger
2020-01-25 9:34 ` Paolo Bonzini
2020-01-27 8:38 ` Andrew Jones [this message]
2020-01-27 9:01 ` Thomas Huth
2020-01-23 18:04 ` [PATCH v4 07/10] KVM: selftests: Support multiple vCPUs in demand paging test Ben Gardon
2020-01-24 10:16 ` Andrew Jones
2020-01-24 10:49 ` Andrew Jones
2020-01-25 9:39 ` Paolo Bonzini
2020-01-27 8:39 ` Andrew Jones
2020-01-23 18:04 ` [PATCH v4 08/10] KVM: selftests: Time guest demand paging Ben Gardon
2020-01-24 10:21 ` Andrew Jones
2020-01-23 18:04 ` [PATCH v4 09/10] KVM: selftests: Stop memslot creation in KVM internal memslot region Ben Gardon
2020-01-24 8:58 ` Paolo Bonzini
2020-01-24 18:41 ` Ben Gardon
2020-01-25 9:37 ` Paolo Bonzini
2020-01-27 17:28 ` Ben Gardon
2020-01-23 18:04 ` [PATCH v4 10/10] KVM: selftests: Move memslot 0 above KVM internal memslots Ben Gardon
2020-01-24 9:01 ` Paolo Bonzini
2020-01-24 18:53 ` Ben Gardon
2020-01-27 9:42 ` Thomas Huth
2020-01-24 9:03 ` [PATCH v4 00/10] Create a userfaultfd demand paging test Paolo Bonzini
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=20200127083838.u32bylca2n4om6zx@kamzik.brq.redhat.com \
--to=drjones@redhat.com \
--cc=bgardon@google.com \
--cc=cannonmatthews@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=pshier@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).