]> 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)
committerJulien Grall <julien@xen.org>
Mon, 27 Jan 2020 11:55:01 +0000 (11:55 +0000)
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>
xen/arch/arm/vtimer.c

index 08411f33a95032d8617f5a1369be94755c434956..6d39fc944f888b30f992a4370909d33ff54ef2a5 100644 (file)
@@ -215,7 +215,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;