Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <coltonlewis@google.com>
Link: https://lore.kernel.org/r/20240823175836.2798235-2-coltonlewis@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Colton Lewis and committed by
Marc Zyngier
ca1a1836 8400291e

+14 -6
+5 -6
tools/testing/selftests/kvm/aarch64/vgic_irq.c
··· 269 269 KVM_INJECT_MULTI(cmd, first_intid, num); 270 270 271 271 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(); 277 276 } 278 - asm volatile("msr daifclr, #2" : : : "memory"); 277 + local_irq_enable(); 279 278 280 279 GUEST_ASSERT_EQ(irq_handled, num); 281 280 for (i = first_intid; i < num + first_intid; i++)
+3
tools/testing/selftests/kvm/include/aarch64/processor.h
··· 243 243 uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, 244 244 uint64_t arg6, struct arm_smccc_res *res); 245 245 246 + /* Execute a Wait For Interrupt instruction. */ 247 + void wfi(void); 248 + 246 249 #endif /* SELFTEST_KVM_PROCESSOR_H */
+6
tools/testing/selftests/kvm/lib/aarch64/processor.c
··· 639 639 sparsebit_set_num(vm->vpages_valid, 0, 640 640 (1ULL << vm->va_bits) >> vm->page_shift); 641 641 } 642 + 643 + /* Helper to call wfi instruction. */ 644 + void wfi(void) 645 + { 646 + asm volatile("wfi"); 647 + }