Skip to content

Commit a6983e8

Browse files
huthsean-jc
authored andcommitted
KVM: selftests: x86: Use TAP interface in the fix_hypercall test
Use the kvm_test_harness.h interface in this test to get TAP output, so that it is easier for the user to see what the test is doing. Signed-off-by: Thomas Huth <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent ba97ed0 commit a6983e8

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/stringify.h>
1010
#include <stdint.h>
1111

12+
#include "kvm_test_harness.h"
1213
#include "apic.h"
1314
#include "test_util.h"
1415
#include "kvm_util.h"
@@ -83,6 +84,8 @@ static void guest_main(void)
8384
GUEST_DONE();
8485
}
8586

87+
KVM_ONE_VCPU_TEST_SUITE(fix_hypercall);
88+
8689
static void enter_guest(struct kvm_vcpu *vcpu)
8790
{
8891
struct kvm_run *run = vcpu->run;
@@ -103,14 +106,11 @@ static void enter_guest(struct kvm_vcpu *vcpu)
103106
}
104107
}
105108

106-
static void test_fix_hypercall(bool disable_quirk)
109+
static void test_fix_hypercall(struct kvm_vcpu *vcpu, bool disable_quirk)
107110
{
108-
struct kvm_vcpu *vcpu;
109-
struct kvm_vm *vm;
110-
111-
vm = vm_create_with_one_vcpu(&vcpu, guest_main);
111+
struct kvm_vm *vm = vcpu->vm;
112112

113-
vm_init_descriptor_tables(vcpu->vm);
113+
vm_init_descriptor_tables(vm);
114114
vcpu_init_descriptor_tables(vcpu);
115115
vm_install_exception_handler(vcpu->vm, UD_VECTOR, guest_ud_handler);
116116

@@ -126,10 +126,19 @@ static void test_fix_hypercall(bool disable_quirk)
126126
enter_guest(vcpu);
127127
}
128128

129-
int main(void)
129+
KVM_ONE_VCPU_TEST(fix_hypercall, enable_quirk, guest_main)
130+
{
131+
test_fix_hypercall(vcpu, false);
132+
}
133+
134+
KVM_ONE_VCPU_TEST(fix_hypercall, disable_quirk, guest_main)
135+
{
136+
test_fix_hypercall(vcpu, true);
137+
}
138+
139+
int main(int argc, char *argv[])
130140
{
131141
TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & KVM_X86_QUIRK_FIX_HYPERCALL_INSN);
132142

133-
test_fix_hypercall(false);
134-
test_fix_hypercall(true);
143+
return test_harness_run(argc, argv);
135144
}

0 commit comments

Comments
 (0)