Commit 34464a5b8937b79801776dfb6970c1b949fed4be

Authored by Rafael J. Wysocki
Committed by Andi Kleen
1 parent a549b86dd0

[PATCH] Detect clock skew during suspend

Detect the situations in which the time after a resume from disk would
be earlier than the time before the suspend and prevent them from
happening on x86_64.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Andi Kleen <ak@suse.de>

Showing 1 changed file with 9 additions and 1 deletions Side-by-side Diff

arch/x86_64/kernel/time.c
... ... @@ -1039,8 +1039,16 @@
1039 1039 unsigned long flags;
1040 1040 unsigned long sec;
1041 1041 unsigned long ctime = get_cmos_time();
1042   - unsigned long sleep_length = (ctime - sleep_start) * HZ;
  1042 + long sleep_length = (ctime - sleep_start) * HZ;
1043 1043  
  1044 + if (sleep_length < 0) {
  1045 + printk(KERN_WARNING "Time skew detected in timer resume!\n");
  1046 + /* The time after the resume must not be earlier than the time
  1047 + * before the suspend or some nasty things will happen
  1048 + */
  1049 + sleep_length = 0;
  1050 + ctime = sleep_start;
  1051 + }
1044 1052 if (vxtime.hpet_address)
1045 1053 hpet_reenable();
1046 1054 else