1
0
Fork 0
remarkable-linux/kernel/time
John Stultz f7bcb70eba ktime: Fix ktime_divns to do signed division
It was noted that the 32bit implementation of ktime_divns()
was doing unsigned division and didn't properly handle
negative values.

And when a ktime helper was changed to utilize
ktime_divns, it caused a regression on some IR blasters.
See the following bugzilla for details:
  https://bugzilla.redhat.com/show_bug.cgi?id=1200353

This patch fixes the problem in ktime_divns by checking
and preserving the sign bit, and then reapplying it if
appropriate after the division, it also changes the return
type to a s64 to make it more obvious this is expected.

Nicolas also pointed out that negative dividers would
cause infinite loops on 32bit systems, negative dividers
is unlikely for users of this function, but out of caution
this patch adds checks for negative dividers for both
32-bit (BUG_ON) and 64-bit(WARN_ON) versions to make sure
no such use cases creep in.

[ tglx: Hand an u64 to do_div() to avoid the compiler warning ]

Fixes: 166afb6451 'ktime: Sanitize ktime_to_us/ms conversion'
Reported-and-tested-by: Trevor Cordes <trevor@tecnopolis.ca>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Josh Boyer <jwboyer@redhat.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/1431118043-23452-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2015-05-13 10:19:35 +02:00
..
Kconfig clockevents: Remove CONFIG_GENERIC_CLOCKEVENTS_BUILD 2015-04-01 14:22:57 +02:00
Makefile clockevents: Remove CONFIG_GENERIC_CLOCKEVENTS_BUILD 2015-04-01 14:22:57 +02:00
alarmtimer.c all arches, signal: move restart_block to struct task_struct 2015-02-12 18:54:12 -08:00
clockevents.c Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-05-09 14:57:49 -07:00
clocksource.c clocksource: Improve comment explaining clocks_calc_max_nsecs()'s 50% safety margin 2015-04-03 08:18:35 +02:00
hrtimer.c ktime: Fix ktime_divns to do signed division 2015-05-13 10:19:35 +02:00
itimer.c time/timers: Move all time(r) related files into kernel/time 2014-06-23 11:22:35 +02:00
jiffies.c tick: Move clocksource related stuff to timekeeping.h 2015-04-01 14:22:58 +02:00
ntp.c time: Add y2038 safe update_persistent_clock64() 2015-04-03 08:18:20 +02:00
ntp_internal.h timekeeping: Convert timekeeping core to use timespec64s 2014-07-23 10:17:54 -07:00
posix-clock.c kernel: Fix files explicitly needing EXPORT_SYMBOL infrastructure 2011-10-31 19:30:05 -04:00
posix-cpu-timers.c all arches, signal: move restart_block to struct task_struct 2015-02-12 18:54:12 -08:00
posix-timers.c posix-timers: Fix stack info leak in timer_create() 2014-10-25 10:43:15 +02:00
sched_clock.c timers, sched/clock: Clean up the code a bit 2015-03-27 08:34:01 +01:00
test_udelay.c time: Rename udelay_test.c to test_udelay.c 2014-11-21 11:59:55 -08:00
tick-broadcast-hrtimer.c timers/tick/broadcast-hrtimer: Fix suspicious RCU usage in idle loop 2015-03-23 10:50:05 +01:00
tick-broadcast.c clockevents: Cleanup dead cpu explicitely 2015-04-03 08:44:37 +02:00
tick-common.c timers/PM: Drop unnecessary braces from tick_freeze() 2015-04-03 15:15:52 +02:00
tick-internal.h clockevents: Cleanup dead cpu explicitely 2015-04-03 08:44:37 +02:00
tick-oneshot.c clockevents: Manage device's state separately for the core 2015-03-27 10:26:19 +01:00
tick-sched.c tick: Move core only declarations and functions to core 2015-04-01 14:22:58 +02:00
tick-sched.h arm/bL_switcher: Kill tick suspend hackery 2015-04-01 14:23:00 +02:00
time.c Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-01-25 17:47:34 -08:00
timeconst.bc time/timers: Move all time(r) related files into kernel/time 2014-06-23 11:22:35 +02:00
timeconv.c time: add function to convert between calendar time and broken-down time for universal use 2009-09-24 07:20:56 -07:00
timecounter.c timecounter: keep track of accumulated fractional nanoseconds 2014-12-30 18:29:27 -05:00
timekeeping.c timekeeping: Get rid of stale comment 2015-04-03 08:44:37 +02:00
timekeeping.h tick: Move clocksource related stuff to timekeeping.h 2015-04-01 14:22:58 +02:00
timekeeping_debug.c timekeeping: Convert timekeeping core to use timespec64s 2014-07-23 10:17:54 -07:00
timekeeping_internal.h clocksource: Move cycle_last validation to core code 2014-07-23 15:01:51 -07:00
timer.c timer: Further simplify the SMP and HOTPLUG logic 2015-04-02 17:46:21 +02:00
timer_list.c tick: Move core only declarations and functions to core 2015-04-01 14:22:58 +02:00
timer_stats.c timer stats: Add a 'Collection: active/inactive' line to timer usage statistics 2013-10-10 09:59:25 +02:00