Skip to content

Commit d5edb7f

Browse files
committed
kvm: selftests: add vmx_tsc_adjust_test
The test checks the behavior of setting MSR_IA32_TSC in a nested guest, and the TSC_OFFSET VMCS field in general. It also introduces the testing infrastructure for Intel nested virtualization. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent dd25993 commit d5edb7f

File tree

6 files changed

+991
-13
lines changed

6 files changed

+991
-13
lines changed

tools/testing/selftests/kvm/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ top_srcdir = ../../../../
44
UNAME_M := $(shell uname -m)
55

66
LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/sparsebit.c
7-
LIBKVM_x86_64 = lib/x86.c
7+
LIBKVM_x86_64 = lib/x86.c lib/vmx.c
88

99
TEST_GEN_PROGS_x86_64 = set_sregs_test
1010
TEST_GEN_PROGS_x86_64 += sync_regs_test
11+
TEST_GEN_PROGS_x86_64 += vmx_tsc_adjust_test
1112

1213
TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
1314
LIBKVM += $(LIBKVM_$(UNAME_M))

tools/testing/selftests/kvm/include/kvm_util.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,27 @@ void virt_pg_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
112112
vm_paddr_t vm_phy_page_alloc(struct kvm_vm *vm,
113113
vm_paddr_t paddr_min, uint32_t memslot);
114114

115-
void kvm_get_supported_cpuid(struct kvm_cpuid2 *cpuid);
115+
struct kvm_cpuid2 *kvm_get_supported_cpuid(void);
116116
void vcpu_set_cpuid(
117117
struct kvm_vm *vm, uint32_t vcpuid, struct kvm_cpuid2 *cpuid);
118118

119-
struct kvm_cpuid2 *allocate_kvm_cpuid2(void);
120119
struct kvm_cpuid_entry2 *
121-
find_cpuid_index_entry(struct kvm_cpuid2 *cpuid, uint32_t function,
122-
uint32_t index);
120+
kvm_get_supported_cpuid_index(uint32_t function, uint32_t index);
123121

124122
static inline struct kvm_cpuid_entry2 *
125-
find_cpuid_entry(struct kvm_cpuid2 *cpuid, uint32_t function)
123+
kvm_get_supported_cpuid_entry(uint32_t function)
126124
{
127-
return find_cpuid_index_entry(cpuid, function, 0);
125+
return kvm_get_supported_cpuid_index(function, 0);
128126
}
129127

130128
struct kvm_vm *vm_create_default(uint32_t vcpuid, void *guest_code);
131129
void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code);
132130

131+
typedef void (*vmx_guest_code_t)(vm_vaddr_t vmxon_vaddr,
132+
vm_paddr_t vmxon_paddr,
133+
vm_vaddr_t vmcs_vaddr,
134+
vm_paddr_t vmcs_paddr);
135+
133136
struct kvm_userspace_memory_region *
134137
kvm_userspace_memory_region_find(struct kvm_vm *vm, uint64_t start,
135138
uint64_t end);

0 commit comments

Comments
 (0)