• Christoffer Dall's avatar
    KVM: arm/arm64: Properly handle arch-timer IRQs after vtimer_save_state · 36e5cfd4
    Christoffer Dall authored
    The recent timer rework was assuming that once the timer was disabled,
    we should no longer see any interrupts from the timer.  This assumption
    turns out to not be true, and instead we have to handle the case when
    the timer ISR runs even after the timer has been disabled.
    
    This requires a couple of changes:
    
    First, we should never overwrite the cached guest state of the timer
    control register when the ISR runs, because KVM may have disabled its
    timers when doing vcpu_put(), even though the guest still had the timer
    enabled.
    
    Second, we shouldn't assume that the timer is actually firing just
    because we see an interrupt, but we should check the actual state of the
    timer in the timer control register to understand if the hardware timer
    is really firing or not.
    
    We also add an ISB to vtimer_save_state() to ensure the timer is
    actually disabled once we enable interrupts, which should clarify the
    intention of the implementation, and reduce the risk of unwanted
    interrupts.
    
    Fixes: b103cc3f ("KVM: arm/arm64: Avoid timer save/restore in vcpu entry/exit")
    Reported-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    Reported-by: default avatarJia He <hejianet@gmail.com>
    Reviewed-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    Tested-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
    36e5cfd4
arch_timer.c 24.9 KB