From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: maz@kernel.org, ricarkol@google.com, eric.auger@redhat.com,
alexandru.elisei@arm.com, pbonzini@redhat.com
Subject: [PATCH 1/6] KVM: arm64: selftests: get-reg-list: Factor out printing
Date: Fri, 7 May 2021 22:04:11 +0200 [thread overview]
Message-ID: <20210507200416.198055-2-drjones@redhat.com> (raw)
In-Reply-To: <20210507200416.198055-1-drjones@redhat.com>
A later patch will need the printing to be factored out of the test
code. To factor out the printing we also factor out the reg-list
initialization.
No functional change intended.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
.../selftests/kvm/aarch64/get-reg-list.c | 62 +++++++++++++------
1 file changed, 42 insertions(+), 20 deletions(-)
diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
index 486932164cf2..44d560a8ca45 100644
--- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c
+++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "kvm_util.h"
#include "test_util.h"
#include "processor.h"
@@ -336,12 +337,47 @@ static void check_supported(void)
}
}
-int main(int ac, char **av)
+static bool fixup_core_regs;
+
+static void reg_list_init(struct kvm_vm *vm)
{
struct kvm_vcpu_init init = { .target = -1, };
+
+ prepare_vcpu_init(&init);
+ aarch64_vcpu_add_default(vm, 0, &init, NULL);
+ finalize_vcpu(vm, 0);
+
+ reg_list = vcpu_get_reg_list(vm, 0);
+
+ if (fixup_core_regs)
+ core_reg_fixup();
+}
+
+static void print_reg_list(bool print_list, bool print_filtered)
+{
+ struct kvm_vm *vm;
+ int i;
+
+ assert(print_list || print_filtered);
+
+ vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR);
+ reg_list_init(vm);
+
+ putchar('\n');
+ for_each_reg(i) {
+ __u64 id = reg_list->reg[i];
+ if ((print_list && !filter_reg(id)) ||
+ (print_filtered && filter_reg(id)))
+ print_reg(id);
+ }
+ putchar('\n');
+}
+
+int main(int ac, char **av)
+{
int new_regs = 0, missing_regs = 0, i;
int failed_get = 0, failed_set = 0, failed_reject = 0;
- bool print_list = false, print_filtered = false, fixup_core_regs = false;
+ bool print_list = false, print_filtered = false;
struct kvm_vm *vm;
__u64 *vec_regs;
@@ -358,28 +394,14 @@ int main(int ac, char **av)
TEST_FAIL("Unknown option: %s\n", av[i]);
}
- vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR);
- prepare_vcpu_init(&init);
- aarch64_vcpu_add_default(vm, 0, &init, NULL);
- finalize_vcpu(vm, 0);
-
- reg_list = vcpu_get_reg_list(vm, 0);
-
- if (fixup_core_regs)
- core_reg_fixup();
-
if (print_list || print_filtered) {
- putchar('\n');
- for_each_reg(i) {
- __u64 id = reg_list->reg[i];
- if ((print_list && !filter_reg(id)) ||
- (print_filtered && filter_reg(id)))
- print_reg(id);
- }
- putchar('\n');
+ print_reg_list(print_list, print_filtered);
return 0;
}
+ vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR);
+ reg_list_init(vm);
+
/*
* We only test that we can get the register and then write back the
* same value. Some registers may allow other values to be written
--
2.30.2
next prev parent reply other threads:[~2021-05-07 20:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-07 20:04 [PATCH 0/6] KVM: arm64: selftests: Fix get-reg-list Andrew Jones
2021-05-07 20:04 ` Andrew Jones [this message]
2021-05-07 20:04 ` [PATCH 2/6] KVM: arm64: selftests: get-reg-list: Introduce vcpu configs Andrew Jones
2021-05-07 20:04 ` [PATCH 3/6] KVM: arm64: selftests: get-reg-list: Prepare to run multiple configs at once Andrew Jones
2021-05-07 20:04 ` [PATCH 4/6] KVM: arm64: selftests: get-reg-list: Provide config selection option Andrew Jones
2021-05-10 6:40 ` Andrew Jones
2021-05-07 20:04 ` [PATCH 5/6] KVM: arm64: selftests: get-reg-list: Remove get-reg-list-sve Andrew Jones
2021-05-07 20:04 ` [PATCH 6/6] KVM: arm64: selftests: get-reg-list: Split base and pmu registers Andrew Jones
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=20210507200416.198055-2-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=alexandru.elisei@arm.com \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=pbonzini@redhat.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;
as well as URLs for NNTP newsgroup(s).