mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-17 16:15:18 +00:00
KVM: selftests: aarch64: Skip tests if we can't create a vgic-v3
The arch_timer and vgic_irq kselftests assume that they can create a vgic-v3, using the library function vgic_v3_setup() which aborts with a test failure if it is not possible to do so. Since vgic-v3 can only be instantiated on systems where the host has GICv3 this leads to false positives on older systems where that is not the case. Fix this by changing vgic_v3_setup() to return an error if the vgic can't be instantiated and have the callers skip if this happens. We could also exit flagging a skip in vgic_v3_setup() but this would prevent future test cases conditionally deciding which GIC to use or generally doing more complex output. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Andrew Jones <drjones@redhat.com> Tested-by: Ricardo Koller <ricarkol@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220223131624.1830351-1-broonie@kernel.org
This commit is contained in:
parent
a867e9d0cc
commit
456f89e092
3 changed files with 13 additions and 2 deletions
|
@ -366,6 +366,7 @@ static struct kvm_vm *test_vm_create(void)
|
||||||
{
|
{
|
||||||
struct kvm_vm *vm;
|
struct kvm_vm *vm;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int ret;
|
||||||
int nr_vcpus = test_args.nr_vcpus;
|
int nr_vcpus = test_args.nr_vcpus;
|
||||||
|
|
||||||
vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
|
vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
|
||||||
|
@ -382,7 +383,11 @@ static struct kvm_vm *test_vm_create(void)
|
||||||
|
|
||||||
ucall_init(vm, NULL);
|
ucall_init(vm, NULL);
|
||||||
test_init_timer_irq(vm);
|
test_init_timer_irq(vm);
|
||||||
vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
|
ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
|
||||||
|
if (ret < 0) {
|
||||||
|
print_skip("Failed to create vgic-v3");
|
||||||
|
exit(KSFT_SKIP);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make all the test's cmdline args visible to the guest */
|
/* Make all the test's cmdline args visible to the guest */
|
||||||
sync_global_to_guest(vm, test_args);
|
sync_global_to_guest(vm, test_args);
|
||||||
|
|
|
@ -761,6 +761,10 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
|
||||||
|
|
||||||
gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
|
gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
|
||||||
GICD_BASE_GPA, GICR_BASE_GPA);
|
GICD_BASE_GPA, GICR_BASE_GPA);
|
||||||
|
if (gic_fd < 0) {
|
||||||
|
print_skip("Failed to create vgic-v3, skipping");
|
||||||
|
exit(KSFT_SKIP);
|
||||||
|
}
|
||||||
|
|
||||||
vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT,
|
vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT,
|
||||||
guest_irq_handlers[args.eoi_split][args.level_sensitive]);
|
guest_irq_handlers[args.eoi_split][args.level_sensitive]);
|
||||||
|
|
|
@ -52,7 +52,9 @@ int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs,
|
||||||
nr_vcpus, nr_vcpus_created);
|
nr_vcpus, nr_vcpus_created);
|
||||||
|
|
||||||
/* Distributor setup */
|
/* Distributor setup */
|
||||||
gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false);
|
if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
|
||||||
|
false, &gic_fd) != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
|
kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
|
||||||
0, &nr_irqs, true);
|
0, &nr_irqs, true);
|
||||||
|
|
Loading…
Reference in a new issue