On Wed, 12 Feb 2025 11:41:38 +0000,
Dan Carpenter <dan.carpen...@linaro.org> wrote:
> 
> On Tue, Feb 11, 2025 at 11:36:31AM +0000, Marc Zyngier wrote:
> > For the crash at hand, which clearly shows nVHE, can you report
> > whether the following hack fixes it for you?
> > 
> >     M.
> 
> No luck, I'm afraid.  It still crashes the same way.

Right. It was one level deeper. The following change fixes it for
me. YMMV.

        M.

diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h 
b/arch/arm64/kvm/hyp/include/hyp/switch.h
index f838a45665f26..b899d815d272f 100644
--- a/arch/arm64/kvm/hyp/include/hyp/switch.h
+++ b/arch/arm64/kvm/hyp/include/hyp/switch.h
@@ -501,9 +501,22 @@ static inline bool handle_tx2_tvm(struct kvm_vcpu *vcpu)
        return true;
 }
 
+/* Open-coded version of timer_get_offset() to allow for kern_hyp_va() */
+static inline u64 hyp_timer_get_offset(struct arch_timer_context *ctxt)
+{
+       u64 offset = 0;
+
+       if (ctxt->offset.vm_offset)
+               offset += *kern_hyp_va(ctxt->offset.vm_offset);
+       if (ctxt->offset.vcpu_offset)
+               offset += *kern_hyp_va(ctxt->offset.vcpu_offset);
+
+       return offset;
+}
+
 static inline u64 compute_counter_value(struct arch_timer_context *ctxt)
 {
-       return arch_timer_read_cntpct_el0() - timer_get_offset(ctxt);
+       return arch_timer_read_cntpct_el0() - hyp_timer_get_offset(ctxt);
 }
 
 static bool kvm_handle_cntxct(struct kvm_vcpu *vcpu)

-- 
Without deviation from the norm, progress is not possible.

Reply via email to