mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 23:52:08 +02:00
KVM: arm64: selftests: Use hyp timer IRQs when test runs at EL2
Arch timer registers are redirected to their hypervisor counterparts when running in VHE EL2. This is great, except for the fact that the hypervisor timers use different PPIs. Use the correct INTIDs when that is the case. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
parent
d72543ac72
commit
0910778e49
|
|
@ -165,10 +165,8 @@ static void guest_code(void)
|
|||
static void test_init_timer_irq(struct kvm_vm *vm)
|
||||
{
|
||||
/* Timer initid should be same for all the vCPUs, so query only vCPU-0 */
|
||||
vcpu_device_attr_get(vcpus[0], KVM_ARM_VCPU_TIMER_CTRL,
|
||||
KVM_ARM_VCPU_TIMER_IRQ_PTIMER, &ptimer_irq);
|
||||
vcpu_device_attr_get(vcpus[0], KVM_ARM_VCPU_TIMER_CTRL,
|
||||
KVM_ARM_VCPU_TIMER_IRQ_VTIMER, &vtimer_irq);
|
||||
ptimer_irq = vcpu_get_ptimer_irq(vcpus[0]);
|
||||
vtimer_irq = vcpu_get_vtimer_irq(vcpus[0]);
|
||||
|
||||
sync_global_to_guest(vm, ptimer_irq);
|
||||
sync_global_to_guest(vm, vtimer_irq);
|
||||
|
|
|
|||
|
|
@ -924,10 +924,8 @@ static void test_run(struct kvm_vm *vm, struct kvm_vcpu *vcpu)
|
|||
|
||||
static void test_init_timer_irq(struct kvm_vm *vm, struct kvm_vcpu *vcpu)
|
||||
{
|
||||
vcpu_device_attr_get(vcpu, KVM_ARM_VCPU_TIMER_CTRL,
|
||||
KVM_ARM_VCPU_TIMER_IRQ_PTIMER, &ptimer_irq);
|
||||
vcpu_device_attr_get(vcpu, KVM_ARM_VCPU_TIMER_CTRL,
|
||||
KVM_ARM_VCPU_TIMER_IRQ_VTIMER, &vtimer_irq);
|
||||
ptimer_irq = vcpu_get_ptimer_irq(vcpu);
|
||||
vtimer_irq = vcpu_get_vtimer_irq(vcpu);
|
||||
|
||||
sync_global_to_guest(vm, ptimer_irq);
|
||||
sync_global_to_guest(vm, vtimer_irq);
|
||||
|
|
|
|||
|
|
@ -155,4 +155,28 @@ static inline void timer_set_next_tval_ms(enum arch_timer timer, uint32_t msec)
|
|||
timer_set_tval(timer, msec_to_cycles(msec));
|
||||
}
|
||||
|
||||
static inline u32 vcpu_get_vtimer_irq(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
u32 intid;
|
||||
u64 attr;
|
||||
|
||||
attr = vcpu_has_el2(vcpu) ? KVM_ARM_VCPU_TIMER_IRQ_HVTIMER :
|
||||
KVM_ARM_VCPU_TIMER_IRQ_VTIMER;
|
||||
vcpu_device_attr_get(vcpu, KVM_ARM_VCPU_TIMER_CTRL, attr, &intid);
|
||||
|
||||
return intid;
|
||||
}
|
||||
|
||||
static inline u32 vcpu_get_ptimer_irq(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
u32 intid;
|
||||
u64 attr;
|
||||
|
||||
attr = vcpu_has_el2(vcpu) ? KVM_ARM_VCPU_TIMER_IRQ_HPTIMER :
|
||||
KVM_ARM_VCPU_TIMER_IRQ_PTIMER;
|
||||
vcpu_device_attr_get(vcpu, KVM_ARM_VCPU_TIMER_CTRL, attr, &intid);
|
||||
|
||||
return intid;
|
||||
}
|
||||
|
||||
#endif /* SELFTEST_KVM_ARCH_TIMER_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user