Commit 11024a7a authored by Ricardo Koller's avatar Ricardo Koller Committed by Marc Zyngier

kvm: selftests: aarch64: pass vgic_irq guest args as a pointer

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. 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: default avatarRicardo Koller <ricarkol@google.com>
Reported-by: default avatarReiji Watanabe <reijiw@google.com>
Cc: Andrew Jones <drjones@redhat.com>
Reviewed-by: default avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220127030858.3269036-3-ricarkol@google.com
parent cc94d47c
...@@ -472,10 +472,10 @@ static void test_restore_active(struct test_args *args, struct kvm_inject_desc * ...@@ -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); 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; uint32_t i, nr_irqs = args->nr_irqs;
bool level_sensitive = args.level_sensitive; bool level_sensitive = args->level_sensitive;
struct kvm_inject_desc *f, *inject_fns; struct kvm_inject_desc *f, *inject_fns;
gic_init(GIC_V3, 1, dist, redist); gic_init(GIC_V3, 1, dist, redist);
...@@ -484,11 +484,11 @@ static void guest_code(struct test_args args) ...@@ -484,11 +484,11 @@ static void guest_code(struct test_args args)
gic_irq_enable(i); gic_irq_enable(i);
for (i = MIN_SPI; i < nr_irqs; 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); gic_set_priority_mask(CPU_PRIO_MASK);
inject_fns = level_sensitive ? inject_level_fns inject_fns = level_sensitive ? inject_level_fns
...@@ -497,17 +497,17 @@ static void guest_code(struct test_args args) ...@@ -497,17 +497,17 @@ static void guest_code(struct test_args args)
local_irq_enable(); local_irq_enable();
/* Start the tests. */ /* Start the tests. */
for_each_supported_inject_fn(&args, inject_fns, f) { for_each_supported_inject_fn(args, inject_fns, f) {
test_injection(&args, f); test_injection(args, f);
test_preemption(&args, f); test_preemption(args, f);
test_injection_failure(&args, f); test_injection_failure(args, f);
} }
/* Restore the active state of IRQs. This would happen when live /* Restore the active state of IRQs. This would happen when live
* migrating IRQs in the middle of being handled. * migrating IRQs in the middle of being handled.
*/ */
for_each_supported_activate_fn(&args, set_active_fns, f) for_each_supported_activate_fn(args, set_active_fns, f)
test_restore_active(&args, f); test_restore_active(args, f);
GUEST_DONE(); GUEST_DONE();
} }
...@@ -739,6 +739,7 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split) ...@@ -739,6 +739,7 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
int gic_fd; int gic_fd;
struct kvm_vm *vm; struct kvm_vm *vm;
struct kvm_inject_args inject_args; struct kvm_inject_args inject_args;
vm_vaddr_t args_gva;
struct test_args args = { struct test_args args = {
.nr_irqs = nr_irqs, .nr_irqs = nr_irqs,
...@@ -757,7 +758,9 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split) ...@@ -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); vcpu_init_descriptor_tables(vm, VCPU_ID);
/* Setup the guest args page (so it gets the args). */ /* 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, gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
GICD_BASE_GPA, GICR_BASE_GPA); GICD_BASE_GPA, GICR_BASE_GPA);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment