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 <reijiw@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220917010600.532642-4-reijiw@google.com
This commit is contained in:
parent
370531d1e9
commit
ff00e73709
|
@ -246,7 +246,7 @@ static int debug_version(struct kvm_vcpu *vcpu)
|
||||||
return id_aa64dfr0 & 0xf;
|
return id_aa64dfr0 & 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
static void test_guest_debug_exceptions(void)
|
||||||
{
|
{
|
||||||
struct kvm_vcpu *vcpu;
|
struct kvm_vcpu *vcpu;
|
||||||
struct kvm_vm *vm;
|
struct kvm_vm *vm;
|
||||||
|
@ -259,9 +259,6 @@ int main(int argc, char *argv[])
|
||||||
vm_init_descriptor_tables(vm);
|
vm_init_descriptor_tables(vm);
|
||||||
vcpu_init_descriptor_tables(vcpu);
|
vcpu_init_descriptor_tables(vcpu);
|
||||||
|
|
||||||
__TEST_REQUIRE(debug_version(vcpu) >= 6,
|
|
||||||
"Armv8 debug architecture not supported.");
|
|
||||||
|
|
||||||
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
|
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
|
||||||
ESR_EC_BRK_INS, guest_sw_bp_handler);
|
ESR_EC_BRK_INS, guest_sw_bp_handler);
|
||||||
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
|
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
|
||||||
|
@ -294,5 +291,18 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
done:
|
done:
|
||||||
kvm_vm_free(vm);
|
kvm_vm_free(vm);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct kvm_vcpu *vcpu;
|
||||||
|
struct kvm_vm *vm;
|
||||||
|
|
||||||
|
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
|
||||||
|
__TEST_REQUIRE(debug_version(vcpu) >= 6,
|
||||||
|
"Armv8 debug architecture not supported.");
|
||||||
|
kvm_vm_free(vm);
|
||||||
|
test_guest_debug_exceptions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue