@@ -76,6 +76,7 @@ TEST_GEN_PROGS_x86_64 += kvm_page_table_test
TEST_GEN_PROGS_x86_64 += memslot_modification_stress_test
TEST_GEN_PROGS_x86_64 += set_memory_region_test
TEST_GEN_PROGS_x86_64 += steal_time
+TEST_GEN_PROGS_x86_64 += system_counter_state_test
TEST_GEN_PROGS_aarch64 += aarch64/counter_emulation_benchmark
TEST_GEN_PROGS_aarch64 += aarch64/get-reg-list
@@ -138,6 +138,38 @@ static uint64_t host_read_guest_counter(struct system_counter_state_test *test)
return r;
}
+#elif __x86_64__
+
+/* no additional information required beyond the counter state. */
+#define system_counter_state_test kvm_system_counter_state
+
+static struct system_counter_state_test test_cases[] = {
+ { .tsc_offset = 0 },
+ { .tsc_offset = 1000000 },
+ { .tsc_offset = -1 },
+};
+
+static void pr_test(struct system_counter_state_test *test)
+{
+ printf("tsc_offset: %lld\n", test->tsc_offset);
+}
+
+static struct kvm_system_counter_state *
+get_system_counter_state(struct system_counter_state_test *test)
+{
+ return test;
+}
+
+static uint64_t guest_read_counter(struct system_counter_state_test *test)
+{
+ return rdtsc();
+}
+
+static uint64_t host_read_guest_counter(struct system_counter_state_test *test)
+{
+ return rdtsc() + test->tsc_offset;
+}
+
#else
#error test not implemented for architecture being built!
#endif