As pm_timer_read() + microsecs * NS_PER_USEC may overflow on 32 bit systems. Use a 64 bit type.
Signed-off-by: Ralf Ramsauer <[email protected]> --- inmates/lib/x86/timing.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inmates/lib/x86/timing.c b/inmates/lib/x86/timing.c index de41fc35..1b28ae48 100644 --- a/inmates/lib/x86/timing.c +++ b/inmates/lib/x86/timing.c @@ -107,9 +107,9 @@ unsigned long pm_timer_read(void) void delay_us(unsigned long microsecs) { - unsigned long timeout = pm_timer_read() + microsecs * NS_PER_USEC; + unsigned long long timeout = pm_timer_read() + microsecs * NS_PER_USEC; - while ((long)(timeout - pm_timer_read()) > 0) + while ((long long)(timeout - pm_timer_read()) > 0) cpu_relax(); } -- 2.22.0 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/20190612130332.6175-3-ralf.ramsauer%40oth-regensburg.de. For more options, visit https://groups.google.com/d/optout.
