summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndrew Jones <drjones@redhat.com>2021-05-31 13:33:42 +0300
committerMarc Zyngier <maz@kernel.org>2021-06-22 10:51:28 +0300
commitf3032fcc9cf065733ce9a50057aaeffd6c464e2e (patch)
tree5e05503af5fa2349ea54b60a9f8fdbca3225d363 /tools
parent94e9223c06bece9165a36f0f56bac3552a45cbfc (diff)
downloadlinux-f3032fcc9cf065733ce9a50057aaeffd6c464e2e.tar.xz
KVM: arm64: selftests: get-reg-list: Provide config selection option
Add a new command line option that allows the user to select a specific configuration, e.g. --config=sve will give the sve config. Also provide help text and the --help/-h options. Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Ricardo Koller <ricarkol@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20210531103344.29325-4-drjones@redhat.com
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/kvm/aarch64/get-reg-list.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
index 14fc8d82e30f..03e041d97a18 100644
--- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c
+++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
@@ -539,6 +539,52 @@ static void run_test(struct vcpu_config *c)
kvm_vm_free(vm);
}
+static void help(void)
+{
+ struct vcpu_config *c;
+ int i;
+
+ printf(
+ "\n"
+ "usage: get-reg-list [--config=<selection>] [--list] [--list-filtered] [--core-reg-fixup]\n\n"
+ " --config=<selection> Used to select a specific vcpu configuration for the test/listing\n"
+ " '<selection>' may be\n");
+
+ for (i = 0; i < vcpu_configs_n; ++i) {
+ c = vcpu_configs[i];
+ printf(
+ " '%s'\n", config_name(c));
+ }
+
+ printf(
+ "\n"
+ " --list Print the register list rather than test it (requires --config)\n"
+ " --list-filtered Print registers that would normally be filtered out (requires --config)\n"
+ " --core-reg-fixup Needed when running on old kernels with broken core reg listings\n"
+ "\n"
+ );
+}
+
+static struct vcpu_config *parse_config(const char *config)
+{
+ struct vcpu_config *c;
+ int i;
+
+ if (config[8] != '=')
+ help(), exit(1);
+
+ for (i = 0; i < vcpu_configs_n; ++i) {
+ c = vcpu_configs[i];
+ if (strcmp(config_name(c), &config[9]) == 0)
+ break;
+ }
+
+ if (i == vcpu_configs_n)
+ help(), exit(1);
+
+ return c;
+}
+
int main(int ac, char **av)
{
struct vcpu_config *c, *sel = NULL;
@@ -547,20 +593,24 @@ int main(int ac, char **av)
for (i = 1; i < ac; ++i) {
if (strcmp(av[i], "--core-reg-fixup") == 0)
fixup_core_regs = true;
+ else if (strncmp(av[i], "--config", 8) == 0)
+ sel = parse_config(av[i]);
else if (strcmp(av[i], "--list") == 0)
print_list = true;
else if (strcmp(av[i], "--list-filtered") == 0)
print_filtered = true;
+ else if (strcmp(av[i], "--help") == 0 || strcmp(av[1], "-h") == 0)
+ help(), exit(0);
else
- TEST_FAIL("Unknown option: %s\n", av[i]);
+ help(), exit(1);
}
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];
+ if (!sel)
+ help(), exit(1);
}
for (i = 0; i < vcpu_configs_n; ++i) {