Lines Matching +full:clock +full:- +full:accuracy
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Tests for Hyper-V clocksources
59 /* For increased accuracy, take mean rdtsc() before and afrer rdmsr() */ in check_tsc_msr_rdtsc()
71 delta_ns = ((t2 - t1) * 100) - ((r2 - r1) * 1000000000 / tsc_freq); in check_tsc_msr_rdtsc()
73 delta_ns = -delta_ns; in check_tsc_msr_rdtsc()
76 GUEST_ASSERT(delta_ns * 100 < (t2 - t1) * 100); in check_tsc_msr_rdtsc()
81 return mul_u64_u64_shr64(rdtsc(), tsc_page->tsc_scale) + tsc_page->tsc_offset; in get_tscpage_ts()
93 GUEST_ASSERT(r1 >= t1 && r1 - t1 < 100000); in check_tsc_msr_tsc_page()
98 GUEST_ASSERT(r2 >= t1 && r2 - t2 < 100000); in check_tsc_msr_tsc_page()
105 /* Set Guest OS id to enable Hyper-V emulation */ in guest_main()
116 GUEST_ASSERT(tsc_page->tsc_sequence == 0); in guest_main()
117 GUEST_ASSERT(tsc_page->tsc_scale == 0); in guest_main()
118 GUEST_ASSERT(tsc_page->tsc_offset == 0); in guest_main()
124 GUEST_ASSERT(tsc_page->tsc_sequence != 0); in guest_main()
132 tsc_offset = tsc_page->tsc_offset; in guest_main()
139 GUEST_ASSERT(tsc_page->tsc_offset != tsc_offset); in guest_main()
144 * Enable Re-enlightenment and check that TSC page stays constant across in guest_main()
149 tsc_offset = tsc_page->tsc_offset; in guest_main()
150 tsc_scale = tsc_page->tsc_scale; in guest_main()
152 GUEST_ASSERT(tsc_page->tsc_offset == tsc_offset); in guest_main()
153 GUEST_ASSERT(tsc_page->tsc_scale == tsc_scale); in guest_main()
160 * Disable re-enlightenment and TSC page, check that KVM doesn't update in guest_main()
169 GUEST_ASSERT(tsc_page->tsc_sequence == 0); in guest_main()
170 GUEST_ASSERT(tsc_page->tsc_offset == 0); in guest_main()
171 GUEST_ASSERT(tsc_page->tsc_scale == 0); in guest_main()
184 /* For increased accuracy, take mean rdtsc() before and afrer ioctl */ in host_check_tsc_msr_rdtsc()
196 delta_ns = ((t2 - t1) * 100) - ((r2 - r1) * 1000000000 / tsc_freq); in host_check_tsc_msr_rdtsc()
198 delta_ns = -delta_ns; in host_check_tsc_msr_rdtsc()
201 TEST_ASSERT(delta_ns * 100 < (t2 - t1) * 100, in host_check_tsc_msr_rdtsc()
203 (t2 - t1) * 100, (r2 - r1) * 1000000000 / tsc_freq); in host_check_tsc_msr_rdtsc()
223 TEST_ASSERT((addr_gva2gpa(vm, tsc_page_gva) & (getpagesize() - 1)) == 0, in main()
255 struct kvm_clock_data clock = {0}; in main() local
257 vm_ioctl(vm, KVM_SET_CLOCK, &clock); in main()