From: Andrew Jones <drjones@redhat.com>
To: Ricardo Koller <ricarkol@google.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
maz@kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
oupton@google.com, reijiw@google.com
Subject: Re: [PATCH v2 2/5] kvm: selftests: aarch64: pass vgic_irq guest args as a pointer
Date: Thu, 27 Jan 2022 08:46:16 +0100 [thread overview]
Message-ID: <20220127074616.vyjf2elhcrx4ptfw@gator> (raw)
In-Reply-To: <20220127030858.3269036-3-ricarkol@google.com>
On Wed, Jan 26, 2022 at 07:08:55PM -0800, Ricardo Koller wrote:
> The guest in vgic_irq gets its arguments in a struct. This struct used
> to fit nicely in a single register so vcpu_args_set() was able to pass
> it by value by setting x0 with it.
Ouch.
> Unfortunately, this args struct grew
> after some commits and some guest args became random (specically
> kvm_supports_irqfd).
>
> Fix this by passing the guest args as a pointer (after allocating some
> guest memory for it).
>
> Signed-off-by: Ricardo Koller <ricarkol@google.com>
> Reported-by: Reiji Watanabe <reijiw@google.com>
> Cc: Andrew Jones <drjones@redhat.com>
> ---
> .../testing/selftests/kvm/aarch64/vgic_irq.c | 29 ++++++++++---------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> index e6c7d7f8fbd1..b701eb80128d 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -472,10 +472,10 @@ static void test_restore_active(struct test_args *args, struct kvm_inject_desc *
> guest_restore_active(args, MIN_SPI, 4, f->cmd);
> }
>
> -static void guest_code(struct test_args args)
> +static void guest_code(struct test_args *args)
> {
> - uint32_t i, nr_irqs = args.nr_irqs;
> - bool level_sensitive = args.level_sensitive;
> + uint32_t i, nr_irqs = args->nr_irqs;
> + bool level_sensitive = args->level_sensitive;
> struct kvm_inject_desc *f, *inject_fns;
>
> gic_init(GIC_V3, 1, dist, redist);
> @@ -484,11 +484,11 @@ static void guest_code(struct test_args args)
> gic_irq_enable(i);
>
> for (i = MIN_SPI; i < nr_irqs; i++)
> - gic_irq_set_config(i, !args.level_sensitive);
> + gic_irq_set_config(i, !level_sensitive);
>
> - gic_set_eoi_split(args.eoi_split);
> + gic_set_eoi_split(args->eoi_split);
>
> - reset_priorities(&args);
> + reset_priorities(args);
> gic_set_priority_mask(CPU_PRIO_MASK);
>
> inject_fns = level_sensitive ? inject_level_fns
> @@ -497,17 +497,17 @@ static void guest_code(struct test_args args)
> local_irq_enable();
>
> /* Start the tests. */
> - for_each_supported_inject_fn(&args, inject_fns, f) {
> - test_injection(&args, f);
> - test_preemption(&args, f);
> - test_injection_failure(&args, f);
> + for_each_supported_inject_fn(args, inject_fns, f) {
> + test_injection(args, f);
> + test_preemption(args, f);
> + test_injection_failure(args, f);
> }
>
> /* Restore the active state of IRQs. This would happen when live
> * migrating IRQs in the middle of being handled.
> */
> - for_each_supported_activate_fn(&args, set_active_fns, f)
> - test_restore_active(&args, f);
> + for_each_supported_activate_fn(args, set_active_fns, f)
> + test_restore_active(args, f);
>
> GUEST_DONE();
> }
> @@ -739,6 +739,7 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
> int gic_fd;
> struct kvm_vm *vm;
> struct kvm_inject_args inject_args;
> + vm_vaddr_t args_gva;
>
> struct test_args args = {
> .nr_irqs = nr_irqs,
> @@ -757,7 +758,9 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
> vcpu_init_descriptor_tables(vm, VCPU_ID);
>
> /* Setup the guest args page (so it gets the args). */
> - vcpu_args_set(vm, 0, 1, args);
> + args_gva = vm_vaddr_alloc_page(vm);
> + memcpy(addr_gva2hva(vm, args_gva), &args, sizeof(args));
> + vcpu_args_set(vm, 0, 1, args_gva);
>
> gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
> GICD_BASE_GPA, GICR_BASE_GPA);
> --
> 2.35.0.rc0.227.g00780c9af4-goog
>
Reviewed-by: Andrew Jones <drjones@redhat.com>
next prev parent reply other threads:[~2022-01-27 7:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 3:08 [PATCH v2 0/5] kvm: selftests: aarch64: some fixes for vgic_irq Ricardo Koller
2022-01-27 3:08 ` [PATCH v2 1/5] kvm: selftests: aarch64: fix assert in gicv3_access_reg Ricardo Koller
2022-01-27 7:34 ` Andrew Jones
2022-01-27 3:08 ` [PATCH v2 2/5] kvm: selftests: aarch64: pass vgic_irq guest args as a pointer Ricardo Koller
2022-01-27 7:46 ` Andrew Jones [this message]
2022-01-27 3:08 ` [PATCH v2 3/5] kvm: selftests: aarch64: fix the failure check in kvm_set_gsi_routing_irqchip_check Ricardo Koller
2022-01-27 3:08 ` [PATCH v2 4/5] kvm: selftests: aarch64: fix some vgic related comments Ricardo Koller
2022-01-27 7:49 ` Andrew Jones
2022-01-27 15:06 ` Ricardo Koller
2022-01-27 3:08 ` [PATCH v2 5/5] kvm: selftests: aarch64: use a tighter assert in vgic_poke_irq() Ricardo Koller
2022-01-27 7:51 ` Andrew Jones
2022-02-08 17:37 ` [PATCH v2 0/5] kvm: selftests: aarch64: some fixes for vgic_irq Marc Zyngier
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=20220127074616.vyjf2elhcrx4ptfw@gator \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=reijiw@google.com \
--cc=ricarkol@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