]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: Sign extend TimerValue when computing the CompareValue
authorJeff Kubascik <jeff.kubascik@dornerworks.com>
Tue, 21 Jan 2020 15:07:04 +0000 (10:07 -0500)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 10 Apr 2020 16:34:16 +0000 (09:34 -0700)
Xen will only store the CompareValue as it can be derived from the
TimerValue (ARM DDI 0487E.a section D11.2.4):

  CompareValue = (Counter[63:0] + SignExtend(TimerValue))[63:0]

While the TimerValue is a 32-bit signed value, our implementation
assumed it is a 32-bit unsigned value.

Signed-off-by: Jeff Kubascik <jeff.kubascik@dornerworks.com>
Acked-by: Julien Grall <julien@xen.org>
(cherry picked from commit 3c601c5f056fba055b7a1438b84b69fc649275c3)

xen/arch/arm/vtimer.c

index b15f304c1eebb2210ef3bde80435ffc0db05d945..2697e6a7846de89ae1cbdf7115f88ae313bc16b9 100644 (file)
@@ -217,7 +217,7 @@ static bool vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r,
     }
     else
     {
-        v->arch.phys_timer.cval = cntpct + *r;
+        v->arch.phys_timer.cval = cntpct + (uint64_t)(int32_t)*r;
         if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE )
         {
             v->arch.phys_timer.ctl &= ~CNTx_CTL_PENDING;