[PATCH v3 15/21] KVM: selftests: Sanity check KVM's default TSC freq in nested TSC scaling test
From: Sean Christopherson
Date: Wed Sep 30 2026 - 16:09:42 EST
Explicitly verify that both L1 and L2 can run at KVM's default TSC
frequency reported via KVM_GET_TSC_KHZ, e.g. that KVM_SET_TSC_KHZ can take
in what KVM_GET_TSC_KHZ spits out.
Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
index a8f9307ed2a4..ee8fda310e33 100644
--- a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
@@ -223,6 +223,9 @@ int main(int argc, char *argv[])
tsc_end = rdtsc();
host_check_tsc_freq(0, tsc_end - tsc_start, l0_tsc_freq);
+ /* Sanity check the frequency reported by KVM_GET_TSC_KHZ. */
+ test_tsc_scaling(l0_tsc_freq, l0_tsc_freq, l0_tsc_freq, BIT_ULL(frac_bits));
+
/* Scale L1 "down" and L2 "up" at a random factor from 2 to 10. */
l1_scale = (kvm_random_u32(&kvm_rng) % 9) + 2;
l2_scale = (kvm_random_u32(&kvm_rng) % 9) + 2;
--
2.56.0.rc1.315.gc6ed9934b7-goog