diff options
author | Marc Zyngier <maz@kernel.org> | 2023-03-30 20:47:56 +0300 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2023-03-30 21:01:10 +0300 |
commit | 1e0eec09d43a55125ff80e40b2d6e2f369a338b9 (patch) | |
tree | 2a359e5a80f73aec8a9fad6d30f7851fc5ade982 /arch/arm64/kvm/arch_timer.c | |
parent | 1935d34afaebe01ddb75bfaa62fb7fe957ddc210 (diff) | |
download | linux-1e0eec09d43a55125ff80e40b2d6e2f369a338b9.tar.xz |
KVM: arm64: nv: timers: Add a per-timer, per-vcpu offset
Being able to set a global offset isn't enough.
With NV, we also need to a per-vcpu, per-timer offset (for example,
CNTVCT_EL0 being offset by CNTVOFF_EL2).
Use a similar method as the VM-wide offset to have a timer point
to the shadow register that contains the offset value.
Reviewed-by: Colton Lewis <coltonlewis@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230330174800.2677007-17-maz@kernel.org
Diffstat (limited to 'arch/arm64/kvm/arch_timer.c')
-rw-r--r-- | arch/arm64/kvm/arch_timer.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index d3a7902269c1..b87bf182af33 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -89,10 +89,17 @@ u64 timer_get_cval(struct arch_timer_context *ctxt) static u64 timer_get_offset(struct arch_timer_context *ctxt) { - if (ctxt && ctxt->offset.vm_offset) - return *ctxt->offset.vm_offset; + u64 offset = 0; - return 0; + if (!ctxt) + return 0; + + if (ctxt->offset.vm_offset) + offset += *ctxt->offset.vm_offset; + if (ctxt->offset.vcpu_offset) + offset += *ctxt->offset.vcpu_offset; + + return offset; } static void timer_set_ctl(struct arch_timer_context *ctxt, u32 ctl) |