#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/mutex.h>
#include <linux/sched/task.h>
#include <linux/uaccess.h>
#include <linux/list.h>
#include <linux/init.h>
#include <linux/compiler.h>
#include <linux/hash.h>
#include <linux/posix-clock.h>
#include <linux/posix-timers.h>
#include <linux/syscalls.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <linux/export.h>
#include <linux/hashtable.h>
#include <linux/compat.h>
#include <linux/nospec.h>
#include <linux/time_namespace.h>
#include "timekeeping.h"
#include "posix-timers.h"
static struct kmem_cache *posix_timers_cache;
static DEFINE_HASHTABLE(posix_timers_hashtable, 9);
static DEFINE_SPINLOCK(hash_lock);
static const struct k_clock * const posix_clocks[];
static const struct k_clock *clockid_to_kclock(const clockid_t id);
static const struct k_clock clock_realtime, clock_monotonic;
#if SIGEV_THREAD_ID != (SIGEV_THREAD_ID & \
~(SIGEV_SIGNAL | SIGEV_NONE | SIGEV_THREAD))
#error "SIGEV_THREAD_ID must not share bit with other SIGEV values!"
#endif
static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags);
#define lock_timer(tid, flags) …
static int hash(struct signal_struct *sig, unsigned int nr)
{ … }
static struct k_itimer *__posix_timers_find(struct hlist_head *head,
struct signal_struct *sig,
timer_t id)
{ … }
static struct k_itimer *posix_timer_by_id(timer_t id)
{ … }
static int posix_timer_add(struct k_itimer *timer)
{ … }
static inline void unlock_timer(struct k_itimer *timr, unsigned long flags)
{ … }
static int posix_get_realtime_timespec(clockid_t which_clock, struct timespec64 *tp)
{ … }
static ktime_t posix_get_realtime_ktime(clockid_t which_clock)
{ … }
static int posix_clock_realtime_set(const clockid_t which_clock,
const struct timespec64 *tp)
{ … }
static int posix_clock_realtime_adj(const clockid_t which_clock,
struct __kernel_timex *t)
{ … }
static int posix_get_monotonic_timespec(clockid_t which_clock, struct timespec64 *tp)
{ … }
static ktime_t posix_get_monotonic_ktime(clockid_t which_clock)
{ … }
static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec64 *tp)
{ … }
static int posix_get_realtime_coarse(clockid_t which_clock, struct timespec64 *tp)
{ … }
static int posix_get_monotonic_coarse(clockid_t which_clock,
struct timespec64 *tp)
{ … }
static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 *tp)
{ … }
static int posix_get_boottime_timespec(const clockid_t which_clock, struct timespec64 *tp)
{ … }
static ktime_t posix_get_boottime_ktime(const clockid_t which_clock)
{ … }
static int posix_get_tai_timespec(clockid_t which_clock, struct timespec64 *tp)
{ … }
static ktime_t posix_get_tai_ktime(clockid_t which_clock)
{ … }
static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
{ … }
static __init int init_posix_timers(void)
{ … }
__initcall(init_posix_timers);
static inline int timer_overrun_to_int(struct k_itimer *timr, int baseval)
{ … }
static void common_hrtimer_rearm(struct k_itimer *timr)
{ … }
void posixtimer_rearm(struct kernel_siginfo *info)
{ … }
int posix_timer_event(struct k_itimer *timr, int si_private)
{ … }
static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
{ … }
static struct pid *good_sigevent(sigevent_t * event)
{ … }
static struct k_itimer * alloc_posix_timer(void)
{ … }
static void k_itimer_rcu_free(struct rcu_head *head)
{ … }
static void posix_timer_free(struct k_itimer *tmr)
{ … }
static void posix_timer_unhash_and_free(struct k_itimer *tmr)
{ … }
static int common_timer_create(struct k_itimer *new_timer)
{ … }
static int do_timer_create(clockid_t which_clock, struct sigevent *event,
timer_t __user *created_timer_id)
{ … }
SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
struct sigevent __user *, timer_event_spec,
timer_t __user *, created_timer_id)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE3(timer_create, clockid_t, which_clock,
struct compat_sigevent __user *, timer_event_spec,
timer_t __user *, created_timer_id)
{ … }
#endif
static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags)
{ … }
static ktime_t common_hrtimer_remaining(struct k_itimer *timr, ktime_t now)
{ … }
static s64 common_hrtimer_forward(struct k_itimer *timr, ktime_t now)
{ … }
void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
{ … }
static int do_timer_gettime(timer_t timer_id, struct itimerspec64 *setting)
{ … }
SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
struct __kernel_itimerspec __user *, setting)
{ … }
#ifdef CONFIG_COMPAT_32BIT_TIME
SYSCALL_DEFINE2(timer_gettime32, timer_t, timer_id,
struct old_itimerspec32 __user *, setting)
{ … }
#endif
SYSCALL_DEFINE1(timer_getoverrun, timer_t, timer_id)
{ … }
static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
bool absolute, bool sigev_none)
{ … }
static int common_hrtimer_try_to_cancel(struct k_itimer *timr)
{ … }
static void common_timer_wait_running(struct k_itimer *timer)
{ … }
static struct k_itimer *timer_wait_running(struct k_itimer *timer,
unsigned long *flags)
{ … }
int common_timer_set(struct k_itimer *timr, int flags,
struct itimerspec64 *new_setting,
struct itimerspec64 *old_setting)
{ … }
static int do_timer_settime(timer_t timer_id, int tmr_flags,
struct itimerspec64 *new_spec64,
struct itimerspec64 *old_spec64)
{ … }
SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
const struct __kernel_itimerspec __user *, new_setting,
struct __kernel_itimerspec __user *, old_setting)
{ … }
#ifdef CONFIG_COMPAT_32BIT_TIME
SYSCALL_DEFINE4(timer_settime32, timer_t, timer_id, int, flags,
struct old_itimerspec32 __user *, new,
struct old_itimerspec32 __user *, old)
{ … }
#endif
int common_timer_del(struct k_itimer *timer)
{ … }
static inline int timer_delete_hook(struct k_itimer *timer)
{ … }
SYSCALL_DEFINE1(timer_delete, timer_t, timer_id)
{ … }
static void itimer_delete(struct k_itimer *timer)
{ … }
void exit_itimers(struct task_struct *tsk)
{ … }
SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
const struct __kernel_timespec __user *, tp)
{ … }
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
struct __kernel_timespec __user *, tp)
{ … }
int do_clock_adjtime(const clockid_t which_clock, struct __kernel_timex * ktx)
{ … }
SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
struct __kernel_timex __user *, utx)
{ … }
SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
struct __kernel_timespec __user *, tp)
{ … }
#ifdef CONFIG_COMPAT_32BIT_TIME
SYSCALL_DEFINE2(clock_settime32, clockid_t, which_clock,
struct old_timespec32 __user *, tp)
{ … }
SYSCALL_DEFINE2(clock_gettime32, clockid_t, which_clock,
struct old_timespec32 __user *, tp)
{ … }
SYSCALL_DEFINE2(clock_adjtime32, clockid_t, which_clock,
struct old_timex32 __user *, utp)
{ … }
SYSCALL_DEFINE2(clock_getres_time32, clockid_t, which_clock,
struct old_timespec32 __user *, tp)
{ … }
#endif
static int common_nsleep(const clockid_t which_clock, int flags,
const struct timespec64 *rqtp)
{ … }
static int common_nsleep_timens(const clockid_t which_clock, int flags,
const struct timespec64 *rqtp)
{ … }
SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
const struct __kernel_timespec __user *, rqtp,
struct __kernel_timespec __user *, rmtp)
{ … }
#ifdef CONFIG_COMPAT_32BIT_TIME
SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,
struct old_timespec32 __user *, rqtp,
struct old_timespec32 __user *, rmtp)
{ … }
#endif
static const struct k_clock clock_realtime = …;
static const struct k_clock clock_monotonic = …;
static const struct k_clock clock_monotonic_raw = …;
static const struct k_clock clock_realtime_coarse = …;
static const struct k_clock clock_monotonic_coarse = …;
static const struct k_clock clock_tai = …;
static const struct k_clock clock_boottime = …;
static const struct k_clock * const posix_clocks[] = …;
static const struct k_clock *clockid_to_kclock(const clockid_t id)
{ … }