It is now possible to select CONFIG_KVM_ARM_TIMER to enable the KVM architected timer support. Signed-off-by: Marc Zyngier <marc.zyngier at arm.com> --- arch/arm/kvm/Kconfig | 7 +++++++ arch/arm/kvm/Makefile | 1 + arch/arm/kvm/arm.c | 11 +++++++++++ arch/arm/kvm/vgic.c | 4 ++++ 4 files changed, 23 insertions(+), 0 deletions(-) diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index b2860fc..b0eb7a3 100644 --- a/arch/arm/kvm/Kconfig +++ b/arch/arm/kvm/Kconfig @@ -47,6 +47,13 @@ config KVM_ARM_VGIC ---help--- Adds support for a hardware assisted, in-kernel GIC emulation. +config KVM_ARM_TIMER + bool "KVM support for Architected Timers" + depends on KVM_ARM_VGIC && ARM_ARCH_TIMER + select HAVE_KVM_IRQCHIP + ---help--- + Adds support for the Architected Timed in virtual machines + source drivers/virtio/Kconfig endif # VIRTUALIZATION diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile index d21c7b7..a2d1534 100644 --- a/arch/arm/kvm/Makefile +++ b/arch/arm/kvm/Makefile @@ -16,3 +16,4 @@ kvm-arm-y += arm.o guest.o mmu.o emulate.o obj-$(CONFIG_KVM) += kvm-arm.o obj-$(CONFIG_KVM_ARM_VGIC) += vgic.o +obj-$(CONFIG_KVM_ARM_TIMER) += timer.o diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index ccb2c08..49ed283 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -231,6 +231,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) { + kvm_timer_vcpu_terminate(vcpu); kvm_arch_vcpu_free(vcpu); } @@ -263,6 +264,9 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) /* Set up VGIC */ kvm_vgic_vcpu_init(vcpu); + /* Set up the timer */ + kvm_timer_vcpu_init(vcpu); + return 0; } @@ -785,6 +789,13 @@ static int init_hyp_mode(void) goto out_free_mappings; /* + * Init HYP architected timer support + */ + err = kvm_timer_hyp_init(); + if (err) + goto out_free_mappings; + + /* * Set the HVBAR to the virtual kernel address */ for_each_online_cpu(cpu) diff --git a/arch/arm/kvm/vgic.c b/arch/arm/kvm/vgic.c index c8bcc9e..e80cd1c 100644 --- a/arch/arm/kvm/vgic.c +++ b/arch/arm/kvm/vgic.c @@ -880,5 +880,9 @@ int kvm_vgic_init(struct kvm *kvm) kvm_err("Unable to remap VGIC CPU to VCPU\n"); out: mutex_unlock(&kvm->lock); + + if (!ret) + kvm_timer_init(kvm); + return ret; } -- 1.7.7.1