Skip to content

Commit d1c2cdc

Browse files
committed
KVM: selftests: Open code vcpu_run() equivalent in guest_printf test
Open code a version of vcpu_run() in the guest_printf test in anticipation of adding UCALL_ABORT handling to _vcpu_run(). The guest_printf test intentionally generates asserts to verify the output, and thus needs to bypass common assert handling. Open code a helper in the guest_printf test, as it's not expected that any other test would want to skip _only_ the UCALL_ABORT handling. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 73b42dc commit d1c2cdc

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tools/testing/selftests/kvm/guest_print_test.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,29 @@ static void ucall_abort(const char *assert_msg, const char *expected_assert_msg)
107107
expected_assert_msg, &assert_msg[offset]);
108108
}
109109

110+
/*
111+
* Open code vcpu_run(), sans the UCALL_ABORT handling, so that intentional
112+
* guest asserts guest can be verified instead of being reported as failures.
113+
*/
114+
static void do_vcpu_run(struct kvm_vcpu *vcpu)
115+
{
116+
int r;
117+
118+
do {
119+
r = __vcpu_run(vcpu);
120+
} while (r == -1 && errno == EINTR);
121+
122+
TEST_ASSERT(!r, KVM_IOCTL_ERROR(KVM_RUN, r));
123+
}
124+
110125
static void run_test(struct kvm_vcpu *vcpu, const char *expected_printf,
111126
const char *expected_assert)
112127
{
113128
struct kvm_run *run = vcpu->run;
114129
struct ucall uc;
115130

116131
while (1) {
117-
vcpu_run(vcpu);
132+
do_vcpu_run(vcpu);
118133

119134
TEST_ASSERT(run->exit_reason == UCALL_EXIT_REASON,
120135
"Unexpected exit reason: %u (%s),",
@@ -159,7 +174,7 @@ static void test_limits(void)
159174

160175
vm = vm_create_with_one_vcpu(&vcpu, guest_code_limits);
161176
run = vcpu->run;
162-
vcpu_run(vcpu);
177+
do_vcpu_run(vcpu);
163178

164179
TEST_ASSERT(run->exit_reason == UCALL_EXIT_REASON,
165180
"Unexpected exit reason: %u (%s),",

0 commit comments

Comments
 (0)