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);
28 struct kvm_s390_vm_cpu_processor info;
30 kvm_fd = open_kvm_dev_path_or_exit();
31 vm_fd = ioctl(kvm_fd, KVM_CREATE_VM, 0);
32 kvm_device_access(vm_fd, KVM_S390_VM_CPU_MODEL,
33 KVM_S390_VM_CPU_PROCESSOR, &info, false);
36 /* Starting with z13 we have 47bits of physical address */
38 guest_mode_append(VM_MODE_P47V64_4K, true, true);
43 void for_each_guest_mode(void (*func)(enum vm_guest_mode, void *), void *arg)
47 for (i = 0; i < NUM_VM_MODES; ++i) {
48 if (!guest_modes[i].enabled)
50 TEST_ASSERT(guest_modes[i].supported,
51 "Guest mode ID %d (%s) not supported.",
52 i, vm_guest_mode_string(i));
57 void guest_modes_help(void)
61 printf(" -m: specify the guest mode ID to test\n"
62 " (default: test all supported modes)\n"
63 " This option may be used multiple times.\n"
64 " Guest mode IDs:\n");
65 for (i = 0; i < NUM_VM_MODES; ++i) {
66 printf(" %d: %s%s\n", i, vm_guest_mode_string(i),
67 guest_modes[i].supported ? " (supported)" : "");
71 void guest_modes_cmdline(const char *arg)
73 static bool mode_selected;
78 for (i = 0; i < NUM_VM_MODES; ++i)
79 guest_modes[i].enabled = false;
83 mode = strtoul(optarg, NULL, 10);
84 TEST_ASSERT(mode < NUM_VM_MODES, "Guest mode ID %d too big", mode);
85 guest_modes[mode].enabled = true;