linux_old1/tools/testing/selftests/kvm/lib
Sean Christopherson 0f73bbc851 KVM: selftests: complete IO before migrating guest state
Documentation/virtual/kvm/api.txt states:

  NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR and
        KVM_EXIT_EPR the corresponding operations are complete (and guest
        state is consistent) only after userspace has re-entered the
        kernel with KVM_RUN.  The kernel side will first finish incomplete
        operations and then check for pending signals.  Userspace can
        re-enter the guest with an unmasked signal pending to complete
        pending operations.

Because guest state may be inconsistent, starting state migration after
an IO exit without first completing IO may result in test failures, e.g.
a proposed change to KVM's handling of %rip in its fast PIO handling[1]
will cause the new VM, i.e. the post-migration VM, to have its %rip set
to the IN instruction that triggered KVM_EXIT_IO, leading to a test
assertion due to a stage mismatch.

For simplicitly, require KVM_CAP_IMMEDIATE_EXIT to complete IO and skip
the test if it's not available.  The addition of KVM_CAP_IMMEDIATE_EXIT
predates the state selftest by more than a year.

[1] https://patchwork.kernel.org/patch/10848545/

Fixes: fa3899add1 ("kvm: selftests: add basic test for state save and restore")
Reported-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-28 17:29:09 +01:00
..
aarch64 kvm: selftests: add pa-48/va-48 VM modes 2018-12-21 11:28:30 +01:00
x86_64 KVM: selftests: add Enlightened VMCS test 2018-10-17 00:30:21 +02:00
assert.c kvm: selftests: move arch-specific files to arch-specific locations 2018-10-17 00:26:16 +02:00
elf.c
io.c
kvm_util.c KVM: selftests: complete IO before migrating guest state 2019-03-28 17:29:09 +01:00
kvm_util_internal.h kvm: selftests: aarch64: dirty_log_test: support greater than 40-bit IPAs 2018-12-21 11:28:30 +01:00
sparsebit.c kvm: selftests: fix spelling mistake: "divisable" and "divisible" 2018-04-10 17:20:03 +02:00
ucall.c kvm: selftests: ucall: fix exit mmio address guessing 2018-12-21 13:58:46 +01:00