summaryrefslogtreecommitdiff
path: root/include/kvm
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@arm.com>2019-01-04 13:31:22 +0100
committerMarc Zyngier <marc.zyngier@arm.com>2019-02-19 21:05:43 +0000
commitbee038a67487598ebbe995f85bf60c3a5b2e9099 (patch)
treec0756ab3d7bc4822adff585a482c940135f4db6e /include/kvm
parent9e01dc76be6a3b5768cb02130d2ff0055a68809a (diff)
downloadlwn-bee038a67487598ebbe995f85bf60c3a5b2e9099.tar.gz
lwn-bee038a67487598ebbe995f85bf60c3a5b2e9099.zip
KVM: arm/arm64: Rework the timer code to use a timer_map
We are currently emulating two timers in two different ways. When we add support for nested virtualization in the future, we are going to be emulating either two timers in two diffferent ways, or four timers in a single way. We need a unified data structure to keep track of how we map virtual state to physical state and we need to cleanup some of the timer code to operate more independently on a struct arch_timer_context instead of trying to consider the global state of the VCPU and recomputing all state. Co-written with Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
Diffstat (limited to 'include/kvm')
-rw-r--r--include/kvm/arm_arch_timer.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h
index 6d4a33a9c45a..05a18dd265b5 100644
--- a/include/kvm/arm_arch_timer.h
+++ b/include/kvm/arm_arch_timer.h
@@ -51,11 +51,24 @@ struct arch_timer_context {
/* Emulated Timer (may be unused) */
struct hrtimer hrtimer;
+ /*
+ * We have multiple paths which can save/restore the timer state onto
+ * the hardware, so we need some way of keeping track of where the
+ * latest state is.
+ */
+ bool loaded;
+
/* Duplicated state from arch_timer.c for convenience */
u32 host_timer_irq;
u32 host_timer_irq_flags;
};
+struct timer_map {
+ struct arch_timer_context *direct_vtimer;
+ struct arch_timer_context *direct_ptimer;
+ struct arch_timer_context *emul_ptimer;
+};
+
struct arch_timer_cpu {
struct arch_timer_context timers[NR_KVM_TIMERS];
@@ -64,16 +77,6 @@ struct arch_timer_cpu {
/* Is the timer enabled */
bool enabled;
-
- /*
- * We have multiple paths which can save/restore the timer state
- * onto the hardware, so we need some way of keeping track of
- * where the latest state is.
- *
- * loaded == true: State is loaded on the hardware registers.
- * loaded == false: State is stored in memory.
- */
- bool loaded;
};
int kvm_timer_hyp_init(bool);