]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: selftests: Ensure pending interrupts are handled in arch_timer test
authorColton Lewis <coltonlewis@google.com>
Fri, 23 Aug 2024 17:58:35 +0000 (17:58 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 30 Aug 2024 08:03:45 +0000 (09:03 +0100)
Break up the asm instructions poking daifclr and daifset to handle
interrupts. R_RBZYL specifies pending interrupts will be handle after
context synchronization events such as an ISB.

Introduce a function wrapper for the WFI instruction.

Signed-off-by: Colton Lewis <coltonlewis@google.com>
Link: https://lore.kernel.org/r/20240823175836.2798235-2-coltonlewis@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
tools/testing/selftests/kvm/aarch64/vgic_irq.c
tools/testing/selftests/kvm/include/aarch64/processor.h
tools/testing/selftests/kvm/lib/aarch64/processor.c

index a51dbd2a5f8459d6dcc300a332a2cd9d079e313e..f4ac28d537473d35bd6c5fa50733ca7aff7bfd97 100644 (file)
@@ -269,13 +269,12 @@ static void guest_inject(struct test_args *args,
        KVM_INJECT_MULTI(cmd, first_intid, num);
 
        while (irq_handled < num) {
-               asm volatile("wfi\n"
-                            "msr daifclr, #2\n"
-                            /* handle IRQ */
-                            "msr daifset, #2\n"
-                            : : : "memory");
+               wfi();
+               local_irq_enable();
+               isb(); /* handle IRQ */
+               local_irq_disable();
        }
-       asm volatile("msr daifclr, #2" : : : "memory");
+       local_irq_enable();
 
        GUEST_ASSERT_EQ(irq_handled, num);
        for (i = first_intid; i < num + first_intid; i++)
index 9b20a355d81ade2dcfd5dee4149d90c2b9aa3bbb..de977d131082a12f9edb8420da3229b7cf8b6a5a 100644 (file)
@@ -243,4 +243,7 @@ void smccc_smc(uint32_t function_id, uint64_t arg0, uint64_t arg1,
               uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5,
               uint64_t arg6, struct arm_smccc_res *res);
 
+/* Execute a Wait For Interrupt instruction. */
+void wfi(void);
+
 #endif /* SELFTEST_KVM_PROCESSOR_H */
index 0ac7cc89f38c1c050fc4b9bd1c20b0363b068743..fe4dc3693112429ab405e911540aa226b9bbb676 100644 (file)
@@ -639,3 +639,9 @@ void vm_vaddr_populate_bitmap(struct kvm_vm *vm)
        sparsebit_set_num(vm->vpages_valid, 0,
                          (1ULL << vm->va_bits) >> vm->page_shift);
 }
+
+/* Helper to call wfi instruction. */
+void wfi(void)
+{
+       asm volatile("wfi");
+}