From: Ricardo Koller <ricarkol@google.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
maz@kernel.org, eric.auger@redhat.com, alexandru.elisei@arm.com,
pbonzini@redhat.com
Subject: Re: [PATCH v3 2/5] KVM: arm64: selftests: get-reg-list: Prepare to run multiple configs at once
Date: Wed, 2 Jun 2021 16:56:01 -0700 [thread overview]
Message-ID: <YLgakV2Eru1J2f4K@google.com> (raw)
In-Reply-To: <20210531103344.29325-3-drjones@redhat.com>
On Mon, May 31, 2021 at 12:33:41PM +0200, Andrew Jones wrote:
> We don't want to have to create a new binary for each vcpu config, so
> prepare to run the test for multiple vcpu configs in a single binary.
> We do this by factoring out the test from main() and then looping over
> configs. When given '--list' we still never print more than a single
> reg-list for a single vcpu config though, because it would be confusing
> otherwise.
>
> No functional change intended.
>
> Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Ricardo Koller <ricarkol@google.com>
> ---
> .../selftests/kvm/aarch64/get-reg-list.c | 68 ++++++++++++++-----
> 1 file changed, 51 insertions(+), 17 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
> index 7bb09ce20dde..14fc8d82e30f 100644
> --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c
> +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
> @@ -56,8 +56,8 @@ struct vcpu_config {
> struct reg_sublist sublists[];
> };
>
> -static struct vcpu_config vregs_config;
> -static struct vcpu_config sve_config;
> +static struct vcpu_config *vcpu_configs[];
> +static int vcpu_configs_n;
>
> #define for_each_sublist(c, s) \
> for ((s) = &(c)->sublists[0]; (s)->regs; ++(s))
> @@ -400,29 +400,20 @@ static void check_supported(struct vcpu_config *c)
> }
> }
>
> -int main(int ac, char **av)
> +static bool print_list;
> +static bool print_filtered;
> +static bool fixup_core_regs;
> +
> +static void run_test(struct vcpu_config *c)
> {
> - struct vcpu_config *c = reg_list_sve() ? &sve_config : &vregs_config;
> struct kvm_vcpu_init init = { .target = -1, };
> int new_regs = 0, missing_regs = 0, i, n;
> int failed_get = 0, failed_set = 0, failed_reject = 0;
> - bool print_list = false, print_filtered = false, fixup_core_regs = false;
> struct kvm_vm *vm;
> struct reg_sublist *s;
>
> check_supported(c);
>
> - for (i = 1; i < ac; ++i) {
> - if (strcmp(av[i], "--core-reg-fixup") == 0)
> - fixup_core_regs = true;
> - else if (strcmp(av[i], "--list") == 0)
> - print_list = true;
> - else if (strcmp(av[i], "--list-filtered") == 0)
> - print_filtered = true;
> - else
> - TEST_FAIL("Unknown option: %s\n", av[i]);
> - }
> -
> vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR);
> prepare_vcpu_init(c, &init);
> aarch64_vcpu_add_default(vm, 0, &init, NULL);
> @@ -442,7 +433,7 @@ int main(int ac, char **av)
> print_reg(c, id);
> }
> putchar('\n');
> - return 0;
> + return;
> }
>
> /*
> @@ -541,6 +532,44 @@ int main(int ac, char **av)
> "%d registers failed get; %d registers failed set; %d registers failed reject",
> config_name(c), missing_regs, failed_get, failed_set, failed_reject);
>
> + pr_info("%s: PASS\n", config_name(c));
> + blessed_n = 0;
> + free(blessed_reg);
> + free(reg_list);
> + kvm_vm_free(vm);
> +}
> +
> +int main(int ac, char **av)
> +{
> + struct vcpu_config *c, *sel = NULL;
> + int i;
> +
> + for (i = 1; i < ac; ++i) {
> + if (strcmp(av[i], "--core-reg-fixup") == 0)
> + fixup_core_regs = true;
> + else if (strcmp(av[i], "--list") == 0)
> + print_list = true;
> + else if (strcmp(av[i], "--list-filtered") == 0)
> + print_filtered = true;
> + else
> + TEST_FAIL("Unknown option: %s\n", av[i]);
> + }
> +
> + if (print_list || print_filtered) {
> + /*
> + * We only want to print the register list of a single config.
> + * TODO: Add command line support to pick which config.
> + */
> + sel = vcpu_configs[0];
> + }
> +
> + for (i = 0; i < vcpu_configs_n; ++i) {
> + c = vcpu_configs[i];
> + if (sel && c != sel)
> + continue;
> + run_test(c);
> + }
> +
> return 0;
> }
>
> @@ -945,3 +974,8 @@ static struct vcpu_config sve_config = {
> {0},
> },
> };
> +
> +static struct vcpu_config *vcpu_configs[] = {
> + reg_list_sve() ? &sve_config : &vregs_config,
> +};
> +static int vcpu_configs_n = ARRAY_SIZE(vcpu_configs);
> --
> 2.31.1
>
next prev parent reply other threads:[~2021-06-02 23:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-31 10:33 [PATCH v3 0/5] KVM: arm64: selftests: Fix get-reg-list Andrew Jones
2021-05-31 10:33 ` [PATCH v3 1/5] KVM: arm64: selftests: get-reg-list: Introduce vcpu configs Andrew Jones
2021-06-02 23:40 ` Ricardo Koller
2021-06-03 12:14 ` Andrew Jones
2021-05-31 10:33 ` [PATCH v3 2/5] KVM: arm64: selftests: get-reg-list: Prepare to run multiple configs at once Andrew Jones
2021-06-02 23:56 ` Ricardo Koller [this message]
2021-05-31 10:33 ` [PATCH v3 3/5] KVM: arm64: selftests: get-reg-list: Provide config selection option Andrew Jones
2021-06-03 0:03 ` Ricardo Koller
2021-05-31 10:33 ` [PATCH v3 4/5] KVM: arm64: selftests: get-reg-list: Remove get-reg-list-sve Andrew Jones
2021-06-03 0:09 ` Ricardo Koller
2021-05-31 10:33 ` [PATCH v3 5/5] KVM: arm64: selftests: get-reg-list: Split base and pmu registers Andrew Jones
2021-06-02 23:26 ` Ricardo Koller
2021-06-22 7:07 ` [PATCH v3 0/5] KVM: arm64: selftests: Fix get-reg-list Andrew Jones
2021-06-22 7:32 ` Marc Zyngier
2021-06-22 7:48 ` Andrew Jones
2021-06-22 7:57 ` 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=YLgakV2Eru1J2f4K@google.com \
--to=ricarkol@google.com \
--cc=alexandru.elisei@arm.com \
--cc=drjones@redhat.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 \
/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).