Lines Matching +full:3 +full:v
77 struct vm_gic v; in vm_gic_create_with_vcpus() local
79 v.gic_dev_type = gic_dev_type; in vm_gic_create_with_vcpus()
80 v.vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); in vm_gic_create_with_vcpus()
81 v.gic_fd = kvm_create_device(v.vm, gic_dev_type); in vm_gic_create_with_vcpus()
83 return v; in vm_gic_create_with_vcpus()
88 struct vm_gic v; in vm_gic_create_barebones() local
90 v.gic_dev_type = gic_dev_type; in vm_gic_create_barebones()
91 v.vm = vm_create_barebones(); in vm_gic_create_barebones()
92 v.gic_fd = kvm_create_device(v.vm, gic_dev_type); in vm_gic_create_barebones()
94 return v; in vm_gic_create_barebones()
98 static void vm_gic_destroy(struct vm_gic *v) in vm_gic_destroy() argument
100 close(v->gic_fd); in vm_gic_destroy()
101 kvm_vm_free(v->vm); in vm_gic_destroy()
142 static void subtest_dist_rdist(struct vm_gic *v) in subtest_dist_rdist() argument
149 rdist = VGIC_DEV_IS_V3(v->gic_dev_type) ? gic_v3_redist_region in subtest_dist_rdist()
151 dist = VGIC_DEV_IS_V3(v->gic_dev_type) ? gic_v3_dist_region in subtest_dist_rdist()
155 kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, dist.attr); in subtest_dist_rdist()
157 kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, rdist.attr); in subtest_dist_rdist()
160 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, -1); in subtest_dist_rdist()
165 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
170 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
176 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
180 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
186 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
193 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
198 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
202 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
207 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
218 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
223 static void subtest_v3_redist_regions(struct vm_gic *v) in subtest_v3_redist_regions() argument
228 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
233 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
238 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
243 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
249 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
254 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
258 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
263 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
269 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
274 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
278 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
285 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
291 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
305 ret = __kvm_device_attr_get(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
311 ret = __kvm_device_attr_get(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
316 ret = __kvm_device_attr_get(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
321 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
325 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
337 struct vm_gic v; in test_vgic_then_vcpus() local
340 v = vm_gic_create_with_vcpus(gic_dev_type, 1, vcpus); in test_vgic_then_vcpus()
342 subtest_dist_rdist(&v); in test_vgic_then_vcpus()
346 vcpus[i] = vm_vcpu_add(v.vm, i, guest_code); in test_vgic_then_vcpus()
348 ret = run_vcpu(vcpus[3]); in test_vgic_then_vcpus()
351 vm_gic_destroy(&v); in test_vgic_then_vcpus()
358 struct vm_gic v; in test_vcpus_then_vgic() local
361 v = vm_gic_create_with_vcpus(gic_dev_type, NR_VCPUS, vcpus); in test_vcpus_then_vgic()
363 subtest_dist_rdist(&v); in test_vcpus_then_vgic()
365 ret = run_vcpu(vcpus[3]); in test_vcpus_then_vgic()
368 vm_gic_destroy(&v); in test_vcpus_then_vgic()
379 struct vm_gic v; in test_v2_uaccess_cpuif_no_vcpus() local
383 v = vm_gic_create_barebones(KVM_DEV_TYPE_ARM_VGIC_V2); in test_v2_uaccess_cpuif_no_vcpus()
384 subtest_dist_rdist(&v); in test_v2_uaccess_cpuif_no_vcpus()
386 ret = __kvm_has_device_attr(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CPU_REGS, in test_v2_uaccess_cpuif_no_vcpus()
391 ret = __kvm_device_attr_get(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CPU_REGS, in test_v2_uaccess_cpuif_no_vcpus()
396 ret = __kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CPU_REGS, in test_v2_uaccess_cpuif_no_vcpus()
402 vm_gic_destroy(&v); in test_v2_uaccess_cpuif_no_vcpus()
409 struct vm_gic v; in test_v3_new_redist_regions() local
413 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
414 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
415 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_new_redist_regions()
418 ret = run_vcpu(vcpus[3]); in test_v3_new_redist_regions()
420 vm_gic_destroy(&v); in test_v3_new_redist_regions()
424 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
425 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
428 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
431 ret = run_vcpu(vcpus[3]); in test_v3_new_redist_regions()
434 vm_gic_destroy(&v); in test_v3_new_redist_regions()
436 /* step 3 */ in test_v3_new_redist_regions()
438 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
439 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
441 ret = __kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
447 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
450 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_new_redist_regions()
453 ret = run_vcpu(vcpus[3]); in test_v3_new_redist_regions()
456 vm_gic_destroy(&v); in test_v3_new_redist_regions()
461 struct vm_gic v; in test_v3_typer_accesses() local
465 v.vm = vm_create(NR_VCPUS); in test_v3_typer_accesses()
466 (void)vm_vcpu_add(v.vm, 0, guest_code); in test_v3_typer_accesses()
468 v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3); in test_v3_typer_accesses()
470 (void)vm_vcpu_add(v.vm, 3, guest_code); in test_v3_typer_accesses()
472 v3_redist_reg_get_errno(v.gic_fd, 1, GICR_TYPER, EINVAL, in test_v3_typer_accesses()
475 (void)vm_vcpu_add(v.vm, 1, guest_code); in test_v3_typer_accesses()
477 v3_redist_reg_get_errno(v.gic_fd, 1, GICR_TYPER, EBUSY, in test_v3_typer_accesses()
480 (void)vm_vcpu_add(v.vm, 2, guest_code); in test_v3_typer_accesses()
482 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_typer_accesses()
486 v3_redist_reg_get(v.gic_fd, i, GICR_TYPER, i * 0x100, in test_v3_typer_accesses()
491 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
494 /* The 2 first rdists should be put there (vcpu 0 and 3) */ in test_v3_typer_accesses()
495 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x0, "read typer of rdist #0"); in test_v3_typer_accesses()
496 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x310, "read typer of rdist #1"); in test_v3_typer_accesses()
499 ret = __kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
503 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, in test_v3_typer_accesses()
505 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x200, in test_v3_typer_accesses()
509 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
512 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #1"); in test_v3_typer_accesses()
513 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x210, in test_v3_typer_accesses()
516 vm_gic_destroy(&v); in test_v3_typer_accesses()
522 struct vm_gic v; in vm_gic_v3_create_with_vcpuids() local
525 v.vm = vm_create(nr_vcpus); in vm_gic_v3_create_with_vcpuids()
527 vm_vcpu_add(v.vm, vcpuids[i], guest_code); in vm_gic_v3_create_with_vcpuids()
529 v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3); in vm_gic_v3_create_with_vcpuids()
531 return v; in vm_gic_v3_create_with_vcpuids()
538 * rdists: 0, 3 (Last)
546 uint32_t vcpuids[] = { 0, 3, 5, 4, 1, 2 }; in test_v3_last_bit_redist_regions()
547 struct vm_gic v; in test_v3_last_bit_redist_regions() local
550 v = vm_gic_v3_create_with_vcpuids(ARRAY_SIZE(vcpuids), vcpuids); in test_v3_last_bit_redist_regions()
552 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_last_bit_redist_regions()
556 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
560 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
564 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
567 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x000, "read typer of rdist #0"); in test_v3_last_bit_redist_regions()
568 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #1"); in test_v3_last_bit_redist_regions()
569 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x200, "read typer of rdist #2"); in test_v3_last_bit_redist_regions()
570 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x310, "read typer of rdist #3"); in test_v3_last_bit_redist_regions()
571 v3_redist_reg_get(v.gic_fd, 5, GICR_TYPER, 0x500, "read typer of rdist #5"); in test_v3_last_bit_redist_regions()
572 v3_redist_reg_get(v.gic_fd, 4, GICR_TYPER, 0x410, "read typer of rdist #4"); in test_v3_last_bit_redist_regions()
574 vm_gic_destroy(&v); in test_v3_last_bit_redist_regions()
580 uint32_t vcpuids[] = { 0, 3, 5, 4, 1, 2 }; in test_v3_last_bit_single_rdist()
581 struct vm_gic v; in test_v3_last_bit_single_rdist() local
584 v = vm_gic_v3_create_with_vcpuids(ARRAY_SIZE(vcpuids), vcpuids); in test_v3_last_bit_single_rdist()
586 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_last_bit_single_rdist()
590 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_single_rdist()
593 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x000, "read typer of rdist #0"); in test_v3_last_bit_single_rdist()
594 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x300, "read typer of rdist #1"); in test_v3_last_bit_single_rdist()
595 v3_redist_reg_get(v.gic_fd, 5, GICR_TYPER, 0x500, "read typer of rdist #2"); in test_v3_last_bit_single_rdist()
596 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #3"); in test_v3_last_bit_single_rdist()
597 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x210, "read typer of rdist #3"); in test_v3_last_bit_single_rdist()
599 vm_gic_destroy(&v); in test_v3_last_bit_single_rdist()
606 struct vm_gic v; in test_v3_redist_ipa_range_check_at_vcpu_run() local
610 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, 1, vcpus); in test_v3_redist_ipa_range_check_at_vcpu_run()
612 /* Set space for 3 redists, we have 1 vcpu, so this succeeds. */ in test_v3_redist_ipa_range_check_at_vcpu_run()
613 addr = max_phys_size - (3 * 2 * 0x10000); in test_v3_redist_ipa_range_check_at_vcpu_run()
614 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_redist_ipa_range_check_at_vcpu_run()
618 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_redist_ipa_range_check_at_vcpu_run()
623 vcpus[i] = vm_vcpu_add(v.vm, i, guest_code); in test_v3_redist_ipa_range_check_at_vcpu_run()
625 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_redist_ipa_range_check_at_vcpu_run()
633 vm_gic_destroy(&v); in test_v3_redist_ipa_range_check_at_vcpu_run()
639 struct vm_gic v; in test_v3_its_region() local
643 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_its_region()
644 its_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_ITS); in test_v3_its_region()
675 vm_gic_destroy(&v); in test_v3_its_region()
684 struct vm_gic v; in test_kvm_device() local
688 v.vm = vm_create_with_vcpus(NR_VCPUS, guest_code, vcpus); in test_kvm_device()
691 ret = __kvm_test_create_device(v.vm, 0); in test_kvm_device()
695 ret = __kvm_test_create_device(v.vm, gic_dev_type); in test_kvm_device()
698 v.gic_fd = kvm_create_device(v.vm, gic_dev_type); in test_kvm_device()
700 ret = __kvm_create_device(v.vm, gic_dev_type); in test_kvm_device()
707 if (!__kvm_test_create_device(v.vm, other)) { in test_kvm_device()
708 ret = __kvm_create_device(v.vm, other); in test_kvm_device()
713 vm_gic_destroy(&v); in test_kvm_device()