KVM: selftests: enable the memslot tests in ARM64
cover KVM: selftests: enable the memslot tests in ARM64
Enable memslot_modification_stress_test and memslot_perf_test in ARM64 (second patch). memslot_modification_stress_test builds and runs in aarch64 without any modification. memslot_perf_test needs some nits regarding ucalls (first patch).
Ricardo Koller (2):
KVM: selftests: make memslot_perf_test arch independent
KVM: selftests: build the memslot tests for arm64
tools/testing/selftests/kvm/Makefile | 2 + .../testing/selftests/kvm/memslot_perf_test.c | 56 +++++++++++-------- 2 files changed, 36 insertions(+), 22 deletions(-)
Signature · 1 line
2.33.0.153.gba50c8fa24-goog
PATCH 1/2 KVM: selftests: make memslot_perf_test arch independent
memslot_perf_test uses ucalls for synchronization between guest and host. Ucalls API is architecture independent: tests do not need know what kind of exit they generate on a specific arch. More specifically, there is no need to check whether an exit is KVM_EXIT_IO in x86 for the host to know that the exit is ucall related, as get_ucall() already makes that check.
Change memslot_perf_test to not require specifying what exit does a ucall generate. Also add a missing ucall_init.
--- .../testing/selftests/kvm/memslot_perf_test.c | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-)
tools/testing/selftests/kvm/memslot_perf_test.c +34 -22
@@ -127,43 +127,54 @@ static bool verbose;pr_info (__VA_ARGS__); \ }while (0 ) +static void check_mmio_access(struct vm_data *vm, struct kvm_run *run) +{ +TEST_ASSERT (vm->mmio_ok,"Unexpected mmio exit" ); +TEST_ASSERT (run->mmio.is_write,"Unexpected mmio read" ); +TEST_ASSERT (run->mmio.len ==8 , +"Unexpected exit mmio size = %u" , run->mmio.len); +TEST_ASSERT (run->mmio.phys_addr >= vm->mmio_gpa_min && + run->mmio.phys_addr <= vm->mmio_gpa_max, +"Unexpected exit mmio address = 0x%llx" , + run->mmio.phys_addr); +} +static void *vcpu_worker (void *data) {struct vm_data *vm = data;struct kvm_run *run;struct ucall uc; -uint64_t cmd; run =vcpu_state (vm->vm,VCPU_ID );while (1 ) {vcpu_run (vm->vm,VCPU_ID ); -if (run->exit_reason ==KVM_EXIT_IO ) { - cmd =get_ucall (vm->vm,VCPU_ID , &uc); -if (cmd !=UCALL_SYNC ) -break ; - +switch (get_ucall (vm->vm,VCPU_ID , &uc)) { +case UCALL_SYNC : +TEST_ASSERT (uc.args[1 ] ==0 , +"Unexpected sync ucall, got %lx" , + (ulong )uc.args[1 ]);sem_post (&vcpu_ready);continue ; - } - -if (run->exit_reason !=KVM_EXIT_MMIO ) +case UCALL_NONE : +if (run->exit_reason ==KVM_EXIT_MMIO ) +check_mmio_access (vm, run); +else + goto done;break ; - -TEST_ASSERT (vm->mmio_ok,"Unexpected mmio exit" ); -TEST_ASSERT (run->mmio.is_write,"Unexpected mmio read" ); -TEST_ASSERT (run->mmio.len ==8 , -"Unexpected exit mmio size = %u" , run->mmio.len); -TEST_ASSERT (run->mmio.phys_addr >= vm->mmio_gpa_min && - run->mmio.phys_addr <= vm->mmio_gpa_max, -"Unexpected exit mmio address = 0x%llx" , - run->mmio.phys_addr); +case UCALL_ABORT : +TEST_FAIL ("%s at %s:%ld, val = %lu" , + (const char *)uc.args[0 ], + __FILE__, uc.args[1 ], uc.args[2 ]); +break ; +case UCALL_DONE : + goto done; +default : +TEST_FAIL ("Unknown ucall %lu" , uc.cmd); + } } -if (run->exit_reason ==KVM_EXIT_IO && cmd ==UCALL_ABORT ) -TEST_FAIL ("%s at %s:%ld, val = %lu" , (const char *)uc.args[0 ], - __FILE__, uc.args[1 ], uc.args[2 ]); - +done:return NULL ; }
@@ -268,6 +279,7 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots,TEST_ASSERT (data->hva_slots,"malloc() fail" ); data->vm =vm_create_default (VCPU_ID , mempages, guest_code); +ucall_init (data->vm,NULL );pr_info_v ("Adding slots 1..%i, each slot with %" PRIu64" pages + %" PRIu64" extra pages last\n" , max_mem_slots -1 , data->pages_per_slot, rempages);
Signature · 1 line
2.33.0.153.gba50c8fa24-goog
Re: [PATCH 1/2] KVM: selftests: make memslot_perf_test arch independent
Quoted 7 lines · Ricardo Koller
memslot_perf_testuses ucalls for synchronization between guest and host. Ucalls API is architecture independent: tests do not need know what kind of exit they generate on a specific arch. More specifically, there is no need to check whether an exit isKVM_EXIT_IOin x86 for the host to know that the exit is ucall related, asget_ucall()already makes that check.
Quoted 8 lines
Change
memslot_perf_testto not require specifying what exit does a ucall generate. Also add a missingucall_init.Signed-off-by Ricardo Koller <[email protected]>--- .../testing/selftests/kvm/memslot_perf_test.c | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-)
Re: [PATCH 1/2] KVM: selftests: make memslot_perf_test arch independent
In reply to Ricardo KollerQuoted 7 lines · Ricardo Koller
memslot_perf_testuses ucalls for synchronization between guest and host. Ucalls API is architecture independent: tests do not need know what kind of exit they generate on a specific arch. More specifically, there is no need to check whether an exit isKVM_EXIT_IOin x86 for the host to know that the exit is ucall related, asget_ucall()already makes that check.
Quoted 5 lines
Change
memslot_perf_testto not require specifying what exit does a ucall generate. Also add a missingucall_init.Signed-off-by Ricardo Koller <[email protected]>---
Thanks,
Maciej
Re: [PATCH 1/2] KVM: selftests: make memslot_perf_test arch independent
In reply to Ricardo KollerQuoted 8 lines · Ricardo Koller
memslot_perf_testuses ucalls for synchronization between guest and host. Ucalls API is architecture independent: tests do not need know what kind of exit they generate on a specific arch. More specifically, there is no need to check whether an exit isKVM_EXIT_IOin x86 for the host to know that the exit is ucall related, asget_ucall()already makes that check.
Quoted 7 lines
Change
memslot_perf_testto not require specifying what exit does a ucall generate. Also add a missingucall_init.Signed-off-by Ricardo Koller <[email protected]>--- .../testing/selftests/kvm/memslot_perf_test.c | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-)
PATCH 2/2 KVM: selftests: build the memslot tests for arm64
In reply to Ricardo KollerAdd memslot_perf_test and memslot_modification_stress_test to the list of aarch64 selftests.
--- tools/testing/selftests/kvm/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/kvm/Makefile +2 -0
@@ -84,6 +84,8 @@ TEST_GEN_PROGS_x86_64 += set_memory_region_test TEST_GEN_PROGS_x86_64 += steal_time TEST_GEN_PROGS_x86_64 += kvm_binary_stats_test +TEST_GEN_PROGS_aarch64 += memslot_modification_stress_test +TEST_GEN_PROGS_aarch64 += memslot_perf_test TEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions TEST_GEN_PROGS_aarch64 += aarch64/get-reg-list TEST_GEN_PROGS_aarch64 += aarch64/vgic_init
Signature · 6 lines
2.33.0.153.gba50c8fa24-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 2/2] KVM: selftests: build the memslot tests for arm64
Quoted 13 lines · Ricardo Koller
Add
memslot_perf_testandmemslot_modification_stress_testto the list of aarch64 selftests.Signed-off-by Ricardo Koller <[email protected]>--- tools/testing/selftests/kvm/Makefile | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/kvm/Makefile +0
-0
tools/testing/selftests/kvm/Makefile TEST_GEN_PROGS_x86_64 += set_memory_region_test · line 91
Quoted 8 lines
tools/testing/selftests/kvm/Makefile +2
-0@@ -84,6 +84,8 @@ TEST_GEN_PROGS_x86_64 += set_memory_region_test TEST_GEN_PROGS_x86_64 += steal_time TEST_GEN_PROGS_x86_64 += kvm_binary_stats_test +TEST_GEN_PROGS_aarch64 += memslot_modification_stress_test +TEST_GEN_PROGS_aarch64 += memslot_perf_test TEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions TEST_GEN_PROGS_aarch64 += aarch64/get-reg-list TEST_GEN_PROGS_aarch64 += aarch64/vgic_init
These tests need to be added below the aarch64/* tests and in alphabetical order.
Thanks,
drew
Quoted 3 lines
Signature · 1 line
2.33.0.153.gba50c8fa24-goog
Re: [PATCH 2/2] KVM: selftests: build the memslot tests for arm64
Quoted 17 lines · Andrew Jones
Quoted 16 lines · Ricardo Koller
Add
memslot_perf_testandmemslot_modification_stress_testto the list of aarch64 selftests.Signed-off-by Ricardo Koller <[email protected]>--- tools/testing/selftests/kvm/Makefile | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/kvm/Makefile +0
-0@@ -84,6 +84,8 @@ TEST_GEN_PROGS_x86_64 += set_memory_region_test TEST_GEN_PROGS_x86_64 += steal_time TEST_GEN_PROGS_x86_64 += kvm_binary_stats_test
Quoted 9 lines
tools/testing/selftests/kvm/Makefile TEST_GEN_PROGS_x86_64 += set_memory_region_test · line 91
Quoted 5 lines
tools/testing/selftests/kvm/Makefile +2
-0+TEST_GEN_PROGS_aarch64 += memslot_modification_stress_test +TEST_GEN_PROGS_aarch64 += memslot_perf_test TEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions TEST_GEN_PROGS_aarch64 += aarch64/get-reg-list TEST_GEN_PROGS_aarch64 += aarch64/vgic_initThese tests need to be added below the aarch64/* tests and in alphabetical order.
Sure, will fix this in v2.
Thanks,
Ricardo
Quoted 7 lines
Thanks,
drewQuoted 3 lines
Signature · 1 line
2.33.0.153.gba50c8fa24-goog
Re: [PATCH 2/2] KVM: selftests: build the memslot tests for arm64
In reply to Ricardo KollerQuoted 5 lines · Ricardo Koller
Add
memslot_perf_testandmemslot_modification_stress_testto the list of aarch64 selftests.Signed-off-by Ricardo Koller <[email protected]>---
Thanks,
Maciej
Re: [PATCH 2/2] KVM: selftests: build the memslot tests for arm64
In reply to Ricardo KollerRicardo,
Quoted 5 lines · Ricardo Koller
Add
memslot_perf_testandmemslot_modification_stress_testto the list of aarch64 selftests.Signed-off-by Ricardo Koller <[email protected]>
There isn't anything that prevents these tests from being used for s390x too right? Of course, we haven't anything to test on but just a thought.
Besides Drew's comments:
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 2/2] KVM: selftests: build the memslot tests for arm64
Quoted 4 lines · Oliver Upton
Ricardo,
Quoted 1 line · Ricardo Koller
Quoted 8 lines
Quoted 4 lines
Add
memslot_perf_testandmemslot_modification_stress_testto the list of aarch64 selftests.Signed-off-by Ricardo Koller <[email protected]>There isn't anything that prevents these tests from being used for s390x too right? Of course, we haven't anything to test on but just a thought.
Tbh I'm not sure. Will ask if somebody can try it in the cover letter for v2.
Thanks,
Ricardo
Quoted 4 lines
Besides Drew's comments:
Reviewed-by Oliver Upton <[email protected]>