qemu-e2k/hw/timer
Peter Maydell d17008bc29 hw/timer/hpet.c: Avoid signed integer overflow which results in bugs on OSX
Signed integer overflow in C is undefined behaviour, and the compiler
is at liberty to assume it can never happen and optimize accordingly.
In particular, the subtractions in hpet_time_after() and hpet_time_after64()
were causing OSX clang to optimize the code such that it was prone to
hangs and complaints about the main loop stalling (presumably because
we were spending all our time trying to service very high frequency
HPET timer callbacks). The clang sanitizer confirms the UB:

hw/timer/hpet.c:119:26: runtime error: signed integer overflow: -2146967296 - 2147003978 cannot be represented in type 'int'

Fix this by doing the subtraction as an unsigned operation and then
converting to signed for the comparison.

Reported-by: Aaron Elkins <threcius@yahoo.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1447080991-24995-1-git-send-email-peter.maydell@linaro.org
2015-11-09 15:48:21 +00:00
..
a9gtimer.c
allwinner-a10-pit.c
arm_mptimer.c
arm_timer.c
cadence_ttc.c
digic-timer.c
ds1338.c
etraxfs_timer.c
exynos4210_mct.c
exynos4210_pwm.c
exynos4210_rtc.c
grlib_gptimer.c
hpet.c hw/timer/hpet.c: Avoid signed integer overflow which results in bugs on OSX 2015-11-09 15:48:21 +00:00
i8254_common.c
i8254.c
imx_epit.c i.MX: Standardize i.MX EPIT debug 2015-10-27 15:59:46 +00:00
imx_gpt.c i.MX: Standardize i.MX GPT debug 2015-10-27 15:59:46 +00:00
lm32_timer.c
m48t59.c hw: timer: Remove unnecessary variable 2015-10-08 19:46:47 +03:00
Makefile.objs
mc146818rtc.c timer: rename NSEC_PER_SEC due to Mac OS X header clash 2015-07-20 17:01:00 +01:00
milkymist-sysctl.c
omap_gptimer.c arm: Use g_new() & friends where that makes obvious sense 2015-09-07 10:39:27 +01:00
omap_synctimer.c
pl031.c
puv3_ost.c
pxa2xx_timer.c
sh_timer.c
slavio_timer.c
stm32f2xx_timer.c
tusb6010.c
twl92230.c
xilinx_timer.c