Skip to contentSkip to conversation

x86-32 CPU configuration cleanups

PATCH In review Arnd Bergmann 7 participants 17 messages Nov 5 – Nov 9

Subsystems (17)
Network drivers Documentation x86 KVM +13 more subsystems
lore
Share & tools
lore
#0 lore raw

v2 cover x86-32 CPU configuration cleanups

From: Arnd Bergmann <[email protected]>

Hi Ingo,

Here are some follow-ups to your x86-32 CPU level changes based on patches I did last year but rebased onto current mainline.

The first three just drop code that is no longer relevant now that Élan is gone and all CPUs support both TSC and CX8.

The other four patches change the CPU configuration to be more like x86-64 and other architectures where all kernels are expected to be generic by default. I did keep the distinction between i586 and i686 class, but everything else is now just an optimization, building e.g. for CONFIG_MATOM will still run on all other i686 class CPUs, and picking any i586-class option will work on everything.

Changes since v1:
https://lore.kernel.org/all/[email protected]/

- rebase to 7.4-rc1
- drop ts5500 removal patch that was merged [Sean Young]
- reorder patches for cache line size [Juergen Gross]

Arnd

Arnd Bergmann (7):
x86: remove AMD Élan remnants
x86: make TSC usage unconditional
x86: make CX8 usage unconditional
x86: require minimum 64 byte cache lines
x86: remove dependencies on CONFIG_M... CPU options
x86: remove dependencies on per-CPU options
x86: simplify 32-bit instruction set selection

 Documentation/virt/kvm/x86/timekeeping.rst |   1 -
 arch/um/include/asm/asm-prototypes.h       |   4 -
 arch/x86/Kconfig.cpu                       |  42 ++---
 arch/x86/Kconfig.cpufeatures               |  14 +-
 arch/x86/Makefile_32.cpu                   |  16 +-
 arch/x86/events/msr.c                      |   5 -
 arch/x86/include/asm/asm-prototypes.h      |   4 -
 arch/x86/include/asm/atomic64_32.h         |  15 --
 arch/x86/include/asm/bitops.h              |   4 +-
 arch/x86/include/asm/cmpxchg_32.h          |  76 +-------
 arch/x86/include/asm/debugreg.h            |  10 +-
 arch/x86/include/asm/percpu.h              |  14 +-
 arch/x86/include/asm/ptrace.h              |   6 +-
 arch/x86/include/asm/timex.h               |   2 -
 arch/x86/include/asm/tsc.h                 |   2 -
 arch/x86/include/asm/vermagic.h            |  36 +---
 arch/x86/kernel/apic/apic.c                |  23 +--
 arch/x86/kernel/apic/io_apic.c             |  22 +--
 arch/x86/kernel/cpu/amd.c                  |  20 ---
 arch/x86/kernel/cpu/centaur.c              |   2 -
 arch/x86/kernel/cpu/common.c               |   4 +-
 arch/x86/kernel/cpu/proc.c                 |  15 +-
 arch/x86/kernel/i8253.c                    |   3 -
 arch/x86/kernel/tsc.c                      |  18 +-
 arch/x86/lib/Makefile                      |   4 -
 arch/x86/lib/atomic64_386_32.S             | 195 ---------------------
 arch/x86/lib/cmpxchg8b_emu.S               |  97 ----------
 arch/x86/lib/kaslr.c                       |  20 +--
 arch/x86/um/Kconfig                        |   2 +-
 arch/x86/um/Makefile                       |   3 +-
 arch/x86/xen/Kconfig                       |   1 -
 arch/x86/xen/time.c                        |   2 -
 drivers/misc/mei/Kconfig                   |   2 +-
 drivers/net/ethernet/intel/igc/igc_ptp.c   |   4 +-
 drivers/ptp/Kconfig                        |   2 +-
 lib/atomic64_test.c                        |   7 +-
 tools/power/cpupower/debug/kernel/Makefile |   5 +-
 37 files changed, 72 insertions(+), 630 deletions(-)
 delete mode 100644 arch/x86/lib/atomic64_386_32.S
 delete mode 100644 arch/x86/lib/cmpxchg8b_emu.S
Signature · 23 lines
2.53.0

Cc: Richard Weinberger <[email protected]>
Cc: Anton Ivanov <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Boqun Feng <[email protected]>
Cc: Gary Guo <[email protected]>
Cc: Yury Norov <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Alexander Usyskin <[email protected]>
Cc: Tony Nguyen <[email protected]>
Cc: Przemek Kitszel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
#1 lore raw

PATCH v2 1/7 x86: remove AMD Élan remnants

From: Arnd Bergmann <[email protected]>

There is one more leftover line in Kconfig and the detection for AMD Generation 4 CPUs (5k86 and Élan) that can now get removed following the increase of the minimum CPU level to 586TSC.

---
 arch/x86/Kconfig.cpu      |  1 -
 arch/x86/kernel/cpu/amd.c | 20 --------------------
 2 files changed, 21 deletions(-)
arch/x86/Kconfig.cpu +0 -1
index 6e7a366f0798..5b67a4567434 100644
@@ -32,7 +32,6 @@ choice
 	  - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird).
 	  - "Crusoe" for the Transmeta Crusoe series.
 	  - "Efficeon" for the Transmeta Efficeon series.
-	  - "AMD Elan" for the 32-bit AMD Elan embedded CPU.
 	  - "GeodeGX1" for Geode GX1 (Cyrix MediaGX).
 	  - "Geode GX/LX" For AMD Geode GX and LX processors.
 	  - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3.
arch/x86/kernel/cpu/amd.c +0 -20
index 3972966cb023..cd468e47b68a 100644
@@ -91,25 +91,6 @@ __asm__(".text\n"
 	"vide: ret\n");
 #endif
 
-static void init_amd_k5(struct cpuinfo_x86 *c)
-{
-#ifdef CONFIG_X86_32
-/*
- * General Systems BIOSen alias the cpu frequency registers
- * of the Elan at 0x000df000. Unfortunately, one of the Linux
- * drivers subsequently pokes it, and changes the CPU speed.
- * Workaround : Remove the unneeded alias.
- */
-#define CBAR		(0xfffc) /* Configuration Base Address  (32-bit) */
-#define CBAR_ENB	(0x80000000)
-#define CBAR_KEY	(0X000000CB)
-	if (c->x86_model == 9 || c->x86_model == 10) {
-		if (inl(CBAR) & CBAR_ENB)
-			outl(0 | CBAR_KEY, CBAR);
-	}
-#endif
-}
-
 static void init_amd_k6(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_32
@@ -1073,7 +1054,6 @@ static void init_amd(struct cpuinfo_x86 *c)
 		clear_cpu_cap(c, X86_FEATURE_MCE);
 
 	switch (c->x86) {
-	case 4:    init_amd_k5(c); break;
 	case 5:    init_amd_k6(c); break;
 	case 6:	   init_amd_k7(c); break;
 	case 0xf:  init_amd_k8(c); break;
Signature · 1 line
2.53.0
#2 lore raw

PATCH v2 2/7 x86: make TSC usage unconditional

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

There are multiple levels of functionality of the TSC that are checked
for: built into the kernel, present in the CPU, reliable and probably more.

Since the TSC-less CPUs are no longer supported in the kernel, remove all checks for CONFIG_TSC and X86_FEATURE_TSC and assume it's always there. Unfortunately the tsc_clocksource_reliable checks are still required though.

---
 Documentation/virt/kvm/x86/timekeeping.rst |  1 -
 arch/x86/Kconfig.cpu                       |  3 ---
 arch/x86/events/msr.c                      |  5 -----
 arch/x86/include/asm/timex.h               |  2 --
 arch/x86/include/asm/tsc.h                 |  2 --
 arch/x86/kernel/apic/apic.c                | 23 +++++++++-------------
 arch/x86/kernel/apic/io_apic.c             | 22 +--------------------
 arch/x86/kernel/cpu/centaur.c              |  2 --
 arch/x86/kernel/cpu/common.c               |  4 +---
 arch/x86/kernel/cpu/proc.c                 | 15 ++++++--------
 arch/x86/kernel/i8253.c                    |  3 ---
 arch/x86/kernel/tsc.c                      | 16 ++-------------
 arch/x86/lib/kaslr.c                       | 20 ++++---------------
 arch/x86/xen/time.c                        |  2 --
 drivers/net/ethernet/intel/igc/igc_ptp.c   |  4 ++--
 drivers/ptp/Kconfig                        |  2 +-
 tools/power/cpupower/debug/kernel/Makefile |  5 +----
 17 files changed, 27 insertions(+), 104 deletions(-)
Documentation/virt/kvm/x86/timekeeping.rst +0 -1
index 21ae7efa29ba..e8519451000d 100644
@@ -471,7 +471,6 @@ The following feature bits are used by Linux to signal various TSC attributes,
 but they can only be taken to be meaningful for UP or single node systems.
 
 =========================	=======================================
-X86_FEATURE_TSC			The TSC is available in hardware
 X86_FEATURE_RDTSCP		The RDTSCP instruction is available
 X86_FEATURE_CONSTANT_TSC	The TSC rate is unchanged with P-states
 X86_FEATURE_NONSTOP_TSC		The TSC does not stop in C-states
arch/x86/Kconfig.cpu +0 -3
index 5b67a4567434..f2c1f544f5f9 100644
@@ -270,9 +270,6 @@ config X86_USE_PPRO_CHECKSUM
 	def_bool y
 	depends on MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MATOM
 
-config X86_TSC
-	def_bool y
-
 config X86_HAVE_PAE
 	def_bool y
 	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC7 || MATOM || X86_64
arch/x86/events/msr.c +0 -5
index 76d6418c5055..130f1a8c8800 100644
@@ -229,11 +229,6 @@ static struct pmu pmu_msr = {
 
 static int __init msr_init(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_TSC)) {
-		pr_cont("no MSR PMU driver.\n");
-		return 0;
-	}
-
 	msr_mask = perf_msr_probe(msr, PERF_MSR_EVENT_MAX, true, NULL);
 
 	perf_pmu_register(&pmu_msr, "msr", -1);
arch/x86/include/asm/timex.h +0 -2
index f397072cf294..a4770765b34d 100644
@@ -7,8 +7,6 @@
 
 static inline unsigned long random_get_entropy(void)
 {
-	if (!cpu_feature_enabled(X86_FEATURE_TSC))
-		return random_get_entropy_fallback();
 	return rdtsc();
 }
 #define random_get_entropy random_get_entropy
arch/x86/include/asm/tsc.h +0 -2
index 4d2d2f21ff06..88d9d2a22152 100644
@@ -76,8 +76,6 @@ extern void disable_TSC(void);
 
 static inline cycles_t get_cycles(void)
 {
-	if (!cpu_feature_enabled(X86_FEATURE_TSC))
-		return 0;
 	return rdtsc();
 }
 #define get_cycles get_cycles
arch/x86/kernel/apic/apic.c +9 -14
index 90025451ace2..31c890618762 100644
@@ -666,8 +666,7 @@ static void __init lapic_cal_handler(struct clock_event_device *dev)
 	long tapic = apic_read(APIC_TMCCT);
 	u32 pm = acpi_pm_read_early();
 
-	if (boot_cpu_has(X86_FEATURE_TSC))
-		tsc = rdtsc();
+	tsc = rdtsc();
 
 	switch (lapic_cal_loops++) {
 	case 0:
@@ -727,13 +726,11 @@ calibrate_by_pmtimer(u32 deltapm, long *delta, long *deltatsc)
 	*delta = (long)res;
 
 	/* Correct the tsc counter value */
-	if (boot_cpu_has(X86_FEATURE_TSC)) {
-		res = (((u64)(*deltatsc)) * pm_100ms);
-		do_div(res, deltapm);
-		apic_pr_verbose("TSC delta adjusted to PM-Timer: %lu (%ld)\n",
-				(unsigned long)res, *deltatsc);
-		*deltatsc = (long)res;
-	}
+	res = (((u64)(*deltatsc)) * pm_100ms);
+	do_div(res, deltapm);
+	apic_pr_verbose("TSC delta adjusted to PM-Timer: %lu (%ld)\n",
+			(unsigned long)res, *deltatsc);
+	*deltatsc = (long)res;
 
 	return 0;
 }
@@ -902,12 +899,10 @@ static int __init calibrate_APIC_clock(void)
 	apic_pr_verbose("..... mult: %u\n", lapic_clockevent.mult);
 	apic_pr_verbose("..... calibration result: %u\n", lapic_timer_period);
 
-	if (boot_cpu_has(X86_FEATURE_TSC)) {
-		delta_tsc_khz = (deltatsc * HZ) / (1000 * LAPIC_CAL_LOOPS);
+	delta_tsc_khz = (deltatsc * HZ) / (1000 * LAPIC_CAL_LOOPS);
 
-		apic_pr_verbose("..... CPU clock speed is %ld.%03ld MHz.\n",
-				delta_tsc_khz / 1000, delta_tsc_khz % 1000);
-	}
+	apic_pr_verbose("..... CPU clock speed is %ld.%03ld MHz.\n",
+			delta_tsc_khz / 1000, delta_tsc_khz % 1000);
 
 	bus_khz = (long)lapic_timer_period * HZ / 1000;
 	apic_pr_verbose("..... host bus clock speed is %ld.%03ld MHz.\n",
arch/x86/kernel/apic/io_apic.c +1 -21
index 7d7175d01228..b3c5ff599fda 100644
@@ -1491,23 +1491,6 @@ static void __init delay_with_tsc(void)
 	} while ((now - start) < 40000000000ULL / HZ &&	time_before_eq(jiffies, end));
 }
 
-static void __init delay_without_tsc(void)
-{
-	unsigned long end = jiffies + 4;
-	int band = 1;
-
-	/*
-	 * We don't know any frequency yet, but waiting for
-	 * 40940000000/HZ cycles is safe:
-	 * 4 GHz == 10 jiffies
-	 * 1 GHz == 40 jiffies
-	 * 1 << 1 + 1 << 2 +...+ 1 << 11 = 4094
-	 */
-	do {
-		__delay(((1U << band++) * 10000000UL) / HZ);
-	} while (band < 12 && time_before_eq(jiffies, end));
-}
-
 /*
  * There is a nasty bug in some older SMP boards, their mptable lies
  * about the timer IRQ. We do the following to work around the situation:
@@ -1524,10 +1507,7 @@ static int __init timer_irq_works(void)
 		return 1;
 
 	local_irq_enable();
-	if (boot_cpu_has(X86_FEATURE_TSC))
-		delay_with_tsc();
-	else
-		delay_without_tsc();
+	delay_with_tsc();
 
 	/*
 	 * Expect a few ticks at least, to be sure some possible
arch/x86/kernel/cpu/centaur.c +0 -2
index 513fa1f640f9..f66ca8335af9 100644
@@ -140,8 +140,6 @@ static void init_centaur(struct cpuinfo_x86 *c)
 			name = "C6";
 			fcr_set = ECX8|DSMC|EDCTLB|EMMX|ERETSTK;
 			fcr_clr = DPDC;
-			pr_notice("Disabling bugged TSC.\n");
-			clear_cpu_cap(c, X86_FEATURE_TSC);
 			break;
 		case 8:
 			switch (c->x86_stepping) {
arch/x86/kernel/cpu/common.c +1 -3
index 9bd50c68cd7e..355bcbfdf2dd 100644
@@ -2478,9 +2478,7 @@ void cpu_init(void)
 #endif
 	pr_debug("Initializing CPU#%d\n", cpu);
 
-	if (IS_ENABLED(CONFIG_X86_64) || cpu_feature_enabled(X86_FEATURE_VME) ||
-	    boot_cpu_has(X86_FEATURE_TSC) || boot_cpu_has(X86_FEATURE_DE))
-		cr4_clear_bits(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
+	cr4_clear_bits(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
 
 	if (IS_ENABLED(CONFIG_X86_64)) {
 		loadsegment(fs, 0);
arch/x86/kernel/cpu/proc.c +6 -9
index 6571d432cbe3..8086c39c2922 100644
@@ -64,7 +64,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 {
 	struct cpuinfo_x86 *c = v;
 	unsigned int cpu;
-	int i;
+	int freq, i;
 
 	cpu = c->cpu_index;
 	seq_printf(m, "processor\t: %u\n"
@@ -85,14 +85,11 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 	if (c->microcode)
 		seq_printf(m, "microcode\t: 0x%x\n", c->microcode);
 
-	if (cpu_has(c, X86_FEATURE_TSC)) {
-		int freq = arch_freq_get_on_cpu(cpu);
-
-		if (freq < 0)
-			seq_puts(m, "cpu MHz\t\t: Unknown\n");
-		else
-			seq_printf(m, "cpu MHz\t\t: %u.%03u\n", freq / 1000, (freq % 1000));
-	}
+	freq = arch_freq_get_on_cpu(cpu);
+	if (freq < 0)
+		seq_puts(m, "cpu MHz\t\t: Unknown\n");
+	else
+		seq_printf(m, "cpu MHz\t\t: %u.%03u\n", freq / 1000, (freq % 1000));
 
 	/* Cache size */
 	if (c->x86_cache_size)
arch/x86/kernel/i8253.c +0 -3
index 0b991035f127..0c91426e4a08 100644
@@ -31,9 +31,6 @@ struct clock_event_device *global_clock_event;
  */
 static bool __init use_pit(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_TSC))
-		return true;
-
 	/* This also returns true when APIC is disabled */
 	return apic_needs_pit();
 }
arch/x86/kernel/tsc.c +2 -14
index 723347e2cf7f..02269dcbde1f 100644
@@ -929,9 +929,6 @@ void recalibrate_cpu_khz(void)
 #ifndef CONFIG_SMP
 	unsigned long cpu_khz_old = cpu_khz;
 
-	if (!boot_cpu_has(X86_FEATURE_TSC))
-		return;
-
 	cpu_khz = x86_platform.calibrate_cpu();
 	tsc_khz = x86_platform.calibrate_tsc();
 	if (tsc_khz == 0)
@@ -1046,8 +1043,6 @@ static struct notifier_block time_cpufreq_notifier_block = {
 
 static int __init cpufreq_register_tsc_scaling(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_TSC))
-		return 0;
 	if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
 		return 0;
 	cpufreq_register_notifier(&time_cpufreq_notifier_block,
@@ -1253,7 +1248,7 @@ static void __init check_system_tsc_reliable(void)
  */
 int unsynchronized_tsc(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_TSC) || tsc_unstable)
+	if (tsc_unstable)
 		return 1;
 
 #ifdef CONFIG_SMP
@@ -1403,7 +1398,7 @@ static void tsc_refine_calibration_work(struct work_struct *work)
 
 static int __init init_tsc_clocksource(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_TSC) || !tsc_khz)
+	if (!tsc_khz)
 		return 0;
 
 	if (tsc_unstable) {
@@ -1502,8 +1497,6 @@ static void __init tsc_enable_sched_clock(void)
 
 void __init tsc_early_init(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_TSC))
-		return;
 	/* Don't change UV TSC multi-chassis synchronization */
 	if (is_early_uv_system())
 		return;
@@ -1517,11 +1510,6 @@ void __init tsc_early_init(void)
 
 void __init tsc_init(void)
 {
-	if (!cpu_feature_enabled(X86_FEATURE_TSC)) {
-		setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
-		return;
-	}
-
 	/*
 	 * native_calibrate_cpu_early can only calibrate using methods that are
 	 * available early in boot.
arch/x86/lib/kaslr.c +4 -16
index 8c7cd115b484..9984eeeb1a7c 100644
@@ -54,7 +54,6 @@ unsigned long kaslr_get_random_long(const char *purpose)
 	const unsigned long mix_const = 0x3f39e593UL;
 #endif
 	unsigned long raw, random = get_boot_seed();
-	bool use_i8254 = true;
 
 	if (purpose) {
 		debug_putstr(purpose);
@@ -66,24 +65,13 @@ unsigned long kaslr_get_random_long(const char *purpose)
 			debug_putstr(" RDRAND");
 		if (rdrand_long(&raw)) {
 			random ^= raw;
-			use_i8254 = false;
 		}
 	}
 
-	if (has_cpuflag(X86_FEATURE_TSC)) {
-		if (purpose)
-			debug_putstr(" RDTSC");
-		raw = rdtsc();
-
-		random ^= raw;
-		use_i8254 = false;
-	}
-
-	if (use_i8254) {
-		if (purpose)
-			debug_putstr(" i8254");
-		random ^= i8254();
-	}
+	if (purpose)
+		debug_putstr(" RDTSC");
+	raw = rdtsc();
+	random ^= raw;
 
 	/* Circular multiply for better bit diffusion */
 	asm(_ASM_MUL "%3"
arch/x86/xen/time.c +0 -2
index 5c7822254a01..b29c94bfce35 100644
@@ -541,8 +541,6 @@ static void __init xen_time_init(void)
 	xen_read_wallclock(&tp);
 	do_settimeofday64(&tp);
 
-	setup_force_cpu_cap(X86_FEATURE_TSC);
-
 	/*
 	 * We check ahead on the primary time info if this
 	 * bit is supported hence speeding up Xen clocksource.
drivers/net/ethernet/intel/igc/igc_ptp.c +2 -2
index b40aba9ab685..3736bd800a5d 100644
@@ -947,7 +947,7 @@ int igc_ptp_hwtstamp_get(struct net_device *netdev,
  */
 static bool igc_is_crosststamp_supported(struct igc_adapter *adapter)
 {
-	if (!IS_ENABLED(CONFIG_X86_TSC))
+	if (!IS_ENABLED(CONFIG_X86))
 		return false;
 
 	/* FIXME: it was noticed that enabling support for PCIe PTM in
@@ -965,7 +965,7 @@ static bool igc_is_crosststamp_supported(struct igc_adapter *adapter)
 
 static struct system_counterval_t igc_device_tstamp_to_system(u64 tstamp)
 {
-#if IS_ENABLED(CONFIG_X86_TSC) && !defined(CONFIG_UML)
+#if IS_ENABLED(CONFIG_X86) && !defined(CONFIG_UML)
 	return (struct system_counterval_t) {
 		.cs_id		= CSID_X86_ART,
 		.cycles		= tstamp,
drivers/ptp/Kconfig +1 -1
index feb50f8cc406..52845a1de7fa 100644
@@ -134,7 +134,7 @@ config PTP_1588_CLOCK_KVM
 
 config PTP_1588_CLOCK_VMCLOCK
 	tristate "Virtual machine PTP clock"
-	depends on X86_TSC || ARM_ARCH_TIMER
+	depends on X86 || ARM_ARCH_TIMER
 	depends on PTP_1588_CLOCK && ARCH_SUPPORTS_INT128
 	default PTP_1588_CLOCK_KVM
 	help
tools/power/cpupower/debug/kernel/Makefile +1 -4
index 7b5c43684be1..89954bba1453 100644
@@ -1,12 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-m	:=
+obj-m	:= cpufreq-test_tsc.o
 
 KDIR	:= /lib/modules/$(shell uname -r)/build
 KMISC   := /lib/modules/$(shell uname -r)/cpufrequtils/
 
-ifeq ("$(CONFIG_X86_TSC)", "y")
-  obj-m	 += cpufreq-test_tsc.o
-endif
 
 default:
 	$(MAKE) -C $(KDIR) M=$(CURDIR)
Signature · 1 line
2.53.0
#3 lore raw

PATCH v2 3/7 x86: make CX8 usage unconditional

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

All supported CPUs now provide the cmpxchg8b instruction, so remove all compile-time and runtime checks for its presence and the fallback implementation, to assume it just works.

---
 arch/um/include/asm/asm-prototypes.h  |   4 -
 arch/x86/Kconfig.cpu                  |   3 -
 arch/x86/Kconfig.cpufeatures          |   6 +-
 arch/x86/include/asm/asm-prototypes.h |   4 -
 arch/x86/include/asm/atomic64_32.h    |  15 --
 arch/x86/include/asm/cmpxchg_32.h     |  76 +---------
 arch/x86/include/asm/percpu.h         |  14 +-
 arch/x86/lib/Makefile                 |   4 -
 arch/x86/lib/atomic64_386_32.S        | 195 --------------------------
 arch/x86/lib/cmpxchg8b_emu.S          |  97 -------------
 arch/x86/um/Kconfig                   |   2 +-
 arch/x86/um/Makefile                  |   3 +-
 lib/atomic64_test.c                   |   7 +-
 13 files changed, 13 insertions(+), 417 deletions(-)
 delete mode 100644 arch/x86/lib/atomic64_386_32.S
 delete mode 100644 arch/x86/lib/cmpxchg8b_emu.S
arch/um/include/asm/asm-prototypes.h +0 -4
index 408b31d59127..b446eec98ed8 100644
@@ -1,6 +1,2 @@
 #include <asm-generic/asm-prototypes.h>
 #include <asm/checksum.h>
-
-#ifdef CONFIG_UML_X86
-extern void cmpxchg8b_emu(void);
-#endif
arch/x86/Kconfig.cpu +0 -3
index f2c1f544f5f9..832e4bd9f6e0 100644
@@ -274,9 +274,6 @@ config X86_HAVE_PAE
 	def_bool y
 	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC7 || MATOM || X86_64
 
-config X86_CX8
-	def_bool y
-
 # this should be set for all -march=.. options where the compiler
 # generates cmov.
 config X86_CMOV
arch/x86/Kconfig.cpufeatures +3 -3
index 09833c88f9ff..e0f2ff65377d 100644
@@ -40,9 +40,6 @@ config X86_REQUIRED_FEATURE_NOPL
 	def_bool y
 	depends on X86_64
 
-config X86_REQUIRED_FEATURE_CX8
-	def_bool y
-
 # this should be set for all -march=.. options where the compiler
 # generates cmov.
 config X86_REQUIRED_FEATURE_CMOV
@@ -59,6 +56,9 @@ config X86_REQUIRED_FEATURE_SYSFAST32
 	def_bool y
 	depends on X86_64 && !X86_FRED
 
+config X86_REQUIRED_FEATURE_CX8
+	def_bool y
+
 config X86_REQUIRED_FEATURE_CPUID
 	def_bool y
 	depends on X86_64
arch/x86/include/asm/asm-prototypes.h +0 -4
index 11c6fecc3ad7..6ec680a36dea 100644
@@ -16,10 +16,6 @@
 #include <asm/gsseg.h>
 #include <asm/nospec-branch.h>
 
-#ifndef CONFIG_X86_CX8
-extern void cmpxchg8b_emu(void);
-#endif
-
 #ifdef CONFIG_STACKPROTECTOR
 extern unsigned long __ref_stack_chk_guard;
 #endif
arch/x86/include/asm/atomic64_32.h +0 -15
index ab838205c1c6..e3da5d0094c4 100644
@@ -48,7 +48,6 @@ static __always_inline s64 arch_atomic64_read_nonatomic(const atomic64_t *v)
 	ATOMIC64_EXPORT(atomic64_##sym)
 #endif
 
-#ifdef CONFIG_X86_CX8
 #define __alternative_atomic64(f, g, out, in, clobbers...)		\
 	asm volatile("call %c[func]"					\
 		     : ALT_OUTPUT_SP(out) \
@@ -57,20 +56,6 @@ static __always_inline s64 arch_atomic64_read_nonatomic(const atomic64_t *v)
 		     : clobbers)
 
 #define ATOMIC64_DECL(sym) ATOMIC64_DECL_ONE(sym##_cx8)
-#else
-#define __alternative_atomic64(f, g, out, in, clobbers...)		\
-	alternative_call(atomic64_##f##_386, atomic64_##g##_cx8,	\
-			 X86_FEATURE_CX8, ASM_OUTPUT(out),		\
-			 ASM_INPUT(in), clobbers)
-
-#define ATOMIC64_DECL(sym) ATOMIC64_DECL_ONE(sym##_cx8); \
-	ATOMIC64_DECL_ONE(sym##_386)
-
-ATOMIC64_DECL_ONE(add_386);
-ATOMIC64_DECL_ONE(sub_386);
-ATOMIC64_DECL_ONE(inc_386);
-ATOMIC64_DECL_ONE(dec_386);
-#endif
 
 #define alternative_atomic64(f, out, in, clobbers...) \
 	__alternative_atomic64(f, f, ASM_OUTPUT(out), ASM_INPUT(in), clobbers)
arch/x86/include/asm/cmpxchg_32.h +1 -75

87 lines not on this page · raw message

arch/x86/include/asm/percpu.h +5 -9
index cef9a4ca9841..539abf94828d 100644
@@ -330,11 +330,9 @@ do {									\
 	old__.var = _oval;						\
 	new__.var = _nval;						\
 									\
-	asm_inline qual (						\
-		ALTERNATIVE("call this_cpu_cmpxchg8b_emu",		\
-			    "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \
-		: ALT_OUTPUT_SP([var] "+m" (__my_cpu_var(_var)),	\
-				"+a" (old__.low), "+d" (old__.high))	\
+	asm_inline qual ("cmpxchg8b " __percpu_arg([var])		\
+		: [var] "+m" (__my_cpu_var(_var)),			\
+				"+a" (old__.low), "+d" (old__.high)	\
 		: "b" (new__.low), "c" (new__.high),			\
 		  "S" (&(_var))						\
 		: "memory");						\
@@ -359,10 +357,8 @@ do {									\
 	old__.var = *_oval;						\
 	new__.var = _nval;						\
 									\
-	asm_inline qual (						\
-		ALTERNATIVE("call this_cpu_cmpxchg8b_emu",		\
-			    "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \
-		: ALT_OUTPUT_SP("=@ccz" (success),			\
+	asm_inline qual ("cmpxchg8b " __percpu_arg([var])		\
+		: "=@ccz" (success),					\
 				[var] "+m" (__my_cpu_var(_var)),	\
 				"+a" (old__.low), "+d" (old__.high))	\
 		: "b" (new__.low), "c" (new__.high),			\
arch/x86/lib/Makefile +0 -4
index 2dba7f83ef97..210af275f468 100644
@@ -48,10 +48,6 @@ ifeq ($(CONFIG_X86_32),y)
         lib-y += strstr_32.o
         lib-y += string_32.o
         lib-y += memmove_32.o
-        lib-y += cmpxchg8b_emu.o
-ifneq ($(CONFIG_X86_CX8),y)
-        lib-y += atomic64_386_32.o
-endif
 else
 ifneq ($(CONFIG_GENERIC_CSUM),y)
         lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
arch/x86/lib/atomic64_386_32.S deleted +0 -195

195 lines not on this page · raw message

arch/x86/lib/cmpxchg8b_emu.S deleted +0 -97

97 lines not on this page · raw message

arch/x86/um/Kconfig +1 -1
index 44b12e45f9a0..5b78440a78b9 100644
@@ -13,7 +13,7 @@ config UML_X86
 	select ARCH_USE_QUEUED_SPINLOCKS
 	select DCACHE_WORD_ACCESS
 	select HAVE_EFFICIENT_UNALIGNED_ACCESS
-	select UML_SUBARCH_SUPPORTS_SMP if X86_CX8
+	select UML_SUBARCH_SUPPORTS_SMP
 
 config 64BIT
 	bool "64-bit kernel" if "$(SUBARCH)" = "x86"
arch/x86/um/Makefile +1 -2
index 100b68f601f9..716da7b1e3e9 100644
@@ -19,8 +19,7 @@ ifeq ($(CONFIG_X86_32),y)
 
 obj-y += syscalls_32.o
 
-subarch-y = ../lib/string_32.o ../lib/atomic64_32.o ../lib/atomic64_cx8_32.o
-subarch-y += ../lib/cmpxchg8b_emu.o ../lib/atomic64_386_32.o
+subarch-y = ../lib/string_32.o ../lib/atomic64_32.o
 subarch-y += ../lib/checksum_32.o
 subarch-y += ../kernel/sys_ia32.o
 
lib/atomic64_test.c +2 -5
index d726068358c7..37af41df3e6a 100644
@@ -251,15 +251,12 @@ static __init int test_atomics_init(void)
 	test_atomic64();
 
 #ifdef CONFIG_X86
-	pr_info("passed for %s platform %s CX8 and %s SSE\n",
+	pr_info("passed for %s platform %s SSE\n",
 #ifdef CONFIG_X86_64
 		"x86-64",
-#elif defined(CONFIG_X86_CX8)
-		"i586+",
 #else
-		"i386+",
+		"i586+",
 #endif
-	       boot_cpu_has(X86_FEATURE_CX8) ? "with" : "without",
 	       boot_cpu_has(X86_FEATURE_XMM) ? "with" : "without");
 #else
 	pr_info("passed\n");
Signature · 1 line
2.53.0
#10 lore raw

PATCH v2 4/7 x86: require minimum 64 byte cache lines

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Later x86-32 CPUs like Pentium-M, K7 and Atom use 64 byte cache lines and are incompatible with kernels built for smaller values of X86_L1_CACHE_SHIFT.

Pentium-4 CPUs have 128 byte cache lines but are compatible with cache operations that expect the lines to be 64 bytes.

Older CPUs have smaller cache lines of 16 or 32 bytes but work correctly when X86_L1_CACHE_SHIFT is set to a larger value.

Remove the per-CPU tuning and always build for 64 or 128 byte cache lines that work correctly in any CPU.

---
 arch/x86/Kconfig.cpu | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
arch/x86/Kconfig.cpu +3 -5
index 832e4bd9f6e0..382c9023c855 100644
@@ -180,8 +180,8 @@ config MVIAC7
 	bool "VIA C7"
 	depends on X86_32
 	help
-	  Select this for a VIA C7.  Selecting this uses the correct cache
-	  shift and tells gcc to treat the CPU as a 686.
+	  Select this for a VIA C7.  Selecting this tells gcc to treat the
+	  CPU as a 686.
 
 config MATOM
 	bool "Intel Atom"
@@ -250,9 +250,7 @@ config X86_INTERNODE_CACHE_SHIFT
 config X86_L1_CACHE_SHIFT
 	int
 	default "7" if MPENTIUM4
-	default "6" if MK7 || MPENTIUMM || MATOM || MVIAC7 || X86_GENERIC || X86_64
-	default "4" if MGEODEGX1
-	default "5" if MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MVIAC3_2 || MGEODE_LX
+	default "6"
 
 config X86_F00F_BUG
 	def_bool y
Signature · 1 line
2.53.0
#11 lore raw

PATCH v2 5/7 x86: remove dependencies on CONFIG_M... CPU options

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

CPU specific features should generally be controlled by CPU_SUP_xxx options rather than CONFIG_Mxxx, to allow generic kernels to be built that work with all of them.

Replace the few options that don't follow this scheme with checks on either CPU_SUP_xxx or X86_PAE by itself.

---
 arch/x86/kernel/tsc.c    | 2 +-
 arch/x86/xen/Kconfig     | 1 -
 drivers/misc/mei/Kconfig | 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/tsc.c +1 -1
index 02269dcbde1f..d8b79d1151da 100644
@@ -1212,7 +1212,7 @@ static void __init tsc_disable_clocksource_watchdog(void)
 
 static void __init check_system_tsc_reliable(void)
 {
-#if defined(CONFIG_MGEODEGX1) || defined(CONFIG_MGEODE_LX) || defined(CONFIG_X86_GENERIC)
+#if defined(CONFIG_CPU_SUP_CYRIX_32)
 	if (is_geode_lx()) {
 		/* RTSC counts during suspend */
 #define RTSC_SUSP 0x100
arch/x86/xen/Kconfig +0 -1
index 609e79942fcb..0655ddd6fd39 100644
@@ -10,7 +10,6 @@ config XEN
 	select X86_HV_CALLBACK_VECTOR
 	select HIBERNATE_CALLBACKS
 	depends on X86_64 || (X86_32 && X86_PAE)
-	depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MATOM)
 	depends on X86_LOCAL_APIC
 	help
 	  This is the Linux Xen port.  Enabling this will allow the
drivers/misc/mei/Kconfig +1 -1
index 2d1bc5b4d11b..faa451584002 100644
@@ -4,7 +4,7 @@ config INTEL_MEI
 	tristate "Intel Management Engine Interface"
 	depends on PCI
 	depends on X86 || DRM_XE!=n || COMPILE_TEST
-	default X86_64 || MATOM
+	default X86_64 || CPU_SUP_INTEL
 	help
 	  The Intel Management Engine (Intel ME) provides Manageability,
 	  Security and Media services for system containing Intel chipsets.
Signature · 1 line
2.53.0
#12 lore raw

PATCH v2 6/7 x86: remove dependencies on per-CPU options

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

A few CPU feature options are defined in terms of CONFIG_Mxxx CPU selection options.

This conflicts with the idea of CONFIG_X86_GENERIC allowing one to build a kernel that works with multiple slightly incompatible CPUs.

As a simplification, change all of these to be enabled in terms of either 586-class or 686-class builds.

---
 arch/x86/Kconfig.cpu            | 14 ++++----------
 arch/x86/Kconfig.cpufeatures    |  8 +-------
 arch/x86/include/asm/bitops.h   |  4 ++--
 arch/x86/include/asm/debugreg.h | 10 ++++------
 arch/x86/include/asm/ptrace.h   |  6 +-----
 5 files changed, 12 insertions(+), 30 deletions(-)
arch/x86/Kconfig.cpu +4 -10
index 382c9023c855..21026e0cb569 100644
@@ -253,8 +253,7 @@ config X86_L1_CACHE_SHIFT
 	default "6"
 
 config X86_F00F_BUG
-	def_bool y
-	depends on M586MMX || M586TSC || M586
+	def_bool X86_MINIMUM_CPU_FAMILY=5 && CPU_SUP_INTEL
 
 config X86_ALIGNMENT_16
 	def_bool y
@@ -272,12 +271,6 @@ config X86_HAVE_PAE
 	def_bool y
 	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC7 || MATOM || X86_64
 
-# this should be set for all -march=.. options where the compiler
-# generates cmov.
-config X86_CMOV
-	def_bool y
-	depends on (MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || MATOM || MGEODE_LX || X86_64)
-
 config X86_MINIMUM_CPU_FAMILY
 	int
 	default "64" if X86_64
@@ -286,7 +279,8 @@ config X86_MINIMUM_CPU_FAMILY
 
 config X86_DEBUGCTLMSR
 	def_bool y
-	depends on !(MK6 || MCYRIXIII || M586MMX || M586TSC || M586) && !UML
+	depends on !UML
+	depends on X86_MINIMUM_CPU_FAMILY=6
 
 config IA32_FEAT_CTL
 	def_bool y
@@ -318,7 +312,7 @@ config CPU_SUP_INTEL
 config CPU_SUP_CYRIX_32
 	default y
 	bool "Support Cyrix processors" if PROCESSOR_SELECT
-	depends on M586 || M586TSC || M586MMX || (EXPERT && !64BIT)
+	depends on X86_MINIMUM_CPU_FAMILY=5
 	help
 	  This enables detection, tunings and quirks for Cyrix processors
 
arch/x86/Kconfig.cpufeatures +1 -7
index e0f2ff65377d..a0a1e838014d 100644
@@ -44,13 +44,7 @@ config X86_REQUIRED_FEATURE_NOPL
 # generates cmov.
 config X86_REQUIRED_FEATURE_CMOV
 	def_bool y
-	depends on X86_CMOV
-
-# this should be set for all -march= options where the compiler
-# generates movbe.
-config X86_REQUIRED_FEATURE_MOVBE
-	def_bool y
-	depends on MATOM
+	depends on X86_MINIMUM_CPU_FAMILY >= 6
 
 config X86_REQUIRED_FEATURE_SYSFAST32
 	def_bool y
arch/x86/include/asm/bitops.h +2 -2
index c2ce213f2b9b..f65872f67820 100644
@@ -312,7 +312,7 @@ static __always_inline __attribute_const__ int variable_ffs(int x)
 	asm("bsfl %1,%0"
 	    : "=r" (r)
 	    : ASM_INPUT_RM (x), "0" (-1));
-#elif defined(CONFIG_X86_CMOV)
+#elif CONFIG_X86_MINIMUM_CPU_FAMILY >= 6
 	asm("bsfl %1,%0\n\t"
 	    "cmovzl %2,%0"
 	    : "=&r" (r) : "rm" (x), "r" (-1));
@@ -369,7 +369,7 @@ static __always_inline __attribute_const__ int fls(unsigned int x)
 	asm("bsrl %1,%0"
 	    : "=r" (r)
 	    : ASM_INPUT_RM (x), "0" (-1));
-#elif defined(CONFIG_X86_CMOV)
+#elif CONFIG_X86_MINIMUM_CPU_FAMILY >= 6
 	asm("bsrl %1,%0\n\t"
 	    "cmovzl %2,%0"
 	    : "=&r" (r) : "rm" (x), "rm" (-1));
arch/x86/include/asm/debugreg.h +4 -6
index 854d82b88ff4..90989e95cb8a 100644
@@ -176,10 +176,9 @@ static inline unsigned long get_debugctlmsr(void)
 {
 	unsigned long debugctlmsr = 0;
 
-#ifndef CONFIG_X86_DEBUGCTLMSR
-	if (boot_cpu_data.x86 < 6)
+	if (CONFIG_X86_MINIMUM_CPU_FAMILY < 6 || boot_cpu_data.x86 < 6)
 		return 0;
-#endif
+
 	rdmsrq(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
 
 	return debugctlmsr;
@@ -187,10 +186,9 @@ static inline unsigned long get_debugctlmsr(void)
 
 static inline void update_debugctlmsr(unsigned long debugctlmsr)
 {
-#ifndef CONFIG_X86_DEBUGCTLMSR
-	if (boot_cpu_data.x86 < 6)
+	if (CONFIG_X86_MINIMUM_CPU_FAMILY < 6 || boot_cpu_data.x86 < 6)
 		return;
-#endif
+
 	wrmsrq(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
 }
 
arch/x86/include/asm/ptrace.h +1 -5
index 7bb7bd90355d..b1d881229fab 100644
@@ -449,11 +449,7 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,
 }
 
 #define arch_has_single_step()	(1)
-#ifdef CONFIG_X86_DEBUGCTLMSR
-#define arch_has_block_step()	(1)
-#else
-#define arch_has_block_step()	(boot_cpu_data.x86 >= 6)
-#endif
+#define arch_has_block_step()	((CONFIG_X86_MINIMUM_CPU_FAMILY >= 6) || (boot_cpu_data.x86 >= 6))
 
 #define ARCH_HAS_USER_SINGLE_STEP_REPORT
 
Signature · 1 line
2.53.0
#13 lore raw

PATCH v2 7/7 x86: simplify 32-bit instruction set selection

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The -march= compiler flags select both instruction set and tuning for a particular CPU, which works well when building a kernel that can only run on this one type, but has some counterintuitive effects because it is not always clear which models are compatible.

E.g. building for Geode LX results in a kernel that can work on all on all 686-class CPUs but crashes on CPUs without the CMOV instructions. Building a kernel for 686 could work on Geode LX and Crusoe but fails because of the CPU generation check that detects these as 585-class. Similarly, building for Intel Atom produces a 32-bit kernel that uses the MOVBE instructions and does not work on any other 32-bit CPU or even 64-bit CPUs before Haswell/Excavator.

Change the CPU selection to build everything with either -march=i586 or -march=i686 and make the specific options only change the -mtune= parameter where this was previously handled by -march=. Note that the only -mtune= options that gcc or clang understand for x86-32 are i486, pentium, pentiumpro, pentium4, atom, geode, k6 and athlon, the other ten are just aliases for one of them.

Selecting any 586-class configuration option now produces a kernel that works on every supported CPU, while selecting a 686-class configuration works on all 686-class CPUs but no 586-class ones.

Consequently, the vermagic.h logic can be simplified to just these two cases.

---
 arch/x86/Kconfig.cpu            | 13 +++++-------
 arch/x86/Makefile_32.cpu        | 16 +++++++--------
 arch/x86/include/asm/vermagic.h | 36 ++-------------------------------
 3 files changed, 15 insertions(+), 50 deletions(-)
arch/x86/Kconfig.cpu +5 -8
index 21026e0cb569..121881c4d076 100644
@@ -6,9 +6,9 @@ choice
 	default M686
 	help
 	  This is the processor type of your CPU. This information is
-	  used for optimizing purposes. In order to compile a kernel
-	  that can run on all supported x86 CPU types (albeit not
-	  optimally fast), you can specify "586" here.
+	  used to pick between i586-class and i686-class processors,
+	  as well as to optimize for a particular microarchitecture
+	  within the two classes.
 
 	  Note that the 386 and 486 is no longer supported, this includes
 	  AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI 486DLC/DLC2,
@@ -164,16 +164,13 @@ config MCYRIXIII
 	  treat this chip as a generic 586. Whilst the CPU is 686 class,
 	  it lacks the cmov extension which gcc assumes is present when
 	  generating 686 code.
-	  Note that Nehemiah (Model 9) and above will not boot with this
-	  kernel due to them lacking the 3DNow! instructions used in earlier
-	  incarnations of the CPU.
 
 config MVIAC3_2
 	bool "VIA C3-2 (Nehemiah)"
 	depends on X86_32
 	help
-	  Select this for a VIA C3 "Nehemiah". Selecting this enables usage
-	  of SSE and tells gcc to treat the CPU as a 686.
+	  Select this for a VIA C3 "Nehemiah". Selecting tells gcc to treat
+	  the CPU as a 686.
 	  Note, this kernel will not boot on older (pre model 9) C3s.
 
 config MVIAC7
arch/x86/Makefile_32.cpu +8 -8
index c5aa169b596d..1735a5f95d33 100644
@@ -11,26 +11,26 @@ align		:= -falign-functions=0 -falign-jumps=0 -falign-loops=0
 endif
 
 cflags-$(CONFIG_M586TSC)	+= -march=i586
-cflags-$(CONFIG_M586MMX)	+= -march=pentium-mmx
+cflags-$(CONFIG_M586MMX)	+= -march=i586
 cflags-$(CONFIG_M686)		+= -march=i686
 cflags-$(CONFIG_MPENTIUMII)	+= -march=i686 $(call tune,pentium2)
 cflags-$(CONFIG_MPENTIUMIII)	+= -march=i686 $(call tune,pentium3)
 cflags-$(CONFIG_MPENTIUMM)	+= -march=i686 $(call tune,pentium3)
 cflags-$(CONFIG_MPENTIUM4)	+= -march=i686 $(call tune,pentium4)
-cflags-$(CONFIG_MK6)		+= -march=k6
+cflags-$(CONFIG_MK6)		+= -march=i586 $(call tune,k6)
 # Please note, that patches that add -march=athlon-xp and friends are pointless.
 # They make zero difference whatsosever to performance at this time.
-cflags-$(CONFIG_MK7)		+= -march=athlon
+cflags-$(CONFIG_MK7)		+= -march=i686 $(call tune,athlon)
 cflags-$(CONFIG_MCRUSOE)	+= -march=i686 $(align)
 cflags-$(CONFIG_MEFFICEON)	+= -march=i686 $(call tune,pentium3) $(align)
-cflags-$(CONFIG_MCYRIXIII)	+= $(call cc-option,-march=c3,-march=i486) $(align)
-cflags-$(CONFIG_MVIAC3_2)	+= $(call cc-option,-march=c3-2,-march=i686)
+cflags-$(CONFIG_MCYRIXIII)	+= -march=i586 $(call tune,i486) $(align)
+cflags-$(CONFIG_MVIAC3_2)	+= -march=i686
 cflags-$(CONFIG_MVIAC7)		+= -march=i686
-cflags-$(CONFIG_MATOM)		+= -march=atom
+cflags-$(CONFIG_MATOM)		+= -march=i686 $(call tune,atom)
 
 # Geode GX1 support
-cflags-$(CONFIG_MGEODEGX1)	+= -march=pentium-mmx
-cflags-$(CONFIG_MGEODE_LX)	+= $(call cc-option,-march=geode,-march=pentium-mmx)
+cflags-$(CONFIG_MGEODEGX1)	+= -march=i586 $(call tune,geode)
+cflags-$(CONFIG_MGEODE_LX)	+= -march=i586 $(call tune,geode)
 # add at the end to overwrite eventual tuning options from earlier
 # cpu entries
 cflags-$(CONFIG_X86_GENERIC) 	+= $(call tune,generic,$(call tune,i686))
arch/x86/include/asm/vermagic.h +2 -34
index e26061df0c9b..5323ed585bc9 100644
@@ -5,42 +5,10 @@
 
 #ifdef CONFIG_X86_64
 /* X86_64 does not define MODULE_PROC_FAMILY */
-#elif defined CONFIG_M586TSC
-#define MODULE_PROC_FAMILY "586TSC "
-#elif defined CONFIG_M586MMX
-#define MODULE_PROC_FAMILY "586MMX "
-#elif defined CONFIG_MATOM
-#define MODULE_PROC_FAMILY "ATOM "
-#elif defined CONFIG_M686
+#elif CONFIG_X86_MINIMUM_CPU_FAMILY == 6
 #define MODULE_PROC_FAMILY "686 "
-#elif defined CONFIG_MPENTIUMII
-#define MODULE_PROC_FAMILY "PENTIUMII "
-#elif defined CONFIG_MPENTIUMIII
-#define MODULE_PROC_FAMILY "PENTIUMIII "
-#elif defined CONFIG_MPENTIUMM
-#define MODULE_PROC_FAMILY "PENTIUMM "
-#elif defined CONFIG_MPENTIUM4
-#define MODULE_PROC_FAMILY "PENTIUM4 "
-#elif defined CONFIG_MK6
-#define MODULE_PROC_FAMILY "K6 "
-#elif defined CONFIG_MK7
-#define MODULE_PROC_FAMILY "K7 "
-#elif defined CONFIG_MCRUSOE
-#define MODULE_PROC_FAMILY "CRUSOE "
-#elif defined CONFIG_MEFFICEON
-#define MODULE_PROC_FAMILY "EFFICEON "
-#elif defined CONFIG_MCYRIXIII
-#define MODULE_PROC_FAMILY "CYRIXIII "
-#elif defined CONFIG_MVIAC3_2
-#define MODULE_PROC_FAMILY "VIAC3-2 "
-#elif defined CONFIG_MVIAC7
-#define MODULE_PROC_FAMILY "VIAC7 "
-#elif defined CONFIG_MGEODEGX1
-#define MODULE_PROC_FAMILY "GEODEGX1 "
-#elif defined CONFIG_MGEODE_LX
-#define MODULE_PROC_FAMILY "GEODE "
 #else
-#error unknown processor family
+#define MODULE_PROC_FAMILY "586 "
 #endif
 
 #ifdef CONFIG_X86_32
Signature · 1 line
2.53.0
#14 lore raw

Re: [PATCH 7/7] x86: simplify 32-bit instruction set selection

Quoted 150 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The -march= compiler flags select both instruction set and tuning for a particular CPU, which works well when building a kernel that can only run on this one type, but has some counterintuitive effects because it is not always clear which models are compatible.

E.g. building for Geode LX results in a kernel that can work on all on all 686-class CPUs but crashes on CPUs without the CMOV instructions. Building a kernel for 686 could work on Geode LX and Crusoe but fails because of the CPU generation check that detects these as 585-class. Similarly, building for Intel Atom produces a 32-bit kernel that uses the MOVBE instructions and does not work on any other 32-bit CPU or even 64-bit CPUs before Haswell/Excavator.

Change the CPU selection to build everything with either -march=i586 or -march=i686 and make the specific options only change the -mtune= parameter where this was previously handled by -march=. Note that the only -mtune= options that gcc or clang understand for x86-32 are i486, pentium, pentiumpro, pentium4, atom, geode, k6 and athlon, the other ten are just aliases for one of them.

Selecting any 586-class configuration option now produces a kernel that works on every supported CPU, while selecting a 686-class configuration works on all 686-class CPUs but no 586-class ones.

Consequently, the vermagic.h logic can be simplified to just these two cases.

---

arch/x86/Kconfig.cpu            | 13 +++++-------
arch/x86/Makefile_32.cpu        | 16 +++++++--------
arch/x86/include/asm/vermagic.h | 36 ++-------------------------------
3 files changed, 15 insertions(+), 50 deletions(-)
arch/x86/Kconfig.cpu +3 -6
index 21026e0cb569..121881c4d076 100644
@@ -6,9 +6,9 @@ choice
 	default M686
 	help
 	  This is the processor type of your CPU. This information is
-	  used for optimizing purposes. In order to compile a kernel
-	  that can run on all supported x86 CPU types (albeit not
-	  optimally fast), you can specify "586" here.
+	  used to pick between i586-class and i686-class processors,
+	  as well as to optimize for a particular microarchitecture
+	  within the two classes.
 
 	  Note that the 386 and 486 is no longer supported, this includes
 	  AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI 486DLC/DLC2,
@@ -164,16 +164,13 @@ config MCYRIXIII
 	  treat this chip as a generic 586. Whilst the CPU is 686 class,
 	  it lacks the cmov extension which gcc assumes is present when
 	  generating 686 code.
-	  Note that Nehemiah (Model 9) and above will not boot with this
-	  kernel due to them lacking the 3DNow! instructions used in earlier
-	  incarnations of the CPU.
 

config MVIAC3_2

	bool "VIA C3-2 (Nehemiah)"
	depends on X86_32
	help
arch/x86/Kconfig.cpu +2 -2
-	  Select this for a VIA C3 "Nehemiah". Selecting this enables usage
-	  of SSE and tells gcc to treat the CPU as a 686.
+	  Select this for a VIA C3 "Nehemiah". Selecting tells gcc to treat
+	  the CPU as a 686.

Note, this kernel will not boot on older (pre model 9) C3s.

config MVIAC7

arch/x86/Makefile_32.cpu +0 -0
index c5aa169b596d..1735a5f95d33 100644
@@ -11,26 +11,26 @@ align		:= -falign-functions=0 -falign-jumps=0 -falign-loops=0

endif

cflags-$(CONFIG_M586TSC) += -march=i586

arch/x86/Makefile_32.cpu +1 -1
-cflags-$(CONFIG_M586MMX)	+= -march=pentium-mmx
+cflags-$(CONFIG_M586MMX)	+= -march=i586

cflags-$(CONFIG_M686) += -march=i686
cflags-$(CONFIG_MPENTIUMII) += -march=i686 $(call tune,pentium2)
cflags-$(CONFIG_MPENTIUMIII) += -march=i686 $(call tune,pentium3)
cflags-$(CONFIG_MPENTIUMM) += -march=i686 $(call tune,pentium3)
cflags-$(CONFIG_MPENTIUM4) += -march=i686 $(call tune,pentium4)

arch/x86/Makefile_32.cpu +1 -1
-cflags-$(CONFIG_MK6)		+= -march=k6
+cflags-$(CONFIG_MK6)		+= -march=i586 $(call tune,k6)

# Please note, that patches that add -march=athlon-xp and friends are pointless. # They make zero difference whatsosever to performance at this time.

arch/x86/Makefile_32.cpu +1 -1
-cflags-$(CONFIG_MK7)		+= -march=athlon
+cflags-$(CONFIG_MK7)		+= -march=i686 $(call tune,athlon)

cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align)
cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) $(align)

arch/x86/Makefile_32.cpu +2 -2
-cflags-$(CONFIG_MCYRIXIII)	+= $(call cc-option,-march=c3,-march=i486) $(align)
-cflags-$(CONFIG_MVIAC3_2)	+= $(call cc-option,-march=c3-2,-march=i686)
+cflags-$(CONFIG_MCYRIXIII)	+= -march=i586 $(call tune,i486) $(align)
+cflags-$(CONFIG_MVIAC3_2)	+= -march=i686

cflags-$(CONFIG_MVIAC7) += -march=i686

arch/x86/Makefile_32.cpu +1 -1
-cflags-$(CONFIG_MATOM)		+= -march=atom
+cflags-$(CONFIG_MATOM)		+= -march=i686 $(call tune,atom)

# Geode GX1 support

arch/x86/Makefile_32.cpu +2 -2
-cflags-$(CONFIG_MGEODEGX1)	+= -march=pentium-mmx
-cflags-$(CONFIG_MGEODE_LX)	+= $(call cc-option,-march=geode,-march=pentium-mmx)
+cflags-$(CONFIG_MGEODEGX1)	+= -march=i586 $(call tune,geode)
+cflags-$(CONFIG_MGEODE_LX)	+= -march=i586 $(call tune,geode)
# add at the end to overwrite eventual tuning options from earlier
# cpu entries
cflags-$(CONFIG_X86_GENERIC) 	+= $(call tune,generic,$(call tune,i686))
arch/x86/include/asm/vermagic.h +1 -29
index e26061df0c9b..5323ed585bc9 100644
@@ -5,42 +5,10 @@
 
 #ifdef CONFIG_X86_64
 /* X86_64 does not define MODULE_PROC_FAMILY */
-#elif defined CONFIG_M586TSC
-#define MODULE_PROC_FAMILY "586TSC "
-#elif defined CONFIG_M586MMX
-#define MODULE_PROC_FAMILY "586MMX "
-#elif defined CONFIG_MATOM
-#define MODULE_PROC_FAMILY "ATOM "
-#elif defined CONFIG_M686
+#elif CONFIG_X86_MINIMUM_CPU_FAMILY == 6
 #define MODULE_PROC_FAMILY "686 "
-#elif defined CONFIG_MPENTIUMII
-#define MODULE_PROC_FAMILY "PENTIUMII "
-#elif defined CONFIG_MPENTIUMIII
-#define MODULE_PROC_FAMILY "PENTIUMIII "
-#elif defined CONFIG_MPENTIUMM
-#define MODULE_PROC_FAMILY "PENTIUMM "
-#elif defined CONFIG_MPENTIUM4
-#define MODULE_PROC_FAMILY "PENTIUM4 "
-#elif defined CONFIG_MK6
-#define MODULE_PROC_FAMILY "K6 "
-#elif defined CONFIG_MK7
-#define MODULE_PROC_FAMILY "K7 "
-#elif defined CONFIG_MCRUSOE
-#define MODULE_PROC_FAMILY "CRUSOE "
-#elif defined CONFIG_MEFFICEON
-#define MODULE_PROC_FAMILY "EFFICEON "
-#elif defined CONFIG_MCYRIXIII
-#define MODULE_PROC_FAMILY "CYRIXIII "
-#elif defined CONFIG_MVIAC3_2
-#define MODULE_PROC_FAMILY "VIAC3-2 "
-#elif defined CONFIG_MVIAC7
-#define MODULE_PROC_FAMILY "VIAC7 "

arch/x86/include/asm/vermagic.h line 14

Quoted 10 lines
arch/x86/include/asm/vermagic.h +1 -5
-#elif defined CONFIG_MGEODEGX1
-#define MODULE_PROC_FAMILY "GEODEGX1 "
-#elif defined CONFIG_MGEODE_LX
-#define MODULE_PROC_FAMILY "GEODE "
 #else
-#error unknown processor family
+#define MODULE_PROC_FAMILY "586 "
 #endif
 
 #ifdef CONFIG_X86_32

Crusoe (TM3xxx/TM5xxx) do have a handful of compiler/user space visible items that are missing from i686, as I recall notably the long nop instructions and *possibly* fcomi (I *think* we caught that one, but I'm not 100% sure.)

As a result, it reports correctly as family 5.

maintainer
#15 lore raw

Re: [PATCH 7/7] x86: simplify 32-bit instruction set selection

Quoted 12 lines · H. Peter Anvin
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The -march= compiler flags select both instruction set and tuning for a particular CPU, which works well when building a kernel that can only run on this one type, but has some counterintuitive effects because it is not always clear which models are compatible.

E.g. building for Geode LX results in a kernel that can work on all on all 686-class CPUs but crashes on CPUs without the CMOV instructions. Building a kernel for 686 could work on Geode LX and Crusoe but fails because of the CPU generation check that detects these as 585-class.

...

Quoted 7 lines

Crusoe (TM3xxx/TM5xxx) do have a handful of compiler/user space visible items that are missing from i686, as I recall notably the long nop instructions and *possibly* fcomi (I *think* we caught that one, but I'm not 100% sure.)

As a result, it reports correctly as family 5.

I don't know about fcomi, but the P6 long NOP hasn't been used in 32-bit kernels since your 2008 commit 14469a8dd236 ("x86:
disable static NOPLs on 32 bits"). From that point, I believe we effectively treated Geode LX and Crusoe as 686-compatible.

binutils apparently uses the same definition and emits long nops for -march=pentiumpro but not for -march=i686 in modern versions.

You are of course correct that this remains inconsistent:
a kernel with CONFIG_MCRUSOE is still built with -march=i686 and CONFIG_X86_MINIMUM_CPU_FAMILY=5, so it will fail to run on 586-class CPUs without CMOV.

I'll fold in this patch to make a MCRUSOE kernel actually compatible with all i586-class CPUs, unless you have a better idea:

arch/x86/Makefile_32.cpu +1 -1
index 1735a5f95d33..9a3a1b1c2452 100644
@@ -21,7 +21,7 @@ cflags-$(CONFIG_MK6)		+= -march=i586 $(call tune,k6)
 # Please note, that patches that add -march=athlon-xp and friends are pointless.
 # They make zero difference whatsosever to performance at this time.
 cflags-$(CONFIG_MK7)		+= -march=i686 $(call tune,athlon)
-cflags-$(CONFIG_MCRUSOE)	+= -march=i686 $(align)
+cflags-$(CONFIG_MCRUSOE)	+= -march=i586 $(call tune,i686) $(align)
 cflags-$(CONFIG_MEFFICEON)	+= -march=i686 $(call tune,pentium3) $(align)
 cflags-$(CONFIG_MCYRIXIII)	+= -march=i586 $(call tune,i486) $(align)
 cflags-$(CONFIG_MVIAC3_2)	+= -march=i686

Arnd

#4 lore raw

Re: [PATCH 3/7] x86: make CX8 usage unconditional

In reply to Arnd Bergmann
Quoted 220 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

All supported CPUs now provide the cmpxchg8b instruction, so remove all compile-time and runtime checks for its presence and the fallback implementation, to assume it just works.

---
  arch/um/include/asm/asm-prototypes.h  |   4 -
  arch/x86/Kconfig.cpu                  |   3 -
  arch/x86/Kconfig.cpufeatures          |   6 +-
  arch/x86/include/asm/asm-prototypes.h |   4 -
  arch/x86/include/asm/atomic64_32.h    |  15 --
  arch/x86/include/asm/cmpxchg_32.h     |  76 +---------
  arch/x86/include/asm/percpu.h         |  14 +-
  arch/x86/lib/Makefile                 |   4 -
  arch/x86/lib/atomic64_386_32.S        | 195 --------------------------
  arch/x86/lib/cmpxchg8b_emu.S          |  97 -------------
  arch/x86/um/Kconfig                   |   2 +-
  arch/x86/um/Makefile                  |   3 +-
  lib/atomic64_test.c                   |   7 +-
  13 files changed, 13 insertions(+), 417 deletions(-)

delete mode 100644 arch/x86/lib/atomic64_386_32.S delete mode 100644 arch/x86/lib/cmpxchg8b_emu.S

arch/um/include/asm/asm-prototypes.h +0 -4
index 408b31d59127..b446eec98ed8 100644
@@ -1,6 +1,2 @@
  #include <asm-generic/asm-prototypes.h>
  #include <asm/checksum.h>
-
-#ifdef CONFIG_UML_X86
-extern void cmpxchg8b_emu(void);
-#endif
arch/x86/Kconfig.cpu +0 -3
index f2c1f544f5f9..832e4bd9f6e0 100644
@@ -274,9 +274,6 @@ config X86_HAVE_PAE
  	def_bool y
  	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC7 || MATOM || X86_64
 
-config X86_CX8
-	def_bool y
-
  # this should be set for all -march=.. options where the compiler
  # generates cmov.
  config X86_CMOV
arch/x86/Kconfig.cpufeatures +3 -3
index 09833c88f9ff..e0f2ff65377d 100644
@@ -40,9 +40,6 @@ config X86_REQUIRED_FEATURE_NOPL
  	def_bool y
  	depends on X86_64
 
-config X86_REQUIRED_FEATURE_CX8
-	def_bool y
-
  # this should be set for all -march=.. options where the compiler
  # generates cmov.
  config X86_REQUIRED_FEATURE_CMOV
@@ -59,6 +56,9 @@ config X86_REQUIRED_FEATURE_SYSFAST32
  	def_bool y
  	depends on X86_64 && !X86_FRED
 
+config X86_REQUIRED_FEATURE_CX8
+	def_bool y
+
  config X86_REQUIRED_FEATURE_CPUID
  	def_bool y
  	depends on X86_64
arch/x86/include/asm/asm-prototypes.h +0 -4
index 11c6fecc3ad7..6ec680a36dea 100644
@@ -16,10 +16,6 @@
  #include <asm/gsseg.h>
  #include <asm/nospec-branch.h>
 
-#ifndef CONFIG_X86_CX8
-extern void cmpxchg8b_emu(void);
-#endif
-
  #ifdef CONFIG_STACKPROTECTOR
  extern unsigned long __ref_stack_chk_guard;
  #endif
arch/x86/include/asm/atomic64_32.h +0 -15
index ab838205c1c6..e3da5d0094c4 100644
@@ -48,7 +48,6 @@ static __always_inline s64 arch_atomic64_read_nonatomic(const atomic64_t *v)
  	ATOMIC64_EXPORT(atomic64_##sym)
  #endif
 
-#ifdef CONFIG_X86_CX8
  #define __alternative_atomic64(f, g, out, in, clobbers...)		\
  	asm volatile("call %c[func]"					\
  		     : ALT_OUTPUT_SP(out) \
@@ -57,20 +56,6 @@ static __always_inline s64 arch_atomic64_read_nonatomic(const atomic64_t *v)
  		     : clobbers)
 
  #define ATOMIC64_DECL(sym) ATOMIC64_DECL_ONE(sym##_cx8)
-#else
-#define __alternative_atomic64(f, g, out, in, clobbers...)		\
-	alternative_call(atomic64_##f##_386, atomic64_##g##_cx8,	\
-			 X86_FEATURE_CX8, ASM_OUTPUT(out),		\
-			 ASM_INPUT(in), clobbers)
-
-#define ATOMIC64_DECL(sym) ATOMIC64_DECL_ONE(sym##_cx8); \
-	ATOMIC64_DECL_ONE(sym##_386)
-
-ATOMIC64_DECL_ONE(add_386);
-ATOMIC64_DECL_ONE(sub_386);
-ATOMIC64_DECL_ONE(inc_386);
-ATOMIC64_DECL_ONE(dec_386);
-#endif
 
  #define alternative_atomic64(f, out, in, clobbers...) \
  	__alternative_atomic64(f, f, ASM_OUTPUT(out), ASM_INPUT(in), clobbers)
arch/x86/include/asm/cmpxchg_32.h +1 -75
index e85c221ed1c9..1019c4bce620 100644
@@ -68,8 +68,6 @@ static __always_inline bool __try_cmpxchg64_local(volatile u64 *ptr, u64 *oldp,
  	return __arch_try_cmpxchg64(ptr, oldp, new,);
  }
 
-#ifdef CONFIG_X86_CX8
-
  #define arch_cmpxchg64 __cmpxchg64
 
  #define arch_cmpxchg64_local __cmpxchg64_local
@@ -78,78 +76,6 @@ static __always_inline bool __try_cmpxchg64_local(volatile u64 *ptr, u64 *oldp,
 
  #define arch_try_cmpxchg64_local __try_cmpxchg64_local
 
-#else
-
-/*
- * Building a kernel capable running on 80386 and 80486. It may be necessary
- * to simulate the cmpxchg8b on the 80386 and 80486 CPU.
- */
-
-#define __arch_cmpxchg64_emu(_ptr, _old, _new, _lock_loc, _lock)	\
-({									\
-	union __u64_halves o = { .full = (_old), },			\
-			   n = { .full = (_new), };			\
-									\
-	asm_inline volatile(						\
-		ALTERNATIVE(_lock_loc					\
-			    "call cmpxchg8b_emu",			\
-			    _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8)	\
-		: ALT_OUTPUT_SP("+a" (o.low), "+d" (o.high))		\
-		: "b" (n.low), "c" (n.high),				\
-		  [ptr] "S" (_ptr)					\
-		: "memory");						\
-									\
-	o.full;								\
-})
-
-static __always_inline u64 arch_cmpxchg64(volatile u64 *ptr, u64 old, u64 new)
-{
-	return __arch_cmpxchg64_emu(ptr, old, new, , "lock ");
-}
-#define arch_cmpxchg64 arch_cmpxchg64
-
-static __always_inline u64 arch_cmpxchg64_local(volatile u64 *ptr, u64 old, u64 new)
-{
-	return __arch_cmpxchg64_emu(ptr, old, new, ,);
-}
-#define arch_cmpxchg64_local arch_cmpxchg64_local
-
-#define __arch_try_cmpxchg64_emu(_ptr, _oldp, _new, _lock_loc, _lock)	\
-({									\
-	union __u64_halves o = { .full = *(_oldp), },			\
-			   n = { .full = (_new), };			\
-	bool ret;							\
-									\
-	asm_inline volatile(						\
-		ALTERNATIVE(_lock_loc					\
-			    "call cmpxchg8b_emu",			\
-			    _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \
-		: ALT_OUTPUT_SP("=@ccz" (ret),				\
-				"+a" (o.low), "+d" (o.high))		\
-		: "b" (n.low), "c" (n.high),				\
-		  [ptr] "S" (_ptr)					\
-		: "memory");						\
-									\
-	if (unlikely(!ret))						\
-		*(_oldp) = o.full;					\
-									\
-	likely(ret);							\
-})
-
-static __always_inline bool arch_try_cmpxchg64(volatile u64 *ptr, u64 *oldp, u64 new)
-{
-	return __arch_try_cmpxchg64_emu(ptr, oldp, new, , "lock ");
-}
-#define arch_try_cmpxchg64 arch_try_cmpxchg64
-
-static __always_inline bool arch_try_cmpxchg64_local(volatile u64 *ptr, u64 *oldp, u64 new)
-{
-	return __arch_try_cmpxchg64_emu(ptr, oldp, new, ,);
-}
-#define arch_try_cmpxchg64_local arch_try_cmpxchg64_local
-
-#endif
-
-#define system_has_cmpxchg64()		boot_cpu_has(X86_FEATURE_CX8)
+#define system_has_cmpxchg64()		true
 
  #endif /* _ASM_X86_CMPXCHG_32_H */
arch/x86/include/asm/percpu.h +0 -0
index cef9a4ca9841..539abf94828d 100644

arch/x86/include/asm/percpu.h do { \ · line 333

Quoted 9 lines
arch/x86/include/asm/percpu.h +1 -5
@@ -330,11 +330,9 @@ do {									\
  	old__.var = _oval;						\
  	new__.var = _nval;						\
  									\
-	asm_inline qual (						\
-		ALTERNATIVE("call this_cpu_cmpxchg8b_emu",		\
-			    "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \
-		: ALT_OUTPUT_SP([var] "+m" (__my_cpu_var(_var)),	\
-				"+a" (old__.low), "+d" (old__.high))	\
+	asm_inline qual ("cmpxchg8b " __percpu_arg([var])		\

This can be plain "asm" instead of "asm_inline"; there is only one asm instruction in the asm template.

arch/x86/include/asm/percpu.h do { \ · line 337

Quoted 4 lines
arch/x86/include/asm/percpu.h +2 -0
+		: [var] "+m" (__my_cpu_var(_var)),			\
+				"+a" (old__.low), "+d" (old__.high)	\
  		: "b" (new__.low), "c" (new__.high),			\
  		  "S" (&(_var))						\

The line above was needed to force address of _var in %esi. This is not needed anymore.

arch/x86/include/asm/percpu.h do { \ · line 360

Quoted 10 lines
arch/x86/include/asm/percpu.h +1 -4
  		: "memory");						\
@@ -359,10 +357,8 @@ do {									\
  	old__.var = *_oval;						\
  	new__.var = _nval;						\
  									\
-	asm_inline qual (						\
-		ALTERNATIVE("call this_cpu_cmpxchg8b_emu",		\
-			    "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \
-		: ALT_OUTPUT_SP("=@ccz" (success),			\
+	asm_inline qual ("cmpxchg8b " __percpu_arg([var])		\

Also here, use "asm" and remove "S" constraint. Please see [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git/commit/?h=WIP.x86/cpu&id=8cfdd354dae90a3db46c351d15c801dfbf76fc5a

Uros.

Quoted 372 lines
arch/x86/include/asm/percpu.h +1 -0
+		: "=@ccz" (success),					\
  				[var] "+m" (__my_cpu_var(_var)),	\
  				"+a" (old__.low), "+d" (old__.high))	\
  		: "b" (new__.low), "c" (new__.high),			\
arch/x86/lib/Makefile +0 -4
index 2dba7f83ef97..210af275f468 100644
@@ -48,10 +48,6 @@ ifeq ($(CONFIG_X86_32),y)
          lib-y += strstr_32.o
          lib-y += string_32.o
          lib-y += memmove_32.o
-        lib-y += cmpxchg8b_emu.o
-ifneq ($(CONFIG_X86_CX8),y)
-        lib-y += atomic64_386_32.o
-endif
  else
  ifneq ($(CONFIG_GENERIC_CSUM),y)
          lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
arch/x86/lib/atomic64_386_32.S deleted +0 -195
deleted file mode 100644
index e768815e58ae..000000000000
@@ -1,195 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * atomic64_t for 386/486
- *
- * Copyright © 2010  Luca Barbieri
- */
-
-#include <linux/linkage.h>
-#include <asm/alternative.h>
-
-/* if you want SMP support, implement these with real spinlocks */
-.macro IRQ_SAVE reg
-	pushfl
-	cli
-.endm
-
-.macro IRQ_RESTORE reg
-	popfl
-.endm
-
-#define BEGIN_IRQ_SAVE(op) \
-.macro endp; \
-SYM_FUNC_END(atomic64_##op##_386); \
-.purgem endp; \
-.endm; \
-SYM_FUNC_START(atomic64_##op##_386); \
-	IRQ_SAVE v;
-
-#define ENDP endp
-
-#define RET_IRQ_RESTORE \
-	IRQ_RESTORE v; \
-	RET
-
-#define v %ecx
-BEGIN_IRQ_SAVE(read)
-	movl  (v), %eax
-	movl 4(v), %edx
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(set)
-	movl %ebx,  (v)
-	movl %ecx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v  %esi
-BEGIN_IRQ_SAVE(xchg)
-	movl  (v), %eax
-	movl 4(v), %edx
-	movl %ebx,  (v)
-	movl %ecx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %ecx
-BEGIN_IRQ_SAVE(add)
-	addl %eax,  (v)
-	adcl %edx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %ecx
-BEGIN_IRQ_SAVE(add_return)
-	addl  (v), %eax
-	adcl 4(v), %edx
-	movl %eax,  (v)
-	movl %edx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %ecx
-BEGIN_IRQ_SAVE(sub)
-	subl %eax,  (v)
-	sbbl %edx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %ecx
-BEGIN_IRQ_SAVE(sub_return)
-	negl %edx
-	negl %eax
-	sbbl $0, %edx
-	addl  (v), %eax
-	adcl 4(v), %edx
-	movl %eax,  (v)
-	movl %edx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(inc)
-	addl $1,  (v)
-	adcl $0, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(inc_return)
-	movl  (v), %eax
-	movl 4(v), %edx
-	addl $1, %eax
-	adcl $0, %edx
-	movl %eax,  (v)
-	movl %edx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(dec)
-	subl $1,  (v)
-	sbbl $0, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(dec_return)
-	movl  (v), %eax
-	movl 4(v), %edx
-	subl $1, %eax
-	sbbl $0, %edx
-	movl %eax,  (v)
-	movl %edx, 4(v)
-	RET_IRQ_RESTORE
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(add_unless)
-	addl %eax, %ecx
-	adcl %edx, %edi
-	addl  (v), %eax
-	adcl 4(v), %edx
-	cmpl %eax, %ecx
-	je 3f
-1:
-	movl %eax,  (v)
-	movl %edx, 4(v)
-	movl $1, %eax
-2:
-	RET_IRQ_RESTORE
-3:
-	cmpl %edx, %edi
-	jne 1b
-	xorl %eax, %eax
-	jmp 2b
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(inc_not_zero)
-	movl  (v), %eax
-	movl 4(v), %edx
-	testl %eax, %eax
-	je 3f
-1:
-	addl $1, %eax
-	adcl $0, %edx
-	movl %eax,  (v)
-	movl %edx, 4(v)
-	movl $1, %eax
-2:
-	RET_IRQ_RESTORE
-3:
-	testl %edx, %edx
-	jne 1b
-	jmp 2b
-ENDP
-#undef v
-
-#define v %esi
-BEGIN_IRQ_SAVE(dec_if_positive)
-	movl  (v), %eax
-	movl 4(v), %edx
-	subl $1, %eax
-	sbbl $0, %edx
-	js 1f
-	movl %eax,  (v)
-	movl %edx, 4(v)
-1:
-	RET_IRQ_RESTORE
-ENDP
-#undef v
arch/x86/lib/cmpxchg8b_emu.S deleted +0 -97
deleted file mode 100644
index d4bb24347ff8..000000000000
@@ -1,97 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#include <linux/export.h>
-#include <linux/linkage.h>
-#include <asm/percpu.h>
-#include <asm/processor-flags.h>
-
-.text
-
-#ifndef CONFIG_X86_CX8
-
-/*
- * Emulate 'cmpxchg8b (%esi)' on UP
- *
- * Inputs:
- * %esi : memory location to compare
- * %eax : low 32 bits of old value
- * %edx : high 32 bits of old value
- * %ebx : low 32 bits of new value
- * %ecx : high 32 bits of new value
- */
-SYM_FUNC_START(cmpxchg8b_emu)
-
-	pushfl
-	cli
-
-	cmpl	(%esi), %eax
-	jne	.Lnot_same
-	cmpl	4(%esi), %edx
-	jne	.Lnot_same
-
-	movl	%ebx, (%esi)
-	movl	%ecx, 4(%esi)
-
-	orl	$X86_EFLAGS_ZF, (%esp)
-
-	popfl
-	RET
-
-.Lnot_same:
-	movl	(%esi), %eax
-	movl	4(%esi), %edx
-
-	andl	$(~X86_EFLAGS_ZF), (%esp)
-
-	popfl
-	RET
-
-SYM_FUNC_END(cmpxchg8b_emu)
-EXPORT_SYMBOL(cmpxchg8b_emu)
-
-#endif
-
-#ifndef CONFIG_UML
-
-/*
- * Emulate 'cmpxchg8b %fs:(%rsi)'
- *
- * Inputs:
- * %esi : memory location to compare
- * %eax : low 32 bits of old value
- * %edx : high 32 bits of old value
- * %ebx : low 32 bits of new value
- * %ecx : high 32 bits of new value
- *
- * Notably this is not LOCK prefixed and is not safe against NMIs
- */
-SYM_FUNC_START(this_cpu_cmpxchg8b_emu)
-
-	pushfl
-	cli
-
-	cmpl	__percpu (%esi), %eax
-	jne	.Lnot_same2
-	cmpl	__percpu 4(%esi), %edx
-	jne	.Lnot_same2
-
-	movl	%ebx, __percpu (%esi)
-	movl	%ecx, __percpu 4(%esi)
-
-	orl	$X86_EFLAGS_ZF, (%esp)
-
-	popfl
-	RET
-
-.Lnot_same2:
-	movl	__percpu (%esi), %eax
-	movl	__percpu 4(%esi), %edx
-
-	andl	$(~X86_EFLAGS_ZF), (%esp)
-
-	popfl
-	RET
-
-SYM_FUNC_END(this_cpu_cmpxchg8b_emu)
-
-#endif
arch/x86/um/Kconfig +1 -1
index 44b12e45f9a0..5b78440a78b9 100644
@@ -13,7 +13,7 @@ config UML_X86
  	select ARCH_USE_QUEUED_SPINLOCKS
  	select DCACHE_WORD_ACCESS
  	select HAVE_EFFICIENT_UNALIGNED_ACCESS
-	select UML_SUBARCH_SUPPORTS_SMP if X86_CX8
+	select UML_SUBARCH_SUPPORTS_SMP
 
  config 64BIT
  	bool "64-bit kernel" if "$(SUBARCH)" = "x86"
arch/x86/um/Makefile +1 -2
index 100b68f601f9..716da7b1e3e9 100644
@@ -19,8 +19,7 @@ ifeq ($(CONFIG_X86_32),y)
 
  obj-y += syscalls_32.o
 
-subarch-y = ../lib/string_32.o ../lib/atomic64_32.o ../lib/atomic64_cx8_32.o
-subarch-y += ../lib/cmpxchg8b_emu.o ../lib/atomic64_386_32.o
+subarch-y = ../lib/string_32.o ../lib/atomic64_32.o
  subarch-y += ../lib/checksum_32.o
  subarch-y += ../kernel/sys_ia32.o
 
lib/atomic64_test.c +2 -5
index d726068358c7..37af41df3e6a 100644
@@ -251,15 +251,12 @@ static __init int test_atomics_init(void)
  	test_atomic64();
 
  #ifdef CONFIG_X86
-	pr_info("passed for %s platform %s CX8 and %s SSE\n",
+	pr_info("passed for %s platform %s SSE\n",
  #ifdef CONFIG_X86_64
  		"x86-64",
-#elif defined(CONFIG_X86_CX8)
-		"i586+",
  #else
-		"i386+",
+		"i586+",
  #endif
-	       boot_cpu_has(X86_FEATURE_CX8) ? "with" : "without",
  	       boot_cpu_has(X86_FEATURE_XMM) ? "with" : "without");
  #else
  	pr_info("passed\n");
#6 lore raw

Re: [PATCH 3/7] x86: make CX8 usage unconditional

In reply to Arnd Bergmann
kernel test robot noticed the following build errors:

Hi Arnd,

kernel test robot noticed the following build errors:

[auto build test ERROR on tip/x86/core]
[also build test ERROR on uml/next linus/master v7.4-rc1 next-20261105] [cannot apply to uml/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Arnd-Bergmann/x86-remove-AMD-lan-remnants/20261105-173432
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/20261105163440.2381661-4-arnd%40kernel.org
patch subject: [PATCH 3/7] x86: make CX8 usage unconditional
config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20261106/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261106/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

/usr/bin/ld: kernel/fork.o: in function `arch_atomic64_set':

>> arch/x86/include/asm/atomic64_32.h:108:(.text+0x5fd): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: kernel/ksysfs.o: in function `arch_atomic64_read':
>> arch/x86/include/asm/atomic64_32.h:117:(.text+0x58): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: kernel/sched/fair.o: in function `arch_atomic64_add':
>> arch/x86/include/asm/atomic64_32.h:165:(.text+0x1c52): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: kernel/sched/build_policy.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x2790): undefined reference to `atomic64_add_return_cx8'
>> /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:165:(.text+0x5310): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: kernel/printk/printk.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0xf41): undefined reference to `atomic64_set_cx8'
>> /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:108:(.text+0xf57): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: kernel/printk/printk.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x115f): undefined reference to `atomic64_read_cx8'
>> /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x1188): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: kernel/printk/printk.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x1228): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: kernel/printk/printk.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x242a): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x248d): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x2501): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x2560): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: kernel/printk/printk.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x25c3): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:108:(.text+0x25e4): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: kernel/time/timekeeping.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x32d3): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x339e): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: kernel/futex/core.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0xbf9): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: kernel/futex/core.o: in function `arch_atomic64_inc_return':
>> arch/x86/include/asm/atomic64_32.h:144:(.text+0xc13): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: fs/inode.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x4cd): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: fs/inode.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x1df4): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x1f3c): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/mballoc.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x253a): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: fs/ext4/mballoc.o: in function `arch_atomic64_inc':
   arch/x86/include/asm/atomic64_32.h:181:(.text+0x2ac8): undefined reference to `atomic64_inc_return_cx8'
>> /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0x4d1a): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0x4ee5): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0x4f7b): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0x523a): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: fs/ext4/mballoc.o:arch/x86/include/asm/atomic64_32.h:181: more undefined references to `atomic64_inc_return_cx8' follow
   /usr/bin/ld: fs/ext4/mballoc.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x5454): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x546c): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x5499): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x54be): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x54d9): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/mballoc.o:arch/x86/include/asm/atomic64_32.h:117: more undefined references to `atomic64_read_cx8' follow
   /usr/bin/ld: fs/ext4/mballoc.o: in function `arch_atomic64_sub':
>> arch/x86/include/asm/atomic64_32.h:173:(.text+0x651f): undefined reference to `atomic64_sub_return_cx8'
   /usr/bin/ld: fs/ext4/mballoc.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x6526): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: fs/ext4/super.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x850): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: fs/ext4/super.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x201a): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/super.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x87f9): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: fs/ext4/super.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x8a43): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: fs/ext4/sysfs.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x1fc): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: fs/ext4/sysfs.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x4f2): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/fast_commit.o: in function `arch_atomic64_inc':
   arch/x86/include/asm/atomic64_32.h:181:(.text+0x3b0): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0xefd): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0xf18): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0xf69): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0xfa4): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: fs/ext4/fast_commit.o:arch/x86/include/asm/atomic64_32.h:181: more undefined references to `atomic64_inc_return_cx8' follow
   /usr/bin/ld: fs/ext4/fast_commit.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x12dc): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: fs/ext4/fast_commit.o: in function `arch_atomic64_inc':
   arch/x86/include/asm/atomic64_32.h:181:(.text+0x133c): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0x17f7): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0x1830): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:181:(.text+0x18fe): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: fs/ext4/fast_commit.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x19db): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: fs/ext4/fast_commit.o: in function `arch_atomic64_inc':
   arch/x86/include/asm/atomic64_32.h:181:(.text+0x19e9): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: fs/ext4/fast_commit.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x19fb): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x2bf4): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x2c06): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x2c17): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x2cd0): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/fast_commit.o:arch/x86/include/asm/atomic64_32.h:117: more undefined references to `atomic64_read_cx8' follow
   /usr/bin/ld: block/genhd.o: in function `arch_atomic64_inc_return':
   arch/x86/include/asm/atomic64_32.h:144:(.text+0x17d5): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:144:(.text+0x18c5): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: net/core/sock_diag.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x4a5): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: net/core/sock_diag.o: in function `arch_atomic64_dec_return':
>> arch/x86/include/asm/atomic64_32.h:155:(.text+0x4e7): undefined reference to `atomic64_dec_return_cx8'
   /usr/bin/ld: net/core/sock_diag.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x50d): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: lib/kobject_uevent.o: in function `arch_atomic64_inc_return':
   arch/x86/include/asm/atomic64_32.h:144:(.text+0x1d0): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:144:(.text+0x75e): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: fs/ext4/inline.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x1faf): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: io_uring/rsrc.o: in function `arch_atomic64_sub':
   arch/x86/include/asm/atomic64_32.h:173:(.text+0x480): undefined reference to `atomic64_sub_return_cx8'
   /usr/bin/ld: io_uring/rsrc.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x5ac): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: kernel/nstree.o: in function `arch_atomic64_inc_return':
   arch/x86/include/asm/atomic64_32.h:144:(.text+0x962): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: kernel/time/posix-cpu-timers.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x129): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x137): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x145): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x1b7): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: kernel/bpf/core.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x260b): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: kernel/bpf/core.o: in function `arch_atomic64_xchg':
>> arch/x86/include/asm/atomic64_32.h:96:(.text+0x2ba8): undefined reference to `atomic64_xchg_cx8'
   /usr/bin/ld: kernel/bpf/core.o: in function `arch_atomic64_dec':
   arch/x86/include/asm/atomic64_32.h:190:(.text+0x46dd): undefined reference to `atomic64_dec_return_cx8'
   /usr/bin/ld: fs/libfs.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x275): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x293): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x303): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/proc/task_mmu.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x272c): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/balloc.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x95): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/dir.o:arch/x86/include/asm/atomic64_32.h:117: more undefined references to `atomic64_read_cx8' follow
   /usr/bin/ld: fs/ext4/inode.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x5221): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: fs/ext4/ioctl.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x1746): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: fs/ext4/resize.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x1adf): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: fs/ext4/xattr.o: in function `arch_atomic64_read':
>> arch/x86/include/asm/atomic64_32.h:117:(.text+0x58): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: fs/ext4/xattr.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x9eb): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: block/blk-cgroup.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x1f9): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x254): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: block/blk-cgroup.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x2d2): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: block/blk-cgroup.o: in function `arch_atomic64_sub':
   arch/x86/include/asm/atomic64_32.h:173:(.text+0x2e6): undefined reference to `atomic64_sub_return_cx8'
   /usr/bin/ld: block/blk-cgroup.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x10dc): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:117:(.text+0x1a77): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: block/blk-cgroup.o: in function `arch_atomic64_add':
   arch/x86/include/asm/atomic64_32.h:165:(.text+0x1f64): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: block/blk-cgroup-rwstat.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x22): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:108:(.text+0x2a): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:108:(.text+0x32): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:108:(.text+0x3a): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: arch/x86/include/asm/atomic64_32.h:108:(.text+0x42): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: block/blk-cgroup-rwstat.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x1b7): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: net/ipv4/inet_timewait_sock.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x254): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: net/ipv4/inet_timewait_sock.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x265): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: net/ipv4/inet_connection_sock.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x112b): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: net/ipv4/inet_connection_sock.o: in function `arch_atomic64_read':
   arch/x86/include/asm/atomic64_32.h:117:(.text+0x17e9): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: net/ipv4/inet_connection_sock.o: in function `arch_atomic64_set':
   arch/x86/include/asm/atomic64_32.h:108:(.text+0x17fa): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_read_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_read_cx8+0x0): undefined reference to `atomic64_read_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_set_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_set_cx8+0x0): undefined reference to `atomic64_set_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_xchg_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_xchg_cx8+0x0): undefined reference to `atomic64_xchg_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_add_return_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_add_return_cx8+0x0): undefined reference to `atomic64_add_return_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_sub_return_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_sub_return_cx8+0x0): undefined reference to `atomic64_sub_return_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_inc_return_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_inc_return_cx8+0x0): undefined reference to `atomic64_inc_return_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_dec_return_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_dec_return_cx8+0x0): undefined reference to `atomic64_dec_return_cx8'
   /usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_dec_if_positive_cx8':
>> .vmlinux.export.c:(___ksymtab+atomic64_dec_if_positive_cx8+0x0): undefined reference to `atomic64_dec_if_positive_cx8'

/usr/bin/ld: .vmlinux.export.o: in function `__ksymtab_atomic64_inc_not_zero_cx8':
.vmlinux.export.c:(___ksymtab+atomic64_inc_not_zero_cx8+0x0): undefined reference to atomic64_inc_not_zero_cx8' /usr/bin/ld: .vmlinux.export.o: in function __ksymtab_atomic64_add_unless_cx8':
.vmlinux.export.c:(___ksymtab+atomic64_add_unless_cx8+0x0): undefined reference to `atomic64_add_unless_cx8'
collect2: error: ld returned 1 exit status

vim +108 arch/x86/include/asm/atomic64_32.h

276b893049e4cd Uros Bizjak    2024-04-10   90  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26   91  static __always_inline s64 arch_atomic64_xchg(atomic64_t *v, s64 n)
a7e926abc3adfb Luca Barbieri  2010-02-24   92  {
79c53a83d7a31a Mark Rutland   2019-05-22   93  	s64 o;
a7e926abc3adfb Luca Barbieri  2010-02-24   94  	unsigned high = (unsigned)(n >> 32);
a7e926abc3adfb Luca Barbieri  2010-02-24   95  	unsigned low = (unsigned)n;
224788b63a2e42 Josh Poimboeuf 2025-03-02  @96  	alternative_atomic64(xchg,
224788b63a2e42 Josh Poimboeuf 2025-03-02   97  			     "=&A" (o),
224788b63a2e42 Josh Poimboeuf 2025-03-02   98  			     ASM_INPUT("S" (v), "b" (low), "c" (high)),
224788b63a2e42 Josh Poimboeuf 2025-03-02   99  			     "memory");
a7e926abc3adfb Luca Barbieri  2010-02-24  100  	return o;
a7e926abc3adfb Luca Barbieri  2010-02-24  101  }
37f8173dd84936 Peter Zijlstra 2020-01-24  102  #define arch_atomic64_xchg arch_atomic64_xchg
1a3b1d89eded68 Brian Gerst    2010-01-07  103  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26  104  static __always_inline void arch_atomic64_set(atomic64_t *v, s64 i)
a7e926abc3adfb Luca Barbieri  2010-02-24  105  {
a7e926abc3adfb Luca Barbieri  2010-02-24  106  	unsigned high = (unsigned)(i >> 32);
a7e926abc3adfb Luca Barbieri  2010-02-24  107  	unsigned low = (unsigned)i;
224788b63a2e42 Josh Poimboeuf 2025-03-02 @108  	alternative_atomic64(set,
224788b63a2e42 Josh Poimboeuf 2025-03-02  109  			     /* no output */,
224788b63a2e42 Josh Poimboeuf 2025-03-02  110  			     ASM_INPUT("S" (v), "b" (low), "c" (high)),
224788b63a2e42 Josh Poimboeuf 2025-03-02  111  			     "eax", "edx", "memory");
a7e926abc3adfb Luca Barbieri  2010-02-24  112  }
1a3b1d89eded68 Brian Gerst    2010-01-07  113  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26  114  static __always_inline s64 arch_atomic64_read(const atomic64_t *v)
1a3b1d89eded68 Brian Gerst    2010-01-07  115  {
79c53a83d7a31a Mark Rutland   2019-05-22  116  	s64 r;
224788b63a2e42 Josh Poimboeuf 2025-03-02 @117  	alternative_atomic64(read, "=&A" (r), "c" (v), "memory");
a7e926abc3adfb Luca Barbieri  2010-02-24  118  	return r;
1a3b1d89eded68 Brian Gerst    2010-01-07  119  }
1a3b1d89eded68 Brian Gerst    2010-01-07  120  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26  121  static __always_inline s64 arch_atomic64_add_return(s64 i, atomic64_t *v)
a7e926abc3adfb Luca Barbieri  2010-02-24  122  {
819165fb34b977 Jan Beulich    2012-01-20  123  	alternative_atomic64(add_return,
224788b63a2e42 Josh Poimboeuf 2025-03-02  124  			     ASM_OUTPUT("+A" (i), "+c" (v)),
224788b63a2e42 Josh Poimboeuf 2025-03-02  125  			     /* no input */,
224788b63a2e42 Josh Poimboeuf 2025-03-02  126  			     "memory");
a7e926abc3adfb Luca Barbieri  2010-02-24  127  	return i;
a7e926abc3adfb Luca Barbieri  2010-02-24  128  }
37f8173dd84936 Peter Zijlstra 2020-01-24  129  #define arch_atomic64_add_return arch_atomic64_add_return
1a3b1d89eded68 Brian Gerst    2010-01-07  130  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26  131  static __always_inline s64 arch_atomic64_sub_return(s64 i, atomic64_t *v)
a7e926abc3adfb Luca Barbieri  2010-02-24  132  {
819165fb34b977 Jan Beulich    2012-01-20  133  	alternative_atomic64(sub_return,
224788b63a2e42 Josh Poimboeuf 2025-03-02  134  			     ASM_OUTPUT("+A" (i), "+c" (v)),
224788b63a2e42 Josh Poimboeuf 2025-03-02  135  			     /* no input */,
224788b63a2e42 Josh Poimboeuf 2025-03-02  136  			     "memory");
a7e926abc3adfb Luca Barbieri  2010-02-24  137  	return i;
a7e926abc3adfb Luca Barbieri  2010-02-24  138  }
37f8173dd84936 Peter Zijlstra 2020-01-24  139  #define arch_atomic64_sub_return arch_atomic64_sub_return
a7e926abc3adfb Luca Barbieri  2010-02-24  140  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26  141  static __always_inline s64 arch_atomic64_inc_return(atomic64_t *v)
a7e926abc3adfb Luca Barbieri  2010-02-24  142  {
79c53a83d7a31a Mark Rutland   2019-05-22  143  	s64 a;
224788b63a2e42 Josh Poimboeuf 2025-03-02 @144  	alternative_atomic64(inc_return,
224788b63a2e42 Josh Poimboeuf 2025-03-02  145  			     "=&A" (a),
224788b63a2e42 Josh Poimboeuf 2025-03-02  146  			     "S" (v),
224788b63a2e42 Josh Poimboeuf 2025-03-02  147  			     "memory", "ecx");
a7e926abc3adfb Luca Barbieri  2010-02-24  148  	return a;
a7e926abc3adfb Luca Barbieri  2010-02-24  149  }
9837559d8eb01c Mark Rutland   2018-06-21  150  #define arch_atomic64_inc_return arch_atomic64_inc_return
a7e926abc3adfb Luca Barbieri  2010-02-24  151  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26  152  static __always_inline s64 arch_atomic64_dec_return(atomic64_t *v)
a7e926abc3adfb Luca Barbieri  2010-02-24  153  {
79c53a83d7a31a Mark Rutland   2019-05-22  154  	s64 a;
224788b63a2e42 Josh Poimboeuf 2025-03-02 @155  	alternative_atomic64(dec_return,
224788b63a2e42 Josh Poimboeuf 2025-03-02  156  			     "=&A" (a),
224788b63a2e42 Josh Poimboeuf 2025-03-02  157  			     "S" (v),
224788b63a2e42 Josh Poimboeuf 2025-03-02  158  			     "memory", "ecx");
a7e926abc3adfb Luca Barbieri  2010-02-24  159  	return a;
a7e926abc3adfb Luca Barbieri  2010-02-24  160  }
9837559d8eb01c Mark Rutland   2018-06-21  161  #define arch_atomic64_dec_return arch_atomic64_dec_return
1a3b1d89eded68 Brian Gerst    2010-01-07  162  
dce2a224763ce9 Uros Bizjak    2024-06-05  163  static __always_inline void arch_atomic64_add(s64 i, atomic64_t *v)
a7e926abc3adfb Luca Barbieri  2010-02-24  164  {
819165fb34b977 Jan Beulich    2012-01-20 @165  	__alternative_atomic64(add, add_return,
224788b63a2e42 Josh Poimboeuf 2025-03-02  166  			       ASM_OUTPUT("+A" (i), "+c" (v)),
224788b63a2e42 Josh Poimboeuf 2025-03-02  167  			       /* no input */,
224788b63a2e42 Josh Poimboeuf 2025-03-02  168  			       "memory");
a7e926abc3adfb Luca Barbieri  2010-02-24  169  }
1a3b1d89eded68 Brian Gerst    2010-01-07  170  
dce2a224763ce9 Uros Bizjak    2024-06-05  171  static __always_inline void arch_atomic64_sub(s64 i, atomic64_t *v)
a7e926abc3adfb Luca Barbieri  2010-02-24  172  {
819165fb34b977 Jan Beulich    2012-01-20 @173  	__alternative_atomic64(sub, sub_return,
224788b63a2e42 Josh Poimboeuf 2025-03-02  174  			       ASM_OUTPUT("+A" (i), "+c" (v)),
224788b63a2e42 Josh Poimboeuf 2025-03-02  175  			       /* no input */,
224788b63a2e42 Josh Poimboeuf 2025-03-02  176  			       "memory");
a7e926abc3adfb Luca Barbieri  2010-02-24  177  }
1a3b1d89eded68 Brian Gerst    2010-01-07  178  
7aab7aa4b4bed2 Peter Zijlstra 2023-01-26  179  static __always_inline void arch_atomic64_inc(atomic64_t *v)
a7e926abc3adfb Luca Barbieri  2010-02-24  180  {
224788b63a2e42 Josh Poimboeuf 2025-03-02 @181  	__alternative_atomic64(inc, inc_return,
224788b63a2e42 Josh Poimboeuf 2025-03-02  182  			       /* no output */,
224788b63a2e42 Josh Poimboeuf 2025-03-02  183  			       "S" (v),
224788b63a2e42 Josh Poimboeuf 2025-03-02  184  			       "memory", "eax", "ecx", "edx");
a7e926abc3adfb Luca Barbieri  2010-02-24  185  }
4331f4d5ada568 Randy Dunlap   2018-09-02  186  #define arch_atomic64_inc arch_atomic64_inc

1a3b1d89eded68 Brian Gerst 2010-01-07 187

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#7 lore raw

Re: [PATCH 3/7] x86: make CX8 usage unconditional

In reply to Arnd Bergmann

Le 06/11/2026 à 00:34, Arnd Bergmann a écrit :

Quoted 8 lines

From: Arnd Bergmann <[email protected]>

All supported CPUs now provide the cmpxchg8b instruction, so remove all compile-time and runtime checks for its presence and the fallback implementation, to assume it just works.

---

Hi Arnd,

As-is, this breaks 32-bit UML, as atomic64_cx8_32.S is removed from the Makefile. With that reinstated, 32-bit UML at least builds and passes some basic KUnit tests here (though I haven't tried it on actual 586+ class hardware yet, and building with CONFIG_M586TSC still fails the checksum tests[1]).

Reproduces with:
make O=.tmpuml ARCH=um SUBARCH=i386
or
./tools/testing/kunit/kunit.py run --arch um --kconfig_add CONFIG_64BIT=n

Quoted 17 lines
  arch/um/include/asm/asm-prototypes.h  |   4 
  arch/x86/Kconfig.cpu                  |   3 -
  arch/x86/Kconfig.cpufeatures          |   6 +-
  arch/x86/include/asm/asm-prototypes.h |   4 -
  arch/x86/include/asm/atomic64_32.h    |  15 --
  arch/x86/include/asm/cmpxchg_32.h     |  76 +---------
  arch/x86/include/asm/percpu.h         |  14 +-
  arch/x86/lib/Makefile                 |   4 -
  arch/x86/lib/atomic64_386_32.S        | 195 --------------------------
  arch/x86/lib/cmpxchg8b_emu.S          |  97 -------------
  arch/x86/um/Kconfig                   |   2 +-
  arch/x86/um/Makefile                  |   3 +-
  lib/atomic64_test.c                   |   7 +-
  13 files changed, 13 insertions(+), 417 deletions(-)

delete mode 100644 arch/x86/lib/atomic64_386_32.S delete mode 100644 arch/x86/lib/cmpxchg8b_emu.S

...snip...

Quoted 18 lines
arch/x86/um/Kconfig +1 -1
index 44b12e45f9a0..5b78440a78b9 100644
@@ -13,7 +13,7 @@ config UML_X86
  	select ARCH_USE_QUEUED_SPINLOCKS
  	select DCACHE_WORD_ACCESS
  	select HAVE_EFFICIENT_UNALIGNED_ACCESS
-	select UML_SUBARCH_SUPPORTS_SMP if X86_CX8
+	select UML_SUBARCH_SUPPORTS_SMP
 
  config 64BIT
  	bool "64-bit kernel" if "$(SUBARCH)" = "x86"
arch/x86/um/Makefile +0 -0
index 100b68f601f9..716da7b1e3e9 100644

arch/x86/um/Makefile ifeq ($(CONFIG_X86_32),y) · line 22

Quoted 6 lines
arch/x86/um/Makefile +1 -2
@@ -19,8 +19,7 @@ ifeq ($(CONFIG_X86_32),y)
 
  obj-y += syscalls_32.o
 
-subarch-y = ../lib/string_32.o ../lib/atomic64_32.o ../lib/atomic64_cx8_32.o
-subarch-y += ../lib/cmpxchg8b_emu.o ../lib/atomic64_386_32.o
+subarch-y = ../lib/string_32.o ../lib/atomic64_32.o

Reinstate ../lib/atomic64_cx8_32.o here!

lib/atomic64_test.c

Quoted 5 lines
arch/x86/um/Makefile +0 -0
  subarch-y += ../lib/checksum_32.o
  subarch-y += ../kernel/sys_ia32.o
 
lib/atomic64_test.c +0 -0
index d726068358c7..37af41df3e6a 100644

Cheers,
-- David

[1]: https://lore.kernel.org/all/[email protected]/

#8 lore raw

Re: [PATCH 3/7] x86: make CX8 usage unconditional

In reply to Arnd Bergmann
Quoted 5 lines · On Thu, 5 Nov 2026 17:34:34 +0100 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

All supported CPUs now provide the cmpxchg8b instruction, so remove all compile-time and runtime checks for its presence and the fallback implementation, to assume it just works.

Is it worth doing a run-time check early on any (trying) to output a message and fail to boot?

There are probably a few other things the kernel could rely on, but probably ought to do a check 'just in case'.

One that springs to mind is whether 'find first set' leaves the dest unchanged for zero. There is a comment that 'at least some 486 didn't' but assuming it can make code smaller.
(Basically you can do a double-width operation by putting the result from the low word in the destination before doing the high word.) But it would be nice to have one test case during boot.

David

maintainer
#5 lore raw

Re: [PATCH 3/7] x86: make CX8 usage unconditional

In reply to Uros Bizjak
Quoted 31 lines

arch/x86/include/asm/percpu.h do { \ · line 333

Quoted 7 lines
arch/x86/include/asm/percpu.h +1 -5
-	asm_inline qual (						\
-		ALTERNATIVE("call this_cpu_cmpxchg8b_emu",		\
-			    "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \
-		: ALT_OUTPUT_SP([var] "+m" (__my_cpu_var(_var)),	\
-				"+a" (old__.low), "+d" (old__.high))	\
+	asm_inline qual ("cmpxchg8b " __percpu_arg([var])		\

This can be plain "asm" instead of "asm_inline"; there is only one asm instruction in the asm template.

arch/x86/include/asm/percpu.h do { \ · line 337

Quoted 4 lines
arch/x86/include/asm/percpu.h +2 -0
+		: [var] "+m" (__my_cpu_var(_var)),			\
+				"+a" (old__.low), "+d" (old__.high)	\
  		: "b" (new__.low), "c" (new__.high),			\
  		  "S" (&(_var))						\

The line above was needed to force address of _var in %esi. This is not needed anymore.

arch/x86/include/asm/percpu.h do { \ · line 360

Quoted 10 lines
  		: "memory");						\
arch/x86/include/asm/percpu.h +1 -4
@@ -359,10 +357,8 @@ do {									\
  	old__.var = *_oval;						\
  	new__.var = _nval;						\
  									\
-	asm_inline qual (						\
-		ALTERNATIVE("call this_cpu_cmpxchg8b_emu",		\
-			    "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \
-		: ALT_OUTPUT_SP("=@ccz" (success),			\
+	asm_inline qual ("cmpxchg8b " __percpu_arg([var])		\

Also here, use "asm" and remove "S" constraint. Please see [1].

Quoted 3 lines

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git/commit/?h=WIP.x86/cpu&id=8cfdd354dae90a3db46c351d15c801dfbf76fc5a

Hi Uros,

Thanks for the suggestions, I changed it all as you suggested now.

Arnd

maintainer
#9 lore raw

Re: [PATCH 3/7] x86: make CX8 usage unconditional

In reply to David Laight
Quoted 11 lines · David Laight
Quoted 5 lines · On Thu, 5 Nov 2026 17:34:34 +0100 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

All supported CPUs now provide the cmpxchg8b instruction, so remove all compile-time and runtime checks for its presence and the fallback implementation, to assume it just works.

Is it worth doing a run-time check early on any (trying) to output a message and fail to boot?

I think the existing checks in arch/x86/boot/cpucheck.c should be enough here, as they cover all known pre-586 CPUs and anyone running some other CPU that we can't detect is already on their own.

Arnd

#16 lore raw

Re: [PATCH 7/7] x86: simplify 32-bit instruction set selection

In reply to Arnd Bergmann
Quoted 53 lines · Arnd Bergmann
Quoted 12 lines · H. Peter Anvin
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The -march= compiler flags select both instruction set and tuning for a particular CPU, which works well when building a kernel that can only run on this one type, but has some counterintuitive effects because it is not always clear which models are compatible.

E.g. building for Geode LX results in a kernel that can work on all on all 686-class CPUs but crashes on CPUs without the CMOV instructions. Building a kernel for 686 could work on Geode LX and Crusoe but fails because of the CPU generation check that detects these as 585-class.

...

Quoted 7 lines

Crusoe (TM3xxx/TM5xxx) do have a handful of compiler/user space visible items that are missing from i686, as I recall notably the long nop instructions and *possibly* fcomi (I *think* we caught that one, but I'm not 100% sure.)

As a result, it reports correctly as family 5.

I don't know about fcomi, but the P6 long NOP hasn't been used in 32-bit kernels since your 2008 commit 14469a8dd236 ("x86:
disable static NOPLs on 32 bits"). From that point, I believe we effectively treated Geode LX and Crusoe as 686-compatible.

binutils apparently uses the same definition and emits long nops for -march=pentiumpro but not for -march=i686 in modern versions.

You are of course correct that this remains inconsistent:
a kernel with CONFIG_MCRUSOE is still built with -march=i686 and CONFIG_X86_MINIMUM_CPU_FAMILY=5, so it will fail to run on 586-class CPUs without CMOV.

I'll fold in this patch to make a MCRUSOE kernel actually compatible with all i586-class CPUs, unless you have a better idea:

arch/x86/Makefile_32.cpu +1 -1
index 1735a5f95d33..9a3a1b1c2452 100644
@@ -21,7 +21,7 @@ cflags-$(CONFIG_MK6)		+= -march=i586 $(call tune,k6)
 # Please note, that patches that add -march=athlon-xp and friends are pointless.
 # They make zero difference whatsosever to performance at this time.
 cflags-$(CONFIG_MK7)		+= -march=i686 $(call tune,athlon)
-cflags-$(CONFIG_MCRUSOE)	+= -march=i686 $(align)
+cflags-$(CONFIG_MCRUSOE)	+= -march=i586 $(call tune,i686) $(align)
 cflags-$(CONFIG_MEFFICEON)	+= -march=i686 $(call tune,pentium3) $(align)
 cflags-$(CONFIG_MCYRIXIII)	+= -march=i586 $(call tune,i486) $(align)

cflags-$(CONFIG_MVIAC3_2) += -march=i686

Quoted 1 line

Arnd

Yeah, the problem isn't the kernel, but user space.