Skip to content

Commit 70a0622

Browse files
Tim Deegantorvalds
authored andcommitted
fix jiffy calculations in calibrate_delay_direct to handle overflow
Fixes a hang when booting as dom0 under Xen, when jiffies can be quite large by the time the kernel init gets this far. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> [jbeulich@novell.com: !time_after() -> time_before_eq() as suggested by Jiri Slaby] Signed-off-by: Jan Beulich <jbeulich@novell.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6148a47 commit 70a0622

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎init/calibrate.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ static unsigned long __cpuinit calibrate_delay_direct(void)
6666
pre_start = 0;
6767
read_current_timer(&start);
6868
start_jiffies = jiffies;
69-
while (jiffies <= (start_jiffies + 1)) {
69+
while (time_before_eq(jiffies, start_jiffies + 1)) {
7070
pre_start = start;
7171
read_current_timer(&start);
7272
}
7373
read_current_timer(&post_start);
7474

7575
pre_end = 0;
7676
end = post_start;
77-
while (jiffies <=
78-
(start_jiffies + 1 + DELAY_CALIBRATION_TICKS)) {
77+
while (time_before_eq(jiffies, start_jiffies + 1 +
78+
DELAY_CALIBRATION_TICKS)) {
7979
pre_end = end;
8080
read_current_timer(&end);
8181
}

0 commit comments

Comments
 (0)