[PATCH] arm64: KVM: Reset arch_timer upon vcpu reset

Anup Patel anup.patel at linaro.org
Sat Apr 27 04:09:55 EDT 2013


This patch does arch_timer reset (i.e. kvm_timer_vcpu_reset()) when a vcpu resetted by kvm_reset_vcpu().

The kvm_reset_vcpu() also informs guest timer irq number to arch_timer code via kvm_timer_vcpu_reset().

Signed-off-by: Anup Patel <anup.patel at linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar at linaro.org>
---
 arch/arm64/include/asm/kvm_arch_timer.h |    2 ++
 arch/arm64/kvm/reset.c                  |   11 ++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/kvm_arch_timer.h b/arch/arm64/include/asm/kvm_arch_timer.h
index eb02273..04949c6 100644
--- a/arch/arm64/include/asm/kvm_arch_timer.h
+++ b/arch/arm64/include/asm/kvm_arch_timer.h
@@ -50,6 +50,8 @@ struct arch_timer_cpu {
 
 int kvm_timer_hyp_init(void);
 int kvm_timer_init(struct kvm *kvm);
+int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu, 
+			 const struct kvm_irq_level *irq);
 void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu);
 void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu);
 void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu);
diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
index 64e0740..1e255a3 100644
--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -27,6 +27,7 @@
 #include <asm/ptrace.h>
 #include <asm/kvm_arm.h>
 #include <asm/kvm_coproc.h>
+#include <asm/kvm_arch_timer.h>
 
 /*
  * ARMv8 Reset Values
@@ -40,6 +41,11 @@ static struct kvm_regs default_regs_reset32 = {
 			COMPAT_PSR_I_BIT | COMPAT_PSR_F_BIT),
 };
 
+static struct kvm_irq_level default_timer_irq = {
+	.irq = 27,
+	.level = 1,
+};
+
 static bool cpu_has_32bit_el1(void)
 {
 	u64 pfr0;
@@ -75,6 +81,7 @@ int kvm_arch_dev_ioctl_check_extension(long ext)
 int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 {
 	struct kvm_regs *cpu_reset;
+	const struct kvm_irq_level *cpu_irq;
 
 	switch (vcpu->arch.target) {
 	default:
@@ -86,6 +93,7 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 		} else {
 			cpu_reset = &default_regs_reset;
 		}
+		cpu_irq = &default_timer_irq;
 		break;
 	}
 
@@ -95,5 +103,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 	/* Reset system registers */
 	kvm_reset_sys_regs(vcpu);
 
-	return 0;
+	/* Reset arch_timer context */
+	return kvm_timer_vcpu_reset(vcpu, cpu_irq);
 }
-- 
1.7.9.5




More information about the linux-arm-kernel mailing list