Skip to content

Commit ca1a183

Browse files
coltonlewisMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Ensure pending interrupts are handled in arch_timer test
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 8400291 commit ca1a183

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

tools/testing/selftests/kvm/aarch64/vgic_irq.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,12 @@ static void guest_inject(struct test_args *args,
269269
KVM_INJECT_MULTI(cmd, first_intid, num);
270270

271271
while (irq_handled < num) {
272-
asm volatile("wfi\n"
273-
"msr daifclr, #2\n"
274-
/* handle IRQ */
275-
"msr daifset, #2\n"
276-
: : : "memory");
272+
wfi();
273+
local_irq_enable();
274+
isb(); /* handle IRQ */
275+
local_irq_disable();
277276
}
278-
asm volatile("msr daifclr, #2" : : : "memory");
277+
local_irq_enable();
279278

280279
GUEST_ASSERT_EQ(irq_handled, num);
281280
for (i = first_intid; i < num + first_intid; i++)

tools/testing/selftests/kvm/include/aarch64/processor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,7 @@ void smccc_smc(uint32_t function_id, uint64_t arg0, uint64_t arg1,
243243
uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5,
244244
uint64_t arg6, struct arm_smccc_res *res);
245245

246+
/* Execute a Wait For Interrupt instruction. */
247+
void wfi(void);
248+
246249
#endif /* SELFTEST_KVM_PROCESSOR_H */

tools/testing/selftests/kvm/lib/aarch64/processor.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,3 +639,9 @@ void vm_vaddr_populate_bitmap(struct kvm_vm *vm)
639639
sparsebit_set_num(vm->vpages_valid, 0,
640640
(1ULL << vm->va_bits) >> vm->page_shift);
641641
}
642+
643+
/* Helper to call wfi instruction. */
644+
void wfi(void)
645+
{
646+
asm volatile("wfi");
647+
}

0 commit comments

Comments
 (0)