1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020, Red Hat, Inc.
5 #include "guest_modes.h"
7 struct guest_mode guest_modes[NUM_VM_MODES];
9 void guest_modes_append_default(void)
11 guest_mode_append(VM_MODE_DEFAULT, true, true);
14 guest_mode_append(VM_MODE_P40V48_64K, true, true);
16 unsigned int limit = kvm_check_cap(KVM_CAP_ARM_VM_IPA_SIZE);
18 guest_mode_append(VM_MODE_P52V48_64K, true, true);
20 guest_mode_append(VM_MODE_P48V48_4K, true, true);
21 guest_mode_append(VM_MODE_P48V48_64K, true, true);
27 void for_each_guest_mode(void (*func)(enum vm_guest_mode, void *), void *arg)
31 for (i = 0; i < NUM_VM_MODES; ++i) {
32 if (!guest_modes[i].enabled)
34 TEST_ASSERT(guest_modes[i].supported,
35 "Guest mode ID %d (%s) not supported.",
36 i, vm_guest_mode_string(i));
41 void guest_modes_help(void)
45 printf(" -m: specify the guest mode ID to test\n"
46 " (default: test all supported modes)\n"
47 " This option may be used multiple times.\n"
48 " Guest mode IDs:\n");
49 for (i = 0; i < NUM_VM_MODES; ++i) {
50 printf(" %d: %s%s\n", i, vm_guest_mode_string(i),
51 guest_modes[i].supported ? " (supported)" : "");
55 void guest_modes_cmdline(const char *arg)
57 static bool mode_selected;
62 for (i = 0; i < NUM_VM_MODES; ++i)
63 guest_modes[i].enabled = false;
67 mode = strtoul(optarg, NULL, 10);
68 TEST_ASSERT(mode < NUM_VM_MODES, "Guest mode ID %d too big", mode);
69 guest_modes[mode].enabled = true;