@@ -4,6 +4,6 @@
extern unsigned char vrtc_cmos_read(unsigned char reg);
extern void vrtc_cmos_write(unsigned char val, unsigned char reg);
extern void vrtc_get_time(struct timespec *now);
-extern int vrtc_set_mmss(const struct timespec *now);
+extern int vrtc_set_mmss(const struct timespec64 *now);
#endif
@@ -95,7 +95,7 @@ static inline unsigned char current_lock_cmos_reg(void)
unsigned char rtc_cmos_read(unsigned char addr);
void rtc_cmos_write(unsigned char val, unsigned char addr);
-extern int mach_set_rtc_mmss(const struct timespec *now);
+extern int mach_set_rtc_mmss(const struct timespec64 *now);
extern void mach_get_cmos_time(struct timespec *now);
#define RTC_IRQ 8
@@ -143,6 +143,7 @@ struct x86_cpuinit_ops {
};
struct timespec;
+struct timespec64;
/**
* struct x86_platform_ops - platform specific runtime functions
@@ -159,7 +160,7 @@ struct timespec;
struct x86_platform_ops {
unsigned long (*calibrate_tsc)(void);
void (*get_wallclock)(struct timespec *ts);
- int (*set_wallclock)(const struct timespec *ts);
+ int (*set_wallclock)(const struct timespec64 *ts);
void (*iommu_shutdown)(void);
bool (*is_untracked_pat_range)(u64 start, u64 end);
void (*nmi_init)(void);
@@ -71,7 +71,7 @@ static void kvm_get_wallclock(struct timespec *now)
preempt_enable();
}
-static int kvm_set_wallclock(const struct timespec *now)
+static int kvm_set_wallclock(const struct timespec64 *now)
{
return -1;
}
@@ -38,13 +38,13 @@ EXPORT_SYMBOL(rtc_lock);
* jump to the next second precisely 500 ms later. Check the Motorola
* MC146818A or Dallas DS12887 data sheet for details.
*/
-int mach_set_rtc_mmss(const struct timespec *now)
+int mach_set_rtc_mmss(const struct timespec64 *now)
{
- unsigned long nowtime = now->tv_sec;
+ time64_t nowtime = now->tv_sec;
struct rtc_time tm;
int retval = 0;
- rtc_time_to_tm(nowtime, &tm);
+ rtc_time_to_tm64(nowtime, &tm);
if (!rtc_valid_tm(&tm)) {
retval = set_rtc_time(&tm);
if (retval)
@@ -52,8 +52,8 @@ int mach_set_rtc_mmss(const struct timespec *now)
__FUNCTION__, retval);
} else {
printk(KERN_ERR
- "%s: Invalid RTC value: write of %lx to RTC failed\n",
- __FUNCTION__, nowtime);
+ "%s: Invalid RTC value: write of %llx to RTC failed\n",
+ __FUNCTION__, (unsigned long long)nowtime);
retval = -EINVAL;
}
return retval;
@@ -135,9 +135,13 @@ void rtc_cmos_write(unsigned char val, unsigned char addr)
}
EXPORT_SYMBOL(rtc_cmos_write);
+/* TODO: [2038 safety] update_persistent_clock() uses timespec64 */
int update_persistent_clock(struct timespec now)
{
- return x86_platform.set_wallclock(&now);
+ struct timespec64 now64;
+
+ now64 = timespec_to_timespec64(now);
+ return x86_platform.set_wallclock(&now64);
}
/* not static: needed by APM */
@@ -86,14 +86,14 @@ void vrtc_get_time(struct timespec *now)
now->tv_nsec = 0;
}
-int vrtc_set_mmss(const struct timespec *now)
+int vrtc_set_mmss(const struct timespec64 *now)
{
unsigned long flags;
struct rtc_time tm;
int year;
int retval = 0;
- rtc_time_to_tm(now->tv_sec, &tm);
+ rtc_time_to_tm64(now->tv_sec, &tm);
if (!rtc_valid_tm(&tm) && tm.tm_year >= 72) {
/*
* tm.year is the number of years since 1900, and the
@@ -109,8 +109,8 @@ int vrtc_set_mmss(const struct timespec *now)
vrtc_cmos_write(tm.tm_sec, RTC_SECONDS);
spin_unlock_irqrestore(&rtc_lock, flags);
} else {
- pr_err("%s: Invalid vRTC value: write of %lx to vRTC failed\n",
- __FUNCTION__, now->tv_sec);
+ pr_err("%s: Invalid vRTC value: write of %llx to vRTC failed\n",
+ __FUNCTION__, (unsigned long long)now->tv_sec);
retval = -EINVAL;
}
return retval;
@@ -189,7 +189,7 @@ static void xen_get_wallclock(struct timespec *now)
*now = timespec64_to_timespec(now64);
}
-static int xen_set_wallclock(const struct timespec *now)
+static int xen_set_wallclock(const struct timespec64 *now)
{
return -1;
}
As part of addressing 2038 saftey for in-kernel uses, this patch creates no functional change, converts x86_platform.set_wallclock() to use timespec64. Signed-off-by: pang.xunlei <pang.xunlei@linaro.org> --- arch/x86/include/asm/intel_mid_vrtc.h | 2 +- arch/x86/include/asm/mc146818rtc.h | 2 +- arch/x86/include/asm/x86_init.h | 3 ++- arch/x86/kernel/kvmclock.c | 2 +- arch/x86/kernel/rtc.c | 16 ++++++++++------ arch/x86/platform/intel-mid/intel_mid_vrtc.c | 8 ++++---- arch/x86/xen/time.c | 2 +- 7 files changed, 20 insertions(+), 15 deletions(-)