All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] x86: don't include asm/x86_init.h in asm/setup.h
@ 2017-10-19 10:53 Arnd Bergmann
  2017-10-19 10:57   ` Arnd Bergmann
  2017-10-19 13:45 ` [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h tip-bot for Arnd Bergmann
  0 siblings, 2 replies; 13+ messages in thread
From: Arnd Bergmann @ 2017-10-19 10:53 UTC (permalink / raw)
  To: Thomas Gleixner, x86
  Cc: y2038, Arnd Bergmann, Ingo Molnar, H. Peter Anvin, Joerg Roedel,
	linux-kernel, iommu

This is a preparation to allow using 'struct timespec64' in the
asm/x86_init.h.  Unfortunately, we can't use a forward declaration
for timespec64 since it is defined as a macro on 64-bit architectures,
and including linux/time64.h breaks compilation of arch/x86/boot/,
which runs in realmode and can't use many of the regular kernel
headers.

As a workaround, I stop including asm/x86_init.h. This works fine
for the realmode boot code since it does not require any of the
x86_init.h contents, and setup.h doesn't either. However, a couple
of other files that do need x86_init.h used to rely on it being
included indirectly, so I have to put an explicit include in there
now.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/x86/include/asm/setup.h            | 1 -
 arch/x86/kernel/platform-quirks.c       | 1 +
 arch/x86/platform/ce4100/ce4100.c       | 1 +
 arch/x86/platform/intel-mid/intel-mid.c | 1 +
 arch/x86/platform/olpc/olpc.c           | 1 +
 drivers/iommu/dmar.c                    | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index a65cf544686a..deed84119a22 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -27,7 +27,6 @@
 
 #ifndef __ASSEMBLY__
 #include <asm/bootparam.h>
-#include <asm/x86_init.h>
 
 extern u64 relocated_ramdisk;
 
diff --git a/arch/x86/kernel/platform-quirks.c b/arch/x86/kernel/platform-quirks.c
index 502a77d0adb0..d900c7b176f0 100644
--- a/arch/x86/kernel/platform-quirks.c
+++ b/arch/x86/kernel/platform-quirks.c
@@ -3,6 +3,7 @@
 
 #include <asm/setup.h>
 #include <asm/bios_ebda.h>
+#include <asm/x86_init.h>
 
 void __init x86_early_init_platform_quirks(void)
 {
diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
index ce4b06733c09..885196300927 100644
--- a/arch/x86/platform/ce4100/ce4100.c
+++ b/arch/x86/platform/ce4100/ce4100.c
@@ -22,6 +22,7 @@
 #include <asm/io.h>
 #include <asm/io_apic.h>
 #include <asm/emergency-restart.h>
+#include <asm/x86_init.h>
 
 /*
  * The CE4100 platform has an internal 8051 Microcontroller which is
diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
index 86676cec99a1..c6322263610a 100644
--- a/arch/x86/platform/intel-mid/intel-mid.c
+++ b/arch/x86/platform/intel-mid/intel-mid.c
@@ -35,6 +35,7 @@
 #include <asm/intel_scu_ipc.h>
 #include <asm/apb_timer.h>
 #include <asm/reboot.h>
+#include <asm/x86_init.h>
 
 #include "intel_mid_weak_decls.h"
 
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index 7c3077e58fa0..11a54f386911 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -26,6 +26,7 @@
 #include <asm/setup.h>
 #include <asm/olpc.h>
 #include <asm/olpc_ofw.h>
+#include <asm/x86_init.h>
 
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 1ea7cd537873..e9304d6247e1 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -41,6 +41,7 @@
 #include <linux/iommu.h>
 #include <asm/irq_remapping.h>
 #include <asm/iommu_table.h>
+#include <asm/x86_init.h>
 
 #include "irq_remapping.h"
 
-- 
2.9.0

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

* [PATCH v2 2/2] x86: convert x86_platform_ops to timespec64
  2017-10-19 10:53 [PATCH 1/2] x86: don't include asm/x86_init.h in asm/setup.h Arnd Bergmann
@ 2017-10-19 10:57   ` Arnd Bergmann
  2017-10-19 13:45 ` [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h tip-bot for Arnd Bergmann
  1 sibling, 0 replies; 13+ messages in thread
From: Arnd Bergmann @ 2017-10-19 10:57 UTC (permalink / raw)
  To: Thomas Gleixner, x86
  Cc: y2038, Arnd Bergmann, Ingo Molnar, H. Peter Anvin, Paolo Bonzini,
	Radim Krčmář,
	Boris Ostrovsky, Juergen Gross, Marcos Paulo de Souza,
	Dmitry Torokhov, Peter Zijlstra, John Stultz, linux-kernel, kvm,
	xen-devel

The x86 platform operations are fairly isolated, so we can
change them from using timespec to timespec64. I checked that
All the users and callers are safe, and there is only one
critical function that is broken beyond 2106:

pvclock_read_wallclock() uses a 32-bit number of seconds since
the epoch to communicate the boot time between host and guest
in a virtual environment. This will work until 2106, but we
should ideally find a replacement anyway. I've added a comment
about it there.

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2 changes:
- move comment block (Boris)
- remove unnecessary type cast (Boris)
- fix format string (0day bot)
- fix include order (0day bot)
---
 arch/x86/include/asm/intel_mid_vrtc.h        |  4 ++--
 arch/x86/include/asm/mc146818rtc.h           |  4 ++--
 arch/x86/include/asm/pvclock.h               |  2 +-
 arch/x86/include/asm/x86_init.h              |  7 +++----
 arch/x86/kernel/kvmclock.c                   |  4 ++--
 arch/x86/kernel/pvclock.c                    | 15 +++++++++++----
 arch/x86/kernel/rtc.c                        | 16 ++++++++--------
 arch/x86/platform/intel-mid/intel_mid_vrtc.c | 12 ++++++------
 arch/x86/xen/time.c                          | 10 +++++-----
 9 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/arch/x86/include/asm/intel_mid_vrtc.h b/arch/x86/include/asm/intel_mid_vrtc.h
index 86ff4685c409..19202320f0be 100644
--- a/arch/x86/include/asm/intel_mid_vrtc.h
+++ b/arch/x86/include/asm/intel_mid_vrtc.h
@@ -3,7 +3,7 @@
 
 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 void vrtc_get_time(struct timespec64 *now);
+extern int vrtc_set_mmss(const struct timespec64 *now);
 
 #endif
diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index 24acd9ba7837..1b574e5eb3b2 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -94,8 +94,8 @@ 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 void mach_get_cmos_time(struct timespec *now);
+extern int mach_set_rtc_mmss(const struct timespec64 *now);
+extern void mach_get_cmos_time(struct timespec64 *now);
 
 #define RTC_IRQ 8
 
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index 448cfe1b48cf..fc3138fd3aff 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -20,7 +20,7 @@ void pvclock_set_flags(u8 flags);
 unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
 void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
 			    struct pvclock_vcpu_time_info *vcpu,
-			    struct timespec *ts);
+			    struct timespec64 *ts);
 void pvclock_resume(void);
 
 void pvclock_touch_watchdogs(void);
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index f45acdf45957..847bdefa7807 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -1,6 +1,7 @@
 #ifndef _ASM_X86_PLATFORM_H
 #define _ASM_X86_PLATFORM_H
 
+#include <linux/time64.h>
 #include <asm/bootparam.h>
 
 struct mpc_bus;
@@ -141,8 +142,6 @@ struct x86_cpuinit_ops {
 	void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
 };
 
-struct timespec;
-
 /**
  * struct x86_legacy_devices - legacy x86 devices
  *
@@ -223,8 +222,8 @@ struct x86_legacy_features {
 struct x86_platform_ops {
 	unsigned long (*calibrate_cpu)(void);
 	unsigned long (*calibrate_tsc)(void);
-	void (*get_wallclock)(struct timespec *ts);
-	int (*set_wallclock)(const struct timespec *ts);
+	void (*get_wallclock)(struct timespec64 *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);
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d88967659098..01c76e8cd4be 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
  * have elapsed since the hypervisor wrote the data. So we try to account for
  * that with system time
  */
-static void kvm_get_wallclock(struct timespec *now)
+static void kvm_get_wallclock(struct timespec64 *now)
 {
 	struct pvclock_vcpu_time_info *vcpu_time;
 	int low, high;
@@ -77,7 +77,7 @@ static void kvm_get_wallclock(struct timespec *now)
 	put_cpu();
 }
 
-static int kvm_set_wallclock(const struct timespec *now)
+static int kvm_set_wallclock(const struct timespec64 *now)
 {
 	return -1;
 }
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 5c3f6d6a5078..013bef851664 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -121,26 +121,33 @@ u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
 
 void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
 			    struct pvclock_vcpu_time_info *vcpu_time,
-			    struct timespec *ts)
+			    struct timespec64 *ts)
 {
 	u32 version;
 	u64 delta;
-	struct timespec now;
+	struct timespec64 now;
 
 	/* get wallclock at system boot */
 	do {
 		version = wall_clock->version;
 		rmb();		/* fetch version before time */
+		/*
+		 * Note: wall_clock->sec is a u32 value, so it can
+		 * only store dates between 1970 and 2106. To allow
+		 * times beyond that, we need to create a new hypercall
+		 * interface with an extended pvclock_wall_clock structure
+		 * like ARM has.
+		 */
 		now.tv_sec  = wall_clock->sec;
 		now.tv_nsec = wall_clock->nsec;
 		rmb();		/* fetch time before checking version */
 	} while ((wall_clock->version & 1) || (version != wall_clock->version));
 
 	delta = pvclock_clocksource_read(vcpu_time);	/* time since system boot */
-	delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
+	delta += now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
 
 	now.tv_nsec = do_div(delta, NSEC_PER_SEC);
 	now.tv_sec = delta;
 
-	set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
+	set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
 }
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 5b21cb7d84d6..f5a687c38c6d 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -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_time64_to_tm(nowtime, &tm);
 	if (!rtc_valid_tm(&tm)) {
 		retval = mc146818_set_time(&tm);
 		if (retval)
@@ -52,14 +52,14 @@ int mach_set_rtc_mmss(const struct timespec *now)
 			       __func__, retval);
 	} else {
 		printk(KERN_ERR
-		       "%s: Invalid RTC value: write of %lx to RTC failed\n",
+		       "%s: Invalid RTC value: write of %llx to RTC failed\n",
 			__func__, nowtime);
 		retval = -EINVAL;
 	}
 	return retval;
 }
 
-void mach_get_cmos_time(struct timespec *now)
+void mach_get_cmos_time(struct timespec64 *now)
 {
 	unsigned int status, year, mon, day, hour, min, sec, century = 0;
 	unsigned long flags;
@@ -117,7 +117,7 @@ void mach_get_cmos_time(struct timespec *now)
 	} else
 		year += CMOS_YEARS_OFFS;
 
-	now->tv_sec = mktime(year, mon, day, hour, min, sec);
+	now->tv_sec = mktime64(year, mon, day, hour, min, sec);
 	now->tv_nsec = 0;
 }
 
@@ -144,13 +144,13 @@ void rtc_cmos_write(unsigned char val, unsigned char addr)
 }
 EXPORT_SYMBOL(rtc_cmos_write);
 
-int update_persistent_clock(struct timespec now)
+int update_persistent_clock64(struct timespec64 now)
 {
 	return x86_platform.set_wallclock(&now);
 }
 
 /* not static: needed by APM */
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
 	x86_platform.get_wallclock(ts);
 }
diff --git a/arch/x86/platform/intel-mid/intel_mid_vrtc.c b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
index 58024862a7eb..a52914aa3b6c 100644
--- a/arch/x86/platform/intel-mid/intel_mid_vrtc.c
+++ b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
@@ -57,7 +57,7 @@ void vrtc_cmos_write(unsigned char val, unsigned char reg)
 }
 EXPORT_SYMBOL_GPL(vrtc_cmos_write);
 
-void vrtc_get_time(struct timespec *now)
+void vrtc_get_time(struct timespec64 *now)
 {
 	u8 sec, min, hour, mday, mon;
 	unsigned long flags;
@@ -83,18 +83,18 @@ void vrtc_get_time(struct timespec *now)
 	pr_info("vRTC: sec: %d min: %d hour: %d day: %d "
 		"mon: %d year: %d\n", sec, min, hour, mday, mon, year);
 
-	now->tv_sec = mktime(year, mon, mday, hour, min, sec);
+	now->tv_sec = mktime64(year, mon, mday, hour, min, sec);
 	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_time64_to_tm(now->tv_sec, &tm);
 	if (!rtc_valid_tm(&tm) && tm.tm_year >= 72) {
 		/*
 		 * tm.year is the number of years since 1900, and the
@@ -110,8 +110,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",
-			__func__, now->tv_sec);
+		pr_err("%s: Invalid vRTC value: write of %llx to vRTC failed\n",
+			__func__, (s64)now->tv_sec);
 		retval = -EINVAL;
 	}
 	return retval;
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 1ecb05db3632..b1eed21a7b46 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -56,7 +56,7 @@ static u64 xen_clocksource_get_cycles(struct clocksource *cs)
 	return xen_clocksource_read();
 }
 
-static void xen_read_wallclock(struct timespec *ts)
+static void xen_read_wallclock(struct timespec64 *ts)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	struct pvclock_wall_clock *wall_clock = &(s->wc);
@@ -67,12 +67,12 @@ static void xen_read_wallclock(struct timespec *ts)
 	put_cpu_var(xen_vcpu);
 }
 
-static void xen_get_wallclock(struct timespec *now)
+static void xen_get_wallclock(struct timespec64 *now)
 {
 	xen_read_wallclock(now);
 }
 
-static int xen_set_wallclock(const struct timespec *now)
+static int xen_set_wallclock(const struct timespec64 *now)
 {
 	return -1;
 }
@@ -373,7 +373,7 @@ static const struct pv_time_ops xen_time_ops __initconst = {
 static void __init xen_time_init(void)
 {
 	int cpu = smp_processor_id();
-	struct timespec tp;
+	struct timespec64 tp;
 
 	/* As Dom0 is never moved, no penalty on using TSC there */
 	if (xen_initial_domain())
@@ -391,7 +391,7 @@ static void __init xen_time_init(void)
 
 	/* Set initial system time with full resolution */
 	xen_read_wallclock(&tp);
-	do_settimeofday(&tp);
+	do_settimeofday64(&tp);
 
 	setup_force_cpu_cap(X86_FEATURE_TSC);
 
-- 
2.9.0

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

* [PATCH v2 2/2] x86: convert x86_platform_ops to timespec64
@ 2017-10-19 10:57   ` Arnd Bergmann
  0 siblings, 0 replies; 13+ messages in thread
From: Arnd Bergmann @ 2017-10-19 10:57 UTC (permalink / raw)
  To: Thomas Gleixner, x86
  Cc: Juergen Gross, kvm, Arnd Bergmann, Radim Krčmář,
	y2038, Dmitry Torokhov, linux-kernel, Peter Zijlstra,
	Ingo Molnar, John Stultz, H. Peter Anvin, Paolo Bonzini,
	Boris Ostrovsky, Marcos Paulo de Souza, xen-devel

The x86 platform operations are fairly isolated, so we can
change them from using timespec to timespec64. I checked that
All the users and callers are safe, and there is only one
critical function that is broken beyond 2106:

pvclock_read_wallclock() uses a 32-bit number of seconds since
the epoch to communicate the boot time between host and guest
in a virtual environment. This will work until 2106, but we
should ideally find a replacement anyway. I've added a comment
about it there.

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2 changes:
- move comment block (Boris)
- remove unnecessary type cast (Boris)
- fix format string (0day bot)
- fix include order (0day bot)
---
 arch/x86/include/asm/intel_mid_vrtc.h        |  4 ++--
 arch/x86/include/asm/mc146818rtc.h           |  4 ++--
 arch/x86/include/asm/pvclock.h               |  2 +-
 arch/x86/include/asm/x86_init.h              |  7 +++----
 arch/x86/kernel/kvmclock.c                   |  4 ++--
 arch/x86/kernel/pvclock.c                    | 15 +++++++++++----
 arch/x86/kernel/rtc.c                        | 16 ++++++++--------
 arch/x86/platform/intel-mid/intel_mid_vrtc.c | 12 ++++++------
 arch/x86/xen/time.c                          | 10 +++++-----
 9 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/arch/x86/include/asm/intel_mid_vrtc.h b/arch/x86/include/asm/intel_mid_vrtc.h
index 86ff4685c409..19202320f0be 100644
--- a/arch/x86/include/asm/intel_mid_vrtc.h
+++ b/arch/x86/include/asm/intel_mid_vrtc.h
@@ -3,7 +3,7 @@
 
 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 void vrtc_get_time(struct timespec64 *now);
+extern int vrtc_set_mmss(const struct timespec64 *now);
 
 #endif
diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index 24acd9ba7837..1b574e5eb3b2 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -94,8 +94,8 @@ 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 void mach_get_cmos_time(struct timespec *now);
+extern int mach_set_rtc_mmss(const struct timespec64 *now);
+extern void mach_get_cmos_time(struct timespec64 *now);
 
 #define RTC_IRQ 8
 
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index 448cfe1b48cf..fc3138fd3aff 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -20,7 +20,7 @@ void pvclock_set_flags(u8 flags);
 unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
 void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
 			    struct pvclock_vcpu_time_info *vcpu,
-			    struct timespec *ts);
+			    struct timespec64 *ts);
 void pvclock_resume(void);
 
 void pvclock_touch_watchdogs(void);
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index f45acdf45957..847bdefa7807 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -1,6 +1,7 @@
 #ifndef _ASM_X86_PLATFORM_H
 #define _ASM_X86_PLATFORM_H
 
+#include <linux/time64.h>
 #include <asm/bootparam.h>
 
 struct mpc_bus;
@@ -141,8 +142,6 @@ struct x86_cpuinit_ops {
 	void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
 };
 
-struct timespec;
-
 /**
  * struct x86_legacy_devices - legacy x86 devices
  *
@@ -223,8 +222,8 @@ struct x86_legacy_features {
 struct x86_platform_ops {
 	unsigned long (*calibrate_cpu)(void);
 	unsigned long (*calibrate_tsc)(void);
-	void (*get_wallclock)(struct timespec *ts);
-	int (*set_wallclock)(const struct timespec *ts);
+	void (*get_wallclock)(struct timespec64 *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);
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d88967659098..01c76e8cd4be 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
  * have elapsed since the hypervisor wrote the data. So we try to account for
  * that with system time
  */
-static void kvm_get_wallclock(struct timespec *now)
+static void kvm_get_wallclock(struct timespec64 *now)
 {
 	struct pvclock_vcpu_time_info *vcpu_time;
 	int low, high;
@@ -77,7 +77,7 @@ static void kvm_get_wallclock(struct timespec *now)
 	put_cpu();
 }
 
-static int kvm_set_wallclock(const struct timespec *now)
+static int kvm_set_wallclock(const struct timespec64 *now)
 {
 	return -1;
 }
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 5c3f6d6a5078..013bef851664 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -121,26 +121,33 @@ u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
 
 void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
 			    struct pvclock_vcpu_time_info *vcpu_time,
-			    struct timespec *ts)
+			    struct timespec64 *ts)
 {
 	u32 version;
 	u64 delta;
-	struct timespec now;
+	struct timespec64 now;
 
 	/* get wallclock at system boot */
 	do {
 		version = wall_clock->version;
 		rmb();		/* fetch version before time */
+		/*
+		 * Note: wall_clock->sec is a u32 value, so it can
+		 * only store dates between 1970 and 2106. To allow
+		 * times beyond that, we need to create a new hypercall
+		 * interface with an extended pvclock_wall_clock structure
+		 * like ARM has.
+		 */
 		now.tv_sec  = wall_clock->sec;
 		now.tv_nsec = wall_clock->nsec;
 		rmb();		/* fetch time before checking version */
 	} while ((wall_clock->version & 1) || (version != wall_clock->version));
 
 	delta = pvclock_clocksource_read(vcpu_time);	/* time since system boot */
-	delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
+	delta += now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
 
 	now.tv_nsec = do_div(delta, NSEC_PER_SEC);
 	now.tv_sec = delta;
 
-	set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
+	set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
 }
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 5b21cb7d84d6..f5a687c38c6d 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -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_time64_to_tm(nowtime, &tm);
 	if (!rtc_valid_tm(&tm)) {
 		retval = mc146818_set_time(&tm);
 		if (retval)
@@ -52,14 +52,14 @@ int mach_set_rtc_mmss(const struct timespec *now)
 			       __func__, retval);
 	} else {
 		printk(KERN_ERR
-		       "%s: Invalid RTC value: write of %lx to RTC failed\n",
+		       "%s: Invalid RTC value: write of %llx to RTC failed\n",
 			__func__, nowtime);
 		retval = -EINVAL;
 	}
 	return retval;
 }
 
-void mach_get_cmos_time(struct timespec *now)
+void mach_get_cmos_time(struct timespec64 *now)
 {
 	unsigned int status, year, mon, day, hour, min, sec, century = 0;
 	unsigned long flags;
@@ -117,7 +117,7 @@ void mach_get_cmos_time(struct timespec *now)
 	} else
 		year += CMOS_YEARS_OFFS;
 
-	now->tv_sec = mktime(year, mon, day, hour, min, sec);
+	now->tv_sec = mktime64(year, mon, day, hour, min, sec);
 	now->tv_nsec = 0;
 }
 
@@ -144,13 +144,13 @@ void rtc_cmos_write(unsigned char val, unsigned char addr)
 }
 EXPORT_SYMBOL(rtc_cmos_write);
 
-int update_persistent_clock(struct timespec now)
+int update_persistent_clock64(struct timespec64 now)
 {
 	return x86_platform.set_wallclock(&now);
 }
 
 /* not static: needed by APM */
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
 	x86_platform.get_wallclock(ts);
 }
diff --git a/arch/x86/platform/intel-mid/intel_mid_vrtc.c b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
index 58024862a7eb..a52914aa3b6c 100644
--- a/arch/x86/platform/intel-mid/intel_mid_vrtc.c
+++ b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
@@ -57,7 +57,7 @@ void vrtc_cmos_write(unsigned char val, unsigned char reg)
 }
 EXPORT_SYMBOL_GPL(vrtc_cmos_write);
 
-void vrtc_get_time(struct timespec *now)
+void vrtc_get_time(struct timespec64 *now)
 {
 	u8 sec, min, hour, mday, mon;
 	unsigned long flags;
@@ -83,18 +83,18 @@ void vrtc_get_time(struct timespec *now)
 	pr_info("vRTC: sec: %d min: %d hour: %d day: %d "
 		"mon: %d year: %d\n", sec, min, hour, mday, mon, year);
 
-	now->tv_sec = mktime(year, mon, mday, hour, min, sec);
+	now->tv_sec = mktime64(year, mon, mday, hour, min, sec);
 	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_time64_to_tm(now->tv_sec, &tm);
 	if (!rtc_valid_tm(&tm) && tm.tm_year >= 72) {
 		/*
 		 * tm.year is the number of years since 1900, and the
@@ -110,8 +110,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",
-			__func__, now->tv_sec);
+		pr_err("%s: Invalid vRTC value: write of %llx to vRTC failed\n",
+			__func__, (s64)now->tv_sec);
 		retval = -EINVAL;
 	}
 	return retval;
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 1ecb05db3632..b1eed21a7b46 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -56,7 +56,7 @@ static u64 xen_clocksource_get_cycles(struct clocksource *cs)
 	return xen_clocksource_read();
 }
 
-static void xen_read_wallclock(struct timespec *ts)
+static void xen_read_wallclock(struct timespec64 *ts)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	struct pvclock_wall_clock *wall_clock = &(s->wc);
@@ -67,12 +67,12 @@ static void xen_read_wallclock(struct timespec *ts)
 	put_cpu_var(xen_vcpu);
 }
 
-static void xen_get_wallclock(struct timespec *now)
+static void xen_get_wallclock(struct timespec64 *now)
 {
 	xen_read_wallclock(now);
 }
 
-static int xen_set_wallclock(const struct timespec *now)
+static int xen_set_wallclock(const struct timespec64 *now)
 {
 	return -1;
 }
@@ -373,7 +373,7 @@ static const struct pv_time_ops xen_time_ops __initconst = {
 static void __init xen_time_init(void)
 {
 	int cpu = smp_processor_id();
-	struct timespec tp;
+	struct timespec64 tp;
 
 	/* As Dom0 is never moved, no penalty on using TSC there */
 	if (xen_initial_domain())
@@ -391,7 +391,7 @@ static void __init xen_time_init(void)
 
 	/* Set initial system time with full resolution */
 	xen_read_wallclock(&tp);
-	do_settimeofday(&tp);
+	do_settimeofday64(&tp);
 
 	setup_force_cpu_cap(X86_FEATURE_TSC);
 
-- 
2.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2 2/2] x86: convert x86_platform_ops to timespec64
  2017-10-19 10:57   ` Arnd Bergmann
  (?)
  (?)
@ 2017-10-19 11:46   ` Paolo Bonzini
  -1 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-10-19 11:46 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, x86
  Cc: y2038, Ingo Molnar, H. Peter Anvin, Radim Krčmář,
	Boris Ostrovsky, Juergen Gross, Marcos Paulo de Souza,
	Dmitry Torokhov, Peter Zijlstra, John Stultz, linux-kernel, kvm,
	xen-devel

On 19/10/2017 12:57, Arnd Bergmann wrote:
> The x86 platform operations are fairly isolated, so we can
> change them from using timespec to timespec64. I checked that
> All the users and callers are safe, and there is only one
> critical function that is broken beyond 2106:
> 
> pvclock_read_wallclock() uses a 32-bit number of seconds since
> the epoch to communicate the boot time between host and guest
> in a virtual environment. This will work until 2106, but we
> should ideally find a replacement anyway. I've added a comment
> about it there.
> 
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2 changes:
> - move comment block (Boris)
> - remove unnecessary type cast (Boris)
> - fix format string (0day bot)
> - fix include order (0day bot)
> ---
>  arch/x86/include/asm/intel_mid_vrtc.h        |  4 ++--
>  arch/x86/include/asm/mc146818rtc.h           |  4 ++--
>  arch/x86/include/asm/pvclock.h               |  2 +-
>  arch/x86/include/asm/x86_init.h              |  7 +++----
>  arch/x86/kernel/kvmclock.c                   |  4 ++--
>  arch/x86/kernel/pvclock.c                    | 15 +++++++++++----
>  arch/x86/kernel/rtc.c                        | 16 ++++++++--------
>  arch/x86/platform/intel-mid/intel_mid_vrtc.c | 12 ++++++------
>  arch/x86/xen/time.c                          | 10 +++++-----
>  9 files changed, 40 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index d88967659098..01c76e8cd4be 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
>   * have elapsed since the hypervisor wrote the data. So we try to account for
>   * that with system time
>   */
> -static void kvm_get_wallclock(struct timespec *now)
> +static void kvm_get_wallclock(struct timespec64 *now)
>  {
>  	struct pvclock_vcpu_time_info *vcpu_time;
>  	int low, high;
> @@ -77,7 +77,7 @@ static void kvm_get_wallclock(struct timespec *now)
>  	put_cpu();
>  }
>  
> -static int kvm_set_wallclock(const struct timespec *now)
> +static int kvm_set_wallclock(const struct timespec64 *now)
>  {
>  	return -1;
>  }
> diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
> index 5c3f6d6a5078..013bef851664 100644
> --- a/arch/x86/kernel/pvclock.c
> +++ b/arch/x86/kernel/pvclock.c
> @@ -121,26 +121,33 @@ u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
>  
>  void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
>  			    struct pvclock_vcpu_time_info *vcpu_time,
> -			    struct timespec *ts)
> +			    struct timespec64 *ts)
>  {
>  	u32 version;
>  	u64 delta;
> -	struct timespec now;
> +	struct timespec64 now;
>  
>  	/* get wallclock at system boot */
>  	do {
>  		version = wall_clock->version;
>  		rmb();		/* fetch version before time */
> +		/*
> +		 * Note: wall_clock->sec is a u32 value, so it can
> +		 * only store dates between 1970 and 2106. To allow
> +		 * times beyond that, we need to create a new hypercall
> +		 * interface with an extended pvclock_wall_clock structure
> +		 * like ARM has.
> +		 */
>  		now.tv_sec  = wall_clock->sec;
>  		now.tv_nsec = wall_clock->nsec;
>  		rmb();		/* fetch time before checking version */
>  	} while ((wall_clock->version & 1) || (version != wall_clock->version));
>  
>  	delta = pvclock_clocksource_read(vcpu_time);	/* time since system boot */
> -	delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
> +	delta += now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
>  
>  	now.tv_nsec = do_div(delta, NSEC_PER_SEC);
>  	now.tv_sec = delta;
>  
> -	set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
> +	set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
>  }
For kvmclock.c and pvclock.c,

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

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

* Re: [PATCH v2 2/2] x86: convert x86_platform_ops to timespec64
  2017-10-19 10:57   ` Arnd Bergmann
  (?)
@ 2017-10-19 11:46   ` Paolo Bonzini
  -1 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-10-19 11:46 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, x86
  Cc: Juergen Gross, kvm, Radim Krčmář,
	y2038, Dmitry Torokhov, linux-kernel, Peter Zijlstra,
	Ingo Molnar, John Stultz, H. Peter Anvin, xen-devel,
	Boris Ostrovsky, Marcos Paulo de Souza

On 19/10/2017 12:57, Arnd Bergmann wrote:
> The x86 platform operations are fairly isolated, so we can
> change them from using timespec to timespec64. I checked that
> All the users and callers are safe, and there is only one
> critical function that is broken beyond 2106:
> 
> pvclock_read_wallclock() uses a 32-bit number of seconds since
> the epoch to communicate the boot time between host and guest
> in a virtual environment. This will work until 2106, but we
> should ideally find a replacement anyway. I've added a comment
> about it there.
> 
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2 changes:
> - move comment block (Boris)
> - remove unnecessary type cast (Boris)
> - fix format string (0day bot)
> - fix include order (0day bot)
> ---
>  arch/x86/include/asm/intel_mid_vrtc.h        |  4 ++--
>  arch/x86/include/asm/mc146818rtc.h           |  4 ++--
>  arch/x86/include/asm/pvclock.h               |  2 +-
>  arch/x86/include/asm/x86_init.h              |  7 +++----
>  arch/x86/kernel/kvmclock.c                   |  4 ++--
>  arch/x86/kernel/pvclock.c                    | 15 +++++++++++----
>  arch/x86/kernel/rtc.c                        | 16 ++++++++--------
>  arch/x86/platform/intel-mid/intel_mid_vrtc.c | 12 ++++++------
>  arch/x86/xen/time.c                          | 10 +++++-----
>  9 files changed, 40 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index d88967659098..01c76e8cd4be 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
>   * have elapsed since the hypervisor wrote the data. So we try to account for
>   * that with system time
>   */
> -static void kvm_get_wallclock(struct timespec *now)
> +static void kvm_get_wallclock(struct timespec64 *now)
>  {
>  	struct pvclock_vcpu_time_info *vcpu_time;
>  	int low, high;
> @@ -77,7 +77,7 @@ static void kvm_get_wallclock(struct timespec *now)
>  	put_cpu();
>  }
>  
> -static int kvm_set_wallclock(const struct timespec *now)
> +static int kvm_set_wallclock(const struct timespec64 *now)
>  {
>  	return -1;
>  }
> diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
> index 5c3f6d6a5078..013bef851664 100644
> --- a/arch/x86/kernel/pvclock.c
> +++ b/arch/x86/kernel/pvclock.c
> @@ -121,26 +121,33 @@ u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
>  
>  void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
>  			    struct pvclock_vcpu_time_info *vcpu_time,
> -			    struct timespec *ts)
> +			    struct timespec64 *ts)
>  {
>  	u32 version;
>  	u64 delta;
> -	struct timespec now;
> +	struct timespec64 now;
>  
>  	/* get wallclock at system boot */
>  	do {
>  		version = wall_clock->version;
>  		rmb();		/* fetch version before time */
> +		/*
> +		 * Note: wall_clock->sec is a u32 value, so it can
> +		 * only store dates between 1970 and 2106. To allow
> +		 * times beyond that, we need to create a new hypercall
> +		 * interface with an extended pvclock_wall_clock structure
> +		 * like ARM has.
> +		 */
>  		now.tv_sec  = wall_clock->sec;
>  		now.tv_nsec = wall_clock->nsec;
>  		rmb();		/* fetch time before checking version */
>  	} while ((wall_clock->version & 1) || (version != wall_clock->version));
>  
>  	delta = pvclock_clocksource_read(vcpu_time);	/* time since system boot */
> -	delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
> +	delta += now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
>  
>  	now.tv_nsec = do_div(delta, NSEC_PER_SEC);
>  	now.tv_sec = delta;
>  
> -	set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
> +	set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
>  }
For kvmclock.c and pvclock.c,

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h
  2017-10-19 10:53 [PATCH 1/2] x86: don't include asm/x86_init.h in asm/setup.h Arnd Bergmann
  2017-10-19 10:57   ` Arnd Bergmann
@ 2017-10-19 13:45 ` tip-bot for Arnd Bergmann
  2017-10-20 11:11   ` Ingo Molnar
  1 sibling, 1 reply; 13+ messages in thread
From: tip-bot for Arnd Bergmann @ 2017-10-19 13:45 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, tglx, joro, linux-kernel, mingo, arnd

Commit-ID:  0f5a0f4f062cc19090a87f9eb8cb79c7c2e4db19
Gitweb:     https://git.kernel.org/tip/0f5a0f4f062cc19090a87f9eb8cb79c7c2e4db19
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Thu, 19 Oct 2017 12:53:02 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 19 Oct 2017 15:41:18 +0200

x86: Don't include asm/x86_init.h in asm/setup.h

This is a preparation to allow using 'struct timespec64' in asm/x86_init.h.

Unfortunately, using a forward declaration for timespec64 is not possible
since it is defined as a macro on 64-bit architectures, and including
linux/time64.h breaks compilation of arch/x86/boot/, which runs in realmode
and can't use many of the regular kernel headers.

As a workaround, stop including asm/x86_init.h. This works fine for the
realmode boot code since it does not require any of the x86_init.h
contents, and setup.h doesn't either.

However, a couple of other files need x86_init.h and rely on it being
included indirectly, so add an explicit include in there now.

[ tglx: Massaged changelog to 'imperative mood' ]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: y2038@lists.linaro.org
Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
Link: https://lkml.kernel.org/r/20171019105451.2892046-1-arnd@arndb.de

---
 arch/x86/include/asm/setup.h            | 1 -
 arch/x86/kernel/platform-quirks.c       | 1 +
 arch/x86/platform/ce4100/ce4100.c       | 1 +
 arch/x86/platform/intel-mid/intel-mid.c | 1 +
 arch/x86/platform/olpc/olpc.c           | 1 +
 drivers/iommu/dmar.c                    | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index a65cf54..deed841 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -27,7 +27,6 @@
 
 #ifndef __ASSEMBLY__
 #include <asm/bootparam.h>
-#include <asm/x86_init.h>
 
 extern u64 relocated_ramdisk;
 
diff --git a/arch/x86/kernel/platform-quirks.c b/arch/x86/kernel/platform-quirks.c
index 502a77d..d900c7b 100644
--- a/arch/x86/kernel/platform-quirks.c
+++ b/arch/x86/kernel/platform-quirks.c
@@ -3,6 +3,7 @@
 
 #include <asm/setup.h>
 #include <asm/bios_ebda.h>
+#include <asm/x86_init.h>
 
 void __init x86_early_init_platform_quirks(void)
 {
diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
index ce4b067..8851963 100644
--- a/arch/x86/platform/ce4100/ce4100.c
+++ b/arch/x86/platform/ce4100/ce4100.c
@@ -22,6 +22,7 @@
 #include <asm/io.h>
 #include <asm/io_apic.h>
 #include <asm/emergency-restart.h>
+#include <asm/x86_init.h>
 
 /*
  * The CE4100 platform has an internal 8051 Microcontroller which is
diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
index 86676ce..c632226 100644
--- a/arch/x86/platform/intel-mid/intel-mid.c
+++ b/arch/x86/platform/intel-mid/intel-mid.c
@@ -35,6 +35,7 @@
 #include <asm/intel_scu_ipc.h>
 #include <asm/apb_timer.h>
 #include <asm/reboot.h>
+#include <asm/x86_init.h>
 
 #include "intel_mid_weak_decls.h"
 
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index 7c3077e..11a54f3 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -26,6 +26,7 @@
 #include <asm/setup.h>
 #include <asm/olpc.h>
 #include <asm/olpc_ofw.h>
+#include <asm/x86_init.h>
 
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 57c920c..ca507c5 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -41,6 +41,7 @@
 #include <linux/iommu.h>
 #include <asm/irq_remapping.h>
 #include <asm/iommu_table.h>
+#include <asm/x86_init.h>
 
 #include "irq_remapping.h"
 

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

* [tip:x86/timers] x86: Convert x86_platform_ops to timespec64
  2017-10-19 10:57   ` Arnd Bergmann
                     ` (2 preceding siblings ...)
  (?)
@ 2017-10-19 13:46   ` tip-bot for Arnd Bergmann
  -1 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Arnd Bergmann @ 2017-10-19 13:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, linux-kernel, mingo, peterz, marcos.souza.org, arnd, hpa,
	rkrcmar, dmitry.torokhov, jgross, john.stultz, boris.ostrovsky

Commit-ID:  d240e4b79fedad1346796b045286fad5ca70ada9
Gitweb:     https://git.kernel.org/tip/d240e4b79fedad1346796b045286fad5ca70ada9
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Thu, 19 Oct 2017 12:57:06 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 19 Oct 2017 15:41:18 +0200

x86: Convert x86_platform_ops to timespec64

The x86 platform operations are fairly isolated so changing the function
signatures to use timespec64 instead of timespec has a limited scope.

All users and callers have been audited for being safe and there is only
one critical function that is broken past 2106:

  pvclock_read_wallclock() uses a 32-bit number of seconds since the epoch
  to communicate the boot time between host and guest in a virtual
  environment. This will work until 2106, which is far away, but ideally a
  replacement for this should be found. Add a comment to that effect.

[ tglx: Massaged changelog to 'imperative mood' ]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com> # kvm/pvclock
Cc: Juergen Gross <jgross@suse.com>
Cc: kvm@vger.kernel.org
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: y2038@lists.linaro.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: xen-devel@lists.xenproject.org
Cc: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Link: https://lkml.kernel.org/r/20171019105824.3035694-1-arnd@arndb.de

---
 arch/x86/include/asm/intel_mid_vrtc.h        |  4 ++--
 arch/x86/include/asm/mc146818rtc.h           |  4 ++--
 arch/x86/include/asm/pvclock.h               |  2 +-
 arch/x86/include/asm/x86_init.h              |  7 +++----
 arch/x86/kernel/kvmclock.c                   |  4 ++--
 arch/x86/kernel/pvclock.c                    | 15 +++++++++++----
 arch/x86/kernel/rtc.c                        | 16 ++++++++--------
 arch/x86/platform/intel-mid/intel_mid_vrtc.c | 12 ++++++------
 arch/x86/xen/time.c                          | 10 +++++-----
 9 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/arch/x86/include/asm/intel_mid_vrtc.h b/arch/x86/include/asm/intel_mid_vrtc.h
index 86ff468..1920232 100644
--- a/arch/x86/include/asm/intel_mid_vrtc.h
+++ b/arch/x86/include/asm/intel_mid_vrtc.h
@@ -3,7 +3,7 @@
 
 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 void vrtc_get_time(struct timespec64 *now);
+extern int vrtc_set_mmss(const struct timespec64 *now);
 
 #endif
diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index 24acd9b..1b574e5 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -94,8 +94,8 @@ 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 void mach_get_cmos_time(struct timespec *now);
+extern int mach_set_rtc_mmss(const struct timespec64 *now);
+extern void mach_get_cmos_time(struct timespec64 *now);
 
 #define RTC_IRQ 8
 
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index 448cfe1..fc3138f 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -20,7 +20,7 @@ void pvclock_set_flags(u8 flags);
 unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
 void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
 			    struct pvclock_vcpu_time_info *vcpu,
-			    struct timespec *ts);
+			    struct timespec64 *ts);
 void pvclock_resume(void);
 
 void pvclock_touch_watchdogs(void);
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 7ba7e90..bfd019a 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -1,6 +1,7 @@
 #ifndef _ASM_X86_PLATFORM_H
 #define _ASM_X86_PLATFORM_H
 
+#include <linux/time64.h>
 #include <asm/bootparam.h>
 
 struct mpc_bus;
@@ -139,8 +140,6 @@ struct x86_cpuinit_ops {
 	void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
 };
 
-struct timespec;
-
 /**
  * struct x86_legacy_devices - legacy x86 devices
  *
@@ -221,8 +220,8 @@ struct x86_legacy_features {
 struct x86_platform_ops {
 	unsigned long (*calibrate_cpu)(void);
 	unsigned long (*calibrate_tsc)(void);
-	void (*get_wallclock)(struct timespec *ts);
-	int (*set_wallclock)(const struct timespec *ts);
+	void (*get_wallclock)(struct timespec64 *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);
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d889676..01c76e8 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
  * have elapsed since the hypervisor wrote the data. So we try to account for
  * that with system time
  */
-static void kvm_get_wallclock(struct timespec *now)
+static void kvm_get_wallclock(struct timespec64 *now)
 {
 	struct pvclock_vcpu_time_info *vcpu_time;
 	int low, high;
@@ -77,7 +77,7 @@ static void kvm_get_wallclock(struct timespec *now)
 	put_cpu();
 }
 
-static int kvm_set_wallclock(const struct timespec *now)
+static int kvm_set_wallclock(const struct timespec64 *now)
 {
 	return -1;
 }
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 5c3f6d6..013bef8 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -121,26 +121,33 @@ u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
 
 void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
 			    struct pvclock_vcpu_time_info *vcpu_time,
-			    struct timespec *ts)
+			    struct timespec64 *ts)
 {
 	u32 version;
 	u64 delta;
-	struct timespec now;
+	struct timespec64 now;
 
 	/* get wallclock at system boot */
 	do {
 		version = wall_clock->version;
 		rmb();		/* fetch version before time */
+		/*
+		 * Note: wall_clock->sec is a u32 value, so it can
+		 * only store dates between 1970 and 2106. To allow
+		 * times beyond that, we need to create a new hypercall
+		 * interface with an extended pvclock_wall_clock structure
+		 * like ARM has.
+		 */
 		now.tv_sec  = wall_clock->sec;
 		now.tv_nsec = wall_clock->nsec;
 		rmb();		/* fetch time before checking version */
 	} while ((wall_clock->version & 1) || (version != wall_clock->version));
 
 	delta = pvclock_clocksource_read(vcpu_time);	/* time since system boot */
-	delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
+	delta += now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
 
 	now.tv_nsec = do_div(delta, NSEC_PER_SEC);
 	now.tv_sec = delta;
 
-	set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
+	set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
 }
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 5b21cb7..f5a687c3 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -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_time64_to_tm(nowtime, &tm);
 	if (!rtc_valid_tm(&tm)) {
 		retval = mc146818_set_time(&tm);
 		if (retval)
@@ -52,14 +52,14 @@ int mach_set_rtc_mmss(const struct timespec *now)
 			       __func__, retval);
 	} else {
 		printk(KERN_ERR
-		       "%s: Invalid RTC value: write of %lx to RTC failed\n",
+		       "%s: Invalid RTC value: write of %llx to RTC failed\n",
 			__func__, nowtime);
 		retval = -EINVAL;
 	}
 	return retval;
 }
 
-void mach_get_cmos_time(struct timespec *now)
+void mach_get_cmos_time(struct timespec64 *now)
 {
 	unsigned int status, year, mon, day, hour, min, sec, century = 0;
 	unsigned long flags;
@@ -117,7 +117,7 @@ void mach_get_cmos_time(struct timespec *now)
 	} else
 		year += CMOS_YEARS_OFFS;
 
-	now->tv_sec = mktime(year, mon, day, hour, min, sec);
+	now->tv_sec = mktime64(year, mon, day, hour, min, sec);
 	now->tv_nsec = 0;
 }
 
@@ -144,13 +144,13 @@ void rtc_cmos_write(unsigned char val, unsigned char addr)
 }
 EXPORT_SYMBOL(rtc_cmos_write);
 
-int update_persistent_clock(struct timespec now)
+int update_persistent_clock64(struct timespec64 now)
 {
 	return x86_platform.set_wallclock(&now);
 }
 
 /* not static: needed by APM */
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
 	x86_platform.get_wallclock(ts);
 }
diff --git a/arch/x86/platform/intel-mid/intel_mid_vrtc.c b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
index 5802486..a52914a 100644
--- a/arch/x86/platform/intel-mid/intel_mid_vrtc.c
+++ b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
@@ -57,7 +57,7 @@ void vrtc_cmos_write(unsigned char val, unsigned char reg)
 }
 EXPORT_SYMBOL_GPL(vrtc_cmos_write);
 
-void vrtc_get_time(struct timespec *now)
+void vrtc_get_time(struct timespec64 *now)
 {
 	u8 sec, min, hour, mday, mon;
 	unsigned long flags;
@@ -83,18 +83,18 @@ void vrtc_get_time(struct timespec *now)
 	pr_info("vRTC: sec: %d min: %d hour: %d day: %d "
 		"mon: %d year: %d\n", sec, min, hour, mday, mon, year);
 
-	now->tv_sec = mktime(year, mon, mday, hour, min, sec);
+	now->tv_sec = mktime64(year, mon, mday, hour, min, sec);
 	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_time64_to_tm(now->tv_sec, &tm);
 	if (!rtc_valid_tm(&tm) && tm.tm_year >= 72) {
 		/*
 		 * tm.year is the number of years since 1900, and the
@@ -110,8 +110,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",
-			__func__, now->tv_sec);
+		pr_err("%s: Invalid vRTC value: write of %llx to vRTC failed\n",
+			__func__, (s64)now->tv_sec);
 		retval = -EINVAL;
 	}
 	return retval;
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 1ecb05d..b1eed21 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -56,7 +56,7 @@ static u64 xen_clocksource_get_cycles(struct clocksource *cs)
 	return xen_clocksource_read();
 }
 
-static void xen_read_wallclock(struct timespec *ts)
+static void xen_read_wallclock(struct timespec64 *ts)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	struct pvclock_wall_clock *wall_clock = &(s->wc);
@@ -67,12 +67,12 @@ static void xen_read_wallclock(struct timespec *ts)
 	put_cpu_var(xen_vcpu);
 }
 
-static void xen_get_wallclock(struct timespec *now)
+static void xen_get_wallclock(struct timespec64 *now)
 {
 	xen_read_wallclock(now);
 }
 
-static int xen_set_wallclock(const struct timespec *now)
+static int xen_set_wallclock(const struct timespec64 *now)
 {
 	return -1;
 }
@@ -373,7 +373,7 @@ static const struct pv_time_ops xen_time_ops __initconst = {
 static void __init xen_time_init(void)
 {
 	int cpu = smp_processor_id();
-	struct timespec tp;
+	struct timespec64 tp;
 
 	/* As Dom0 is never moved, no penalty on using TSC there */
 	if (xen_initial_domain())
@@ -391,7 +391,7 @@ static void __init xen_time_init(void)
 
 	/* Set initial system time with full resolution */
 	xen_read_wallclock(&tp);
-	do_settimeofday(&tp);
+	do_settimeofday64(&tp);
 
 	setup_force_cpu_cap(X86_FEATURE_TSC);
 

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

* Re: [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h
  2017-10-19 13:45 ` [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h tip-bot for Arnd Bergmann
@ 2017-10-20 11:11   ` Ingo Molnar
  2017-10-20 11:37     ` Arnd Bergmann
  2017-10-20 11:41     ` Thomas Gleixner
  0 siblings, 2 replies; 13+ messages in thread
From: Ingo Molnar @ 2017-10-20 11:11 UTC (permalink / raw)
  To: arnd, linux-kernel, tglx, joro, hpa; +Cc: linux-tip-commits, linux-kernel


* tip-bot for Arnd Bergmann <tipbot@zytor.com> wrote:

> Commit-ID:  0f5a0f4f062cc19090a87f9eb8cb79c7c2e4db19
> Gitweb:     https://git.kernel.org/tip/0f5a0f4f062cc19090a87f9eb8cb79c7c2e4db19
> Author:     Arnd Bergmann <arnd@arndb.de>
> AuthorDate: Thu, 19 Oct 2017 12:53:02 +0200
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> CommitDate: Thu, 19 Oct 2017 15:41:18 +0200
> 
> x86: Don't include asm/x86_init.h in asm/setup.h
> 
> This is a preparation to allow using 'struct timespec64' in asm/x86_init.h.
> 
> Unfortunately, using a forward declaration for timespec64 is not possible
> since it is defined as a macro on 64-bit architectures, and including
> linux/time64.h breaks compilation of arch/x86/boot/, which runs in realmode
> and can't use many of the regular kernel headers.
> 
> As a workaround, stop including asm/x86_init.h. This works fine for the
> realmode boot code since it does not require any of the x86_init.h
> contents, and setup.h doesn't either.
> 
> However, a couple of other files need x86_init.h and rely on it being
> included indirectly, so add an explicit include in there now.
> 
> [ tglx: Massaged changelog to 'imperative mood' ]
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: y2038@lists.linaro.org
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: iommu@lists.linux-foundation.org
> Link: https://lkml.kernel.org/r/20171019105451.2892046-1-arnd@arndb.de
> 
> ---
>  arch/x86/include/asm/setup.h            | 1 -
>  arch/x86/kernel/platform-quirks.c       | 1 +
>  arch/x86/platform/ce4100/ce4100.c       | 1 +
>  arch/x86/platform/intel-mid/intel-mid.c | 1 +
>  arch/x86/platform/olpc/olpc.c           | 1 +
>  drivers/iommu/dmar.c                    | 1 +
>  6 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
> index a65cf54..deed841 100644
> --- a/arch/x86/include/asm/setup.h
> +++ b/arch/x86/include/asm/setup.h
> @@ -27,7 +27,6 @@
>  
>  #ifndef __ASSEMBLY__
>  #include <asm/bootparam.h>
> -#include <asm/x86_init.h>
>  
>  extern u64 relocated_ramdisk;
>  
> diff --git a/arch/x86/kernel/platform-quirks.c b/arch/x86/kernel/platform-quirks.c
> index 502a77d..d900c7b 100644
> --- a/arch/x86/kernel/platform-quirks.c
> +++ b/arch/x86/kernel/platform-quirks.c
> @@ -3,6 +3,7 @@
>  
>  #include <asm/setup.h>
>  #include <asm/bios_ebda.h>
> +#include <asm/x86_init.h>
>  
>  void __init x86_early_init_platform_quirks(void)
>  {
> diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
> index ce4b067..8851963 100644
> --- a/arch/x86/platform/ce4100/ce4100.c
> +++ b/arch/x86/platform/ce4100/ce4100.c
> @@ -22,6 +22,7 @@
>  #include <asm/io.h>
>  #include <asm/io_apic.h>
>  #include <asm/emergency-restart.h>
> +#include <asm/x86_init.h>
>  
>  /*
>   * The CE4100 platform has an internal 8051 Microcontroller which is
> diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
> index 86676ce..c632226 100644
> --- a/arch/x86/platform/intel-mid/intel-mid.c
> +++ b/arch/x86/platform/intel-mid/intel-mid.c
> @@ -35,6 +35,7 @@
>  #include <asm/intel_scu_ipc.h>
>  #include <asm/apb_timer.h>
>  #include <asm/reboot.h>
> +#include <asm/x86_init.h>
>  
>  #include "intel_mid_weak_decls.h"
>  
> diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
> index 7c3077e..11a54f3 100644
> --- a/arch/x86/platform/olpc/olpc.c
> +++ b/arch/x86/platform/olpc/olpc.c
> @@ -26,6 +26,7 @@
>  #include <asm/setup.h>
>  #include <asm/olpc.h>
>  #include <asm/olpc_ofw.h>
> +#include <asm/x86_init.h>
>  
>  struct olpc_platform_t olpc_platform_info;
>  EXPORT_SYMBOL_GPL(olpc_platform_info);
> diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
> index 57c920c..ca507c5 100644
> --- a/drivers/iommu/dmar.c
> +++ b/drivers/iommu/dmar.c
> @@ -41,6 +41,7 @@
>  #include <linux/iommu.h>
>  #include <asm/irq_remapping.h>
>  #include <asm/iommu_table.h>
> +#include <asm/x86_init.h>
>  
>  #include "irq_remapping.h"

This breaks the IA64 build:

  drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory

Thanks,

	Ingo

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

* Re: [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h
  2017-10-20 11:11   ` Ingo Molnar
@ 2017-10-20 11:37     ` Arnd Bergmann
  2017-10-20 11:48       ` Thomas Gleixner
  2017-10-20 11:41     ` Thomas Gleixner
  1 sibling, 1 reply; 13+ messages in thread
From: Arnd Bergmann @ 2017-10-20 11:37 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Linux Kernel Mailing List, Thomas Gleixner, Joerg Roedel,
	H. Peter Anvin, linux-tip-commits

On Fri, Oct 20, 2017 at 1:11 PM, Ingo Molnar <mingo@kernel.org> wrote:
>>  #include <asm/iommu_table.h>
>> +#include <asm/x86_init.h>
>>
>>  #include "irq_remapping.h"
>
> This breaks the IA64 build:
>
>   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory

I've sent a fixup to add an #ifdef around it now. Alternatively, we
could include
it implicitly in asm/iommu_table.h, which would avoid the #ifdef but
seem a little
hacky.

      Arnd

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

* Re: [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h
  2017-10-20 11:11   ` Ingo Molnar
  2017-10-20 11:37     ` Arnd Bergmann
@ 2017-10-20 11:41     ` Thomas Gleixner
  2017-10-20 12:20       ` Ingo Molnar
  1 sibling, 1 reply; 13+ messages in thread
From: Thomas Gleixner @ 2017-10-20 11:41 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: arnd, linux-kernel, joro, hpa, linux-tip-commits

On Fri, 20 Oct 2017, Ingo Molnar wrote:
> * tip-bot for Arnd Bergmann <tipbot@zytor.com> wrote:
> This breaks the IA64 build:
> 
>   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory

The commits are already removed from x86/timers

Thanks,

	tglx

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

* Re: [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h
  2017-10-20 11:37     ` Arnd Bergmann
@ 2017-10-20 11:48       ` Thomas Gleixner
  2017-10-20 12:09         ` Arnd Bergmann
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Gleixner @ 2017-10-20 11:48 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Ingo Molnar, Linux Kernel Mailing List, Joerg Roedel,
	H. Peter Anvin, linux-tip-commits

On Fri, 20 Oct 2017, Arnd Bergmann wrote:
> On Fri, Oct 20, 2017 at 1:11 PM, Ingo Molnar <mingo@kernel.org> wrote:
> >>  #include <asm/iommu_table.h>
> >> +#include <asm/x86_init.h>
> >>
> >>  #include "irq_remapping.h"
> >
> > This breaks the IA64 build:
> >
> >   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory
> 
> I've sent a fixup to add an #ifdef around it now. Alternatively, we
> could include
> it implicitly in asm/iommu_table.h, which would avoid the #ifdef but
> seem a little
> hacky.

Hrm. Both solutions are ugly. Is there no other way to split stuff up in
those headers (maybe create an extra one).

Thanks,

	tglx

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

* Re: [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h
  2017-10-20 11:48       ` Thomas Gleixner
@ 2017-10-20 12:09         ` Arnd Bergmann
  0 siblings, 0 replies; 13+ messages in thread
From: Arnd Bergmann @ 2017-10-20 12:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, Linux Kernel Mailing List, Joerg Roedel,
	H. Peter Anvin, linux-tip-commits

On Fri, Oct 20, 2017 at 1:48 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Fri, 20 Oct 2017, Arnd Bergmann wrote:
>> On Fri, Oct 20, 2017 at 1:11 PM, Ingo Molnar <mingo@kernel.org> wrote:
>> >>  #include <asm/iommu_table.h>
>> >> +#include <asm/x86_init.h>
>> >>
>> >>  #include "irq_remapping.h"
>> >
>> > This breaks the IA64 build:
>> >
>> >   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory
>>
>> I've sent a fixup to add an #ifdef around it now. Alternatively, we
>> could include
>> it implicitly in asm/iommu_table.h, which would avoid the #ifdef but
>> seem a little
>> hacky.
>
> Hrm. Both solutions are ugly. Is there no other way to split stuff up in
> those headers (maybe create an extra one).

Hmm, looking at it again, I think we can get away without the explicit
include, and rely on asm/pci.h to include x86_init.h.

For some files I had build failures without the explicit include and for
others I added it for consistency. From looking at the source, this
file seems to belong in the second category. If you think that's ok,
I'll do some more build testing without the #include and send a new
version.

Another idea: add an abstraction for the init handler assignment,
see untested patch below.

      Arnd

---
diff --git a/arch/ia64/include/asm/iommu.h b/arch/ia64/include/asm/iommu.h
index 1d1212901ae7..f2ad4a39bafe 100644
--- a/arch/ia64/include/asm/iommu.h
+++ b/arch/ia64/include/asm/iommu.h
@@ -18,4 +18,8 @@ extern int iommu_detected;
 extern void iommu_dma_init(void);
 extern void machvec_init(const char *name);

+static inline void iommu_set_init_handler(int (*init_fn)(void))
+{
+}
+
 #endif
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index fca144a104e4..09cbbc6beaab 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -1,6 +1,8 @@
 #ifndef _ASM_X86_IOMMU_H
 #define _ASM_X86_IOMMU_H

+#include <asm/x86_init.h>
+
 extern const struct dma_map_ops nommu_dma_ops;
 extern int force_iommu, no_iommu;
 extern int iommu_detected;
@@ -8,6 +10,11 @@ extern int iommu_pass_through;

 int x86_dma_supported(struct device *dev, u64 mask);

+static inline void iommu_set_init_handler(int (*init_fn)(void))
+{
+       x86_init.iommu.iommu_init = init_fn;
+}
+
 /* 10 seconds */
 #define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 6fe2d0346073..f464aef16a02 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2781,7 +2781,7 @@ int __init amd_iommu_detect(void)

        amd_iommu_detected = true;
        iommu_detected = 1;
-       x86_init.iommu.iommu_init = amd_iommu_init;
+       iomm_set_init_handler(amd_iommu_init);

        return 1;
 }
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 1ea7cd537873..b3bcbb07f789 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -905,10 +905,8 @@ int __init detect_intel_iommu(void)
                pci_request_acs();
        }

-#ifdef CONFIG_X86
        if (!ret)
-               x86_init.iommu.iommu_init = intel_iommu_init;
-#endif
+               iommu_set_init_handler(intel_iommu_init);

        if (dmar_tbl) {
                acpi_put_table(dmar_tbl);

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

* Re: [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h
  2017-10-20 11:41     ` Thomas Gleixner
@ 2017-10-20 12:20       ` Ingo Molnar
  0 siblings, 0 replies; 13+ messages in thread
From: Ingo Molnar @ 2017-10-20 12:20 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: arnd, linux-kernel, joro, hpa, linux-tip-commits


* Thomas Gleixner <tglx@linutronix.de> wrote:

> On Fri, 20 Oct 2017, Ingo Molnar wrote:
> > * tip-bot for Arnd Bergmann <tipbot@zytor.com> wrote:
> > This breaks the IA64 build:
> > 
> >   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory
> 
> The commits are already removed from x86/timers

Ok.

Thanks,

	Ingo

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

end of thread, other threads:[~2017-10-20 12:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-19 10:53 [PATCH 1/2] x86: don't include asm/x86_init.h in asm/setup.h Arnd Bergmann
2017-10-19 10:57 ` [PATCH v2 2/2] x86: convert x86_platform_ops to timespec64 Arnd Bergmann
2017-10-19 10:57   ` Arnd Bergmann
2017-10-19 11:46   ` Paolo Bonzini
2017-10-19 11:46   ` Paolo Bonzini
2017-10-19 13:46   ` [tip:x86/timers] x86: Convert " tip-bot for Arnd Bergmann
2017-10-19 13:45 ` [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h tip-bot for Arnd Bergmann
2017-10-20 11:11   ` Ingo Molnar
2017-10-20 11:37     ` Arnd Bergmann
2017-10-20 11:48       ` Thomas Gleixner
2017-10-20 12:09         ` Arnd Bergmann
2017-10-20 11:41     ` Thomas Gleixner
2017-10-20 12:20       ` Ingo Molnar

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.