Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: selftests: Add support for GICv2 on v3

The current vgic_init test wrongly assumes that the host cannot
multiple versions of the GIC architecture, while v2 emulation
on v3 has almost always been supported (it was supported before
the standalone v3 emulation).

Tweak the test to support multiple GIC incarnations.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Fixes: 3f4db37e203b ("KVM: arm64: selftests: Make vgic_init gic version agnostic")
Reviewed-by: Ricardo Koller <ricarkol@google.com>
Link: https://lore.kernel.org/r/20220714154108.3531213-1-maz@kernel.org

+8 -5
+8 -5
tools/testing/selftests/kvm/aarch64/vgic_init.c
··· 670 670 671 671 if (!_kvm_create_device(v.vm, other, true, &fd)) { 672 672 ret = _kvm_create_device(v.vm, other, false, &fd); 673 - TEST_ASSERT(ret && errno == EINVAL, 673 + TEST_ASSERT(ret && (errno == EINVAL || errno == EEXIST), 674 674 "create GIC device while other version exists"); 675 675 } 676 676 ··· 698 698 { 699 699 int ret; 700 700 int pa_bits; 701 + int cnt_impl = 0; 701 702 702 703 pa_bits = vm_guest_mode_params[VM_MODE_DEFAULT].pa_bits; 703 704 max_phys_size = 1ULL << pa_bits; ··· 707 706 if (!ret) { 708 707 pr_info("Running GIC_v3 tests.\n"); 709 708 run_tests(KVM_DEV_TYPE_ARM_VGIC_V3); 710 - return 0; 709 + cnt_impl++; 711 710 } 712 711 713 712 ret = test_kvm_device(KVM_DEV_TYPE_ARM_VGIC_V2); 714 713 if (!ret) { 715 714 pr_info("Running GIC_v2 tests.\n"); 716 715 run_tests(KVM_DEV_TYPE_ARM_VGIC_V2); 717 - return 0; 716 + cnt_impl++; 718 717 } 719 718 720 - print_skip("No GICv2 nor GICv3 support"); 721 - exit(KSFT_SKIP); 719 + if (!cnt_impl) { 720 + print_skip("No GICv2 nor GICv3 support"); 721 + exit(KSFT_SKIP); 722 + } 722 723 return 0; 723 724 }