diff options
author | Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> | 2013-11-09 18:52:21 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-11-09 18:52:21 +0100 |
commit | e2dde67c3f46f5bbe7deb90e52b61977df30a52c (patch) | |
tree | a4090bea6ecedb4cfe7b78aef465311a04740503 | |
parent | 24d8170fa18e3bad9ef2fa1e100e34e93a6c1126 (diff) |
Fix overflow in Xen clock computation
* xen/time.c (hyp_get_stime): Split `delta` into `delta_high` and
`delta_low`, as it may overflow 4 second timing nowadays.
-rw-r--r-- | xen/time.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -34,6 +34,7 @@ static unsigned64_t lastnsec; static unsigned64_t hyp_get_stime(void) { unsigned32_t version; unsigned64_t cpu_clock, last_cpu_clock, delta, system_time; + unsigned64_t delta_high, delta_low; unsigned32_t mul; signed8_t shift; volatile struct vcpu_time_info *time = &hyp_shared_info.vcpu_info[0].time; @@ -54,7 +55,10 @@ static unsigned64_t hyp_get_stime(void) { delta >>= -shift; else delta <<= shift; - return system_time + ((delta * (unsigned64_t) mul) >> 32); + delta_high = delta >> 32; + delta_low = (unsigned32_t) delta; + return system_time + ((delta_low * (unsigned64_t) mul) >> 32) + + (delta_high * (unsigned64_t) mul); } unsigned64_t hyp_get_time(void) { |