Skip to content

Commit ff00e73

Browse files
reijiw-kvmMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Refactor debug-exceptions to make it amenable to new test cases
Split up the current test into a helper, but leave the debug version checking in main(), to make it convenient to add a new debug exception test case in a subsequent patch. Signed-off-by: Reiji Watanabe <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 370531d commit ff00e73

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tools/testing/selftests/kvm/aarch64/debug-exceptions.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static int debug_version(struct kvm_vcpu *vcpu)
246246
return id_aa64dfr0 & 0xf;
247247
}
248248

249-
int main(int argc, char *argv[])
249+
static void test_guest_debug_exceptions(void)
250250
{
251251
struct kvm_vcpu *vcpu;
252252
struct kvm_vm *vm;
@@ -259,9 +259,6 @@ int main(int argc, char *argv[])
259259
vm_init_descriptor_tables(vm);
260260
vcpu_init_descriptor_tables(vcpu);
261261

262-
__TEST_REQUIRE(debug_version(vcpu) >= 6,
263-
"Armv8 debug architecture not supported.");
264-
265262
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
266263
ESR_EC_BRK_INS, guest_sw_bp_handler);
267264
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
@@ -294,5 +291,18 @@ int main(int argc, char *argv[])
294291

295292
done:
296293
kvm_vm_free(vm);
294+
}
295+
296+
int main(int argc, char *argv[])
297+
{
298+
struct kvm_vcpu *vcpu;
299+
struct kvm_vm *vm;
300+
301+
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
302+
__TEST_REQUIRE(debug_version(vcpu) >= 6,
303+
"Armv8 debug architecture not supported.");
304+
kvm_vm_free(vm);
305+
test_guest_debug_exceptions();
306+
297307
return 0;
298308
}

0 commit comments

Comments
 (0)