Commit f77e63e2 authored by Marc Zyngier's avatar Marc Zyngier

Merge branch kvm-arm64/selftests-6.12 into kvmarm-master/next

* kvm-arm64/selftests-6.12:
  : .
  : KVM/arm64 selftest updates for 6.12
  :
  : - Check for a bunch of timer emulation corner cases (COlton Lewis)
  : .
  KVM: arm64: selftests: Add arch_timer_edge_cases selftest
  KVM: arm64: selftests: Ensure pending interrupts are handled in arch_timer test
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parents acf2ab28 54306f56
...@@ -152,6 +152,7 @@ TEST_GEN_PROGS_x86_64 += pre_fault_memory_test ...@@ -152,6 +152,7 @@ TEST_GEN_PROGS_x86_64 += pre_fault_memory_test
TEST_GEN_PROGS_EXTENDED_x86_64 += x86_64/nx_huge_pages_test TEST_GEN_PROGS_EXTENDED_x86_64 += x86_64/nx_huge_pages_test
TEST_GEN_PROGS_aarch64 += aarch64/aarch32_id_regs TEST_GEN_PROGS_aarch64 += aarch64/aarch32_id_regs
TEST_GEN_PROGS_aarch64 += aarch64/arch_timer_edge_cases
TEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions TEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions
TEST_GEN_PROGS_aarch64 += aarch64/hypercalls TEST_GEN_PROGS_aarch64 += aarch64/hypercalls
TEST_GEN_PROGS_aarch64 += aarch64/page_fault_test TEST_GEN_PROGS_aarch64 += aarch64/page_fault_test
......
This diff is collapsed.
...@@ -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++)
......
...@@ -79,7 +79,7 @@ static inline uint64_t timer_get_cval(enum arch_timer timer) ...@@ -79,7 +79,7 @@ static inline uint64_t timer_get_cval(enum arch_timer timer)
return 0; return 0;
} }
static inline void timer_set_tval(enum arch_timer timer, uint32_t tval) static inline void timer_set_tval(enum arch_timer timer, int32_t tval)
{ {
switch (timer) { switch (timer) {
case VIRTUAL: case VIRTUAL:
...@@ -95,6 +95,22 @@ static inline void timer_set_tval(enum arch_timer timer, uint32_t tval) ...@@ -95,6 +95,22 @@ static inline void timer_set_tval(enum arch_timer timer, uint32_t tval)
isb(); isb();
} }
static inline int32_t timer_get_tval(enum arch_timer timer)
{
isb();
switch (timer) {
case VIRTUAL:
return read_sysreg(cntv_tval_el0);
case PHYSICAL:
return read_sysreg(cntp_tval_el0);
default:
GUEST_FAIL("Could not get timer %d\n", timer);
}
/* We should not reach here */
return 0;
}
static inline void timer_set_ctl(enum arch_timer timer, uint32_t ctl) static inline void timer_set_ctl(enum arch_timer timer, uint32_t ctl)
{ {
switch (timer) { switch (timer) {
......
...@@ -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