KVM: arm/arm64: Move timer save/restore out of the hyp code
authorChristoffer Dall <cdall@linaro.org>
Wed, 4 Jan 2017 15:10:28 +0000 (16:10 +0100)
committerChristoffer Dall <christoffer.dall@linaro.org>
Mon, 6 Nov 2017 15:23:13 +0000 (16:23 +0100)
commit688c50aa72f64ca21767486e5eef876ec23e418c
treee5e2b86ee875d005308f7540692d5373eba7605f
parentf2a2129e0ac8d8fa79c3f85425c36f6e3368f022
KVM: arm/arm64: Move timer save/restore out of the hyp code

As we are about to be lazy with saving and restoring the timer
registers, we prepare by moving all possible timer configuration logic
out of the hyp code.  All virtual timer registers can be programmed from
EL1 and since the arch timer is always a level triggered interrupt we
can safely do this with interrupts disabled in the host kernel on the
way to the guest without taking vtimer interrupts in the host kernel
(yet).

The downside is that the cntvoff register can only be programmed from
hyp mode, so we jump into hyp mode and back to program it.  This is also
safe, because the host kernel doesn't use the virtual timer in the KVM
code.  It may add a little performance performance penalty, but only
until following commits where we move this operation to vcpu load/put.

Signed-off-by: Christoffer Dall <cdall@linaro.org>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm/include/asm/kvm_asm.h
arch/arm/include/asm/kvm_hyp.h
arch/arm/kvm/hyp/switch.c
arch/arm64/include/asm/kvm_asm.h
arch/arm64/include/asm/kvm_hyp.h
arch/arm64/kvm/hyp/switch.c
virt/kvm/arm/arch_timer.c
virt/kvm/arm/hyp/timer-sr.c