[PATCH v2 2/2] KVM: selftests: Reject GICv3 ITS with a GICv5 VGIC
Sascha Bischoff
sascha.bischoff at arm.com
Mon Oct 19 06:42:42 PDT 2026
Check that a GICv3 ITS and a GICv5 VGIC cannot be paired, regardless
of which device is created first. Skip the check when the host does not
expose a GICv3 ITS.
Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
---
tools/testing/selftests/kvm/arm64/vgic_v5.c | 32 +++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tools/testing/selftests/kvm/arm64/vgic_v5.c b/tools/testing/selftests/kvm/arm64/vgic_v5.c
index d5df742b23001..5bf7d99d29147 100644
--- a/tools/testing/selftests/kvm/arm64/vgic_v5.c
+++ b/tools/testing/selftests/kvm/arm64/vgic_v5.c
@@ -2003,8 +2003,40 @@ int test_kvm_device(u32 gic_dev_type)
return 0;
}
+static void test_vgic_v3_its_with_vgic_v5(void)
+{
+ struct kvm_vm *vm = vm_create_barebones();
+ int gic_fd, its_fd, ret;
+
+ if (__kvm_test_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_ITS)) {
+ pr_info("No GICv3 ITS support; skipping mixed-model test.\n");
+ kvm_vm_free(vm);
+ return;
+ }
+
+ gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V5);
+ ret = __kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_ITS);
+ TEST_ASSERT(ret < 0 && errno == ENODEV,
+ "GICv3 ITS created after GICv5 VGIC: ret=%d errno=%d",
+ ret, errno);
+ close(gic_fd);
+ kvm_vm_free(vm);
+
+ vm = vm_create_barebones();
+ its_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_ITS);
+ ret = __kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V5);
+ TEST_ASSERT(ret < 0 && errno == ENODEV,
+ "GICv5 VGIC created after GICv3 ITS: ret=%d errno=%d",
+ ret, errno);
+ close(its_fd);
+ kvm_vm_free(vm);
+}
+
void run_tests(u32 gic_dev_type)
{
+ pr_info("Test VGICv5 and GICv3 ITS model mismatch\n");
+ test_vgic_v3_its_with_vgic_v5();
+
pr_info("Test VGICv5 address attrs\n");
test_vgic_v5_addr_attrs();
--
2.34.1
More information about the linux-arm-kernel
mailing list