diff mbox series

[v4,2/2] xen/arm: Sign extend TimerValue when computing the CompareValue

Message ID 20200121150704.126001-3-jeff.kubascik@dornerworks.com (mailing list archive)
State New, archived
Headers show
Series xen/arm: physical timer improvements | expand

Commit Message

Jeff Kubascik Jan. 21, 2020, 3:07 p.m. UTC
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>
---
 xen/arch/arm/vtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Julien Grall Jan. 23, 2020, 12:29 p.m. UTC | #1
Hi,

On 21/01/2020 15:07, Jeff Kubascik wrote:
> 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>

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c
index 0c78a65863..fed89498a9 100644
--- a/xen/arch/arm/vtimer.c
+++ b/xen/arch/arm/vtimer.c
@@ -211,7 +211,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;