Lines Matching +full:2 +full:v
64 GUEST_SYNC(2); in guest_code()
80 struct vm_gic v; in vm_gic_create_with_vcpus() local
82 v.gic_dev_type = gic_dev_type; in vm_gic_create_with_vcpus()
83 v.vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); in vm_gic_create_with_vcpus()
84 v.gic_fd = kvm_create_device(v.vm, gic_dev_type); in vm_gic_create_with_vcpus()
86 return v; in vm_gic_create_with_vcpus()
89 static void vm_gic_destroy(struct vm_gic *v) in vm_gic_destroy() argument
91 close(v->gic_fd); in vm_gic_destroy()
92 kvm_vm_free(v->vm); in vm_gic_destroy()
133 static void subtest_dist_rdist(struct vm_gic *v) in subtest_dist_rdist() argument
140 rdist = VGIC_DEV_IS_V3(v->gic_dev_type) ? gic_v3_redist_region in subtest_dist_rdist()
142 dist = VGIC_DEV_IS_V3(v->gic_dev_type) ? gic_v3_dist_region in subtest_dist_rdist()
146 kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, dist.attr); in subtest_dist_rdist()
148 kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, rdist.attr); in subtest_dist_rdist()
151 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, -1); in subtest_dist_rdist()
156 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
161 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
167 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
171 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
175 /* Space for half a rdist (a rdist is: 2 * rdist.alignment). */ in subtest_dist_rdist()
177 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
184 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
189 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
193 ret = __kvm_has_device_attr(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()
209 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_dist_rdist()
214 static void subtest_v3_redist_regions(struct vm_gic *v) in subtest_v3_redist_regions() argument
219 ret = __kvm_has_device_attr(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
223 addr = REDIST_REGION_ATTR_ADDR(NR_VCPUS, 0x100000, 2, 0); in subtest_v3_redist_regions()
224 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
229 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
233 addr = REDIST_REGION_ATTR_ADDR(2, 0x200000, 0, 1); in subtest_v3_redist_regions()
234 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
239 addr = REDIST_REGION_ATTR_ADDR(2, 0x201000, 0, 1); in subtest_v3_redist_regions()
240 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
244 addr = REDIST_REGION_ATTR_ADDR(2, 0x200000, 0, 0); in subtest_v3_redist_regions()
245 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
248 addr = REDIST_REGION_ATTR_ADDR(2, 0x200000, 0, 1); 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()
253 addr = REDIST_REGION_ATTR_ADDR(1, 0x210000, 0, 2); in subtest_v3_redist_regions()
254 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
259 addr = REDIST_REGION_ATTR_ADDR(1, 0x240000, 0, 2); in subtest_v3_redist_regions()
260 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
265 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
268 addr = REDIST_REGION_ATTR_ADDR(1, max_phys_size, 0, 2); 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()
275 addr = REDIST_REGION_ATTR_ADDR(2, max_phys_size - 0x30000, 0, 2); in subtest_v3_redist_regions()
276 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
282 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
288 * Now there are 2 redist regions: in subtest_v3_redist_regions()
289 * region 0 @ 0x200000 2 redists in subtest_v3_redist_regions()
295 expected_addr = REDIST_REGION_ATTR_ADDR(2, 0x200000, 0, 0); in subtest_v3_redist_regions()
296 ret = __kvm_device_attr_get(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
302 ret = __kvm_device_attr_get(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
306 addr = REDIST_REGION_ATTR_ADDR(0, 0, 0, 2); in subtest_v3_redist_regions()
307 ret = __kvm_device_attr_get(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
312 kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
315 addr = REDIST_REGION_ATTR_ADDR(1, 0x260000, 0, 2); in subtest_v3_redist_regions()
316 ret = __kvm_device_attr_set(v->gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in subtest_v3_redist_regions()
328 struct vm_gic v; in test_vgic_then_vcpus() local
331 v = vm_gic_create_with_vcpus(gic_dev_type, 1, vcpus); in test_vgic_then_vcpus()
333 subtest_dist_rdist(&v); in test_vgic_then_vcpus()
337 vcpus[i] = vm_vcpu_add(v.vm, i, guest_code); in test_vgic_then_vcpus()
342 vm_gic_destroy(&v); in test_vgic_then_vcpus()
349 struct vm_gic v; in test_vcpus_then_vgic() local
352 v = vm_gic_create_with_vcpus(gic_dev_type, NR_VCPUS, vcpus); in test_vcpus_then_vgic()
354 subtest_dist_rdist(&v); in test_vcpus_then_vgic()
359 vm_gic_destroy(&v); in test_vcpus_then_vgic()
366 struct vm_gic v; in test_v3_new_redist_regions() local
370 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
371 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
372 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_new_redist_regions()
377 vm_gic_destroy(&v); in test_v3_new_redist_regions()
381 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
382 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
384 addr = REDIST_REGION_ATTR_ADDR(1, 0x280000, 0, 2); in test_v3_new_redist_regions()
385 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
391 vm_gic_destroy(&v); in test_v3_new_redist_regions()
395 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_new_redist_regions()
396 subtest_v3_redist_regions(&v); in test_v3_new_redist_regions()
398 ret = __kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
403 addr = REDIST_REGION_ATTR_ADDR(1, 0x280000, 0, 2); in test_v3_new_redist_regions()
404 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_new_redist_regions()
407 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_new_redist_regions()
413 vm_gic_destroy(&v); in test_v3_new_redist_regions()
418 struct vm_gic v; in test_v3_typer_accesses() local
422 v.vm = vm_create(NR_VCPUS); in test_v3_typer_accesses()
423 (void)vm_vcpu_add(v.vm, 0, guest_code); in test_v3_typer_accesses()
425 v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3); in test_v3_typer_accesses()
427 (void)vm_vcpu_add(v.vm, 3, guest_code); in test_v3_typer_accesses()
429 v3_redist_reg_get_errno(v.gic_fd, 1, GICR_TYPER, EINVAL, in test_v3_typer_accesses()
432 (void)vm_vcpu_add(v.vm, 1, guest_code); in test_v3_typer_accesses()
434 v3_redist_reg_get_errno(v.gic_fd, 1, GICR_TYPER, EBUSY, in test_v3_typer_accesses()
437 (void)vm_vcpu_add(v.vm, 2, guest_code); in test_v3_typer_accesses()
439 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_typer_accesses()
443 v3_redist_reg_get(v.gic_fd, i, GICR_TYPER, i * 0x100, in test_v3_typer_accesses()
447 addr = REDIST_REGION_ATTR_ADDR(2, 0x200000, 0, 0); in test_v3_typer_accesses()
448 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
451 /* The 2 first rdists should be put there (vcpu 0 and 3) */ in test_v3_typer_accesses()
452 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x0, "read typer of rdist #0"); in test_v3_typer_accesses()
453 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x310, "read typer of rdist #1"); in test_v3_typer_accesses()
456 ret = __kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
460 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, in test_v3_typer_accesses()
462 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x200, in test_v3_typer_accesses()
463 "no redist region attached to vcpu #2, last cannot be returned"); in test_v3_typer_accesses()
466 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_typer_accesses()
469 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #1"); in test_v3_typer_accesses()
470 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x210, in test_v3_typer_accesses()
473 vm_gic_destroy(&v); in test_v3_typer_accesses()
479 struct vm_gic v; in vm_gic_v3_create_with_vcpuids() local
482 v.vm = vm_create(nr_vcpus); in vm_gic_v3_create_with_vcpuids()
484 vm_vcpu_add(v.vm, vcpuids[i], guest_code); in vm_gic_v3_create_with_vcpuids()
486 v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3); in vm_gic_v3_create_with_vcpuids()
488 return v; in vm_gic_v3_create_with_vcpuids()
493 * rdist regions #1 and #2 are contiguous
494 * rdist region #0 @0x100000 2 rdist capacity
496 * rdist region #1 @0x240000 2 rdist capacity
498 * rdist region #2 @0x200000 2 rdist capacity
499 * rdists: 1, 2
503 uint32_t vcpuids[] = { 0, 3, 5, 4, 1, 2 }; in test_v3_last_bit_redist_regions()
504 struct vm_gic v; in test_v3_last_bit_redist_regions() local
507 v = vm_gic_v3_create_with_vcpuids(ARRAY_SIZE(vcpuids), vcpuids); in test_v3_last_bit_redist_regions()
509 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_last_bit_redist_regions()
512 addr = REDIST_REGION_ATTR_ADDR(2, 0x100000, 0, 0); in test_v3_last_bit_redist_regions()
513 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
516 addr = REDIST_REGION_ATTR_ADDR(2, 0x240000, 0, 1); in test_v3_last_bit_redist_regions()
517 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
520 addr = REDIST_REGION_ATTR_ADDR(2, 0x200000, 0, 2); in test_v3_last_bit_redist_regions()
521 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_redist_regions()
524 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x000, "read typer of rdist #0"); in test_v3_last_bit_redist_regions()
525 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #1"); in test_v3_last_bit_redist_regions()
526 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x200, "read typer of rdist #2"); in test_v3_last_bit_redist_regions()
527 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x310, "read typer of rdist #3"); in test_v3_last_bit_redist_regions()
528 v3_redist_reg_get(v.gic_fd, 5, GICR_TYPER, 0x500, "read typer of rdist #5"); in test_v3_last_bit_redist_regions()
529 v3_redist_reg_get(v.gic_fd, 4, GICR_TYPER, 0x410, "read typer of rdist #4"); in test_v3_last_bit_redist_regions()
531 vm_gic_destroy(&v); in test_v3_last_bit_redist_regions()
537 uint32_t vcpuids[] = { 0, 3, 5, 4, 1, 2 }; in test_v3_last_bit_single_rdist()
538 struct vm_gic v; in test_v3_last_bit_single_rdist() local
541 v = vm_gic_v3_create_with_vcpuids(ARRAY_SIZE(vcpuids), vcpuids); in test_v3_last_bit_single_rdist()
543 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_last_bit_single_rdist()
547 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_last_bit_single_rdist()
550 v3_redist_reg_get(v.gic_fd, 0, GICR_TYPER, 0x000, "read typer of rdist #0"); in test_v3_last_bit_single_rdist()
551 v3_redist_reg_get(v.gic_fd, 3, GICR_TYPER, 0x300, "read typer of rdist #1"); in test_v3_last_bit_single_rdist()
552 v3_redist_reg_get(v.gic_fd, 5, GICR_TYPER, 0x500, "read typer of rdist #2"); in test_v3_last_bit_single_rdist()
553 v3_redist_reg_get(v.gic_fd, 1, GICR_TYPER, 0x100, "read typer of rdist #3"); in test_v3_last_bit_single_rdist()
554 v3_redist_reg_get(v.gic_fd, 2, GICR_TYPER, 0x210, "read typer of rdist #3"); in test_v3_last_bit_single_rdist()
556 vm_gic_destroy(&v); in test_v3_last_bit_single_rdist()
563 struct vm_gic v; in test_v3_redist_ipa_range_check_at_vcpu_run() local
567 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, 1, vcpus); in test_v3_redist_ipa_range_check_at_vcpu_run()
570 addr = max_phys_size - (3 * 2 * 0x10000); in test_v3_redist_ipa_range_check_at_vcpu_run()
571 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_redist_ipa_range_check_at_vcpu_run()
575 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, in test_v3_redist_ipa_range_check_at_vcpu_run()
580 vcpus[i] = vm_vcpu_add(v.vm, i, guest_code); in test_v3_redist_ipa_range_check_at_vcpu_run()
582 kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, in test_v3_redist_ipa_range_check_at_vcpu_run()
586 ret = run_vcpu(vcpus[2]); in test_v3_redist_ipa_range_check_at_vcpu_run()
590 vm_gic_destroy(&v); in test_v3_redist_ipa_range_check_at_vcpu_run()
596 struct vm_gic v; in test_v3_its_region() local
600 v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus); in test_v3_its_region()
601 its_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_ITS); in test_v3_its_region()
632 vm_gic_destroy(&v); in test_v3_its_region()
641 struct vm_gic v; in test_kvm_device() local
645 v.vm = vm_create_with_vcpus(NR_VCPUS, guest_code, vcpus); in test_kvm_device()
648 ret = __kvm_test_create_device(v.vm, 0); in test_kvm_device()
652 ret = __kvm_test_create_device(v.vm, gic_dev_type); in test_kvm_device()
655 v.gic_fd = kvm_create_device(v.vm, gic_dev_type); in test_kvm_device()
657 ret = __kvm_create_device(v.vm, gic_dev_type); in test_kvm_device()
664 if (!__kvm_test_create_device(v.vm, other)) { in test_kvm_device()
665 ret = __kvm_create_device(v.vm, other); in test_kvm_device()
670 vm_gic_destroy(&v); in test_kvm_device()