diff options
author | David Woodhouse <dwmw@amazon.co.uk> | 2022-03-09 14:38:35 +0000 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-04-02 05:41:18 -0400 |
commit | a29833e36b43b326e6371c181474119069d6073a (patch) | |
tree | bc9fdb6d7b56c1d319704094799a129f481310ad /tools | |
parent | 25eaeebe710c8c3aa588ee0830155fefb2548c28 (diff) | |
download | linux-a29833e36b43b326e6371c181474119069d6073a.tar.gz linux-a29833e36b43b326e6371c181474119069d6073a.tar.bz2 linux-a29833e36b43b326e6371c181474119069d6073a.zip |
KVM: x86/xen: Update self test for Xen PV timers
Add test cases for timers in the past, and reading the status of a timer
which has already fired.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Message-Id: <20220309143835.253911-3-dwmw2@infradead.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c index 63b0ca7685b0..d9d9d1deec45 100644 --- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c +++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c @@ -325,6 +325,11 @@ static void guest_code(void) guest_wait_for_irq(); GUEST_SYNC(20); + + /* Timer should have fired already */ + guest_wait_for_irq(); + + GUEST_SYNC(21); } static int cmp_timespec(struct timespec *a, struct timespec *b) @@ -746,6 +751,7 @@ int main(int argc, char *argv[]) tmr.u.timer.expires_ns = rs->state_entry_time + 100000000, vcpu_ioctl(vm, VCPU_ID, KVM_XEN_VCPU_SET_ATTR, &tmr); + alarm(1); break; case 19: @@ -753,15 +759,38 @@ int main(int argc, char *argv[]) if (verbose) printf("Testing SCHEDOP_poll wake on unmasked event\n"); - tmr.u.timer.expires_ns = rs->state_entry_time + 100000000, - vcpu_ioctl(vm, VCPU_ID, KVM_XEN_VCPU_SET_ATTR, &tmr); evtchn_irq_expected = true; + tmr.u.timer.expires_ns = rs->state_entry_time + 100000000; + vcpu_ioctl(vm, VCPU_ID, KVM_XEN_VCPU_SET_ATTR, &tmr); + + /* Read it back and check the pending time is reported correctly */ + tmr.u.timer.expires_ns = 0; + vcpu_ioctl(vm, VCPU_ID, KVM_XEN_VCPU_GET_ATTR, &tmr); + TEST_ASSERT(tmr.u.timer.expires_ns == rs->state_entry_time + 100000000, + "Timer not reported pending"); + alarm(1); break; case 20: TEST_ASSERT(!evtchn_irq_expected, "Expected event channel IRQ but it didn't happen"); - shinfo->evtchn_pending[1] = 0; + /* Read timer and check it is no longer pending */ + vcpu_ioctl(vm, VCPU_ID, KVM_XEN_VCPU_GET_ATTR, &tmr); + TEST_ASSERT(!tmr.u.timer.expires_ns, "Timer still reported pending"); + + shinfo->evtchn_pending[0] = 0; + if (verbose) + printf("Testing timer in the past\n"); + + evtchn_irq_expected = true; + tmr.u.timer.expires_ns = rs->state_entry_time - 100000000ULL; + vcpu_ioctl(vm, VCPU_ID, KVM_XEN_VCPU_SET_ATTR, &tmr); + alarm(1); + break; + + case 21: + TEST_ASSERT(!evtchn_irq_expected, + "Expected event channel IRQ but it didn't happen"); goto done; case 0x20: |