Skip to content

Commit d68712e

Browse files
arndbdavem330
authored andcommitted
y2038: sparc: remove use of struct timex
'struct timex' is one of the last users of 'struct timeval' and is only referenced in one place in the kernel any more, to convert the user space timex into the kernel-internal version on sparc64, with a different tv_usec member type. As a preparation for hiding the time_t definition and everything using that in the kernel, change the implementation once more to only convert the timeval member, and then enclose the struct definition in an #ifdef. Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Julian Calaby <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5637bc5 commit d68712e

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

arch/sparc/kernel/sys_sparc_64.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -545,34 +545,35 @@ SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len)
545545
return err;
546546
}
547547

548-
SYSCALL_DEFINE1(sparc_adjtimex, struct timex __user *, txc_p)
548+
SYSCALL_DEFINE1(sparc_adjtimex, struct __kernel_timex __user *, txc_p)
549549
{
550-
struct timex txc; /* Local copy of parameter */
551-
struct __kernel_timex *kt = (void *)&txc;
550+
struct __kernel_timex txc;
551+
struct __kernel_old_timeval *tv = (void *)&txc_p->time;
552552
int ret;
553553

554554
/* Copy the user data space into the kernel copy
555555
* structure. But bear in mind that the structures
556556
* may change
557557
*/
558-
if (copy_from_user(&txc, txc_p, sizeof(struct timex)))
558+
if (copy_from_user(&txc, txc_p, sizeof(txc)))
559559
return -EFAULT;
560560

561561
/*
562562
* override for sparc64 specific timeval type: tv_usec
563563
* is 32 bit wide instead of 64-bit in __kernel_timex
564564
*/
565-
kt->time.tv_usec = txc.time.tv_usec;
566-
ret = do_adjtimex(kt);
567-
txc.time.tv_usec = kt->time.tv_usec;
565+
txc.time.tv_usec = tv->tv_usec;
566+
ret = do_adjtimex(&txc);
567+
tv->tv_usec = txc.time.tv_usec;
568568

569-
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
569+
return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret;
570570
}
571571

572-
SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex __user *, txc_p)
572+
SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,
573+
struct __kernel_timex __user *, txc_p)
573574
{
574-
struct timex txc; /* Local copy of parameter */
575-
struct __kernel_timex *kt = (void *)&txc;
575+
struct __kernel_timex txc;
576+
struct __kernel_old_timeval *tv = (void *)&txc_p->time;
576577
int ret;
577578

578579
if (!IS_ENABLED(CONFIG_POSIX_TIMERS)) {
@@ -587,18 +588,18 @@ SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex _
587588
* structure. But bear in mind that the structures
588589
* may change
589590
*/
590-
if (copy_from_user(&txc, txc_p, sizeof(struct timex)))
591+
if (copy_from_user(&txc, txc_p, sizeof(txc)))
591592
return -EFAULT;
592593

593594
/*
594595
* override for sparc64 specific timeval type: tv_usec
595596
* is 32 bit wide instead of 64-bit in __kernel_timex
596597
*/
597-
kt->time.tv_usec = txc.time.tv_usec;
598-
ret = do_clock_adjtime(which_clock, kt);
599-
txc.time.tv_usec = kt->time.tv_usec;
598+
txc.time.tv_usec = tv->tv_usec;
599+
ret = do_clock_adjtime(which_clock, &txc);
600+
tv->tv_usec = txc.time.tv_usec;
600601

601-
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
602+
return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret;
602603
}
603604

604605
SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,

include/uapi/linux/timex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
#define NTP_API 4 /* NTP API version */
5959

60+
#ifndef __KERNEL__
6061
/*
6162
* syscall interface - used (mainly by NTP daemon)
6263
* to discipline kernel clock oscillator
@@ -91,6 +92,7 @@ struct timex {
9192
int :32; int :32; int :32; int :32;
9293
int :32; int :32; int :32;
9394
};
95+
#endif
9496

9597
struct __kernel_timex_timeval {
9698
__kernel_time64_t tv_sec;

0 commit comments

Comments
 (0)