diff options
author | Dan Crowell <dcrowell@us.ibm.com> | 2018-04-11 10:43:18 -0500 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2018-04-19 09:10:24 -0400 |
commit | a322b3d7b9bf9f41192ee757fa78f55816da9a71 (patch) | |
tree | 3272246a348d8a1f074f6d0c0863b1c2c99e6f38 | |
parent | e86221ce862640b1bc72b26182ef166a75a8ef1e (diff) | |
download | talos-hostboot-a322b3d7b9bf9f41192ee757fa78f55816da9a71.tar.gz talos-hostboot-a322b3d7b9bf9f41192ee757fa78f55816da9a71.zip |
Handle overruns in nanosleep
The nanosleep takes seconds and nanoseconds as parameters but it
doesn't currently enforce that nsec doesn't exceed a sec.
The change here is to handle any overlaps to get the desired
results.
Change-Id: Ic9f32c3164499af5d5ee888aaad4a1beee8ed625
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/57075
CI-Ready: Daniel M. Crowell <dcrowell@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
-rw-r--r-- | src/lib/syscall_time.C | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/syscall_time.C b/src/lib/syscall_time.C index 75bc0e312..6b34c1b60 100644 --- a/src/lib/syscall_time.C +++ b/src/lib/syscall_time.C @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2010,2014 */ +/* Contributors Listed Below - COPYRIGHT 2010,2018 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -25,15 +27,19 @@ #include <sys/syscall.h> #include <errno.h> #include <kernel/timemgr.H> +#include <kernel/console.H> +#include <sys/task.h> using namespace Systemcalls; -void nanosleep(uint64_t sec, uint64_t nsec) +void nanosleep(uint64_t i_sec, uint64_t i_nsec) { + uint64_t l_sec = i_sec + i_nsec/NS_PER_SEC; + uint64_t l_nsec = i_nsec%NS_PER_SEC; // If the delay is short then simpleDelay() will perform the delay - if(unlikely(!TimeManager::simpleDelay(sec, nsec))) + if(unlikely(!TimeManager::simpleDelay(l_sec, l_nsec))) { - _syscall2(TIME_NANOSLEEP, (void*)sec, (void*)nsec); + _syscall2(TIME_NANOSLEEP, (void*)l_sec, (void*)l_nsec); } } |