diff options
-rw-r--r-- | arch/um/os-Linux/time.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index bee98f466d66..dec5678fc17f 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c | |||
@@ -106,6 +106,10 @@ static void deliver_alarm(void) | |||
106 | unsigned long long this_tick = os_nsecs(); | 106 | unsigned long long this_tick = os_nsecs(); |
107 | int one_tick = UM_NSEC_PER_SEC / UM_HZ; | 107 | int one_tick = UM_NSEC_PER_SEC / UM_HZ; |
108 | 108 | ||
109 | /* Protection against the host's time going backwards */ | ||
110 | if ((last_tick != 0) && (this_tick < last_tick)) | ||
111 | this_tick = last_tick; | ||
112 | |||
109 | if (last_tick == 0) | 113 | if (last_tick == 0) |
110 | last_tick = this_tick - one_tick; | 114 | last_tick = this_tick - one_tick; |
111 | 115 | ||
@@ -148,6 +152,9 @@ static int after_sleep_interval(struct timespec *ts) | |||
148 | start_usecs = usec; | 152 | start_usecs = usec; |
149 | 153 | ||
150 | start_usecs -= skew / UM_NSEC_PER_USEC; | 154 | start_usecs -= skew / UM_NSEC_PER_USEC; |
155 | if (start_usecs < 0) | ||
156 | start_usecs = 0; | ||
157 | |||
151 | tv = ((struct timeval) { .tv_sec = start_usecs / UM_USEC_PER_SEC, | 158 | tv = ((struct timeval) { .tv_sec = start_usecs / UM_USEC_PER_SEC, |
152 | .tv_usec = start_usecs % UM_USEC_PER_SEC }); | 159 | .tv_usec = start_usecs % UM_USEC_PER_SEC }); |
153 | interval = ((struct itimerval) { { 0, usec }, tv }); | 160 | interval = ((struct itimerval) { { 0, usec }, tv }); |