aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/lib/aarch64/processor.c
diff options
context:
space:
mode:
authorBen Gardon <bgardon@google.com>2020-01-23 10:04:32 -0800
committerPaolo Bonzini <pbonzini@redhat.com>2020-03-16 17:57:04 +0100
commit9bbf24744e12bb6b9b32e30917b07f9242cc0341 (patch)
tree51e95188afa8f33de588fb1cc0c14c21d911a813 /tools/testing/selftests/kvm/lib/aarch64/processor.c
parentKVM: selftests: Pass args to vCPU in global vCPU args struct (diff)
downloadlinux-dev-9bbf24744e12bb6b9b32e30917b07f9242cc0341.tar.xz
linux-dev-9bbf24744e12bb6b9b32e30917b07f9242cc0341.zip
KVM: selftests: Add support for vcpu_args_set to aarch64 and s390x
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> [Fixed array index (num => i) and made some style changes.] Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/aarch64/processor.c')
-rw-r--r--tools/testing/selftests/kvm/lib/aarch64/processor.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c
index f9decadfbe71..216d802479dd 100644
--- a/tools/testing/selftests/kvm/lib/aarch64/processor.c
+++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c
@@ -333,3 +333,38 @@ 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;
+ int i;
+
+ 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[i]),
+ va_arg(ap, uint64_t));
+ }
+
+ va_end(ap);
+}