KVM: selftests: Add test to verify KVM handling of ICR
authorSean Christopherson <seanjc@google.com>
Fri, 4 Feb 2022 21:42:05 +0000 (21:42 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 1 Mar 2022 13:50:48 +0000 (08:50 -0500)
commit85c68eb429f7fc136b9bbb3646eb38a9e0e30fa2
tree14d433bdf00bec55edde4681724d89d8163a2fd4
parentb9964ee36bdf2ffcbe9084510874c2ff97b3cb46
KVM: selftests: Add test to verify KVM handling of ICR

The main thing that the selftest verifies is that KVM copies x2APIC's
ICR[63:32] to/from ICR2 when userspace accesses the vAPIC page via
KVM_{G,S}ET_LAPIC.  KVM previously split x2APIC ICR to ICR+ICR2 at the
time of write (from the guest), and so KVM must preserve that behavior
for backwards compatibility between different versions of KVM.

It will also test other invariants, e.g. that KVM clears the BUSY
flag on ICR writes, that the reserved bits in ICR2 are dropped on writes
from the guest, etc...

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220204214205.3306634-12-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/.gitignore
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/include/x86_64/apic.h
tools/testing/selftests/kvm/x86_64/xapic_state_test.c [new file with mode: 0644]