Lines Matching +full:3 +full:v

78 	struct vm_gic v;  in vm_gic_create_with_vcpus()  local
80 v.gic_dev_type = gic_dev_type; in vm_gic_create_with_vcpus()
81 v.vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); in vm_gic_create_with_vcpus()
82 v.gic_fd = kvm_create_device(v.vm, gic_dev_type); in vm_gic_create_with_vcpus()
84 return v; in vm_gic_create_with_vcpus()
87 static void vm_gic_destroy(struct vm_gic *v) in vm_gic_destroy() argument
89 close(v->gic_fd); in vm_gic_destroy()
90 kvm_vm_free(v->vm); in vm_gic_destroy()
131 static void subtest_dist_rdist(struct vm_gic *v) in subtest_dist_rdist() argument
138 rdist = VGIC_DEV_IS_V3(v->gic_dev_type) ? gic_v3_redist_region in subtest_dist_rdist()
140 dist = VGIC_DEV_IS_V3(v->gic_dev_type) ? gic_v3_dist_region in subtest_dist_rdist()
144 kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, dist.attr); in subtest_dist_rdist()
146 kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, rdist.attr); in subtest_dist_rdist()
149 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, -1); in subtest_dist_rdist()
154 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
159 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
165 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
169 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
175 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
182 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
187 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
191 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
196 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
207 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
212 static void subtest_v3_redist_regions(struct vm_gic *v) in subtest_v3_redist_regions() argument
217 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
222 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
227 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
232 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 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
247 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
252 ret = __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 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
267 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
274 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
280 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
294 ret = __kvm_device_attr_get(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
300 ret = __kvm_device_attr_get(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()
310 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
314 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
326 struct vm_gic v; in test_vgic_then_vcpus() local
329 v = vm_gic_create_with_vcpus(gic_dev_type, 1, vcpus); in test_vgic_then_vcpus()
331 subtest_dist_rdist(&v); in test_vgic_then_vcpus()
335 vcpus[i] = vm_vcpu_add(v.vm, i, guest_code); in test_vgic_then_vcpus()
337 ret = run_vcpu(vcpus[3]); in test_vgic_then_vcpus()
340 vm_gic_destroy(&v); in test_vgic_then_vcpus()
347 struct vm_gic v; in test_vcpus_then_vgic() local
350 v = vm_gic_create_with_vcpus(gic_dev_type, NR_VCPUS, vcpus); in test_vcpus_then_vgic()
352 subtest_dist_rdist(&v); in test_vcpus_then_vgic()
354 ret = run_vcpu(vcpus[3]); in test_vcpus_then_vgic()
357 vm_gic_destroy(&v); in test_vcpus_then_vgic()
364 struct vm_gic v; in test_v3_new_redist_regions() local
368 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
369 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
370 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_new_redist_regions()
373 ret = run_vcpu(vcpus[3]); in test_v3_new_redist_regions()
375 vm_gic_destroy(&v); in test_v3_new_redist_regions()
379 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
380 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
383 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
386 ret = run_vcpu(vcpus[3]); in test_v3_new_redist_regions()
389 vm_gic_destroy(&v); in test_v3_new_redist_regions()
391 /* step 3 */ in test_v3_new_redist_regions()
393 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
394 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
396 ret = __kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
402 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
405 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_new_redist_regions()
408 ret = run_vcpu(vcpus[3]); in test_v3_new_redist_regions()
411 vm_gic_destroy(&v); in test_v3_new_redist_regions()
416 struct vm_gic v; in test_v3_typer_accesses() local
420 v.vm = vm_create(NR_VCPUS); in test_v3_typer_accesses()
421 (void)vm_vcpu_add(v.vm, 0, guest_code); in test_v3_typer_accesses()
423 v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3); in test_v3_typer_accesses()
425 (void)vm_vcpu_add(v.vm, 3, guest_code); in test_v3_typer_accesses()
427 v3_redist_reg_get_errno(v.gic_fd, 1, GICR_TYPER, EINVAL, in test_v3_typer_accesses()
430 (void)vm_vcpu_add(v.vm, 1, guest_code); in test_v3_typer_accesses()
432 v3_redist_reg_get_errno(v.gic_fd, 1, GICR_TYPER, EBUSY, in test_v3_typer_accesses()
435 (void)vm_vcpu_add(v.vm, 2, guest_code); in test_v3_typer_accesses()
437 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_typer_accesses()
441 v3_redist_reg_get(v.gic_fd, i, GICR_TYPER, i * 0x100, in test_v3_typer_accesses()
446 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
449 /* The 2 first rdists should be put there (vcpu 0 and 3) */ in test_v3_typer_accesses()
450 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x0, "read typer of rdist #0"); in test_v3_typer_accesses()
451 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x310, "read typer of rdist #1"); in test_v3_typer_accesses()
454 ret = __kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
458 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, in test_v3_typer_accesses()
460 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x200, in test_v3_typer_accesses()
464 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
467 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #1"); in test_v3_typer_accesses()
468 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x210, in test_v3_typer_accesses()
471 vm_gic_destroy(&v); in test_v3_typer_accesses()
477 struct vm_gic v; in vm_gic_v3_create_with_vcpuids() local
480 v.vm = vm_create(nr_vcpus); in vm_gic_v3_create_with_vcpuids()
482 vm_vcpu_add(v.vm, vcpuids[i], guest_code); in vm_gic_v3_create_with_vcpuids()
484 v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3); in vm_gic_v3_create_with_vcpuids()
486 return v; in vm_gic_v3_create_with_vcpuids()
493 * rdists: 0, 3 (Last)
501 uint32_t vcpuids[] = { 0, 3, 5, 4, 1, 2 }; in test_v3_last_bit_redist_regions()
502 struct vm_gic v; in test_v3_last_bit_redist_regions() local
505 v = vm_gic_v3_create_with_vcpuids(ARRAY_SIZE(vcpuids), vcpuids); in test_v3_last_bit_redist_regions()
507 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_last_bit_redist_regions()
511 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
515 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
519 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
522 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x000, "read typer of rdist #0"); in test_v3_last_bit_redist_regions()
523 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #1"); in test_v3_last_bit_redist_regions()
524 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x200, "read typer of rdist #2"); in test_v3_last_bit_redist_regions()
525 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x310, "read typer of rdist #3"); in test_v3_last_bit_redist_regions()
526 v3_redist_reg_get(v.gic_fd, 5, GICR_TYPER, 0x500, "read typer of rdist #5"); in test_v3_last_bit_redist_regions()
527 v3_redist_reg_get(v.gic_fd, 4, GICR_TYPER, 0x410, "read typer of rdist #4"); in test_v3_last_bit_redist_regions()
529 vm_gic_destroy(&v); in test_v3_last_bit_redist_regions()
535 uint32_t vcpuids[] = { 0, 3, 5, 4, 1, 2 }; in test_v3_last_bit_single_rdist()
536 struct vm_gic v; in test_v3_last_bit_single_rdist() local
539 v = vm_gic_v3_create_with_vcpuids(ARRAY_SIZE(vcpuids), vcpuids); in test_v3_last_bit_single_rdist()
541 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_last_bit_single_rdist()
545 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_single_rdist()
548 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x000, "read typer of rdist #0"); in test_v3_last_bit_single_rdist()
549 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x300, "read typer of rdist #1"); in test_v3_last_bit_single_rdist()
550 v3_redist_reg_get(v.gic_fd, 5, GICR_TYPER, 0x500, "read typer of rdist #2"); in test_v3_last_bit_single_rdist()
551 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #3"); in test_v3_last_bit_single_rdist()
552 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x210, "read typer of rdist #3"); in test_v3_last_bit_single_rdist()
554 vm_gic_destroy(&v); in test_v3_last_bit_single_rdist()
561 struct vm_gic v; in test_v3_redist_ipa_range_check_at_vcpu_run() local
565 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, 1, vcpus); in test_v3_redist_ipa_range_check_at_vcpu_run()
567 /* Set space for 3 redists, we have 1 vcpu, so this succeeds. */ in test_v3_redist_ipa_range_check_at_vcpu_run()
568 addr = max_phys_size - (3 * 2 * 0x10000); in test_v3_redist_ipa_range_check_at_vcpu_run()
569 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_redist_ipa_range_check_at_vcpu_run()
573 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_redist_ipa_range_check_at_vcpu_run()
578 vcpus[i] = vm_vcpu_add(v.vm, i, guest_code); in test_v3_redist_ipa_range_check_at_vcpu_run()
580 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_redist_ipa_range_check_at_vcpu_run()
588 vm_gic_destroy(&v); in test_v3_redist_ipa_range_check_at_vcpu_run()
594 struct vm_gic v; in test_v3_its_region() local
598 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_its_region()
599 its_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_ITS); in test_v3_its_region()
630 vm_gic_destroy(&v); in test_v3_its_region()
639 struct vm_gic v; in test_kvm_device() local
643 v.vm = vm_create_with_vcpus(NR_VCPUS, guest_code, vcpus); in test_kvm_device()
646 ret = __kvm_test_create_device(v.vm, 0); in test_kvm_device()
650 ret = __kvm_test_create_device(v.vm, gic_dev_type); in test_kvm_device()
653 v.gic_fd = kvm_create_device(v.vm, gic_dev_type); in test_kvm_device()
655 ret = __kvm_create_device(v.vm, gic_dev_type); in test_kvm_device()
662 if (!__kvm_test_create_device(v.vm, other)) { in test_kvm_device()
663 ret = __kvm_create_device(v.vm, other); in test_kvm_device()
668 vm_gic_destroy(&v); in test_kvm_device()