summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/include/x86_64
diff options
context:
space:
mode:
authorIsaku Yamahata <isaku.yamahata@intel.com>2024-06-12 11:16:12 -0700
committerSean Christopherson <seanjc@google.com>2024-06-28 15:21:43 -0700
commit82222ee7e84cb03158935e053c4c4960ac1debbd (patch)
tree1a3ada46e16f0074c6367e1cc7152e9d59fcfc97 /tools/testing/selftests/kvm/include/x86_64
parent6b878cbb87bf4fc4c07906ada431624911e3d85a (diff)
downloadlinux-82222ee7e84cb03158935e053c4c4960ac1debbd.tar.gz
linux-82222ee7e84cb03158935e053c4c4960ac1debbd.zip
KVM: selftests: Add test for configure of x86 APIC bus frequency
Test if KVM emulates the APIC bus clock at the expected frequency when userspace configures the frequency via KVM_CAP_X86_APIC_BUS_CYCLES_NS. Set APIC timer's initial count to the maximum value and busy wait for 100 msec (largely arbitrary) using the TSC. Read the APIC timer's "current count" to calculate the actual APIC bus clock frequency based on TSC frequency. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> Co-developed-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/r/2fccf35715b5ba8aec5e5708d86ad7015b8d74e6.1718214999.git.reinette.chatre@intel.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/x86_64')
-rw-r--r--tools/testing/selftests/kvm/include/x86_64/apic.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/x86_64/apic.h b/tools/testing/selftests/kvm/include/x86_64/apic.h
index bed316fdecd5..0f268b55fa06 100644
--- a/tools/testing/selftests/kvm/include/x86_64/apic.h
+++ b/tools/testing/selftests/kvm/include/x86_64/apic.h
@@ -60,6 +60,14 @@
#define APIC_VECTOR_MASK 0x000FF
#define APIC_ICR2 0x310
#define SET_APIC_DEST_FIELD(x) ((x) << 24)
+#define APIC_LVTT 0x320
+#define APIC_LVT_TIMER_ONESHOT (0 << 17)
+#define APIC_LVT_TIMER_PERIODIC (1 << 17)
+#define APIC_LVT_TIMER_TSCDEADLINE (2 << 17)
+#define APIC_LVT_MASKED (1 << 16)
+#define APIC_TMICT 0x380
+#define APIC_TMCCT 0x390
+#define APIC_TDCR 0x3E0
void apic_disable(void);
void xapic_enable(void);