All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 09/22] posix-timers:Convert to the 64bit methods for the clock_settime syscall function
@ 2015-05-11 11:16 Baolin Wang
  2015-05-12 14:51 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Baolin Wang @ 2015-05-11 11:16 UTC (permalink / raw)
  To: tglx; +Cc: arnd, linux-kernel, baolin.wang, y2038

This patch introduces the clock_set64 methods with timespec64 type for k_clock
structure.

Convert to the 64bit methods with timespec64 type for the clock_settime syscall
function, and change the clock_settime syscall implementation according the the
CONFIG_64BIT macro.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/linux/posix-timers.h |    2 ++
 kernel/time/posix-timers.c   |   28 +++++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 870ab93..9b6469c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -100,6 +100,8 @@ struct k_clock {
 	int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
 	int (*clock_set) (const clockid_t which_clock,
 			  const struct timespec *tp);
+	int (*clock_set64) (const clockid_t which_clock,
+			    const struct timespec64 *tp);
 	int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
 	int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
 	int (*timer_create) (struct k_itimer *timer);
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index dcc35fc..0fe8a65 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -535,6 +535,16 @@ static int default_timer_set64(struct k_itimer *timr, int flags,
 	return 0;
 }
 
+static int default_clock_set64(const clockid_t which_clock,
+			       const struct timespec64 *tp64)
+{
+	struct k_clock *kc = clockid_to_kclock(which_clock);
+	struct timespec tp;
+
+	kc->clock_set(which_clock, &tp);
+	return 0;
+}
+
 void posix_timers_register_clock(const clockid_t clock_id,
 				 struct k_clock *new_clock)
 {
@@ -559,6 +569,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
 		new_clock->timer_get64 = default_timer_get64;
 	if (new_clock->timer_set && !new_clock->timer_set64)
 		new_clock->timer_set64 = default_timer_set64;
+	if (new_clock->clock_set && !new_clock->clock_set64)
+		new_clock->clock_set64 = default_clock_set64;
 
 	posix_clocks[clock_id] = *new_clock;
 }
@@ -1072,25 +1084,35 @@ void exit_itimers(struct signal_struct *sig)
 	}
 }
 
-static int __clock_settime(clockid_t which_clock, struct timespec *ts)
+static int __clock_settime(clockid_t which_clock, struct timespec64 *ts)
 {
 	struct k_clock *kc = clockid_to_kclock(which_clock);
 
-	if (!kc || !kc->clock_set)
+	if (!kc || !kc->clock_set64)
 		return -EINVAL;
 
-	return kc->clock_set(which_clock, ts);
+	return kc->clock_set64(which_clock, ts);
 }
 
 SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
 		const struct timespec __user *, tp)
 {
+#ifdef CONFIG_64BIT
+	struct timespec64 new_tp;
+#else
 	struct timespec new_tp;
+	struct timespec64 new_tp64;
+#endif
 
 	if (copy_from_user(&new_tp, tp, sizeof (*tp)))
 		return -EFAULT;
 
+#ifdef CONFIG_64BIT
 	return __clock_settime(which_clock, &new_tp);
+#else
+	new_tp64 = timespec_to_timespec64(new_tp);
+	return __clock_settime(which_clock, &new_tp64);
+#endif
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 09/22] posix-timers:Convert to the 64bit methods for the clock_settime syscall function
  2015-05-11 11:16 [PATCH v3 09/22] posix-timers:Convert to the 64bit methods for the clock_settime syscall function Baolin Wang
@ 2015-05-12 14:51 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2015-05-12 14:51 UTC (permalink / raw)
  To: Baolin Wang; +Cc: arnd, linux-kernel, y2038

On Mon, 11 May 2015, Baolin Wang wrote:
> +static int default_clock_set64(const clockid_t which_clock,
> +			       const struct timespec64 *tp64)
> +{
> +	struct k_clock *kc = clockid_to_kclock(which_clock);
> +	struct timespec tp;
> +
> +	kc->clock_set(which_clock, &tp);

So you set the clock from an unitialized variable.....

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-12 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-11 11:16 [PATCH v3 09/22] posix-timers:Convert to the 64bit methods for the clock_settime syscall function Baolin Wang
2015-05-12 14:51 ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.