diff options
| -rw-r--r-- | tools/testing/selftests/kvm/lib/kvm_util.c | 5 | ||||
| -rw-r--r-- | tools/testing/selftests/kvm/lib/x86_64/processor.c | 8 | ||||
| -rw-r--r-- | tools/testing/selftests/kvm/x86_64/evmcs_test.c | 5 | ||||
| -rw-r--r-- | tools/testing/selftests/kvm/x86_64/state_test.c | 15 |
4 files changed, 17 insertions, 16 deletions
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index efa0aad8b3c6..4ca96b228e46 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c | |||
| @@ -91,6 +91,11 @@ static void vm_open(struct kvm_vm *vm, int perm, unsigned long type) | |||
| 91 | if (vm->kvm_fd < 0) | 91 | if (vm->kvm_fd < 0) |
| 92 | exit(KSFT_SKIP); | 92 | exit(KSFT_SKIP); |
| 93 | 93 | ||
| 94 | if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) { | ||
| 95 | fprintf(stderr, "immediate_exit not available, skipping test\n"); | ||
| 96 | exit(KSFT_SKIP); | ||
| 97 | } | ||
| 98 | |||
| 94 | vm->fd = ioctl(vm->kvm_fd, KVM_CREATE_VM, type); | 99 | vm->fd = ioctl(vm->kvm_fd, KVM_CREATE_VM, type); |
| 95 | TEST_ASSERT(vm->fd >= 0, "KVM_CREATE_VM ioctl failed, " | 100 | TEST_ASSERT(vm->fd >= 0, "KVM_CREATE_VM ioctl failed, " |
| 96 | "rc: %i errno: %i", vm->fd, errno); | 101 | "rc: %i errno: %i", vm->fd, errno); |
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c index f28127f4a3af..b363c9611bd6 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c | |||
| @@ -1030,6 +1030,14 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid) | |||
| 1030 | nested_size, sizeof(state->nested_)); | 1030 | nested_size, sizeof(state->nested_)); |
| 1031 | } | 1031 | } |
| 1032 | 1032 | ||
| 1033 | /* | ||
| 1034 | * When KVM exits to userspace with KVM_EXIT_IO, KVM guarantees | ||
| 1035 | * guest state is consistent only after userspace re-enters the | ||
| 1036 | * kernel with KVM_RUN. Complete IO prior to migrating state | ||
| 1037 | * to a new VM. | ||
| 1038 | */ | ||
| 1039 | vcpu_run_complete_io(vm, vcpuid); | ||
| 1040 | |||
| 1033 | nmsrs = kvm_get_num_msrs(vm); | 1041 | nmsrs = kvm_get_num_msrs(vm); |
| 1034 | list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0])); | 1042 | list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0])); |
| 1035 | list->nmsrs = nmsrs; | 1043 | list->nmsrs = nmsrs; |
diff --git a/tools/testing/selftests/kvm/x86_64/evmcs_test.c b/tools/testing/selftests/kvm/x86_64/evmcs_test.c index c49c2a28b0eb..36669684eca5 100644 --- a/tools/testing/selftests/kvm/x86_64/evmcs_test.c +++ b/tools/testing/selftests/kvm/x86_64/evmcs_test.c | |||
| @@ -123,8 +123,6 @@ int main(int argc, char *argv[]) | |||
| 123 | stage, run->exit_reason, | 123 | stage, run->exit_reason, |
| 124 | exit_reason_str(run->exit_reason)); | 124 | exit_reason_str(run->exit_reason)); |
| 125 | 125 | ||
| 126 | memset(®s1, 0, sizeof(regs1)); | ||
| 127 | vcpu_regs_get(vm, VCPU_ID, ®s1); | ||
| 128 | switch (get_ucall(vm, VCPU_ID, &uc)) { | 126 | switch (get_ucall(vm, VCPU_ID, &uc)) { |
| 129 | case UCALL_ABORT: | 127 | case UCALL_ABORT: |
| 130 | TEST_ASSERT(false, "%s at %s:%d", (const char *)uc.args[0], | 128 | TEST_ASSERT(false, "%s at %s:%d", (const char *)uc.args[0], |
| @@ -144,6 +142,9 @@ int main(int argc, char *argv[]) | |||
| 144 | stage, (ulong)uc.args[1]); | 142 | stage, (ulong)uc.args[1]); |
| 145 | 143 | ||
| 146 | state = vcpu_save_state(vm, VCPU_ID); | 144 | state = vcpu_save_state(vm, VCPU_ID); |
| 145 | memset(®s1, 0, sizeof(regs1)); | ||
| 146 | vcpu_regs_get(vm, VCPU_ID, ®s1); | ||
| 147 | |||
| 147 | kvm_vm_release(vm); | 148 | kvm_vm_release(vm); |
| 148 | 149 | ||
| 149 | /* Restore state in a new VM. */ | 150 | /* Restore state in a new VM. */ |
diff --git a/tools/testing/selftests/kvm/x86_64/state_test.c b/tools/testing/selftests/kvm/x86_64/state_test.c index 30f75856cf39..e0a3c0204b7c 100644 --- a/tools/testing/selftests/kvm/x86_64/state_test.c +++ b/tools/testing/selftests/kvm/x86_64/state_test.c | |||
| @@ -134,11 +134,6 @@ int main(int argc, char *argv[]) | |||
| 134 | 134 | ||
| 135 | struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); | 135 | struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); |
| 136 | 136 | ||
| 137 | if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) { | ||
| 138 | fprintf(stderr, "immediate_exit not available, skipping test\n"); | ||
| 139 | exit(KSFT_SKIP); | ||
| 140 | } | ||
| 141 | |||
| 142 | /* Create VM */ | 137 | /* Create VM */ |
| 143 | vm = vm_create_default(VCPU_ID, 0, guest_code); | 138 | vm = vm_create_default(VCPU_ID, 0, guest_code); |
| 144 | vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); | 139 | vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); |
| @@ -179,18 +174,10 @@ int main(int argc, char *argv[]) | |||
| 179 | uc.args[1] == stage, "Unexpected register values vmexit #%lx, got %lx", | 174 | uc.args[1] == stage, "Unexpected register values vmexit #%lx, got %lx", |
| 180 | stage, (ulong)uc.args[1]); | 175 | stage, (ulong)uc.args[1]); |
| 181 | 176 | ||
| 182 | /* | 177 | state = vcpu_save_state(vm, VCPU_ID); |
| 183 | * When KVM exits to userspace with KVM_EXIT_IO, KVM guarantees | ||
| 184 | * guest state is consistent only after userspace re-enters the | ||
| 185 | * kernel with KVM_RUN. Complete IO prior to migrating state | ||
| 186 | * to a new VM. | ||
| 187 | */ | ||
| 188 | vcpu_run_complete_io(vm, VCPU_ID); | ||
| 189 | |||
| 190 | memset(®s1, 0, sizeof(regs1)); | 178 | memset(®s1, 0, sizeof(regs1)); |
| 191 | vcpu_regs_get(vm, VCPU_ID, ®s1); | 179 | vcpu_regs_get(vm, VCPU_ID, ®s1); |
| 192 | 180 | ||
| 193 | state = vcpu_save_state(vm, VCPU_ID); | ||
| 194 | kvm_vm_release(vm); | 181 | kvm_vm_release(vm); |
| 195 | 182 | ||
| 196 | /* Restore state in a new VM. */ | 183 | /* Restore state in a new VM. */ |
