summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-07-19 10:44:45 -0700
committergVisor bot <gvisor-bot@google.com>2019-07-19 10:44:45 -0700
commitf544509c01970f4143526e7e85bc02b3b1799a8a (patch)
treefae21bd74c7b4f632a5ef216362e777c01b4356a /pkg
parent0e040ba6e87f5fdcb23854909aad39aa1883925f (diff)
parent2d11fa05f7b705f74c737f5a59fe40414bb6f8d8 (diff)
Merge pull request #450 from Pixep:feature/add-clock-boottime-as-monotonic
PiperOrigin-RevId: 258996346
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/syscalls/linux/sys_time.go9
-rw-r--r--pkg/sentry/syscalls/linux/sys_timerfd.go2
2 files changed, 9 insertions, 2 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_time.go b/pkg/sentry/syscalls/linux/sys_time.go
index fe8725191..4b3f043a2 100644
--- a/pkg/sentry/syscalls/linux/sys_time.go
+++ b/pkg/sentry/syscalls/linux/sys_time.go
@@ -121,8 +121,15 @@ func getClock(t *kernel.Task, clockID int32) (ktime.Clock, error) {
switch clockID {
case linux.CLOCK_REALTIME, linux.CLOCK_REALTIME_COARSE:
return t.Kernel().RealtimeClock(), nil
- case linux.CLOCK_MONOTONIC, linux.CLOCK_MONOTONIC_COARSE, linux.CLOCK_MONOTONIC_RAW:
+ case linux.CLOCK_MONOTONIC, linux.CLOCK_MONOTONIC_COARSE,
+ linux.CLOCK_MONOTONIC_RAW, linux.CLOCK_BOOTTIME:
// CLOCK_MONOTONIC approximates CLOCK_MONOTONIC_RAW.
+ // CLOCK_BOOTTIME is internally mapped to CLOCK_MONOTONIC, as:
+ // - CLOCK_BOOTTIME should behave as CLOCK_MONOTONIC while also
+ // including suspend time.
+ // - gVisor has no concept of suspend/resume.
+ // - CLOCK_MONOTONIC already includes save/restore time, which is
+ // the closest to suspend time.
return t.Kernel().MonotonicClock(), nil
case linux.CLOCK_PROCESS_CPUTIME_ID:
return t.ThreadGroup().CPUClock(), nil
diff --git a/pkg/sentry/syscalls/linux/sys_timerfd.go b/pkg/sentry/syscalls/linux/sys_timerfd.go
index 1ce5ce4c3..cf49b43db 100644
--- a/pkg/sentry/syscalls/linux/sys_timerfd.go
+++ b/pkg/sentry/syscalls/linux/sys_timerfd.go
@@ -37,7 +37,7 @@ func TimerfdCreate(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel
switch clockID {
case linux.CLOCK_REALTIME:
c = t.Kernel().RealtimeClock()
- case linux.CLOCK_MONOTONIC:
+ case linux.CLOCK_MONOTONIC, linux.CLOCK_BOOTTIME:
c = t.Kernel().MonotonicClock()
default:
return 0, nil, syserror.EINVAL