Lines Matching +full:case +full:- +full:sensitive
1 // SPDX-License-Identifier: GPL-2.0
3 * vgic_irq.c - Test userspace injection of IRQs
36 * 0x00 (highest priority) - 0xF8 (lowest priority), in steps of 8
38 * Note that these macros will still be correct in the case that KVM implements
44 #define LOWEST_PRIO (KVM_NUM_PRIOS - 1)
46 #define IRQ_DEFAULT_PRIO (LOWEST_PRIO - 1)
81 kvm_inject_call(cmd, intid, num, -1 /* not used */, expect_failure)
125 for ((f) = (t); (f)->cmd; (f)++)
129 if ((args)->kvm_supports_irqfd || (f)->cmd != KVM_INJECT_IRQFD)
235 for (i = 0; i < args->nr_irqs; i++) in reset_priorities()
266 gic_set_priority(i, (i % (KVM_NUM_PRIOS - 1)) << 3); in guest_inject()
289 * concurrent_irqs). This does what a live-migration would do on the
301 * Set the priorities of the first (KVM_NUM_PRIOS - 1) IRQs in guest_restore_active()
304 for (i = 0, prio = (num - 1) * 8; i < num; i++, prio -= 8) { in guest_restore_active()
326 intid = num - i - 1 + first_intid; in guest_restore_active()
328 if (args->eoi_split) in guest_restore_active()
368 /* Set the priorities of the first (KVM_NUM_PRIOS - 1) IRQs in test_inject_preemption()
371 for (i = 0, prio = (num - 1) * step; i < num; i++, prio -= step) { in test_inject_preemption()
386 if (args->level_sensitive) in test_inject_preemption()
392 intid = num - i - 1 + first_intid; in test_inject_preemption()
394 if (args->eoi_split) in test_inject_preemption()
410 uint32_t nr_irqs = args->nr_irqs; in test_injection()
412 if (f->sgi) { in test_injection()
413 guest_inject(args, MIN_SGI, 1, f->cmd); in test_injection()
414 guest_inject(args, 0, 16, f->cmd); in test_injection()
417 if (f->ppi) in test_injection()
418 guest_inject(args, MIN_PPI, 1, f->cmd); in test_injection()
420 if (f->spi) { in test_injection()
421 guest_inject(args, MIN_SPI, 1, f->cmd); in test_injection()
422 guest_inject(args, nr_irqs - 1, 1, f->cmd); in test_injection()
423 guest_inject(args, MIN_SPI, nr_irqs - MIN_SPI, f->cmd); in test_injection()
430 uint32_t bad_intid[] = { args->nr_irqs, 1020, 1024, 1120, 5120, ~0U, }; in test_injection_failure()
434 test_inject_fail(args, bad_intid[i], f->cmd); in test_injection_failure()
441 * currently implement the ability to have more than the number-of-LRs in test_preemption()
445 if (f->sgi) in test_preemption()
446 test_inject_preemption(args, MIN_SGI, 4, f->cmd); in test_preemption()
448 if (f->ppi) in test_preemption()
449 test_inject_preemption(args, MIN_PPI, 4, f->cmd); in test_preemption()
451 if (f->spi) in test_preemption()
452 test_inject_preemption(args, MIN_SPI, 4, f->cmd); in test_preemption()
458 if (f->sgi) in test_restore_active()
459 guest_restore_active(args, MIN_SGI, 4, f->cmd); in test_restore_active()
461 if (f->ppi) in test_restore_active()
462 guest_restore_active(args, MIN_PPI, 4, f->cmd); in test_restore_active()
464 if (f->spi) in test_restore_active()
465 guest_restore_active(args, MIN_SPI, 4, f->cmd); in test_restore_active()
470 uint32_t i, nr_irqs = args->nr_irqs; in guest_code()
471 bool level_sensitive = args->level_sensitive; in guest_code()
482 gic_set_eoi_split(args->eoi_split); in guest_code()
537 * are not level-sensitive). It only checks for intid to not in kvm_irq_set_level_info_check()
564 kvm_gsi_routing_irqchip_add(routing, i - MIN_SPI, i - MIN_SPI); in kvm_set_gsi_routing_irqchip_check()
570 /* The kernel only checks e->irqchip.pin >= KVM_IRQCHIP_NUM_PINS */ in kvm_set_gsi_routing_irqchip_check()
571 if (((uint64_t)intid + num - 1 - MIN_SPI) >= KVM_IRQCHIP_NUM_PINS) in kvm_set_gsi_routing_irqchip_check()
619 * will silently fail. And in any case, the guest will check in kvm_routing_and_irqfd_check()
625 TEST_ASSERT(fd[f] != -1, __KVM_SYSCALL_ERROR("eventfd()", fd[f])); in kvm_routing_and_irqfd_check()
631 .gsi = i - MIN_SPI, in kvm_routing_and_irqfd_check()
648 /* handles the valid case: intid=0xffffffff num=1 */
658 kvm_inject_cmd cmd = inject_args->cmd; in run_guest_cmd()
659 uint32_t intid = inject_args->first_intid; in run_guest_cmd()
660 uint32_t num = inject_args->num; in run_guest_cmd()
661 int level = inject_args->level; in run_guest_cmd()
662 bool expect_failure = inject_args->expect_failure; in run_guest_cmd()
663 struct kvm_vm *vm = vcpu->vm; in run_guest_cmd()
667 /* handles the valid case: intid=0xffffffff num=1 */ in run_guest_cmd()
668 assert(intid < UINT_MAX - num || num == 1); in run_guest_cmd()
671 case KVM_INJECT_EDGE_IRQ_LINE: in run_guest_cmd()
679 case KVM_SET_IRQ_LINE: in run_guest_cmd()
684 case KVM_SET_IRQ_LINE_HIGH: in run_guest_cmd()
689 case KVM_SET_LEVEL_INFO_HIGH: in run_guest_cmd()
694 case KVM_INJECT_IRQFD: in run_guest_cmd()
696 test_args->kvm_max_routes, in run_guest_cmd()
699 case KVM_WRITE_ISPENDR: in run_guest_cmd()
704 case KVM_WRITE_ISACTIVER: in run_guest_cmd()
719 kvm_args_gva = uc->args[1]; in kvm_inject_get_call()
726 printf("nr-irqs=%d level-sensitive=%d eoi-split=%d\n", in print_args()
727 args->nr_irqs, args->level_sensitive, in print_args()
728 args->eoi_split); in print_args()
761 __TEST_REQUIRE(gic_fd >= 0, "Failed to create vgic-v3, skipping"); in test_vgic()
770 case UCALL_SYNC: in test_vgic()
774 case UCALL_ABORT: in test_vgic()
777 case UCALL_DONE: in test_vgic()
793 "usage: %s [-n num_irqs] [-e eoi_split] [-l level_sensitive]\n", name); in help()
794 printf(" -n: specify number of IRQs to setup the vgic with. " in help()
796 printf(" -e: if 1 then EOI is split into a write to DIR on top " in help()
798 printf(" -l: specify whether the IRQs are level-sensitive (1) or not (0)."); in help()
811 while ((opt = getopt(argc, argv, "hn:e:l:")) != -1) { in main()
813 case 'n': in main()
818 case 'e': in main()
822 case 'l': in main()
826 case 'h': in main()