Commit ca1a1836 authored by Colton Lewis's avatar Colton Lewis Committed by Marc Zyngier

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: default avatarColton Lewis <coltonlewis@google.com>
Link: https://lore.kernel.org/r/20240823175836.2798235-2-coltonlewis@google.comSigned-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 8400291e
...@@ -269,13 +269,12 @@ static void guest_inject(struct test_args *args, ...@@ -269,13 +269,12 @@ static void guest_inject(struct test_args *args,
KVM_INJECT_MULTI(cmd, first_intid, num); KVM_INJECT_MULTI(cmd, first_intid, num);
while (irq_handled < num) { while (irq_handled < num) {
asm volatile("wfi\n" wfi();
"msr daifclr, #2\n" local_irq_enable();
/* handle IRQ */ isb(); /* handle IRQ */
"msr daifset, #2\n" local_irq_disable();
: : : "memory");
} }
asm volatile("msr daifclr, #2" : : : "memory"); local_irq_enable();
GUEST_ASSERT_EQ(irq_handled, num); GUEST_ASSERT_EQ(irq_handled, num);
for (i = first_intid; i < num + first_intid; i++) for (i = first_intid; i < num + first_intid; i++)
......
...@@ -243,4 +243,7 @@ void smccc_smc(uint32_t function_id, uint64_t arg0, uint64_t arg1, ...@@ -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 arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5,
uint64_t arg6, struct arm_smccc_res *res); uint64_t arg6, struct arm_smccc_res *res);
/* Execute a Wait For Interrupt instruction. */
void wfi(void);
#endif /* SELFTEST_KVM_PROCESSOR_H */ #endif /* SELFTEST_KVM_PROCESSOR_H */
...@@ -639,3 +639,9 @@ void vm_vaddr_populate_bitmap(struct kvm_vm *vm) ...@@ -639,3 +639,9 @@ void vm_vaddr_populate_bitmap(struct kvm_vm *vm)
sparsebit_set_num(vm->vpages_valid, 0, sparsebit_set_num(vm->vpages_valid, 0,
(1ULL << vm->va_bits) >> vm->page_shift); (1ULL << vm->va_bits) >> vm->page_shift);
} }
/* Helper to call wfi instruction. */
void wfi(void)
{
asm volatile("wfi");
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment