[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] hvm/hpet: Prevent master clock equal to comparator while enabled



commit 62d514c2e7943490ffdc140996c02c9ba2059790
Author:     Don Slutz <dslutz@xxxxxxxxxxx>
AuthorDate: Fri May 2 16:18:07 2014 -0400
Commit:     Tim Deegan <tim@xxxxxxx>
CommitDate: Thu May 8 12:03:53 2014 +0100

    hvm/hpet: Prevent master clock equal to comparator while enabled
    
    Based on the software-developers-hpet-spec-1-0a.pdf, the comparator
    for a periodic timer will change to the new value when it matches
    the master clock.  The current code here uses a very standard
    rounding formula of "((x + y - 1) / y) * y".  This is wrong because
    in this case you need to go to the next comparator value when "x"
    equals "y". Not when "x + 1" equals "y".  In this case "y" is the
    period and "x" is the master clock.
    
    The code lines:
    
        elapsed = hpet_read_maincounter(h, guest_time) +
            period - 1 - comparator;
        comparator += (elapsed / period) * period;
    
    are what matter here.
    
    Using some numbers to help show the issue:
    
    hpet_read_maincounter(h, guest_time) = 130252
    period = 62500
    
    comparator       : 130252
    elapsed          : 62499
    elapsed/period   : 0
    comparator_delta : 0
    new comparator   : 130252
    
    Signed-off-by: Don Slutz <dslutz@xxxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Tim Deegan <tim@xxxxxxx>
---
 xen/arch/x86/hvm/hpet.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c
index f938da9..2a99fed 100644
--- a/xen/arch/x86/hvm/hpet.c
+++ b/xen/arch/x86/hvm/hpet.c
@@ -99,7 +99,7 @@ static uint64_t hpet_get_comparator(HPETState *h, unsigned 
int tn,
         if (period)
         {
             elapsed = hpet_read_maincounter(h, guest_time) +
-                period - 1 - comparator;
+                period - comparator;
             comparator += (elapsed / period) * period;
             h->hpet.comparator64[tn] = comparator;
         }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.