Skip to contentSkip to conversation

x86: 32-bit cleanups

PATCH Superseded Arnd Bergmann 20 participants 77 messages Dec 4, 2024 – Apr 18, 2025

Subsystems (13)
Stable branch Documentation x86 KVM +9 more subsystems

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover x86: 32-bit cleanups

From: Arnd Bergmann <[email protected]>

While looking at 32-bit arm cleanups, I came across some related topics on x86 and ended up making a series for those as well.

Primarily this is about running 32-bit kernels on 64-bit hardware, which usually works but should probably be discouraged more clearly by only providing support for features that are used on real 32-bit hardware:

I found only a few 2003-era high-end servers (HP DL740 and DL760 G2) that were the only possible remaining uses of HIGHMEM64G and BIGSMP after the removal of 32-bit NUMA machines in 2014. Similary, there is only one generation of hardware with support for VT-x. All these features can be removed without hurting users.

In the CPU selection, building a 32-bit kernel optimized for AMD K8 or Intel Core2 is anachronistic, so instead only 32-bit CPU types need to be offered as optimization targets. The "generic" target on 64-bit turned out to be slightly broken, so I included a fix for that as well, replacing the compiler default target with an intentional selection between the useful levels.

Arnd Bergmann (11):
x86/Kconfig: Geode CPU has cmpxchg8b
x86: drop 32-bit "bigsmp" machine support
x86: Kconfig.cpu: split out 64-bit atom
x86: split CPU selection into 32-bit and 64-bit
x86: remove HIGHMEM64G support
x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE
x86: drop support for CONFIG_HIGHPTE
x86: document X86_INTEL_MID as 64-bit-only
x86: rework CONFIG_GENERIC_CPU compiler flags
x86: remove old STA2x11 support
x86: drop 32-bit KVM host support

 Documentation/admin-guide/kdump/kdump.rst     |   4 -
 .../admin-guide/kernel-parameters.txt         |  11 -
 Documentation/arch/x86/usb-legacy-support.rst |  11 +-
 arch/x86/Kconfig                              | 119 ++-------
 arch/x86/Kconfig.cpu                          | 130 +++++++---
 arch/x86/Makefile                             |  10 +-
 arch/x86/Makefile_32.cpu                      |   3 +-
 arch/x86/configs/xen.config                   |   2 -
 arch/x86/include/asm/page_32_types.h          |   4 +-
 arch/x86/include/asm/pgalloc.h                |   5 -
 arch/x86/include/asm/sta2x11.h                |  13 -
 arch/x86/include/asm/vermagic.h               |   4 -
 arch/x86/kernel/apic/Makefile                 |   3 -
 arch/x86/kernel/apic/apic.c                   |   3 -
 arch/x86/kernel/apic/bigsmp_32.c              | 105 --------
 arch/x86/kernel/apic/local.h                  |  13 -
 arch/x86/kernel/apic/probe_32.c               |  29 ---
 arch/x86/kernel/head32.c                      |   3 -
 arch/x86/kvm/Kconfig                          |   6 +-
 arch/x86/kvm/Makefile                         |   4 +-
 arch/x86/kvm/cpuid.c                          |   9 +-
 arch/x86/kvm/emulate.c                        |  34 +--
 arch/x86/kvm/fpu.h                            |   4 -
 arch/x86/kvm/hyperv.c                         |   5 +-
 arch/x86/kvm/i8254.c                          |   4 -
 arch/x86/kvm/kvm_cache_regs.h                 |   2 -
 arch/x86/kvm/kvm_emulate.h                    |   8 -
 arch/x86/kvm/lapic.c                          |   4 -
 arch/x86/kvm/mmu.h                            |   4 -
 arch/x86/kvm/mmu/mmu.c                        | 134 ----------
 arch/x86/kvm/mmu/mmu_internal.h               |   9 -
 arch/x86/kvm/mmu/paging_tmpl.h                |   9 -
 arch/x86/kvm/mmu/spte.h                       |   5 -
 arch/x86/kvm/mmu/tdp_mmu.h                    |   4 -
 arch/x86/kvm/smm.c                            |  19 --
 arch/x86/kvm/svm/sev.c                        |   2 -
 arch/x86/kvm/svm/svm.c                        |  23 +-
 arch/x86/kvm/svm/vmenter.S                    |  20 --
 arch/x86/kvm/trace.h                          |   4 -
 arch/x86/kvm/vmx/main.c                       |   2 -
 arch/x86/kvm/vmx/nested.c                     |  24 +-
 arch/x86/kvm/vmx/vmcs.h                       |   2 -
 arch/x86/kvm/vmx/vmenter.S                    |  25 +-
 arch/x86/kvm/vmx/vmx.c                        | 117 +--------
 arch/x86/kvm/vmx/vmx.h                        |  23 +-
 arch/x86/kvm/vmx/vmx_ops.h                    |   7 -
 arch/x86/kvm/vmx/x86_ops.h                    |   2 -
 arch/x86/kvm/x86.c                            |  74 +-----
 arch/x86/kvm/x86.h                            |   4 -
 arch/x86/kvm/xen.c                            |  61 ++---
 arch/x86/mm/init_32.c                         |   9 +-
 arch/x86/mm/pgtable.c                         |  29 +--
 arch/x86/pci/Makefile                         |   2 -
 arch/x86/pci/sta2x11-fixup.c                  | 233 ------------------
 include/linux/mm.h                            |   2 +-
 55 files changed, 185 insertions(+), 1216 deletions(-)
 delete mode 100644 arch/x86/include/asm/sta2x11.h
 delete mode 100644 arch/x86/kernel/apic/bigsmp_32.c
 delete mode 100644 arch/x86/pci/sta2x11-fixup.c
Signature · 15 lines
2.39.5

To: [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: Linus Torvalds <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Sean Christopherson <[email protected]> 
Cc: Davide Ciminaghi <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: [email protected]
#1 lore raw

PATCH 1/11 x86/Kconfig: Geode CPU has cmpxchg8b

From: Arnd Bergmann <[email protected]>

An older cleanup of mine inadvertently removed geode-gx1 and geode-lx from the list of CPUs that are known to support a working cmpxchg8b.

Fixes 88a2b4edda3d ("x86/Kconfig: Rework CONFIG_X86_PAE dependency")
---
 arch/x86/Kconfig.cpu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Kconfig.cpu +1 -1
index 2a7279d80460..42e6a40876ea 100644
@@ -368,7 +368,7 @@ config X86_HAVE_PAE
 
 config X86_CMPXCHG64
 	def_bool y
-	depends on X86_HAVE_PAE || M586TSC || M586MMX || MK6 || MK7
+	depends on X86_HAVE_PAE || M586TSC || M586MMX || MK6 || MK7 || MGEODEGX1 || MGEODE_LX
 
 # this should be set for all -march=.. options where the compiler
 # generates cmov.
Signature · 1 line
2.39.5
#2 lore raw

PATCH 2/11 x86: drop 32-bit "bigsmp" machine support

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The x86-32 kernel used to support multiple platforms with more than eight logical CPUs, from the 1999-2003 timeframe: Sequent NUMA-Q, IBM Summit, Unisys ES7000 and HP F8. Support for all except the latter was dropped back in 2014, leaving only the F8 based DL740 and DL760 G2 machines in this catery, with up to eight single-core Socket-603 Xeon-MP processors with hyperthreading.

Like the already removed machines, the HP F8 servers at the cost upwards of $100k in typical configurations, but were quickly obsoleted by their 64-bit Socket-604 cousins and the AMD Opteron.

Earlier servers with up to 8 Pentium Pro or Xeon processors remain fully supported as they had no hyperthreading. Similarly, the more common 4-socket Xeon-MP machines with hyperthreading using Intel or ServerWorks chipsets continue to work without this, and all the multi-core Xeon processors also run 64-bit kernels.

While the "bigsmp" support can also be used to run on later 64-bit machines (including VM guests), it seems best to discourage that and get any remaining users to update their kernels to 64-bit builds on these. As a side-effect of this, there is also no more need to support NUMA configurations on 32-bit x86, as all true 32-bit NUMA platforms are already gone.

---
 .../admin-guide/kernel-parameters.txt         |   4 -
 arch/x86/Kconfig                              |  20 +---
 arch/x86/kernel/apic/Makefile                 |   3 -
 arch/x86/kernel/apic/apic.c                   |   3 -
 arch/x86/kernel/apic/bigsmp_32.c              | 105 ------------------
 arch/x86/kernel/apic/local.h                  |  13 ---
 arch/x86/kernel/apic/probe_32.c               |  29 -----
 7 files changed, 4 insertions(+), 173 deletions(-)
 delete mode 100644 arch/x86/kernel/apic/bigsmp_32.c
Documentation/admin-guide/kernel-parameters.txt +0 -4
index dc663c0ca670..eca370e99844 100644
@@ -410,10 +410,6 @@
 			Format: { quiet (default) | verbose | debug }
 			Change the amount of debugging information output
 			when initialising the APIC and IO-APIC components.
-			For X86-32, this can also be used to specify an APIC
-			driver name.
-			Format: apic=driver_name
-			Examples: apic=bigsmp
 
 	apic_extnmi=	[APIC,X86,EARLY] External NMI delivery setting
 			Format: { bsp (default) | all | none }
arch/x86/Kconfig +4 -16
index 9d7bd0ae48c4..42494739344d 100644
@@ -526,12 +526,6 @@ config X86_FRED
 	  ring transitions and exception/interrupt handling if the
 	  system supports it.
 
-config X86_BIGSMP
-	bool "Support for big SMP systems with more than 8 CPUs"
-	depends on SMP && X86_32
-	help
-	  This option is needed for the systems that have more than 8 CPUs.
-
 config X86_EXTENDED_PLATFORM
 	bool "Support for extended (non-PC) x86 platforms"
 	default y
@@ -730,8 +724,8 @@ config X86_32_NON_STANDARD
 	depends on X86_32 && SMP
 	depends on X86_EXTENDED_PLATFORM
 	help
-	  This option compiles in the bigsmp and STA2X11 default
-	  subarchitectures.  It is intended for a generic binary
+	  This option compiles in the STA2X11 default
+	  subarchitecture.  It is intended for a generic binary
 	  kernel. If you select them all, kernel will probe it one by
 	  one and will fallback to default.
 
@@ -1008,8 +1002,7 @@ config NR_CPUS_RANGE_BEGIN
 config NR_CPUS_RANGE_END
 	int
 	depends on X86_32
-	default   64 if  SMP &&  X86_BIGSMP
-	default    8 if  SMP && !X86_BIGSMP
+	default    8 if  SMP
 	default    1 if !SMP
 
 config NR_CPUS_RANGE_END
@@ -1022,7 +1015,6 @@ config NR_CPUS_RANGE_END
 config NR_CPUS_DEFAULT
 	int
 	depends on X86_32
-	default   32 if  X86_BIGSMP
 	default    8 if  SMP
 	default    1 if !SMP
 
@@ -1568,8 +1560,7 @@ config AMD_MEM_ENCRYPT
 config NUMA
 	bool "NUMA Memory Allocation and Scheduler Support"
 	depends on SMP
-	depends on X86_64 || (X86_32 && HIGHMEM64G && X86_BIGSMP)
-	default y if X86_BIGSMP
+	depends on X86_64
 	select USE_PERCPU_NUMA_NODE_ID
 	select OF_NUMA if OF
 	help
@@ -1582,9 +1573,6 @@ config NUMA
 	  For 64-bit this is recommended if the system is Intel Core i7
 	  (or later), AMD Opteron, or EM64T NUMA.
 
-	  For 32-bit this is only needed if you boot a 32-bit
-	  kernel on a 64-bit NUMA platform.
-
 	  Otherwise, you should say N.
 
 config AMD_NUMA
arch/x86/kernel/apic/Makefile +0 -3
index 3bf0487cf3b7..52d1808ee360 100644
@@ -23,8 +23,5 @@ obj-$(CONFIG_X86_X2APIC)	+= x2apic_cluster.o
 obj-y				+= apic_flat_64.o
 endif
 
-# APIC probe will depend on the listing order here
-obj-$(CONFIG_X86_BIGSMP)	+= bigsmp_32.o
-
 # For 32bit, probe_32 need to be listed last
 obj-$(CONFIG_X86_LOCAL_APIC)	+= probe_$(BITS).o
arch/x86/kernel/apic/apic.c +0 -3
index c5fb28e6451a..cb453bacf281 100644
@@ -1371,8 +1371,6 @@ void __init apic_intr_mode_init(void)
 
 	x86_64_probe_apic();
 
-	x86_32_install_bigsmp();
-
 	if (x86_platform.apic_post_init)
 		x86_platform.apic_post_init();
 
@@ -1674,7 +1672,6 @@ static __init void apic_read_boot_cpu_id(bool x2apic)
 		boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR));
 	}
 	topology_register_boot_apic(boot_cpu_physical_apicid);
-	x86_32_probe_bigsmp_early();
 }
 
 #ifdef CONFIG_X86_X2APIC
arch/x86/kernel/apic/bigsmp_32.c deleted +0 -105

105 lines not on this page · raw message

arch/x86/kernel/apic/local.h +0 -13
index 842fe28496be..bdcf609eb283 100644
@@ -65,17 +65,4 @@ void default_send_IPI_self(int vector);
 void default_send_IPI_mask_sequence_logical(const struct cpumask *mask, int vector);
 void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector);
 void default_send_IPI_mask_logical(const struct cpumask *mask, int vector);
-void x86_32_probe_bigsmp_early(void);
-void x86_32_install_bigsmp(void);
-#else
-static inline void x86_32_probe_bigsmp_early(void) { }
-static inline void x86_32_install_bigsmp(void) { }
-#endif
-
-#ifdef CONFIG_X86_BIGSMP
-bool apic_bigsmp_possible(bool cmdline_selected);
-void apic_bigsmp_force(void);
-#else
-static inline bool apic_bigsmp_possible(bool cmdline_selected) { return false; };
-static inline void apic_bigsmp_force(void) { }
 #endif
arch/x86/kernel/apic/probe_32.c +0 -29
index f75ee345c02d..87bc9e7ca5d6 100644
@@ -93,35 +93,6 @@ static int __init parse_apic(char *arg)
 }
 early_param("apic", parse_apic);
 
-void __init x86_32_probe_bigsmp_early(void)
-{
-	if (nr_cpu_ids <= 8 || xen_pv_domain())
-		return;
-
-	if (IS_ENABLED(CONFIG_X86_BIGSMP)) {
-		switch (boot_cpu_data.x86_vendor) {
-		case X86_VENDOR_INTEL:
-			if (!APIC_XAPIC(boot_cpu_apic_version))
-				break;
-			/* P4 and above */
-			fallthrough;
-		case X86_VENDOR_HYGON:
-		case X86_VENDOR_AMD:
-			if (apic_bigsmp_possible(cmdline_apic))
-				return;
-			break;
-		}
-	}
-	pr_info("Limiting to 8 possible CPUs\n");
-	set_nr_cpu_ids(8);
-}
-
-void __init x86_32_install_bigsmp(void)
-{
-	if (nr_cpu_ids > 8 && !xen_pv_domain())
-		apic_bigsmp_force();
-}
-
 void __init x86_32_probe_apic(void)
 {
 	if (!cmdline_apic) {
Signature · 1 line
2.39.5
#3 lore raw

PATCH 3/11 x86: Kconfig.cpu: split out 64-bit atom

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Both 32-bit and 64-bit builds allow optimizing using "-march=atom", but this is somewhat suboptimal, as gcc and clang use this option to refer to the original in-order "Bonnell" microarchitecture used in the early "Diamondville" and "Silverthorne" processors that were mostly 32-bit only.

The later 22nm "Silvermont" architecture saw a significant redesign to an out-of-order architecture that is reflected in the -mtune=silvermont flag in the compilers, and all of these are 64-bit capable. Variations of this microarchitecture were in CPUs launched from 2014 to 2021 and are still common in 2024.

Split this up so that 32-bit targets keep building with -march=atom, but 64-bit ones get the more useful silvermont optimization. On modern "tremont" and newer CPUs, using -march=generic or -march=tremont would be even better, but the silvermont optimization is still an improvement.

---
 arch/x86/Kconfig.cpu     | 28 ++++++++++++++++++++--------
 arch/x86/Makefile        |  4 ++--
 arch/x86/Makefile_32.cpu |  3 +--
 3 files changed, 23 insertions(+), 12 deletions(-)
arch/x86/Kconfig.cpu +20 -8
index 42e6a40876ea..05a3f57ac20b 100644
@@ -155,6 +155,15 @@ config MPENTIUM4
 		-Paxville
 		-Dempsey
 
+config MATOM
+	bool "Intel Atom (Bonnell)"
+	help
+
+	  Select this for the Intel Atom platform. Intel Atom CPUs have an
+	  in-order pipelining architecture and thus can benefit from
+	  accordingly optimized code.
+	  This includes all the 32-bit-only Atom chips such as N2xx and
+	  Z5xx/Z6xx.
 
 config MK6
 	bool "K6/K6-II/K6-III"
@@ -278,14 +287,17 @@ config MCORE2
 	  family in /proc/cpuinfo. Newer ones have 6 and older ones 15
 	  (not a typo)
 
-config MATOM
-	bool "Intel Atom"
+config MSILVERMONT
+	bool "Intel Atom (Silvermont/Goldmont)"
+	depends on X86_64
 	help
-
-	  Select this for the Intel Atom platform. Intel Atom CPUs have an
-	  in-order pipelining architecture and thus can benefit from
-	  accordingly optimized code. Use a recent GCC with specific Atom
-	  support in order to fully benefit from selecting this option.
+	  Select this to optimize for the 64-bit Intel Atom platform
+	  of the 22nm Silvermont microarchitecture and its 14nm
+	  Goldmont shrink (e.g. Atom C2xxx, Atom Z3xxx, Celeron
+	  N2xxx/J1xxx, Pentium N3xxx/J2xxx).
+	  Kernels built with this option are incompatible with very
+	  early Atom CPUs based on the Bonnell microarchitecture,
+	  such as Atom 230/330, D4xx/D5xx, D2xxx, N2xxx or Z2xxx.
 
 config GENERIC_CPU
 	bool "Generic-x86-64"
@@ -318,7 +330,7 @@ config X86_INTERNODE_CACHE_SHIFT
 config X86_L1_CACHE_SHIFT
 	int
 	default "7" if MPENTIUM4 || MPSC
-	default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
+	default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MSILVERMONT || MVIAC7 || X86_GENERIC || GENERIC_CPU
 	default "4" if MELAN || M486SX || M486 || MGEODEGX1
 	default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
 
arch/x86/Makefile +2 -2
index 5b773b34768d..05887ae282f5 100644
@@ -182,14 +182,14 @@ else
         cflags-$(CONFIG_MK8)		+= -march=k8
         cflags-$(CONFIG_MPSC)		+= -march=nocona
         cflags-$(CONFIG_MCORE2)		+= -march=core2
-        cflags-$(CONFIG_MATOM)		+= -march=atom
+        cflags-$(CONFIG_MSILVERMONT)	+= -march=silvermont
         cflags-$(CONFIG_GENERIC_CPU)	+= -mtune=generic
         KBUILD_CFLAGS += $(cflags-y)
 
         rustflags-$(CONFIG_MK8)		+= -Ctarget-cpu=k8
         rustflags-$(CONFIG_MPSC)	+= -Ctarget-cpu=nocona
         rustflags-$(CONFIG_MCORE2)	+= -Ctarget-cpu=core2
-        rustflags-$(CONFIG_MATOM)	+= -Ctarget-cpu=atom
+        rustflags-$(CONFIG_MSILVERMONT)	+= -Ctarget-cpu=silvermont
         rustflags-$(CONFIG_GENERIC_CPU)	+= -Ztune-cpu=generic
         KBUILD_RUSTFLAGS += $(rustflags-y)
 
arch/x86/Makefile_32.cpu +1 -2
index 94834c4b5e5e..0adc3a59520a 100644
@@ -33,8 +33,7 @@ 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_MVIAC7)		+= -march=i686
 cflags-$(CONFIG_MCORE2)		+= -march=i686 $(call tune,core2)
-cflags-$(CONFIG_MATOM)		+= $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
-	$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
+cflags-$(CONFIG_MATOM)		+= -march=atom
 
 # AMD Elan support
 cflags-$(CONFIG_MELAN)		+= -march=i486
Signature · 1 line
2.39.5
#4 lore raw

Re: [PATCH 03/11] x86: Kconfig.cpu: split out 64-bit atom

Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Both 32-bit and 64-bit builds allow optimizing using "-march=atom", but this is somewhat suboptimal, as gcc and clang use this option to refer to the original in-order "Bonnell" microarchitecture used in the early "Diamondville" and "Silverthorne" processors that were mostly 32-bit only.

The later 22nm "Silvermont" architecture saw a significant redesign to an out-of-order architecture that is reflected in the -mtune=silvermont flag in the compilers, and all of these are 64-bit capable.

In theory. There are quite some crippled variants of silvermont which are 32-bit only (either fused or at least officially not-supported to run 64-bit)...

#5 lore raw

Re: [PATCH 03/11] x86: Kconfig.cpu: split out 64-bit atom

Quoted 8 lines · Thomas Gleixner
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Both 32-bit and 64-bit builds allow optimizing using "-march=atom", but this is somewhat suboptimal, as gcc and clang use this option to refer to the original in-order "Bonnell" microarchitecture used in the early "Diamondville" and "Silverthorne" processors that were mostly 32-bit only.

Quoted 8 lines
Quoted 3 lines

The later 22nm "Silvermont" architecture saw a significant redesign to an out-of-order architecture that is reflected in the -mtune=silvermont flag in the compilers, and all of these are 64-bit capable.

In theory. There are quite some crippled variants of silvermont which are 32-bit only (either fused or at least officially not-supported to run 64-bit)...

Yeah. That was a sad story, which I unfortunately am not at liberty to share.

#6 lore raw

Re: [PATCH 03/11] x86: Kconfig.cpu: split out 64-bit atom

Quoted 14 lines · H. Peter Anvin
Quoted 12 lines · Thomas Gleixner
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Both 32-bit and 64-bit builds allow optimizing using "-march=atom", but this is somewhat suboptimal, as gcc and clang use this option to refer to the original in-order "Bonnell" microarchitecture used in the early "Diamondville" and "Silverthorne" processors that were mostly 32-bit only.

The later 22nm "Silvermont" architecture saw a significant redesign to an out-of-order architecture that is reflected in the -mtune=silvermont flag in the compilers, and all of these are 64-bit capable.

Quoted 5 lines
Quoted 3 lines

In theory. There are quite some crippled variants of silvermont which are 32-bit only (either fused or at least officially not-supported to run 64-bit)...

Yeah. That was a sad story, which I unfortunately am not at liberty to share.

Are they available in the wild? What I know with that core are Merrifield, Moorefield, and Bay Trail that were distributed in millions and are perfectly available, but I never heard about ones that are 32-bit only. The Avoton and Rangley I have read about on
https://en.wikipedia.org/wiki/Silvermont seems specific to the servers and routers and most likely are gone from use.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

PATCH 4/11 x86: split CPU selection into 32-bit and 64-bit

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The x86 CPU selection menu is confusing for a number of reasons. One of them is how it's possible to build a 32-bit kernel for a small number of early 64-bit microarchitectures (K8, Core2) but not the regular generic 64-bit target that is the normal default.

There is no longer a reason to run 32-bit kernels on production 64-bit systems, so simplify the configuration menu by completely splitting the two into 32-bit-only and 64-bit-only machines.

Testing generic 32-bit kernels on 64-bit hardware remains possible, just not building a 32-bit kernel that requires a 64-bit CPU.

---
 arch/x86/Kconfig.cpu            | 65 ++++++++++++++++++++-------------
 arch/x86/include/asm/vermagic.h |  4 --
 2 files changed, 40 insertions(+), 29 deletions(-)
arch/x86/Kconfig.cpu +40 -25
index 05a3f57ac20b..139db904e564 100644
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
 # Put here option for CPU selection and depending optimization
 choice
-	prompt "Processor family"
-	default M686 if X86_32
-	default GENERIC_CPU if X86_64
+	prompt "x86-32 Processor family"
+	depends on X86_32
+	default M686
 	help
 	  This is the processor type of your CPU. This information is
 	  used for optimizing purposes. In order to compile a kernel
@@ -31,7 +31,6 @@ choice
 	  - "Pentium-4" for the Intel Pentium 4 or P4-based Celeron.
 	  - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D).
 	  - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird).
-	  - "Opteron/Athlon64/Hammer/K8" for all K8 and newer AMD CPUs.
 	  - "Crusoe" for the Transmeta Crusoe series.
 	  - "Efficeon" for the Transmeta Efficeon series.
 	  - "Winchip-C6" for original IDT Winchip.
@@ -42,13 +41,10 @@ choice
 	  - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3.
 	  - "VIA C3-2" for VIA C3-2 "Nehemiah" (model 9 and above).
 	  - "VIA C7" for VIA C7.
-	  - "Intel P4" for the Pentium 4/Netburst microarchitecture.
-	  - "Core 2/newer Xeon" for all core2 and newer Intel CPUs.
 	  - "Intel Atom" for the Atom-microarchitecture CPUs.
-	  - "Generic-x86-64" for a kernel which runs on any x86-64 CPU.
 
 	  See each option's help text for additional details. If you don't know
-	  what to do, choose "486".
+	  what to do, choose "Pentium-Pro".
 
 config M486SX
 	bool "486SX"
@@ -114,11 +110,11 @@ config MPENTIUMIII
 	  extensions.
 
 config MPENTIUMM
-	bool "Pentium M"
+	bool "Pentium M/Pentium Dual Core/Core Solo/Core Duo"
 	depends on X86_32
 	help
 	  Select this for Intel Pentium M (not Pentium-4 M)
-	  notebook chips.
+	  "Merom" Core Solo/Duo notebook chips
 
 config MPENTIUM4
 	bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
@@ -181,13 +177,6 @@ config MK7
 	  some extended instructions, and passes appropriate optimization
 	  flags to GCC.
 
-config MK8
-	bool "Opteron/Athlon64/Hammer/K8"
-	help
-	  Select this for an AMD Opteron or Athlon64 Hammer-family processor.
-	  Enables use of some extended instructions, and passes appropriate
-	  optimization flags to GCC.
-
 config MCRUSOE
 	bool "Crusoe"
 	depends on X86_32
@@ -266,10 +255,37 @@ config MVIAC7
 	help
 	  Select this for a VIA C7.  Selecting this uses the correct cache
 	  shift and tells gcc to treat the CPU as a 686.
+endchoice
+
+choice
+	prompt "x86-64 Processor family"
+	depends on X86_64
+	default GENERIC_CPU
+	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 "Generic-x86-64" here.
+
+	  Here are the settings recommended for greatest speed:
+	  - "Opteron/Athlon64/Hammer/K8" for all K8 and newer AMD CPUs.
+	  - "Intel P4" for the Pentium 4/Netburst microarchitecture.
+	  - "Core 2/newer Xeon" for all core2 and newer Intel CPUs.
+	  - "Intel Atom" for the Atom-microarchitecture CPUs.
+	  - "Generic-x86-64" for a kernel which runs on any x86-64 CPU.
+
+	  See each option's help text for additional details. If you don't know
+	  what to do, choose "Generic-x86-64".
+
+config MK8
+	bool "Opteron/Athlon64/Hammer/K8"
+	help
+	  Select this for an AMD Opteron or Athlon64 Hammer-family processor.
+	  Enables use of some extended instructions, and passes appropriate
+	  optimization flags to GCC.
 
 config MPSC
 	bool "Intel P4 / older Netburst based Xeon"
-	depends on X86_64
 	help
 	  Optimize for Intel Pentium 4, Pentium D and older Nocona/Dempsey
 	  Xeon CPUs with Intel 64bit which is compatible with x86-64.
@@ -281,7 +297,6 @@ config MPSC
 config MCORE2
 	bool "Core 2/newer Xeon"
 	help
-
 	  Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
 	  53xx) CPUs. You can distinguish newer from older Xeons by the CPU
 	  family in /proc/cpuinfo. Newer ones have 6 and older ones 15
@@ -348,11 +363,11 @@ config X86_ALIGNMENT_16
 
 config X86_INTEL_USERCOPY
 	def_bool y
-	depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
+	depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK7 || MEFFICEON
 
 config X86_USE_PPRO_CHECKSUM
 	def_bool y
-	depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM
+	depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MATOM
 
 #
 # P6_NOPs are a relatively minor optimization that require a family >=
@@ -372,11 +387,11 @@ config X86_P6_NOP
 
 config X86_TSC
 	def_bool y
-	depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
+	depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MATOM) || X86_64
 
 config X86_HAVE_PAE
 	def_bool y
-	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC7 || MCORE2 || MATOM || X86_64
+	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC7 || MATOM || X86_64
 
 config X86_CMPXCHG64
 	def_bool y
@@ -386,12 +401,12 @@ config X86_CMPXCHG64
 # generates cmov.
 config X86_CMOV
 	def_bool y
-	depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
+	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
-	default "6" if X86_32 && (MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MATOM || MCORE2 || MK7 || MK8)
+	default "6" if X86_32 && (MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MATOM || MK7)
 	default "5" if X86_32 && X86_CMPXCHG64
 	default "4"
 
arch/x86/include/asm/vermagic.h +0 -4
index 75884d2cdec3..5d471253c755 100644
@@ -15,8 +15,6 @@
 #define MODULE_PROC_FAMILY "586TSC "
 #elif defined CONFIG_M586MMX
 #define MODULE_PROC_FAMILY "586MMX "
-#elif defined CONFIG_MCORE2
-#define MODULE_PROC_FAMILY "CORE2 "
 #elif defined CONFIG_MATOM
 #define MODULE_PROC_FAMILY "ATOM "
 #elif defined CONFIG_M686
@@ -33,8 +31,6 @@
 #define MODULE_PROC_FAMILY "K6 "
 #elif defined CONFIG_MK7
 #define MODULE_PROC_FAMILY "K7 "
-#elif defined CONFIG_MK8
-#define MODULE_PROC_FAMILY "K8 "
 #elif defined CONFIG_MELAN
 #define MODULE_PROC_FAMILY "ELAN "
 #elif defined CONFIG_MCRUSOE
Signature · 1 line
2.39.5
#8 lore raw

Re: [PATCH 04/11] x86: split CPU selection into 32-bit and 64-bit

Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The x86 CPU selection menu is confusing for a number of reasons. One of them is how it's possible to build a 32-bit kernel for a small number of early 64-bit microarchitectures (K8, Core2)

Core 2

It spells with a space starting with a capital letter, some issues of the spelling below as well.

Quoted 15 lines

but not the regular generic 64-bit target that is the normal default.

There is no longer a reason to run 32-bit kernels on production 64-bit systems, so simplify the configuration menu by completely splitting the two into 32-bit-only and 64-bit-only machines.

Testing generic 32-bit kernels on 64-bit hardware remains possible, just not building a 32-bit kernel that requires a 64-bit CPU.

arch/x86/Kconfig.cpu +4 -0
+choice
+       prompt "x86-64 Processor family"
+       depends on X86_64
+       default GENERIC_CPU

arch/x86/Kconfig.cpu config MVIAC7 · line 273

Quoted 10 lines
arch/x86/Kconfig.cpu +10 -0
+       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 "Generic-x86-64" here.
+
+         Here are the settings recommended for greatest speed:
+         - "Opteron/Athlon64/Hammer/K8" for all K8 and newer AMD CPUs.
+         - "Intel P4" for the Pentium 4/Netburst microarchitecture.
+         - "Core 2/newer Xeon" for all core2 and newer Intel CPUs.

Core 2

Quoted 5 lines
arch/x86/Kconfig.cpu +5 -0
+         - "Intel Atom" for the Atom-microarchitecture CPUs.
+         - "Generic-x86-64" for a kernel which runs on any x86-64 CPU.
+
+         See each option's help text for additional details. If you don't know
+         what to do, choose "Generic-x86-64".
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH 04/11] x86: split CPU selection into 32-bit and 64-bit

Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The x86 CPU selection menu is confusing for a number of reasons. One of them is how it's possible to build a 32-bit kernel for a small number of early 64-bit microarchitectures (K8, Core2)

Core 2

Fixed

Quoted 8 lines
Quoted 8 lines
arch/x86/Kconfig.cpu +8 -0
+choice
+       prompt "x86-64 Processor family"
+       depends on X86_64
+       default GENERIC_CPU
+       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
Quoted 8 lines

arch/x86/Kconfig.cpu config MVIAC7 · line 273

Quoted 6 lines
arch/x86/Kconfig.cpu +6 -0
+         optimally fast), you can specify "Generic-x86-64" here.
+
+         Here are the settings recommended for greatest speed:
+         - "Opteron/Athlon64/Hammer/K8" for all K8 and newer AMD CPUs.
+         - "Intel P4" for the Pentium 4/Netburst microarchitecture.
+         - "Core 2/newer Xeon" for all core2 and newer Intel CPUs.

Core 2

Fixed, though this is the preexisting help text that I just moved around.

Arnd

#10 lore raw

PATCH 5/11 x86: remove HIGHMEM64G support

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The HIGHMEM64G support was added in linux-2.3.25 to support (then) high-end Pentium Pro and Pentium III Xeon servers with more than 4GB of addressing, NUMA and PCI-X slots started appearing.

I have found no evidence of this ever being used in regular dual-socket servers or consumer devices, all the users seem obsolete these days, even by i386 standards:

- Support for NUMA servers (NUMA-Q, IBM x440, unisys) was already removed ten years ago.

- 4+ socket non-NUMA servers based on Intel 450GX/450NX, HP F8 and ServerWorks ServerSet/GrandChampion could theoretically still work with 8GB, but these were exceptionally rare even 20 years ago and would have usually been equipped with than the maximum amount of RAM.

- Some SKUs of the Celeron D from 2004 had 64-bit mode fused off but could still work in a Socket 775 mainboard designed for the later Core 2 Duo and 8GB. Apparently most BIOSes at the time only allowed 64-bit CPUs.

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

---
 Documentation/admin-guide/kdump/kdump.rst     |  4 --
 Documentation/arch/x86/usb-legacy-support.rst | 11 +----
 arch/x86/Kconfig                              | 46 +++----------------
 arch/x86/configs/xen.config                   |  2 -
 arch/x86/include/asm/page_32_types.h          |  4 +-
 arch/x86/mm/init_32.c                         |  9 +---
 6 files changed, 11 insertions(+), 65 deletions(-)
Documentation/admin-guide/kdump/kdump.rst +0 -4
index 5376890adbeb..1f7f14c6e184 100644
@@ -180,10 +180,6 @@ Dump-capture kernel config options (Arch Dependent, i386 and x86_64)
 1) On i386, enable high memory support under "Processor type and
    features"::
 
-	CONFIG_HIGHMEM64G=y
-
-   or::
-
 	CONFIG_HIGHMEM4G
 
 2) With CONFIG_SMP=y, usually nr_cpus=1 need specified on the kernel
Documentation/arch/x86/usb-legacy-support.rst +1 -10
index e01c08b7c981..b17bf122270a 100644
@@ -20,11 +20,7 @@ It has several drawbacks, though:
    features (wheel, extra buttons, touchpad mode) of the real PS/2 mouse may
    not be available.
 
-2) If CONFIG_HIGHMEM64G is enabled, the PS/2 mouse emulation can cause
-   system crashes, because the SMM BIOS is not expecting to be in PAE mode.
-   The Intel E7505 is a typical machine where this happens.
-
-3) If AMD64 64-bit mode is enabled, again system crashes often happen,
+2) If AMD64 64-bit mode is enabled, again system crashes often happen,
    because the SMM BIOS isn't expecting the CPU to be in 64-bit mode.  The
    BIOS manufacturers only test with Windows, and Windows doesn't do 64-bit
    yet.
@@ -38,11 +34,6 @@ Problem 1)
   compiled-in, too.
 
 Problem 2)
-  can currently only be solved by either disabling HIGHMEM64G
-  in the kernel config or USB Legacy support in the BIOS. A BIOS update
-  could help, but so far no such update exists.
-
-Problem 3)
   is usually fixed by a BIOS update. Check the board
   manufacturers web site. If an update is not available, disable USB
   Legacy support in the BIOS. If this alone doesn't help, try also adding
arch/x86/Kconfig +6 -40

67 lines not on this page · raw message

arch/x86/configs/xen.config +0 -2
index 581296255b39..d5d091e03bd3 100644
@@ -1,6 +1,4 @@
 # global x86 required specific stuff
-# On 32-bit HIGHMEM4G is not allowed
-CONFIG_HIGHMEM64G=y
 CONFIG_64BIT=y
 
 # These enable us to allow some of the
arch/x86/include/asm/page_32_types.h +2 -2
index faf9cc1c14bb..25c32652f404 100644
@@ -11,8 +11,8 @@
  * a virtual address space of one gigabyte, which limits the
  * amount of physical memory you can use to about 950MB.
  *
- * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
- * and CONFIG_HIGHMEM64G options in the kernel configuration.
+ * If you want more physical memory than this then see the CONFIG_VMSPLIT_2G
+ * and CONFIG_HIGHMEM4G options in the kernel configuration.
  */
 #define __PAGE_OFFSET_BASE	_AC(CONFIG_PAGE_OFFSET, UL)
 #define __PAGE_OFFSET		__PAGE_OFFSET_BASE
arch/x86/mm/init_32.c +2 -7
index ac41b1e0940d..f288aad8dc74 100644
@@ -582,7 +582,7 @@ static void __init lowmem_pfn_init(void)
 	"only %luMB highmem pages available, ignoring highmem size of %luMB!\n"
 
 #define MSG_HIGHMEM_TRIMMED \
-	"Warning: only 4GB will be used. Use a HIGHMEM64G enabled kernel!\n"
+	"Warning: only 4GB will be used. Support for for CONFIG_HIGHMEM64G was removed!\n"
 /*
  * We have more RAM than fits into lowmem - we try to put it into
  * highmem, also taking the highmem=x boot parameter into account:
@@ -606,18 +606,13 @@ static void __init highmem_pfn_init(void)
 #ifndef CONFIG_HIGHMEM
 	/* Maximum memory usable is what is directly addressable */
 	printk(KERN_WARNING "Warning only %ldMB will be used.\n", MAXMEM>>20);
-	if (max_pfn > MAX_NONPAE_PFN)
-		printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
-	else
-		printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
+	printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
 	max_pfn = MAXMEM_PFN;
 #else /* !CONFIG_HIGHMEM */
-#ifndef CONFIG_HIGHMEM64G
 	if (max_pfn > MAX_NONPAE_PFN) {
 		max_pfn = MAX_NONPAE_PFN;
 		printk(KERN_WARNING MSG_HIGHMEM_TRIMMED);
 	}
-#endif /* !CONFIG_HIGHMEM64G */
 #endif /* !CONFIG_HIGHMEM */
 }
 
Signature · 1 line
2.39.5
#11 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 25 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The HIGHMEM64G support was added in linux-2.3.25 to support (then) high-end Pentium Pro and Pentium III Xeon servers with more than 4GB of addressing, NUMA and PCI-X slots started appearing.

I have found no evidence of this ever being used in regular dual-socket servers or consumer devices, all the users seem obsolete these days, even by i386 standards:

- Support for NUMA servers (NUMA-Q, IBM x440, unisys) was already removed ten years ago.

- 4+ socket non-NUMA servers based on Intel 450GX/450NX, HP F8 and ServerWorks ServerSet/GrandChampion could theoretically still work with 8GB, but these were exceptionally rare even 20 years ago and would have usually been equipped with than the maximum amount of RAM.

- Some SKUs of the Celeron D from 2004 had 64-bit mode fused off but could still work in a Socket 775 mainboard designed for the later Core 2 Duo and 8GB. Apparently most BIOSes at the time only allowed 64-bit CPUs.

Quoted 8 lines

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

8GB of memory is still useful for 32-bit guest VMs.

Brian Gerst

#12 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 7 lines · Brian Gerst
Quoted 6 lines · Arnd Bergmann

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Quoted 5 lines
Quoted 3 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

8GB of memory is still useful for 32-bit guest VMs.

Can you give some more background on this?

It's clear that one can run a virtual machine this way and it currently works, but are you able to construct a case where this is a good idea, compared to running the same userspace with a 64-bit kernel?

From what I can tell, any practical workload that requires 8GB of total RAM will likely run into either the lowmem limits or into virtual addressig limits, in addition to the problems of 32-bit kernels being generally worse than 64-bit ones in terms of performance, features and testing.

Arnd

#13 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 22 lines · Arnd Bergmann
Quoted 7 lines · Brian Gerst
Quoted 6 lines · Arnd Bergmann

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Quoted 5 lines
Quoted 3 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

8GB of memory is still useful for 32-bit guest VMs.

Can you give some more background on this?

It's clear that one can run a virtual machine this way and it currently works, but are you able to construct a case where this is a good idea, compared to running the same userspace with a 64-bit kernel?

Quoted 5 lines

From what I can tell, any practical workload that requires 8GB of total RAM will likely run into either the lowmem limits or into virtual addressig limits, in addition to the problems of 32-bit kernels being generally worse than 64-bit ones in terms of performance, features and testing.

I use a 32-bit VM to test 32-bit kernel builds. I haven't benchmarked kernel builds with 4GB/8GB yet, but logically more memory would be better for caching files.

Brian Gerst

#14 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 30 lines · Brian Gerst
Quoted 22 lines · Arnd Bergmann
Quoted 7 lines · Brian Gerst
Quoted 6 lines · Arnd Bergmann

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Quoted 5 lines
Quoted 3 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

8GB of memory is still useful for 32-bit guest VMs.

Can you give some more background on this?

It's clear that one can run a virtual machine this way and it currently works, but are you able to construct a case where this is a good idea, compared to running the same userspace with a 64-bit kernel?

Quoted 5 lines

From what I can tell, any practical workload that requires 8GB of total RAM will likely run into either the lowmem limits or into virtual addressig limits, in addition to the problems of 32-bit kernels being generally worse than 64-bit ones in terms of performance, features and testing.

Quoted 6 lines

I use a 32-bit VM to test 32-bit kernel builds. I haven't benchmarked kernel builds with 4GB/8GB yet, but logically more memory would be better for caching files.

Brian Gerst

After verifying, I only had the VM set to 4GB and CONFIG_HIGHMEM64G was not set. So I have no issue with this.

Brian Gerst

#15 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

In reply to Brian Gerst
Quoted 29 lines · Brian Gerst
Quoted 22 lines · Arnd Bergmann
Quoted 7 lines · Brian Gerst
Quoted 6 lines · Arnd Bergmann

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Quoted 5 lines
Quoted 3 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

8GB of memory is still useful for 32-bit guest VMs.

Can you give some more background on this?

It's clear that one can run a virtual machine this way and it currently works, but are you able to construct a case where this is a good idea, compared to running the same userspace with a 64-bit kernel?

Quoted 5 lines

From what I can tell, any practical workload that requires 8GB of total RAM will likely run into either the lowmem limits or into virtual addressig limits, in addition to the problems of 32-bit kernels being generally worse than 64-bit ones in terms of performance, features and testing.

Quoted 7 lines

I use a 32-bit VM to test 32-bit kernel builds. I haven't benchmarked kernel builds with 4GB/8GB yet, but logically more memory would be better for caching files.

Brian Gerst

For the record, back when kernel.org was still a 32-bit machine which, once would have thought, would have been ideal for caching files, rarely achieved more than 50% memory usage with which I believe was 8 GB RAM. The next generation was 16 GB x86-64.

#16 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

In reply to Arnd Bergmann
Quoted 21 lines · Arnd Bergmann
Quoted 7 lines · Brian Gerst
Quoted 6 lines · Arnd Bergmann

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Quoted 5 lines
Quoted 3 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

8GB of memory is still useful for 32-bit guest VMs.

Can you give some more background on this?

It's clear that one can run a virtual machine this way and it currently works, but are you able to construct a case where this is a good idea, compared to running the same userspace with a 64-bit kernel?

Quoted 8 lines

From what I can tell, any practical workload that requires 8GB of total RAM will likely run into either the lowmem limits or into virtual addressig limits, in addition to the problems of 32-bit kernels being generally worse than 64-bit ones in terms of performance, features and testing.

Arnd

The biggest proven is that without HIGHMEM you put a limit of just under 1 GB (892 MiB if I recall correctly), *not* 4 GB, on 32-bit kernels. That is *well* below the amount of RAM present in late-era 32-bit legacy systems, which were put in production as "recently" as 20 years ago and may still be in niche production uses. Embedded systems may be significantly more recent; I know for a fact that 32-bit systems were put in production in the 2010s.

#17 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

In reply to Brian Gerst
Quoted 31 lines · Brian Gerst
Quoted 30 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The HIGHMEM64G support was added in linux-2.3.25 to support (then) high-end Pentium Pro and Pentium III Xeon servers with more than 4GB of addressing, NUMA and PCI-X slots started appearing.

I have found no evidence of this ever being used in regular dual-socket servers or consumer devices, all the users seem obsolete these days, even by i386 standards:

- Support for NUMA servers (NUMA-Q, IBM x440, unisys) was already removed ten years ago.

- 4+ socket non-NUMA servers based on Intel 450GX/450NX, HP F8 and ServerWorks ServerSet/GrandChampion could theoretically still work with 8GB, but these were exceptionally rare even 20 years ago and would have usually been equipped with than the maximum amount of RAM.

- Some SKUs of the Celeron D from 2004 had 64-bit mode fused off but could still work in a Socket 775 mainboard designed for the later Core 2 Duo and 8GB. Apparently most BIOSes at the time only allowed 64-bit CPUs.

- In the early days of x86-64 hardware, there was sometimes the need to run a 32-bit kernel to work around bugs in the hardware drivers, or in the syscall emulation for 32-bit userspace. This likely still works but there should never be a need for this any more.

Quoted 9 lines
Quoted 3 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

8GB of memory is still useful for 32-bit guest VMs.

Brian Gerst

By the way, there are 64-bit machines which require swiotlb.

#18 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 7 lines · H. Peter Anvin
Quoted 4 lines · Brian Gerst
Quoted 4 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

By the way, there are 64-bit machines which require swiotlb.

What I meant to write here was that CONFIG_X86_PAE no longer needs to select PHYS_ADDR_T_64BIT and SWIOTLB. I ended up splitting that change out to patch 06/11 with a better explanation, so the sentence above is just wrong now and I've removed it in my local copy now.

Obviously 64-bit kernels still generally need swiotlb.

Arnd

#19 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · H. Peter Anvin
Quoted 4 lines · Brian Gerst
Quoted 4 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

By the way, there are 64-bit machines which require swiotlb.

Quoted 7 lines

What I meant to write here was that CONFIG_X86_PAE no longer needs to select PHYS_ADDR_T_64BIT and SWIOTLB. I ended up splitting that change out to patch 06/11 with a better explanation, so the sentence above is just wrong now and I've removed it in my local copy now.

Obviously 64-bit kernels still generally need swiotlb.

Theoretically swiotlb can be useful on 32-bit machines as well for the DMA controllers that have < 32-bit mask. Dunno if swiotlb was designed to run on 32-bit machines at all.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#20 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Arnd Bergmann
Quoted 7 lines · H. Peter Anvin
Quoted 4 lines · Brian Gerst
Quoted 4 lines

Removing this also drops the need for PHYS_ADDR_T_64BIT and SWIOTLB. PAE mode is still required to get access to the 'NX' bit on Atom 'Pentium M' and 'Core Duo' CPUs.

By the way, there are 64-bit machines which require swiotlb.

What I meant to write here was that CONFIG_X86_PAE no longer needs to select PHYS_ADDR_T_64BIT and SWIOTLB. I ended up splitting that change out to patch 06/11 with a better explanation, so the sentence above is just wrong now and I've removed it in my local copy now.

Quoted 5 lines
Quoted 1 line

Obviously 64-bit kernels still generally need swiotlb.

Theoretically swiotlb can be useful on 32-bit machines as well for the DMA controllers that have < 32-bit mask. Dunno if swiotlb was designed to run on 32-bit machines at all.

Right, that is a possibility. However those machines would currently be broken on kernels without X86_PAE, since they don't select swiotlb.

If anyone does rely on the current behavior of X86_PAE to support broken DMA devices, it's probably best to fix it in a different way.

Arnd

#21 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

In reply to Arnd Bergmann

Has anyone run into any problems on 6.15-rc1 with this stuff?

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops. Looks like the memblock for the >4GB memory didn't get removed although the pgdats seem correct.

I'll dig into it some more. Just wanted to make sure there wasn't a fix out there already.

The way I'm triggering this is booting qemu with a 32-bit PAE kernel, and "-m 4096" (or more).

Quoted 1 line
[    0.003806] Warning: only 4GB will be used. Support for for CONFIG_HIGHMEM64G was removed!

...

Quoted 67 lines
[    0.561310] BUG: unable to handle page fault for address: f75fe000
[    0.562226] #PF: supervisor write access in kernel mode
[    0.562947] #PF: error_code(0x0002) - not-present page
[    0.563653] *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000 
[    0.564728] Oops: Oops: 0002 [#1] SMP NOPTI
[    0.565315] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef) 
[    0.567428] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[    0.568777] EIP: __free_pages_core+0x3c/0x74
[    0.569378] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.571943] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.572806] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.573776] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.574606] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.575464] Call Trace:
[    0.575816]  memblock_free_pages+0x11/0x2c
[    0.576392]  memblock_free_all+0x2ce/0x3a0
[    0.576955]  mm_core_init+0xf5/0x320
[    0.577423]  start_kernel+0x296/0x79c
[    0.577950]  ? set_init_arg+0x70/0x70
[    0.578478]  ? load_ucode_bsp+0x13c/0x1a8
[    0.579059]  i386_start_kernel+0xad/0xb0
[    0.579614]  startup_32_smp+0x151/0x154
[    0.580100] Modules linked in:
[    0.580358] CR2: 00000000f75fe000
[    0.580630] ---[ end trace 0000000000000000 ]---
[    0.581111] EIP: __free_pages_core+0x3c/0x74
[    0.581455] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.584767] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.585651] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.586530] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.587480] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.588344] Kernel panic - not syncing: Attempted to kill the idle task!
[    0.589435] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
[    0.561310] BUG: unable to handle page fault for address: f75fe000
[    0.562226] #PF: supervisor write access in kernel mode
[    0.562947] #PF: error_code(0x0002) - not-present page
[    0.563653] *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000 
[    0.564728] Oops: Oops: 0002 [#1] SMP NOPTI
[    0.565315] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef) 
[    0.567428] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[    0.568777] EIP: __free_pages_core+0x3c/0x74
[    0.569378] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.571943] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.572806] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.573776] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.574606] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.575464] Call Trace:
[    0.575816]  memblock_free_pages+0x11/0x2c
[    0.576392]  memblock_free_all+0x2ce/0x3a0
[    0.576955]  mm_core_init+0xf5/0x320
[    0.577423]  start_kernel+0x296/0x79c
[    0.577950]  ? set_init_arg+0x70/0x70
[    0.578478]  ? load_ucode_bsp+0x13c/0x1a8
[    0.579059]  i386_start_kernel+0xad/0xb0
[    0.579614]  startup_32_smp+0x151/0x154
[    0.580100] Modules linked in:
[    0.580358] CR2: 00000000f75fe000
[    0.580630] ---[ end trace 0000000000000000 ]---
[    0.581111] EIP: __free_pages_core+0x3c/0x74
[    0.581455] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.584767] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.585651] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.586530] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.587480] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.588344] Kernel panic - not syncing: Attempted to kill the idle task!
[    0.589435] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
#22 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 9 lines · Dave Hansen

Has anyone run into any problems on 6.15-rc1 with this stuff?

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops. Looks like the memblock for the >4GB memory didn't get removed although the pgdats seem correct.

I'll dig into it some more. Just wanted to make sure there wasn't a fix out there already.

Not that I'm aware of.

Quoted 2 lines

The way I'm triggering this is booting qemu with a 32-bit PAE kernel, and "-m 4096" (or more).

That's a new regression indeed.

Thanks,

Ingo

maintainer
#23 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

In reply to Dave Hansen
Quoted 5 lines · Dave Hansen

Has anyone run into any problems on 6.15-rc1 with this stuff?

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops. Looks like the memblock for the >4GB memory didn't get removed although the pgdats seem correct.

That's apparently because of 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing").
Freeing of high memory was clamped to the end of ZONE_HIGHMEM which is 4G and after 6faea3422e3b there's no more clamping, so memblock_free_all() tries to free memory >4G as well.

Quoted 2 lines

I'll dig into it some more. Just wanted to make sure there wasn't a fix out there already.

This should fix it.

arch/x86/kernel/e820.c +2 -0
index 57120f0749cc..4b24c0ccade4 100644
@@ -1300,6 +1300,8 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+	memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);
 
Quoted 72 lines

The way I'm triggering this is booting qemu with a 32-bit PAE kernel, and "-m 4096" (or more).

Quoted 1 line
[    0.003806] Warning: only 4GB will be used. Support for for CONFIG_HIGHMEM64G was removed!

...

Quoted 67 lines
[    0.561310] BUG: unable to handle page fault for address: f75fe000
[    0.562226] #PF: supervisor write access in kernel mode
[    0.562947] #PF: error_code(0x0002) - not-present page
[    0.563653] *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000 
[    0.564728] Oops: Oops: 0002 [#1] SMP NOPTI
[    0.565315] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef) 
[    0.567428] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[    0.568777] EIP: __free_pages_core+0x3c/0x74
[    0.569378] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.571943] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.572806] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.573776] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.574606] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.575464] Call Trace:
[    0.575816]  memblock_free_pages+0x11/0x2c
[    0.576392]  memblock_free_all+0x2ce/0x3a0
[    0.576955]  mm_core_init+0xf5/0x320
[    0.577423]  start_kernel+0x296/0x79c
[    0.577950]  ? set_init_arg+0x70/0x70
[    0.578478]  ? load_ucode_bsp+0x13c/0x1a8
[    0.579059]  i386_start_kernel+0xad/0xb0
[    0.579614]  startup_32_smp+0x151/0x154
[    0.580100] Modules linked in:
[    0.580358] CR2: 00000000f75fe000
[    0.580630] ---[ end trace 0000000000000000 ]---
[    0.581111] EIP: __free_pages_core+0x3c/0x74
[    0.581455] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.584767] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.585651] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.586530] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.587480] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.588344] Kernel panic - not syncing: Attempted to kill the idle task!
[    0.589435] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
[    0.561310] BUG: unable to handle page fault for address: f75fe000
[    0.562226] #PF: supervisor write access in kernel mode
[    0.562947] #PF: error_code(0x0002) - not-present page
[    0.563653] *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000 
[    0.564728] Oops: Oops: 0002 [#1] SMP NOPTI
[    0.565315] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef) 
[    0.567428] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[    0.568777] EIP: __free_pages_core+0x3c/0x74
[    0.569378] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.571943] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.572806] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.573776] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.574606] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.575464] Call Trace:
[    0.575816]  memblock_free_pages+0x11/0x2c
[    0.576392]  memblock_free_all+0x2ce/0x3a0
[    0.576955]  mm_core_init+0xf5/0x320
[    0.577423]  start_kernel+0x296/0x79c
[    0.577950]  ? set_init_arg+0x70/0x70
[    0.578478]  ? load_ucode_bsp+0x13c/0x1a8
[    0.579059]  i386_start_kernel+0xad/0xb0
[    0.579614]  startup_32_smp+0x151/0x154
[    0.580100] Modules linked in:
[    0.580358] CR2: 00000000f75fe000
[    0.580630] ---[ end trace 0000000000000000 ]---
[    0.581111] EIP: __free_pages_core+0x3c/0x74
[    0.581455] Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b 03 c1
[    0.584767] EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
[    0.585651] ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
[    0.586530] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
[    0.587480] CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0
[    0.588344] Kernel panic - not syncing: Attempted to kill the idle task!
[    0.589435] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
Signature · 2 lines
Sincerely yours,
Mike.
#24 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

Quoted 7 lines · Mike Rapoport
Quoted 5 lines · Dave Hansen

Has anyone run into any problems on 6.15-rc1 with this stuff?

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops. Looks like the memblock for the >4GB memory didn't get removed although the pgdats seem correct.

Quoted 5 lines

That's apparently because of 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing").
Freeing of high memory was clamped to the end of ZONE_HIGHMEM which is 4G and after 6faea3422e3b there's no more clamping, so memblock_free_all() tries to free memory >4G as well.

Ah, I should have waited with my bisection, you found it first...

Quoted 4 lines
Quoted 2 lines

I'll dig into it some more. Just wanted to make sure there wasn't a fix out there already.

This should fix it.

Confirmed on 6.15-rc1.

Arnd

#25 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

In reply to Mike Rapoport
Quoted 23 lines · Mike Rapoport
Quoted 5 lines · Dave Hansen

Has anyone run into any problems on 6.15-rc1 with this stuff?

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops. Looks like the memblock for the >4GB memory didn't get removed although the pgdats seem correct.

That's apparently because of 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing").
Freeing of high memory was clamped to the end of ZONE_HIGHMEM which is 4G and after 6faea3422e3b there's no more clamping, so memblock_free_all() tries to free memory >4G as well.

Quoted 2 lines

I'll dig into it some more. Just wanted to make sure there wasn't a fix out there already.

This should fix it.

arch/x86/kernel/e820.c +0 -0
index 57120f0749cc..4b24c0ccade4 100644

arch/x86/kernel/e820.c void __init e820__memblock_setup(void) · line 1306

Quoted 7 lines
arch/x86/kernel/e820.c +2 -0
@@ -1300,6 +1300,8 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+	memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);

Mind sending a full patch with changelog, SOB, Ard's Tested-by, Dave's Reported-by, etc.?

Thanks,

Ingo

maintainer
#26 lore raw

PATCH 1/1 x86/e820: discard high memory that can't be addressed by 32-bit systems

From: "Mike Rapoport (Microsoft)" <[email protected]>

Dave Hansen reports the following crash on a 32-bit system with CONFIG_HIGHMEM=y and CONFIG_X86_PAE=y:

Quoted 2 lines

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops.

  BUG: unable to handle page fault for address: f75fe000
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000
  Oops: Oops: 0002 [#1] SMP NOPTI
  CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  EIP: __free_pages_core+0x3c/0x74
  Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b

EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0

  Call Trace:
   memblock_free_pages+0x11/0x2c
   memblock_free_all+0x2ce/0x3a0
   mm_core_init+0xf5/0x320
   start_kernel+0x296/0x79c
   ? set_init_arg+0x70/0x70
   ? load_ucode_bsp+0x13c/0x1a8
   i386_start_kernel+0xad/0xb0
   startup_32_smp+0x151/0x154
  Modules linked in:
  CR2: 00000000f75fe000

The mem_map[] is allocated up to the end of ZONE_HIGHMEM which is defined by max_pfn.

Before 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing") freeing of high memory was also clamped to the end of ZONE_HIGHMEM but after 6faea3422e3b memblock_free_all() tries to free memory above the of ZONE_HIGHMEM as well and that causes access to mem_map[] entries beyond the end of the memory map.

Discard the memory after max_pfn from memblock on 32-bit systems so that core MM would be aware only of actually usable memory.

---
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +8 -0
index 57120f0749cc..5f673bd6c7d7 100644
@@ -1300,6 +1300,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);
 

base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8

Signature · 1 line
2.47.2
#27 lore raw

[tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     3f0036c0b5f850d1200dbfa7365ed24197a0f157
Gitweb:        https://git.kernel.org/tip/3f0036c0b5f850d1200dbfa7365ed24197a0f157
Author:        Mike Rapoport (Microsoft) <[email protected]>
AuthorDate:    Sun, 13 Apr 2025 11:08:58 +03:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Sun, 13 Apr 2025 11:09:39 +02:00

x86/e820: Discard high memory that can't be addressed by 32-bit systems

Dave Hansen reports the following crash on a 32-bit system with CONFIG_HIGHMEM=y and CONFIG_X86_PAE=y:

Quoted 2 lines

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops.

  BUG: unable to handle page fault for address: f75fe000
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000
  Oops: Oops: 0002 [#1] SMP NOPTI
  CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  EIP: __free_pages_core+0x3c/0x74
  ...
  Call Trace:
   memblock_free_pages+0x11/0x2c
   memblock_free_all+0x2ce/0x3a0
   mm_core_init+0xf5/0x320
   start_kernel+0x296/0x79c
   i386_start_kernel+0xad/0xb0
   startup_32_smp+0x151/0x154

The mem_map[] is allocated up to the end of ZONE_HIGHMEM which is defined by max_pfn.

The bug was introduced by this recent commit:

6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")

Previously, freeing of high memory was also clamped to the end of ZONE_HIGHMEM but after this change, memblock_free_all() tries to free memory above the of ZONE_HIGHMEM as well and that causes access to mem_map[] entries beyond the end of the memory map.

To fix this, discard the memory after max_pfn from memblock on 32-bit systems so that core MM would be aware only of actually usable memory.

Fixes 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Davide Ciminaghi <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Sean Christopherson <[email protected]>
---
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +8 -0
index 9d8dd8d..9920122 100644
@@ -1299,6 +1299,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);
 
#28 lore raw

Re: [tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

arch/x86/kernel/e820.c void __init e820__memblock_setup(void) · line 1308

Quoted 7 lines · On 4/13/25 02:23, tip-bot2 for Mike Rapoport (Microsoft) wrote:
arch/x86/kernel/e820.c +7 -0
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);

Mike, thanks for the quick fix! I did verify that this gets my silly test VM booting again.

The patch obviously _works_. But in the case I was hitting max_pfn was set MAX_NONPAE_PFN. The unfortunate part about this hunk is that it's far away from the related warning:

Quoted 4 lines
        if (max_pfn > MAX_NONPAE_PFN) {
                max_pfn = MAX_NONPAE_PFN;
                printk(KERN_WARNING MSG_HIGHMEM_TRIMMED);
        }

and it's logically doing the same thing: truncating memory at MAX_NONPAE_PFN.

How about we reuse 'MAX_NONPAE_PFN' like this:

	if (IS_ENABLED(CONFIG_X86_32))
		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);

Would that make the connection more obvious?

maintainer Tested-by Arnd Bergmann
#29 lore raw

Re: [tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

Quoted 12 lines · Dave Hansen

Review

Quoted 7 lines · On 4/13/25 02:23, tip-bot2 for Mike Rapoport (Microsoft) wrote:
(quoted diff) +7 -0
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);

Mike, thanks for the quick fix! I did verify that this gets my silly test VM booting again.

Quoted 3 lines

The patch obviously _works_. But in the case I was hitting max_pfn was set MAX_NONPAE_PFN. The unfortunate part about this hunk is that it's far away from the related warning:

Yeah, my first instinct was to put memblock_remove() in the same 'if', but there's no memblock there yet :)

Quoted 8 lines
Quoted 4 lines
        if (max_pfn > MAX_NONPAE_PFN) {
                max_pfn = MAX_NONPAE_PFN;
                printk(KERN_WARNING MSG_HIGHMEM_TRIMMED);
        }

and it's logically doing the same thing: truncating memory at MAX_NONPAE_PFN.

Quoted 6 lines

How about we reuse 'MAX_NONPAE_PFN' like this:

	if (IS_ENABLED(CONFIG_X86_32))
		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);

Would that make the connection more obvious?

Yes, that's better. Here's the updated patch:

From a235764221e4a849fa274a546ff2a3d9f15da2a9 Mon Sep 17 00:00:00 2001
From: "Mike Rapoport (Microsoft)" <[email protected]>
Date: Sun, 13 Apr 2025 10:36:17 +0300
Subject: [PATCH v2] x86/e820: discard high memory that can't be addressed by
32-bit systems

Dave Hansen reports the following crash on a 32-bit system with CONFIG_HIGHMEM=y and CONFIG_X86_PAE=y:

Quoted 2 lines

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops.

  BUG: unable to handle page fault for address: f75fe000
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000
  Oops: Oops: 0002 [#1] SMP NOPTI
  CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  EIP: __free_pages_core+0x3c/0x74
  Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b

EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0

  Call Trace:
   memblock_free_pages+0x11/0x2c
   memblock_free_all+0x2ce/0x3a0
   mm_core_init+0xf5/0x320
   start_kernel+0x296/0x79c
   ? set_init_arg+0x70/0x70
   ? load_ucode_bsp+0x13c/0x1a8
   i386_start_kernel+0xad/0xb0
   startup_32_smp+0x151/0x154
  Modules linked in:
  CR2: 00000000f75fe000

The mem_map[] is allocated up to the end of ZONE_HIGHMEM which is defined by max_pfn.

Before 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing") freeing of high memory was also clamped to the end of ZONE_HIGHMEM but after 6faea3422e3b memblock_free_all() tries to free memory above the of ZONE_HIGHMEM as well and that causes access to mem_map[] entries beyond the end of the memory map.

Discard the memory after MAX_NONPAE_PFN from memblock on 32-bit systems so that core MM would be aware only of actually usable memory.

---
 arch/x86/kernel/e820.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/kernel/e820.c +7 -0
index 57120f0749cc..5e6b1034e6f1 100644
@@ -1300,6 +1300,13 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+	/*
+	 * Discard memory above 4GB because 32-bit systems are limited to 4GB
+	 * of memory even with HIGHMEM.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);
 
Signature · 5 lines
2.47.2

-- 
Sincerely yours,
Mike.
Tested-by Acked-by
#30 lore raw

Re: [tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

Quoted 7 lines · Mike Rapoport
Quoted 6 lines

How about we reuse 'MAX_NONPAE_PFN' like this:

	if (IS_ENABLED(CONFIG_X86_32))
		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);

Would that make the connection more obvious?

Yes, that's better. Here's the updated patch:

Looks, great. Thanks for the update and the quick turnaround on the first one after the bug report!

#31 lore raw

Re: [tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

Quoted 6 lines · Dave Hansen
Quoted 5 lines · Mike Rapoport
Quoted 5 lines

How about we reuse 'MAX_NONPAE_PFN' like this:

	if (IS_ENABLED(CONFIG_X86_32))
		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);
Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Would that make the connection more obvious?

Yes, that's better. Here's the updated patch:

Looks, great. Thanks for the update and the quick turnaround on the first one after the bug report!

I've amended the fix in tip:x86/urgent accordingly and added your tags, thanks!

Ingo

#32 lore raw

Re: [tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

Quoted 12 lines · Ingo Molnar
Quoted 9 lines · Dave Hansen
Quoted 7 lines · Mike Rapoport
Quoted 6 lines

How about we reuse 'MAX_NONPAE_PFN' like this:

	if (IS_ENABLED(CONFIG_X86_32))
		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);

Would that make the connection more obvious?

Yes, that's better. Here's the updated patch:

Quoted 8 lines
Quoted 5 lines

Looks, great. Thanks for the update and the quick turnaround on the first one after the bug report!

I've amended the fix in tip:x86/urgent accordingly and added your tags, thanks!

So I had to apply the fix below as well, due to this build failure on x86-defconfig:

arch/x86/kernel/e820.c:1307:42: error: ‘MAX_NONPAE_PFN’ undeclared (first use in this function); did you mean ‘MAX_DMA_PFN’?

IS_ENABLED(CONFIG_X86_32) can only be used when the code is syntactically correct on !CONFIG_X86_32 kernels too - which it wasn't.

So I went for the straightforward #ifdef block instead.

Thanks,

Ingo

===========>

 arch/x86/kernel/e820.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/e820.c +3 -2
index de6238886cb2..c984be8ee060 100644
@@ -1299,13 +1299,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+#ifdef CONFIG_X86_32
 	/*
 	 * Discard memory above 4GB because 32-bit systems are limited to 4GB
 	 * of memory even with HIGHMEM.
 	 */
-	if (IS_ENABLED(CONFIG_X86_32))
-		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);
+	memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);
+#endif
 
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);
#33 lore raw

[tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

In reply to Mike Rapoport
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     e71b6094c20f5dc9c43dc89af8a569ffa511d676
Gitweb:        https://git.kernel.org/tip/e71b6094c20f5dc9c43dc89af8a569ffa511d676
Author:        Mike Rapoport (Microsoft) <[email protected]>
AuthorDate:    Sun, 13 Apr 2025 11:08:58 +03:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 16 Apr 2025 09:16:02 +02:00

x86/e820: Discard high memory that can't be addressed by 32-bit systems

Dave Hansen reports the following crash on a 32-bit system with CONFIG_HIGHMEM=y and CONFIG_X86_PAE=y:

Quoted 2 lines

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops.

  BUG: unable to handle page fault for address: f75fe000
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000
  Oops: Oops: 0002 [#1] SMP NOPTI
  CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  EIP: __free_pages_core+0x3c/0x74
  ...
  Call Trace:
   memblock_free_pages+0x11/0x2c
   memblock_free_all+0x2ce/0x3a0
   mm_core_init+0xf5/0x320
   start_kernel+0x296/0x79c
   i386_start_kernel+0xad/0xb0
   startup_32_smp+0x151/0x154

The mem_map[] is allocated up to the end of ZONE_HIGHMEM which is defined by max_pfn.

The bug was introduced by this recent commit:

6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")

Previously, freeing of high memory was also clamped to the end of ZONE_HIGHMEM but after this change, memblock_free_all() tries to free memory above the of ZONE_HIGHMEM as well and that causes access to mem_map[] entries beyond the end of the memory map.

To fix this, discard the memory after max_pfn from memblock on 32-bit systems so that core MM would be aware only of actually usable memory.

Fixes 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Davide Ciminaghi <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Sean Christopherson <[email protected]>
---
 arch/x86/kernel/e820.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/kernel/e820.c +7 -0
index 9d8dd8d..de62388 100644
@@ -1299,6 +1299,13 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+	/*
+	 * Discard memory above 4GB because 32-bit systems are limited to 4GB
+	 * of memory even with HIGHMEM.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);
 
#34 lore raw

[tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

In reply to Mike Rapoport
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     1e07b9fad022e0e02215150ca1e20912e78e8ec1
Gitweb:        https://git.kernel.org/tip/1e07b9fad022e0e02215150ca1e20912e78e8ec1
Author:        Mike Rapoport (Microsoft) <[email protected]>
AuthorDate:    Sun, 13 Apr 2025 11:08:58 +03:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 16 Apr 2025 09:51:02 +02:00

x86/e820: Discard high memory that can't be addressed by 32-bit systems

Dave Hansen reports the following crash on a 32-bit system with CONFIG_HIGHMEM=y and CONFIG_X86_PAE=y:

Quoted 2 lines

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops.

  BUG: unable to handle page fault for address: f75fe000
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000
  Oops: Oops: 0002 [#1] SMP NOPTI
  CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  EIP: __free_pages_core+0x3c/0x74
  ...
  Call Trace:
   memblock_free_pages+0x11/0x2c
   memblock_free_all+0x2ce/0x3a0
   mm_core_init+0xf5/0x320
   start_kernel+0x296/0x79c
   i386_start_kernel+0xad/0xb0
   startup_32_smp+0x151/0x154

The mem_map[] is allocated up to the end of ZONE_HIGHMEM which is defined by max_pfn.

The bug was introduced by this recent commit:

6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")

Previously, freeing of high memory was also clamped to the end of ZONE_HIGHMEM but after this change, memblock_free_all() tries to free memory above the of ZONE_HIGHMEM as well and that causes access to mem_map[] entries beyond the end of the memory map.

To fix this, discard the memory after max_pfn from memblock on 32-bit systems so that core MM would be aware only of actually usable memory.

[ mingo: Fixed build failure. ]

Fixes 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Davide Ciminaghi <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Sean Christopherson <[email protected]>
---
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +8 -0
index 9d8dd8d..2f38175 100644
@@ -1299,6 +1299,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
+#ifdef CONFIG_X86_32
+	/*
+	 * Discard memory above 4GB because 32-bit systems are limited to 4GB
+	 * of memory even with HIGHMEM.
+	 */
+	memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);
+#endif
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);
 
#35 lore raw

Re: [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems

In reply to Mike Rapoport

Hi Mike,

On Sun, Apr 13, 2025 at 11:08:58AM +0300, Mike Rapoport wrote:
...

Quoted 11 lines
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +0 -0
index 57120f0749cc..5f673bd6c7d7 100644
@@ -1300,6 +1300,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 

arch/x86/kernel/e820.c void __init e820__memblock_setup(void) · line 1312

Quoted 10 lines
arch/x86/kernel/e820.c +8 -0
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);

Our CI noticed a boot failure after this change as commit 1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems") in -tip when booting i386_defconfig with a simple buildroot initrd.

  $ make -skj"$(nproc)" ARCH=i386 CROSS_COMPILE=i386-linux- mrproper defconfig bzImage
  $ curl -LSs https://github.com/ClangBuiltLinux/boot-utils/releases/download/20241120-044434/x86-rootfs.cpio.zst | zstd -d >rootfs.cpio
  $ qemu-system-i386 \
      -display none \
      -nodefaults \
      -M q35 \
      -d unimp,guest_errors \
      -append 'console=ttyS0 earlycon=uart8250,io,0x3f8' \
      -kernel arch/x86/boot/bzImage \
      -initrd rootfs.cpio \
      -cpu host \
      -enable-kvm \
      -m 512m \
      -smp 8 \
      -serial mon:stdio
  [    0.000000] Linux version 6.15.0-rc1-00177-g1e07b9fad022 (nathan@ax162) (i386-linux-gcc (GCC) 14.2.0, GNU ld (GNU Binutils) 2.42) #1 SMP PREEMPT_DYNAMIC Thu Apr 17 09:02:19 MST 2025
  [    0.000000] BIOS-provided physical RAM map:
  [    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
  [    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
  [    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
  [    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000001ffdffff] usable
  [    0.000000] BIOS-e820: [mem 0x000000001ffe0000-0x000000001fffffff] reserved
  [    0.000000] BIOS-e820: [mem 0x00000000b0000000-0x00000000bfffffff] reserved
  [    0.000000] BIOS-e820: [mem 0x00000000fed1c000-0x00000000fed1ffff] reserved
  [    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
  [    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
  [    0.000000] earlycon: uart8250 at I/O port 0x3f8 (options '')
  [    0.000000] printk: legacy bootconsole [uart8250] enabled
  [    0.000000] Notice: NX (Execute Disable) protection cannot be enabled: non-PAE kernel!
  [    0.000000] APIC: Static calls initialized
  [    0.000000] SMBIOS 2.8 present.
  [    0.000000] DMI: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
  [    0.000000] DMI: Memory slots populated: 1/1
  [    0.000000] Hypervisor detected: KVM
  [    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
  [    0.000000] kvm-clock: using sched offset of 196444860 cycles
  [    0.000589] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
  [    0.002401] tsc: Detected 2750.000 MHz processor
  [    0.003126] last_pfn = 0x1ffe0 max_arch_pfn = 0x100000
  [    0.003728] MTRR map: 4 entries (3 fixed + 1 variable; max 19), built from 8 variable MTRRs
  [    0.004664] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT
  [    0.007149] found SMP MP-table at [mem 0x000f5480-0x000f548f]
  [    0.007802] No sub-1M memory is available for the trampoline
  [    0.008435] Failed to release memory for alloc_low_pages()
  [    0.008438] RAMDISK: [mem 0x1fa5f000-0x1ffdffff]
  [    0.009571] Kernel panic - not syncing: Cannot find place for new RAMDISK of size 5771264
  [    0.010486] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00177-g1e07b9fad022 #1 PREEMPT(undef)
  [    0.011601] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
  [    0.012857] Call Trace:
  [    0.013135]  dump_stack_lvl+0x43/0x58
  [    0.013555]  dump_stack+0xd/0x10
  [    0.013919]  panic+0xa5/0x221
  [    0.014252]  setup_arch+0x86f/0x9f0
  [    0.014650]  ? vprintk_default+0x29/0x30
  [    0.015089]  start_kernel+0x4b/0x570
  [    0.015487]  i386_start_kernel+0x65/0x68
  [    0.015919]  startup_32_smp+0x151/0x154
  [    0.016344] ---[ end Kernel panic - not syncing: Cannot find place for new RAMDISK of size 5771264 ]---

At the parent change with the same command, the boot completes fine.

  [    0.000000] Linux version 6.15.0-rc1-00176-gd466304c4322 (nathan@ax162) (i386-linux-gcc (GCC) 14.2.0, GNU ld (GNU Binutils) 2.42) #1 SMP PREEMPT_DYNAMIC Thu Apr 17 09:00:12 MST 2025
  [    0.000000] BIOS-provided physical RAM map:
  ...
  [    0.000000] earlycon: uart8250 at I/O port 0x3f8 (options '')
  [    0.000000] printk: legacy bootconsole [uart8250] enabled
  [    0.000000] Notice: NX (Execute Disable) protection cannot be enabled: non-PAE kernel!
  [    0.000000] APIC: Static calls initialized
  [    0.000000] SMBIOS 2.8 present.
  [    0.000000] DMI: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
  [    0.000000] DMI: Memory slots populated: 1/1
  [    0.000000] Hypervisor detected: KVM
  [    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
  [    0.000001] kvm-clock: using sched offset of 429786443 cycles
  [    0.000806] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
  [    0.003278] tsc: Detected 2750.000 MHz processor
  [    0.004730] last_pfn = 0x1ffe0 max_arch_pfn = 0x100000
  [    0.006220] MTRR map: 4 entries (3 fixed + 1 variable; max 19), built from 8 variable MTRRs
  [    0.009169] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT
  [    0.012840] found SMP MP-table at [mem 0x000f5480-0x000f548f]
  [    0.014310] RAMDISK: [mem 0x1fa5f000-0x1ffdffff]
  [    0.015141] ACPI: Early table checksum verification disabled
  ...
  [    0.046564] 511MB LOWMEM available.
  [    0.047421]   mapped low ram: 0 - 1ffe0000
  [    0.048431]   low ram: 0 - 1ffe0000
  [    0.049289] Zone ranges:
  [    0.049934]   DMA      [mem 0x0000000000001000-0x0000000000ffffff]
  [    0.051184]   Normal   [mem 0x0000000001000000-0x000000001ffdffff]
  [    0.053087] Movable zone start for each node
  [    0.054409] Early memory node ranges
  [    0.055513]   node   0: [mem 0x0000000000001000-0x000000000009efff]
  [    0.057411]   node   0: [mem 0x0000000000100000-0x000000001ffdffff]
  [    0.059176] Initmem setup node 0 [mem 0x0000000000001000-0x000000001ffdffff]
  ...

Is this an invalid configuration or virtual setup that is being tested here or is there something else problematic with this change?

Cheers,
Nathan

#36 lore raw

Re: [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems

Quoted 15 lines · Nathan Chancellor

Hi Mike,

On Sun, Apr 13, 2025 at 11:08:58AM +0300, Mike Rapoport wrote:
...

Quoted 11 lines
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +0 -0
index 57120f0749cc..5f673bd6c7d7 100644
@@ -1300,6 +1300,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
Quoted 15 lines

arch/x86/kernel/e820.c void __init e820__memblock_setup(void) · line 1312

Quoted 10 lines
arch/x86/kernel/e820.c +8 -0
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);

Our CI noticed a boot failure after this change as commit 1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems") in -tip when booting i386_defconfig with a simple buildroot initrd.

I've zapped this commit from tip:x86/urgent for the time being:

1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems")

until these bugs are better understood.

Thanks,

Ingo

maintainer
#37 lore raw

Re: [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems

Quoted 34 lines · Ingo Molnar
Quoted 15 lines · Nathan Chancellor

Hi Mike,

On Sun, Apr 13, 2025 at 11:08:58AM +0300, Mike Rapoport wrote:
...

Quoted 11 lines
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +0 -0
index 57120f0749cc..5f673bd6c7d7 100644
@@ -1300,6 +1300,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
Quoted 15 lines

arch/x86/kernel/e820.c void __init e820__memblock_setup(void) · line 1312

Quoted 10 lines
arch/x86/kernel/e820.c +8 -0
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);

Our CI noticed a boot failure after this change as commit 1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems") in -tip when booting i386_defconfig with a simple buildroot initrd.

Quoted 5 lines

I've zapped this commit from tip:x86/urgent for the time being:

1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems")

until these bugs are better understood.

With X86_PAE disabled phys_addr_t is 32 bit, PFN_PHYS(MAX_NONPAE_PFN) overflows and we get memblock_remove(0, -1) :(

Using max_pfn instead of MAX_NONPAE_PFN would work because there's a hole under 4G and max_pfn should never overflow.

Another option is to skip e820 entries above 4G and not add them to memblock at the first place, e.g.

arch/x86/kernel/e820.c +11 -0
index 57120f0749cc..2b617f36f11a 100644
@@ -1297,6 +1297,17 @@ void __init e820__memblock_setup(void)
 		if (entry->type != E820_TYPE_RAM)
 			continue;
 
+#ifdef CONFIG_X86_32
+		/*
+		 * Discard memory above 4GB because 32-bit systems are limited
+		 * to 4GB of memory even with HIGHMEM.
+		 */
+		if (entry->addr > SZ_4G)
+			continue;
+		if (entry->addr + entry->size > SZ_4G)
+			entry->size = SZ_4G - entry->addr;
+#endif
+
 		memblock_add(entry->addr, entry->size);
 	}
 
Quoted 3 lines

Thanks,

Ingo

Signature · 2 lines
Sincerely yours,
Mike.
#38 lore raw

Re: [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems

Quoted 39 lines · Mike Rapoport
Quoted 38 lines · Ingo Molnar
Quoted 15 lines · Nathan Chancellor

Hi Mike,

On Sun, Apr 13, 2025 at 11:08:58AM +0300, Mike Rapoport wrote:
...

Quoted 11 lines
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +0 -0
index 57120f0749cc..5f673bd6c7d7 100644
@@ -1300,6 +1300,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
Quoted 15 lines

arch/x86/kernel/e820.c void __init e820__memblock_setup(void) · line 1312

Quoted 10 lines
arch/x86/kernel/e820.c +8 -0
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);

Our CI noticed a boot failure after this change as commit 1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems") in -tip when booting i386_defconfig with a simple buildroot initrd.

I've zapped this commit from tip:x86/urgent for the time being:

1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems")

Quoted 7 lines
Quoted 1 line

until these bugs are better understood.

With X86_PAE disabled phys_addr_t is 32 bit, PFN_PHYS(MAX_NONPAE_PFN) overflows and we get memblock_remove(0, -1) :(

Using max_pfn instead of MAX_NONPAE_PFN would work because there's a hole under 4G and max_pfn should never overflow.

So why don't we use max_pfn like your -v1 fix did IIRC?

Ingo

maintainer
#39 lore raw

Re: [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems

Quoted 44 lines · Ingo Molnar
Quoted 41 lines · Mike Rapoport
Quoted 39 lines · Ingo Molnar
Quoted 15 lines · Nathan Chancellor

Hi Mike,

On Sun, Apr 13, 2025 at 11:08:58AM +0300, Mike Rapoport wrote:
...

Quoted 11 lines
 arch/x86/kernel/e820.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/x86/kernel/e820.c +0 -0
index 57120f0749cc..5f673bd6c7d7 100644
@@ -1300,6 +1300,14 @@ void __init e820__memblock_setup(void)
 		memblock_add(entry->addr, entry->size);
 	}
 
Quoted 15 lines

arch/x86/kernel/e820.c void __init e820__memblock_setup(void) · line 1312

Quoted 10 lines
arch/x86/kernel/e820.c +8 -0
+	/*
+	 * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
+	 * to even less without it.
+	 * Discard memory after max_pfn - the actual limit detected at runtime.
+	 */
+	if (IS_ENABLED(CONFIG_X86_32))
+		memblock_remove(PFN_PHYS(max_pfn), -1);
+
 	/* Throw away partial pages: */
 	memblock_trim_memory(PAGE_SIZE);

Our CI noticed a boot failure after this change as commit 1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems") in -tip when booting i386_defconfig with a simple buildroot initrd.

I've zapped this commit from tip:x86/urgent for the time being:

1e07b9fad022 ("x86/e820: Discard high memory that can't be addressed by 32-bit systems")

until these bugs are better understood.

Quoted 7 lines
Quoted 5 lines

With X86_PAE disabled phys_addr_t is 32 bit, PFN_PHYS(MAX_NONPAE_PFN) overflows and we get memblock_remove(0, -1) :(

Using max_pfn instead of MAX_NONPAE_PFN would work because there's a hole under 4G and max_pfn should never overflow.

So why don't we use max_pfn like your -v1 fix did IIRC?

Dave didn't like max_pfn. I don't feel strongly about using max_pfn or skipping e820 ranges above 4G and not adding them to memblock.

Quoted 1 line

Ingo

Signature · 2 lines
Sincerely yours,
Mike.
#40 lore raw

Re: [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems

Quoted 3 lines · Mike Rapoport
Quoted 1 line

So why don't we use max_pfn like your -v1 fix did IIRC?

Dave didn't like max_pfn. I don't feel strongly about using max_pfn or skipping e820 ranges above 4G and not adding them to memblock.

I feel more strongly about fixing the bug than avoiding max_pfn. ;)

Going back to v1 is fine with me.

#41 lore raw

Re: [PATCH] x86/e820: discard high memory that can't be addressed by 32-bit systems

In reply to Mike Rapoport

Hi,

Quoted 43 lines · Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

Dave Hansen reports the following crash on a 32-bit system with CONFIG_HIGHMEM=y and CONFIG_X86_PAE=y:

Quoted 2 lines

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops.

  BUG: unable to handle page fault for address: f75fe000
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  *pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000
  Oops: Oops: 0002 [#1] SMP NOPTI
  CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  EIP: __free_pages_core+0x3c/0x74
  Code: c3 d3 e6 83 ec 10 89 44 24 08 89 74 24 04 c7 04 24 c6 32 3a c2 89 55 f4 e8 a9 11 45 fe 85 f6 8b 55 f4 74 19 89 d8 31 c9 66 90 <0f> ba 30 0d c7 40 1c 00 00 00 00 41 83 c0 28 39 ce 75 ed 8b

EAX: f75fe000 EBX: f75fe000 ECX: 00000000 EDX: 0000000a
ESI: 00000400 EDI: 00500000 EBP: c247becc ESP: c247beb4
DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210046
CR0: 80050033 CR2: f75fe000 CR3: 02da6000 CR4: 000000b0

  Call Trace:
   memblock_free_pages+0x11/0x2c
   memblock_free_all+0x2ce/0x3a0
   mm_core_init+0xf5/0x320
   start_kernel+0x296/0x79c
   ? set_init_arg+0x70/0x70
   ? load_ucode_bsp+0x13c/0x1a8
   i386_start_kernel+0xad/0xb0
   startup_32_smp+0x151/0x154
  Modules linked in:
  CR2: 00000000f75fe000

The mem_map[] is allocated up to the end of ZONE_HIGHMEM which is defined by max_pfn.

Before 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing") freeing of high memory was also clamped to the end of ZONE_HIGHMEM but after 6faea3422e3b memblock_free_all() tries to free memory above the of ZONE_HIGHMEM as well and that causes access to mem_map[] entries beyond the end of the memory map.

Quoted 6 lines

Discard the memory after max_pfn from memblock on 32-bit systems so that core MM would be aware only of actually usable memory.

With this patch in pending-fixes ( v6.15-rc2-434-g93ced5296772), all my i386 test runs crash.

[    0.020893] Kernel panic - not syncing: ioapic_setup_resources: Failed to allocate 0x0000002b bytes
[    0.021248] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc2-00434-g93ced5296772 #1 PREEMPT(undef)
[    0.021373] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
[    0.021549] Call Trace:
[    0.021711]  dump_stack_lvl+0x20/0x104
[    0.022023]  dump_stack+0x12/0x18
[    0.022064]  panic+0x2c1/0x2d8
[    0.022116]  ? vprintk_default+0x29/0x30
[    0.022163]  __memblock_alloc_or_panic+0x57/0x58
[    0.022221]  io_apic_init_mappings+0x2e/0x1a8
[    0.022284]  setup_arch+0x909/0xdac
[    0.022338]  ? vprintk_default+0x29/0x30
[    0.022410]  start_kernel+0x63/0x760
[    0.022457]  ? load_ucode_bsp+0x12c/0x198
[    0.022507]  i386_start_kernel+0x74/0x74
[    0.022548]  startup_32_smp+0x151/0x154
[    0.023089] ---[ end Kernel panic - not syncing: ioapic_setup_resources: Failed to allocate 0x0000002b bytes ]---

Reverting this patch fixes the problem. Bisect log is attached for reference.

Guenter

---
# bad: [93ced5296772b7b704f48e4bad9fcfdf0633c780] Merge branch 'for-linux-next-fixes' of https://gitlab.freedesktop.org/drm/misc/kernel.git
# good: [8ffd015db85fea3e15a77027fda6c02ced4d2444] Linux 6.15-rc2
git bisect start 'HEAD' 'v6.15-rc2'
# good: [5d6f363fc974e32dd9930fecaae63958b68a1df4] Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git
git bisect good 5d6f363fc974e32dd9930fecaae63958b68a1df4
# good: [1790b4a242fe119fead08fccc5bf923423c7449a] Merge branch 'dma-mapping-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mszyprowski/linux.git
git bisect good 1790b4a242fe119fead08fccc5bf923423c7449a
# good: [5d37ee8a1d6455968ea3134d78223090d487c7f4] Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
git bisect good 5d37ee8a1d6455968ea3134d78223090d487c7f4
# good: [9d4de5ae5208548eb9c6a490ac454601f4fbf00b] Merge branch 'i2c/i2c-host-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
git bisect good 9d4de5ae5208548eb9c6a490ac454601f4fbf00b
# bad: [f737ab93945fb8f0213e1cccc39d028eb5d880e0] Merge branch into tip/master: 'x86/urgent'
git bisect bad f737ab93945fb8f0213e1cccc39d028eb5d880e0
# good: [2e7a2843d0de7677b7bb908ca006dc435e52c416] Merge branch into tip/master: 'irq/urgent'
git bisect good 2e7a2843d0de7677b7bb908ca006dc435e52c416
# good: [d466304c4322ad391797437cd84cca7ce1660de0] x86/cpu: Add CPU model number for Bartlett Lake CPUs with Raptor Cove cores git bisect good d466304c4322ad391797437cd84cca7ce1660de0
# good: [39893b1e4ad7c4380abe4cfddaa58b34c4363bf4] Merge branch into tip/master: 'timers/urgent'
git bisect good 39893b1e4ad7c4380abe4cfddaa58b34c4363bf4
# bad: [1e07b9fad022e0e02215150ca1e20912e78e8ec1] x86/e820: Discard high memory that can't be addressed by 32-bit systems
git bisect bad 1e07b9fad022e0e02215150ca1e20912e78e8ec1

# first bad commit: [1e07b9fad022e0e02215150ca1e20912e78e8ec1] x86/e820: Discard high memory that can't be addressed by 32-bit systems
#42 lore raw

Re: [PATCH 05/11] x86: remove HIGHMEM64G support

In reply to Dave Hansen
Quoted 11 lines · Dave Hansen

Has anyone run into any problems on 6.15-rc1 with this stuff?

0xf75fe000 is the mem_map[] entry for the first page >4GB. It obviously wasn't allocated, thus the oops. Looks like the memblock for the >4GB memory didn't get removed although the pgdats seem correct.

I'll dig into it some more. Just wanted to make sure there wasn't a fix out there already.

The way I'm triggering this is booting qemu with a 32-bit PAE kernel, and "-m 4096" (or more).

I have reproduced the bug now and found that it did not happen in my series. Bisection points to Mike Rapoport's highmem series, specifically 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")

There was a related bug that was caused by an earlier version of my series when I also removed CONFIG_PHYS_ADDR_T_64BIT
https://lore.kernel.org/all/[email protected]/

Arnd

#43 lore raw

PATCH 6/11 x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Since kernels with and without CONFIG_X86_PAE are now limited to the low 4GB of physical address space, there is no need to use either swiotlb or 64-bit phys_addr_t any more, so stop selecting these and fix up the build warnings from that.

---
 arch/x86/Kconfig      | 2 --
 arch/x86/mm/pgtable.c | 2 +-
 include/linux/mm.h    | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/Kconfig +0 -2
index b373db8a8176..d0d055f6f56e 100644
@@ -1456,8 +1456,6 @@ config HIGHMEM
 config X86_PAE
 	bool "PAE (Physical Address Extension) Support"
 	depends on X86_32 && X86_HAVE_PAE
-	select PHYS_ADDR_T_64BIT
-	select SWIOTLB
 	help
 	  PAE is required for NX support, and furthermore enables
 	  larger swapspace support for non-overcommit purposes. It
arch/x86/mm/pgtable.c +1 -1
index 5745a354a241..bdf63524e30a 100644
@@ -769,7 +769,7 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
 	mtrr_type_lookup(addr, addr + PMD_SIZE, &uniform);
 	if (!uniform) {
 		pr_warn_once("%s: Cannot satisfy [mem %#010llx-%#010llx] with a huge-page mapping due to MTRR override.\n",
-			     __func__, addr, addr + PMD_SIZE);
+			     __func__, (u64)addr, (u64)addr + PMD_SIZE);
 		return 0;
 	}
 
include/linux/mm.h +1 -1
index c39c4945946c..7725e9e46e90 100644
@@ -99,7 +99,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
 
 #ifndef DIRECT_MAP_PHYSMEM_END
 # ifdef MAX_PHYSMEM_BITS
-# define DIRECT_MAP_PHYSMEM_END	((1ULL << MAX_PHYSMEM_BITS) - 1)
+# define DIRECT_MAP_PHYSMEM_END	(phys_addr_t)((1ULL << MAX_PHYSMEM_BITS) - 1)
 # else
 # define DIRECT_MAP_PHYSMEM_END	(((phys_addr_t)-1)&~(1ULL<<63))
 # endif
Signature · 1 line
2.39.5
#44 lore raw

Re: [PATCH 06/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE

Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Since kernels with and without CONFIG_X86_PAE are now limited to the low 4GB of physical address space, there is no need to use either swiotlb or 64-bit phys_addr_t any more, so stop selecting these and fix up the build warnings from that.

...

arch/x86/mm/pgtable.c int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) · line 772

Quoted 5 lines
        mtrr_type_lookup(addr, addr + PMD_SIZE, &uniform);
        if (!uniform) {
                pr_warn_once("%s: Cannot satisfy [mem %#010llx-%#010llx] with a huge-page mapping due to MTRR override.\n",
arch/x86/mm/pgtable.c +1 -1
-                            __func__, addr, addr + PMD_SIZE);
+                            __func__, (u64)addr, (u64)addr + PMD_SIZE);

Instead of castings I would rather:
1) have addr and size (? does above have off-by-one error?) or end;
2) use struct resource / range with the respective %p[Rr][a] specifier or use %pa.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#45 lore raw

Re: [PATCH 06/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE

Quoted 17 lines · Andy Shevchenko
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Since kernels with and without CONFIG_X86_PAE are now limited to the low 4GB of physical address space, there is no need to use either swiotlb or 64-bit phys_addr_t any more, so stop selecting these and fix up the build warnings from that.

...

arch/x86/mm/pgtable.c int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) · line 772

Quoted 5 lines
        mtrr_type_lookup(addr, addr + PMD_SIZE, &uniform);
        if (!uniform) {
                pr_warn_once("%s: Cannot satisfy [mem %#010llx-%#010llx] with a huge-page mapping due to MTRR override.\n",
arch/x86/mm/pgtable.c +1 -1
-                            __func__, addr, addr + PMD_SIZE);
+                            __func__, (u64)addr, (u64)addr + PMD_SIZE);
Quoted 4 lines

Instead of castings I would rather:
1) have addr and size (? does above have off-by-one error?) or end;
2) use struct resource / range with the respective %p[Rr][a] specifier or use %pa.

Changed as below now. I'm still not sure whether the mtrr_type_lookup end argument is meant to be inclusive or exclusive, so I've left that alone, but the printed range should be correct now.

Thanks,

Arnd

@@ -740,11 +740,12 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)

 {
        u8 uniform;

+ struct resource res = DEFINE_RES_MEM(addr, PMD_SIZE);

        mtrr_type_lookup(addr, addr + PMD_SIZE, &uniform);
        if (!uniform) {
-               pr_warn_once("%s: Cannot satisfy [mem %#010llx-%#010llx] with a huge-page mapping due to MTRR override.\n",
-                            __func__, (u64)addr, (u64)addr + PMD_SIZE);
+               pr_warn_once("%s: Cannot satisfy %pR with a huge-page mapping due to MTRR override.\n",
+                            __func__, &res);
                return 0;
        }
#46 lore raw

Re: [PATCH 06/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE

Quoted 2 lines · Arnd Bergmann
Quoted 1 line · Andy Shevchenko

On Wed, Dec 4, 2024 at 12:31 PM Arnd Bergmann <[email protected]> wrote:

...

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

pr_warn_once("%s: Cannot satisfy [mem %#010llx-%#010llx] with a huge-page mapping due to MTRR override.\n",

arch/x86/mm/pgtable.c +1 -1
-                            __func__, addr, addr + PMD_SIZE);
+                            __func__, (u64)addr, (u64)addr + PMD_SIZE);
Quoted 8 lines
Quoted 4 lines

Instead of castings I would rather:
1) have addr and size (? does above have off-by-one error?) or end;
2) use struct resource / range with the respective %p[Rr][a] specifier or use %pa.

Changed as below now. I'm still not sure whether the mtrr_type_lookup end argument is meant to be inclusive or exclusive, so I've left that alone, but the printed range should be correct now.

Yep, thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#47 lore raw

PATCH 7/11 x86: drop support for CONFIG_HIGHPTE

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

With the maximum amount of RAM now 4GB, there is very little point to still have PTE pages in highmem. Drop this for simplification.

The only other architecture supporting HIGHPTE is 32-bit arm, and once that feature is removed as well, the highpte logic can be dropped from common code as well.

---
 .../admin-guide/kernel-parameters.txt         |  7 -----
 arch/x86/Kconfig                              |  9 -------
 arch/x86/include/asm/pgalloc.h                |  5 ----
 arch/x86/mm/pgtable.c                         | 27 +------------------
 4 files changed, 1 insertion(+), 47 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -7
index eca370e99844..cf25853a5c4a 100644
@@ -7341,13 +7341,6 @@
 				16 - SIGBUS faults
 			Example: user_debug=31
 
-	userpte=
-			[X86,EARLY] Flags controlling user PTE allocations.
-
-				nohigh = do not allocate PTE pages in
-					HIGHMEM regardless of setting
-					of CONFIG_HIGHPTE.
-
 	vdso=		[X86,SH,SPARC]
 			On X86_32, this is an alias for vdso32=.  Otherwise:
 
arch/x86/Kconfig +0 -9
index d0d055f6f56e..d8a8bf9ea9b9 100644
@@ -1621,15 +1621,6 @@ config X86_PMEM_LEGACY
 
 	  Say Y if unsure.
 
-config HIGHPTE
-	bool "Allocate 3rd-level pagetables from highmem"
-	depends on HIGHMEM
-	help
-	  The VM uses one page table entry for each page of physical memory.
-	  For systems with a lot of RAM, this can be wasteful of precious
-	  low memory.  Setting this option will put user-space page table
-	  entries in high memory.
-
 config X86_CHECK_BIOS_CORRUPTION
 	bool "Check for low memory corruption"
 	help
arch/x86/include/asm/pgalloc.h +0 -5
index dcd836b59beb..582cf5b7ec8c 100644
@@ -29,11 +29,6 @@ static inline void paravirt_release_pud(unsigned long pfn) {}
 static inline void paravirt_release_p4d(unsigned long pfn) {}
 #endif
 
-/*
- * Flags to use when allocating a user page table page.
- */
-extern gfp_t __userpte_alloc_gfp;
-
 #ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
 /*
  * Instead of one PGD, we acquire two PGDs.  Being order-1, it is
arch/x86/mm/pgtable.c +1 -26
index bdf63524e30a..895d91e879b4 100644
@@ -12,12 +12,6 @@ phys_addr_t physical_mask __ro_after_init = (1ULL << __PHYSICAL_MASK_SHIFT) - 1;
 EXPORT_SYMBOL(physical_mask);
 #endif
 
-#ifdef CONFIG_HIGHPTE
-#define PGTABLE_HIGHMEM __GFP_HIGHMEM
-#else
-#define PGTABLE_HIGHMEM 0
-#endif
-
 #ifndef CONFIG_PARAVIRT
 static inline
 void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table)
@@ -26,29 +20,10 @@ void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table)
 }
 #endif
 
-gfp_t __userpte_alloc_gfp = GFP_PGTABLE_USER | PGTABLE_HIGHMEM;
-
 pgtable_t pte_alloc_one(struct mm_struct *mm)
 {
-	return __pte_alloc_one(mm, __userpte_alloc_gfp);
-}
-
-static int __init setup_userpte(char *arg)
-{
-	if (!arg)
-		return -EINVAL;
-
-	/*
-	 * "userpte=nohigh" disables allocation of user pagetables in
-	 * high memory.
-	 */
-	if (strcmp(arg, "nohigh") == 0)
-		__userpte_alloc_gfp &= ~__GFP_HIGHMEM;
-	else
-		return -EINVAL;
-	return 0;
+	return __pte_alloc_one(mm, GFP_PGTABLE_USER);
 }
-early_param("userpte", setup_userpte);
 
 void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte)
 {
Signature · 1 line
2.39.5
#48 lore raw

PATCH 8/11 x86: document X86_INTEL_MID as 64-bit-only

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The X86_INTEL_MID code was originally introduced for the 32-bit Moorestown/Medfield/Clovertrail platform, later the 64-bit Merrifield/Moorefield variant got added, but the final Morganfield/Broxton 14nm chips were canceled before they hit the market.

To help users understand what the option actually refers to, update the help text, and make it a hard dependency on 64-bit kernels. While they could theoretically run a 32-bit kernel, the devices originally shipped with 64-bit one in 2015, so that was proabably never tested.

---
 arch/x86/Kconfig         | 16 ++++++++++------
 arch/x86/kernel/head32.c |  3 ---
 2 files changed, 10 insertions(+), 9 deletions(-)
arch/x86/Kconfig +10 -6
index d8a8bf9ea9b9..fa6dd9ec4bdf 100644
@@ -544,12 +544,12 @@ config X86_EXTENDED_PLATFORM
 		RDC R-321x SoC
 		SGI 320/540 (Visual Workstation)
 		STA2X11-based (e.g. Northville)
-		Moorestown MID devices
 
 	  64-bit platforms (CONFIG_64BIT=y):
 		Numascale NumaChip
 		ScaleMP vSMP
 		SGI Ultraviolet
+		Merrifield/Moorefield MID devices
 
 	  If you have one of these systems, or if you want to build a
 	  generic distribution kernel, say Y here - otherwise say N.
@@ -621,11 +621,11 @@ config X86_INTEL_CE
 	  boxes and media devices.
 
 config X86_INTEL_MID
-	bool "Intel MID platform support"
+	bool "Intel Z34xx/Z35xx MID platform support"
 	depends on X86_EXTENDED_PLATFORM
 	depends on X86_PLATFORM_DEVICES
 	depends on PCI
-	depends on X86_64 || (PCI_GOANY && X86_32)
+	depends on X86_64
 	depends on X86_IO_APIC
 	select I2C
 	select DW_APB_TIMER
@@ -633,10 +633,14 @@ config X86_INTEL_MID
 	help
 	  Select to build a kernel capable of supporting Intel MID (Mobile
 	  Internet Device) platform systems which do not have the PCI legacy
-	  interfaces. If you are building for a PC class system say N here.
+	  interfaces.
+
+	  The only supported devices are the 22nm Merrified (Z34xx) and
+	  Moorefield (Z35xx) SoC used in Android devices such as the
+	  Asus Zenfone 2, Asus FonePad 8 and Dell Venue 7.
 
-	  Intel MID platforms are based on an Intel processor and chipset which
-	  consume less power than most of the x86 derivatives.
+	  If you are building for a PC class system or non-MID tablet
+	  SoCs like Bay Trail (Z36xx/Z37xx), say N here.
 
 config X86_INTEL_QUARK
 	bool "Intel Quark platform support"
arch/x86/kernel/head32.c +0 -3
index de001b2146ab..4f69239556e4 100644
@@ -65,9 +65,6 @@ asmlinkage __visible void __init __noreturn i386_start_kernel(void)
 
 	/* Call the subarch specific early setup function */
 	switch (boot_params.hdr.hardware_subarch) {
-	case X86_SUBARCH_INTEL_MID:
-		x86_intel_mid_early_setup();
-		break;
 	case X86_SUBARCH_CE4100:
 		x86_ce4100_early_setup();
 		break;
Signature · 1 line
2.39.5
#49 lore raw

Re: [PATCH 08/11] x86: document X86_INTEL_MID as 64-bit-only

+Cc: Ferry

Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The X86_INTEL_MID code was originally introduced for the 32-bit Moorestown/Medfield/Clovertrail platform, later the 64-bit Merrifield/Moorefield variant got added, but the final

variant got --> variants were

Quoted 2 lines

Morganfield/Broxton 14nm chips were canceled before they hit the market.

Inaccurate. "Broxton for Mobile", and not "Broxton" in general.

Quoted 5 lines

To help users understand what the option actually refers to, update the help text, and make it a hard dependency on 64-bit kernels. While they could theoretically run a 32-bit kernel, the devices originally shipped with 64-bit one in 2015, so that was proabably never tested.

probably

It's all other way around (from SW point of view). For unknown reasons Intel decided to release only 32-bit SW and it became the only thing that was heavily tested (despite misunderstanding by some developers that pointed finger to the HW without researching the issue that appears to be purely software in a few cases) _that_ time. Starting ca. 2017 I enabled 64-bit for Merrifield and from then it's being used by both 32- and 64-bit builds.

I'm totally fine to drop 32-bit defaults for Merrifield/Moorefield, but let's hear Ferry who might/may still have a use case for that.

...

Quoted 1 line

- Moorestown MID devices

FTR, a year or so ago it was a (weak) interest to revive Medfield, but I think it would require too much work even for the person who is quite familiar with HW, U-Boot, and Linux kernel, so it is most unlikely to happen.

...

arch/x86/Kconfig config X86_INTEL_MID · line 640

Quoted 8 lines

Select to build a kernel capable of supporting Intel MID (Mobile Internet Device) platform systems which do not have the PCI legacy

arch/x86/Kconfig +5 -1
-         interfaces. If you are building for a PC class system say N here.
+         interfaces.
+
+         The only supported devices are the 22nm Merrified (Z34xx) and
+         Moorefield (Z35xx) SoC used in Android devices such as the
+         Asus Zenfone 2, Asus FonePad 8 and Dell Venue 7.

The list is missing the Intel Edison DIY platform which is probably the main user of Intel MID kernels nowadays.

...

arch/x86/Kconfig config X86_INTEL_MID · line 639

Quoted 2 lines
arch/x86/Kconfig +0 -2
-         Intel MID platforms are based on an Intel processor and chipset which
-         consume less power than most of the x86 derivatives.

Why remove this? AFAIK it states the truth.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#50 lore raw

Re: [PATCH 08/11] x86: document X86_INTEL_MID as 64-bit-only

Quoted 11 lines · Andy Shevchenko

+Cc: Ferry

Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The X86_INTEL_MID code was originally introduced for the 32-bit Moorestown/Medfield/Clovertrail platform, later the 64-bit Merrifield/Moorefield variant got added, but the final

variant got --> variants were

Fixed

Quoted 4 lines
Quoted 2 lines

Morganfield/Broxton 14nm chips were canceled before they hit the market.

Inaccurate. "Broxton for Mobile", and not "Broxton" in general.

Changed to "but the final Morganfield 14nm platform was canceled before it hit the market"

Quoted 7 lines
Quoted 5 lines

To help users understand what the option actually refers to, update the help text, and make it a hard dependency on 64-bit kernels. While they could theoretically run a 32-bit kernel, the devices originally shipped with 64-bit one in 2015, so that was proabably never tested.

probably

Fixed.

Quoted 10 lines

It's all other way around (from SW point of view). For unknown reasons Intel decided to release only 32-bit SW and it became the only thing that was heavily tested (despite misunderstanding by some developers that pointed finger to the HW without researching the issue that appears to be purely software in a few cases) _that_ time. Starting ca. 2017 I enabled 64-bit for Merrifield and from then it's being used by both 32- and 64-bit builds.

I'm totally fine to drop 32-bit defaults for Merrifield/Moorefield, but let's hear Ferry who might/may still have a use case for that.

Ok. I tried to find the oldest Android image and saw it used a 64-bit kernel, but that must have been after your work then.

Quoted 7 lines
Quoted 2 lines

- Moorestown MID devices

FTR, a year or so ago it was a (weak) interest to revive Medfield, but I think it would require too much work even for the person who is quite familiar with HW, U-Boot, and Linux kernel, so it is most unlikely to happen.

Ok.

Quoted 7 lines

arch/x86/Kconfig config X86_INTEL_MID · line 640

Quoted 4 lines
arch/x86/Kconfig +4 -0
+
+         The only supported devices are the 22nm Merrified (Z34xx) and
+         Moorefield (Z35xx) SoC used in Android devices such as the
+         Asus Zenfone 2, Asus FonePad 8 and Dell Venue 7.

The list is missing the Intel Edison DIY platform which is probably the main user of Intel MID kernels nowadays.

Ah, that explains a lot ;-)

Changed now to

The only supported devices are the 22nm Merrified (Z34xx) and Moorefield (Z35xx) SoC used in the Intel Edison board and a small number of Android devices such as the Asus Zenfone 2, Asus FonePad 8 and Dell Venue 7.

Quoted 6 lines

...

arch/x86/Kconfig config X86_INTEL_MID · line 639

Quoted 2 lines
arch/x86/Kconfig +0 -2
-         Intel MID platforms are based on an Intel processor and chipset which
-         consume less power than most of the x86 derivatives.

Why remove this? AFAIK it states the truth.

It seemed irrelevant for users that configure the kernel. I've put it back now.

Thanks for the review!

Arnd

#51 lore raw

Re: [PATCH 08/11] x86: document X86_INTEL_MID as 64-bit-only

Quoted 2 lines · Arnd Bergmann
Quoted 1 line · Andy Shevchenko

On Wed, Dec 4, 2024 at 12:31 PM Arnd Bergmann <[email protected]> wrote:

...

Quoted 8 lines
Quoted 8 lines

It's all other way around (from SW point of view). For unknown reasons Intel decided to release only 32-bit SW and it became the only thing that was heavily tested (despite misunderstanding by some developers that pointed finger to the HW without researching the issue that appears to be purely software in a few cases) _that_ time. Starting ca. 2017 I enabled 64-bit for Merrifield and from then it's being used by both 32- and 64-bit builds.

Quoted 5 lines
Quoted 2 lines

I'm totally fine to drop 32-bit defaults for Merrifield/Moorefield, but let's hear Ferry who might/may still have a use case for that.

Ok. I tried to find the oldest Android image and saw it used a 64-bit kernel, but that must have been after your work then.

I stand up corrected, what I said is related to Merrifield, Moorefield may have 64-bit users on the phones from day 1, though.

...

Quoted 6 lines

Changed now to

The only supported devices are the 22nm Merrified (Z34xx) and Moorefield (Z35xx) SoC used in the Intel Edison board and a small number of Android devices such as the Asus Zenfone 2, Asus FonePad 8 and Dell Venue 7.

LGTM, thanks!

...

Quoted 7 lines
Quoted 4 lines

arch/x86/Kconfig config X86_INTEL_MID · line 639

Quoted 2 lines
arch/x86/Kconfig +0 -2
-         Intel MID platforms are based on an Intel processor and chipset which
-         consume less power than most of the x86 derivatives.

Why remove this? AFAIK it states the truth.

It seemed irrelevant for users that configure the kernel. I've put it back now.

It might be, but it was already there. Thanks for leaving it untouched.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#52 lore raw

Re: [PATCH 08/11] x86: document X86_INTEL_MID as 64-bit-only

In reply to Andy Shevchenko

Hi,

Op 04-12-2024 om 19:55 schreef Andy Shevchenko:

Quoted 30 lines

+Cc: Ferry

Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The X86_INTEL_MID code was originally introduced for the 32-bit Moorestown/Medfield/Clovertrail platform, later the 64-bit Merrifield/Moorefield variant got added, but the final

variant got --> variants were

Quoted 2 lines

Morganfield/Broxton 14nm chips were canceled before they hit the market.

Inaccurate. "Broxton for Mobile", and not "Broxton" in general.

Quoted 5 lines

To help users understand what the option actually refers to, update the help text, and make it a hard dependency on 64-bit kernels. While they could theoretically run a 32-bit kernel, the devices originally shipped with 64-bit one in 2015, so that was proabably never tested.

probably

It's all other way around (from SW point of view). For unknown reasons Intel decided to release only 32-bit SW and it became the only thing that was heavily tested (despite misunderstanding by some developers that pointed finger to the HW without researching the issue that appears to be purely software in a few cases) _that_ time. Starting ca. 2017 I enabled 64-bit for Merrifield and from then it's being used by both 32- and 64-bit builds.

Quoted 2 lines

I'm totally fine to drop 32-bit defaults for Merrifield/Moorefield, but let's hear Ferry who might/may still have a use case for that.

Do to the design of SLM if found (and it is also documented in Intel's HW documentation)

that there is a penalty introduced when executing certain instructions in 64b mode. The one I found

is crc32di, running slower than 2 crc32si in series. Then there are other instructions seem to runs faster in 64b mode.

And there is of course the usual limited memory space than could benefit for 32b mode. I never tried the mixed (x86_32?)

mode. But I am building and testing both i686 and x86_64 for each Edison image.

I think that should at minimum be useful to catch 32b errors in the kernel in certain areas (shared with other 32b

archs. So, I would prefer 32b support for this platform to continue.

Quoted 18 lines

...

Quoted 1 line

- Moorestown MID devices

FTR, a year or so ago it was a (weak) interest to revive Medfield, but I think it would require too much work even for the person who is quite familiar with HW, U-Boot, and Linux kernel, so it is most unlikely to happen.

...

arch/x86/Kconfig config X86_INTEL_MID · line 640

Quoted 8 lines

Select to build a kernel capable of supporting Intel MID (Mobile Internet Device) platform systems which do not have the PCI legacy

arch/x86/Kconfig +5 -1
-         interfaces. If you are building for a PC class system say N here.
+         interfaces.
+
+         The only supported devices are the 22nm Merrified (Z34xx) and
+         Moorefield (Z35xx) SoC used in Android devices such as the
+         Asus Zenfone 2, Asus FonePad 8 and Dell Venue 7.
Quoted 2 lines

The list is missing the Intel Edison DIY platform which is probably the main user of Intel MID kernels nowadays.

Despite the Dell Venue 7 originally running a 32b Android kernel (I think), I got it run linux/Yocto in 64 bits.

Quoted 7 lines

...

arch/x86/Kconfig config X86_INTEL_MID · line 639

Quoted 2 lines
arch/x86/Kconfig +0 -2
-         Intel MID platforms are based on an Intel processor and chipset which
-         consume less power than most of the x86 derivatives.

Why remove this? AFAIK it states the truth.

#53 lore raw

Re: [PATCH 08/11] x86: document X86_INTEL_MID as 64-bit-only

Quoted 19 lines · Ferry Toth

Op 04-12-2024 om 19:55 schreef Andy Shevchenko:

Quoted 11 lines

It's all other way around (from SW point of view). For unknown reasons Intel decided to release only 32-bit SW and it became the only thing that was heavily tested (despite misunderstanding by some developers that pointed finger to the HW without researching the issue that appears to be purely software in a few cases) _that_ time. Starting ca. 2017 I enabled 64-bit for Merrifield and from then it's being used by both 32- and 64-bit builds.

I'm totally fine to drop 32-bit defaults for Merrifield/Moorefield, but let's hear Ferry who might/may still have a use case for that.

Do to the design of SLM if found (and it is also documented in Intel's HW documentation)

that there is a penalty introduced when executing certain instructions in 64b mode. The one I found

Quoted 8 lines

is crc32di, running slower than 2 crc32si in series. Then there are other instructions seem to runs faster in 64b mode.

And there is of course the usual limited memory space than could benefit for 32b mode. I never tried the mixed (x86_32?)

mode. But I am building and testing both i686 and x86_64 for each Edison image.

Hi Ferry,

Thanks a lot for the detailed reply, this is exactly the kind of information I was hoping to get out of my series, in particular since we have a lot of the same tradeoffs on low-end 64-bit Arm platforms, and I've been trying to push users toward running 64-bit kernels on those.

I generally think that it makes a lot of sense to run 32-bit userspace on memory limited devices, in particular with less than 512MB, but it's often still useful on devices with 1GB.

Running a 32-bit kernel is usually not worth it if you can avoid it, and with 1GB of RAM you definitely run into limits either from using HIGHMEM (with CONFIG_VMSPLIT_3G) or in user addressing (with any other VMPLIT_*), in addition to the 32-bit kernels just being less well maintained and missing security features.

Using a 64-bit kernel with CONFIG_COMPAT for 32-bit userspace tends to be the best combination for a large number of embedded workloads. As a rough estimate on Arm hardware, I found that a 64-bit kernel tends to use close to twice the amount of RAM for itself (vmlinux, slab caches, page tables, mem_map[]) compared to a 32-bit kernel, but this should be no more than 10-20% of the total RAM for sensible workloads as all the interesting bits happen in userland. I expect the numbers to be similar for x86, but have not looked in detail.

In userspace there is more variation depending on the type of application: the base system has a similar 2x ratio, but once you get into data intensive tasks (file server, networking, image/video processing, ...) the overhead of 64-bit userspace is lower because the size of the actual data is the same on both.

For the specific case of the crc32di instruction, I suspect the in-kernel version of this can be trivially changed like

arch/x86/crypto/crc32c-intel_glue.c +2 -2
index 52c5d47ef5a1..60b9b3cab679 100644
@@ -60,10 +60,10 @@ static u32 __pure crc32c_intel_le_hw(u32 crc, unsigned char const *p, size_t len
 {
        unsigned int iquotient = len / SCALE_F;
        unsigned int iremainder = len % SCALE_F;
-       unsigned long *ptmp = (unsigned long *)p;
+       unsigned int *ptmp = (unsigned int *)p;
 
        while (iquotient--) {
-               asm(CRC32_INST
+               asm("crc32l %1, %0"
                    : "+r" (crc) : "rm" (*ptmp));
                ptmp++;
        }

to get you the faster version, plus some form of configurability to make sure other CPUs still get the crc32q version by default.

Quoted 3 lines

I think that should at minimum be useful to catch 32b errors in the kernel in certain areas (shared with other 32b
archs. So, I would prefer 32b support for this platform to continue.

I can certainly see this both ways, on the one hand I do care a lot about 32-bit Arm platforms and appreciate the help in finding issues on 32-bit kernels. On the other hand I really don't want anyone to waste time testing something that should never be used in practice and keeping a feature in the kernel only for the purpose of regression testing that feature.

The platform is also special enough that I don't see testing it in 32-bit mode as particularly helpful to others, and it's unlikely to catch bugs that testing in KVM won't.

Testing your 32-bit userland with a 64-bit kernel would be helpful of course to ensure it keeps working for anyone that had been using 32-bit kernel+userspace if we drop 32-bit kernel support for it.

One related idea that I've discussed before is to have 32-bit kernels refuse to boot on 64-bit hardware and instead print the URL of a wiki page to explain all of the above. There would probably have to be whitelist of platforms that are buggy in 64-bit mode, and a command line option to revert back to the previous behavior to allow testing.

Arnd

#54 lore raw

PATCH 9/11 x86: rework CONFIG_GENERIC_CPU compiler flags

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building an x86-64 kernel with CONFIG_GENERIC_CPU is documented to run on all CPUs, but the Makefile does not actually pass an -march= argument, instead relying on the default that was used to configure the toolchain.

In many cases, gcc will be configured to -march=x86-64 or -march=k8 for maximum compatibility, but in other cases a distribution default may be either raised to a more recent ISA, or set to -march=native to build for the CPU used for compilation. This still works in the case of building a custom kernel for the local machine.

The point where it breaks down is building a kernel for another machine that is older the the default target. Changing the default to -march=x86-64 would make it work reliable, but possibly produce worse code on distros that intentionally default to a newer ISA.

To allow reliably building a kernel for either the oldest x86-64 CPUs or a more recent level, add three separate options for v1, v2 and v3 of the architecture as defined by gcc and clang and make them all turn on CONFIG_GENERIC_CPU. Based on this it should be possible to change runtime feature detection into build-time detection for things like cmpxchg16b, or possibly gate features that are only available on older architectures.

---
 arch/x86/Kconfig.cpu | 39 ++++++++++++++++++++++++++++++++++-----
 arch/x86/Makefile    |  6 ++++++
 2 files changed, 40 insertions(+), 5 deletions(-)
arch/x86/Kconfig.cpu +34 -5
index 139db904e564..1461a739237b 100644
@@ -260,7 +260,7 @@ endchoice
 choice
 	prompt "x86-64 Processor family"
 	depends on X86_64
-	default GENERIC_CPU
+	default X86_64_V2
 	help
 	  This is the processor type of your CPU. This information is
 	  used for optimizing purposes. In order to compile a kernel
@@ -314,15 +314,44 @@ config MSILVERMONT
 	  early Atom CPUs based on the Bonnell microarchitecture,
 	  such as Atom 230/330, D4xx/D5xx, D2xxx, N2xxx or Z2xxx.
 
-config GENERIC_CPU
-	bool "Generic-x86-64"
+config X86_64_V1
+	bool "Generic x86-64"
 	depends on X86_64
 	help
-	  Generic x86-64 CPU.
-	  Run equally well on all x86-64 CPUs.
+	  Generic x86-64-v1 CPU.
+	  Run equally well on all x86-64 CPUs, including early Pentium-4
+	  variants lacking the sahf and cmpxchg16b instructions as well
+	  as the AMD K8 and Intel Core 2 lacking popcnt.
+
+config X86_64_V2
+	bool "Generic x86-64 v2"
+	depends on X86_64
+	help
+	  Generic x86-64-v2 CPU.
+	  Run equally well on all x86-64 CPUs that meet the x86-64-v2
+	  definition as well as those that only miss the optional
+	  SSE3/SSSE3/SSE4.1 portions.
+	  Examples of this include Intel Nehalem and Silvermont,
+	  AMD Bulldozer (K10) and Jaguar as well as VIA Nano that
+	  include popcnt, cmpxchg16b and sahf.
+
+config X86_64_V3
+	bool "Generic x86-64 v3"
+	depends on X86_64
+	help
+	  Generic x86-64-v3 CPU.
+	  Run equally well on all x86-64 CPUs that meet the x86-64-v3
+	  definition as well as those that only miss the optional
+	  AVX/AVX2 portions.
+	  Examples of this include the Intel Haswell and AMD Excavator
+	  microarchitectures that include the bmi1/bmi2, lzncnt, movbe
+	  and xsave instruction set extensions.
 
 endchoice
 
+config GENERIC_CPU
+	def_bool X86_64_V1 || X86_64_V2 || X86_64_V3
+
 config X86_GENERIC
 	bool "Generic x86 support"
 	depends on X86_32
arch/x86/Makefile +6 -0
index 05887ae282f5..1fdc3fc6a54e 100644
@@ -183,6 +183,9 @@ else
         cflags-$(CONFIG_MPSC)		+= -march=nocona
         cflags-$(CONFIG_MCORE2)		+= -march=core2
         cflags-$(CONFIG_MSILVERMONT)	+= -march=silvermont
+        cflags-$(CONFIG_MX86_64_V1)	+= -march=x86-64
+        cflags-$(CONFIG_MX86_64_V2)	+= $(call cc-option,-march=x86-64-v2,-march=x86-64)
+        cflags-$(CONFIG_MX86_64_V3)	+= $(call cc-option,-march=x86-64-v3,-march=x86-64)
         cflags-$(CONFIG_GENERIC_CPU)	+= -mtune=generic
         KBUILD_CFLAGS += $(cflags-y)
 
@@ -190,6 +193,9 @@ else
         rustflags-$(CONFIG_MPSC)	+= -Ctarget-cpu=nocona
         rustflags-$(CONFIG_MCORE2)	+= -Ctarget-cpu=core2
         rustflags-$(CONFIG_MSILVERMONT)	+= -Ctarget-cpu=silvermont
+        rustflags-$(CONFIG_MX86_64_V1)	+= -Ctarget-cpu=x86-64
+        rustflags-$(CONFIG_MX86_64_V2)	+= -Ctarget-cpu=x86-64-v2
+        rustflags-$(CONFIG_MX86_64_V3)	+= -Ctarget-cpu=x86-64-v3
         rustflags-$(CONFIG_GENERIC_CPU)	+= -Ztune-cpu=generic
         KBUILD_RUSTFLAGS += $(rustflags-y)
 
Signature · 1 line
2.39.5
#55 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 18 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building an x86-64 kernel with CONFIG_GENERIC_CPU is documented to run on all CPUs, but the Makefile does not actually pass an -march= argument, instead relying on the default that was used to configure the toolchain.

In many cases, gcc will be configured to -march=x86-64 or -march=k8 for maximum compatibility, but in other cases a distribution default may be either raised to a more recent ISA, or set to -march=native to build for the CPU used for compilation. This still works in the case of building a custom kernel for the local machine.

The point where it breaks down is building a kernel for another machine that is older the the default target. Changing the default to -march=x86-64 would make it work reliable, but possibly produce worse code on distros that intentionally default to a newer ISA.

Quoted 8 lines

To allow reliably building a kernel for either the oldest x86-64 CPUs or a more recent level, add three separate options for v1, v2 and v3 of the architecture as defined by gcc and clang and make them all turn on CONFIG_GENERIC_CPU. Based on this it should be possible to change runtime feature detection into build-time detection for things like cmpxchg16b, or possibly gate features that are only available on older architectures.

Hi Arnd,

Similar but not identical changes have been proposed in the past several times like e.g. in 1, 2 and likely even more often.

Your solution seems to be much cleaner, I like it.

That said, on my Skylake platform, there is no difference between -march=x86-64 and -march=x86-64-v3 in terms of kernel binary size or performance. I think Boris also said that these settings make no real difference on code generation.

Other settings might make a small difference (numbers are from 2023):
-generic: 85.089.784 bytes
-core2: 85.139.932 bytes
-march=skylake: 85.017.808 bytes

----
[1] https://lore.kernel.org/all/4_u6ZNYPbaK36xkLt8ApRhiRTyWp_-NExHCH_tTFO_fanDglEmcbfowmiB505heI4md2AuR9hS-VSkf4s90sXb5--AnNTOwvPaTmcgzRYSY=@proton.me/

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

#56 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 5 lines · Tor Vic

On 12/4/24 11:30, Arnd Bergmann wrote:
Similar but not identical changes have been proposed in the past several times like e.g. in 1, 2 and likely even more often.

Your solution seems to be much cleaner, I like it.

Thanks. It looks like the other two did not actually address the bug I'm fixing in my version.

Quoted 5 lines

That said, on my Skylake platform, there is no difference between -march=x86-64 and -march=x86-64-v3 in terms of kernel binary size or performance.
I think Boris also said that these settings make no real difference on code generation.

As Nathan pointed out, I had a typo in my patch, so the options didn't actually do anything at all. I fixed it now and did a 'defconfig' test build with all three:

Quoted 4 lines

Other settings might make a small difference (numbers are from 2023):

   -generic:       85.089.784 bytes
   -core2:         85.139.932 bytes
   -march=skylake: 85.017.808 bytes

text data bss dec hex filename
26664466 10806622 1490948 38962036 2528374 obj-x86/vmlinux-v1
26664466 10806622 1490948 38962036 2528374 obj-x86/vmlinux-v2
26662504 10806654 1490948 38960106 2527bea obj-x86/vmlinux-v3

which is a tiny 2KB saved between v2 and v3. I looked at the object code and found that the v3 version takes advantage of the BMI extension, which makes perfect sense. Not sure if it has any real performance benefits.

Between v1 and v2, there is a chance to turn things like system_has_cmpxchg128() into a constant on v2 and higher.

The v4 version is meaningless in practice since it only adds AVX512 instructions that are only present in very few CPUs and not that useful inside the kernel side from specialized crypto and raid helpers.

Arnd

#57 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

In reply to Arnd Bergmann

Hi Arnd,

On Wed, Dec 04, 2024 at 11:30:40AM +0100, Arnd Bergmann wrote:
...

Quoted 4 lines

+++ b/arch/x86/Kconfig.cpu

arch/x86/Kconfig.cpu +3 -0
+config X86_64_V1
+config X86_64_V2
+config X86_64_V3

...

Quoted 4 lines

+++ b/arch/x86/Makefile

arch/x86/Makefile +3 -0
+        cflags-$(CONFIG_MX86_64_V1)	+= -march=x86-64
+        cflags-$(CONFIG_MX86_64_V2)	+= $(call cc-option,-march=x86-64-v2,-march=x86-64)
+        cflags-$(CONFIG_MX86_64_V3)	+= $(call cc-option,-march=x86-64-v3,-march=x86-64)

...

arch/x86/Makefile else · line 198

Quoted 3 lines
arch/x86/Makefile +3 -0
+        rustflags-$(CONFIG_MX86_64_V1)	+= -Ctarget-cpu=x86-64
+        rustflags-$(CONFIG_MX86_64_V2)	+= -Ctarget-cpu=x86-64-v2
+        rustflags-$(CONFIG_MX86_64_V3)	+= -Ctarget-cpu=x86-64-v3

There appears to be an extra 'M' when using these CONFIGs in Makefile, so I don't think this works as is?

Cheers,
Nathan

#58 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 14 lines · Nathan Chancellor

Hi Arnd,

On Wed, Dec 04, 2024 at 11:30:40AM +0100, Arnd Bergmann wrote:
...

Quoted 4 lines

+++ b/arch/x86/Kconfig.cpu

arch/x86/Kconfig.cpu +3 -0
+config X86_64_V1
+config X86_64_V2
+config X86_64_V3

...

Quoted 4 lines

+++ b/arch/x86/Makefile

arch/x86/Makefile +3 -0
+        cflags-$(CONFIG_MX86_64_V1)	+= -march=x86-64
+        cflags-$(CONFIG_MX86_64_V2)	+= $(call cc-option,-march=x86-64-v2,-march=x86-64)
+        cflags-$(CONFIG_MX86_64_V3)	+= $(call cc-option,-march=x86-64-v3,-march=x86-64)

...

Quoted 6 lines

arch/x86/Makefile else · line 198

Quoted 3 lines
arch/x86/Makefile +3 -0
+        rustflags-$(CONFIG_MX86_64_V1)	+= -Ctarget-cpu=x86-64
+        rustflags-$(CONFIG_MX86_64_V2)	+= -Ctarget-cpu=x86-64-v2
+        rustflags-$(CONFIG_MX86_64_V3)	+= -Ctarget-cpu=x86-64-v3

There appears to be an extra 'M' when using these CONFIGs in Makefile, so I don't think this works as is?

Fixed now by adding the 'M' in the Kconfig file, thanks for noticing it.

Arnd

#59 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

In reply to Arnd Bergmann

"On second thought , let’s not go to x86-64 microarchitectural
levels. ‘Tis a silly place"

Quoted 5 lines · Arnd Bergmann

To allow reliably building a kernel for either the oldest x86-64 CPUs or a more recent level, add three separate options for v1, v2 and v3 of the architecture as defined by gcc and clang and make them all turn on CONFIG_GENERIC_CPU.

The whole "v2", "v3", "v4" etc naming seems to be some crazy glibc artifact and is stupid and needs to die.

It has no relevance to anything. Please do *not* introduce that mind-fart into the kernel sources.

I have no idea who came up with the "microarchitecture levels" garbage, but as far as I can tell, it's entirely unofficial, and it's a completely broken model.

There is a very real model for microarchitectural features, and it's the CPUID bits. Trying to linearize those bits is technically wrong, since these things simply aren't some kind of linear progression.

And worse, it's a "simplification" that literally adds complexity. Now instead of asking "does this CPU support the cmpxchgb16 instruction?", the question instead becomes one of "what the hell does 'v3' mean again?"

So no. We are *NOT* introducing that idiocy in the kernel.

Linus

#60 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 2 lines · Linus Torvalds

"On second thought , let’s not go to x86-64 microarchitectural levels. ‘Tis a silly place"

Fair enough. I'll just make it use -march=x86_64 to override the compiler default then.

Quoted 10 lines · Arnd Bergmann
Quoted 5 lines

To allow reliably building a kernel for either the oldest x86-64 CPUs or a more recent level, add three separate options for v1, v2 and v3 of the architecture as defined by gcc and clang and make them all turn on CONFIG_GENERIC_CPU.

The whole "v2", "v3", "v4" etc naming seems to be some crazy glibc artifact and is stupid and needs to die.

Quoted 6 lines

It has no relevance to anything. Please do *not* introduce that mind-fart into the kernel sources.

I have no idea who came up with the "microarchitecture levels" garbage, but as far as I can tell, it's entirely unofficial, and it's a completely broken model.

I agree that both the name and the concept are broken. My idea was based on how distros (Red Hat Enterprise Linux at least) already use the same levels for making userspace require newer CPUs, so using the same flag for the kernel makes some sense.

Making a point about the levels being stupid is a useful goal as well.

Quoted 8 lines

There is a very real model for microarchitectural features, and it's the CPUID bits. Trying to linearize those bits is technically wrong, since these things simply aren't some kind of linear progression.

And worse, it's a "simplification" that literally adds complexity. Now instead of asking "does this CPU support the cmpxchgb16 instruction?", the question instead becomes one of "what the hell does 'v3' mean again?"

I guess the other side of it is that the current selection between pentium4/core2/k8/bonnell/generic is not much better, given that in practice nobody has any of the pentium4/core2/k8/bonnell variants any more.

A more radical solution would be to just drop the entire menu for 64-bit kernels and always default to "-march=x86_64 -mtune=generic" and 64 byte L1 cachelines.

Arnd

#61 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 5 lines · Arnd Bergmann

I guess the other side of it is that the current selection between pentium4/core2/k8/bonnell/generic is not much better, given that in practice nobody has any of the pentium4/core2/k8/bonnell variants any more.

Yeah, I think that whole part of the x86 Kconfig is almost entirely historical.

It's historical also in the sense that a lot of those decisions matter a whole lot less these days.

The whole CPU tuning issue is happily mostly a thing of the past, since all modern CPU's do fairly well, and you don't have the crazy glass jaws of yesteryear with in-order cores and the insane instruction choice sensitivity of the P4 uarch.

And on our side, we've just also basically turned to much more dynamic models, with either instruction rewriting or static branches or both.

So I suspect:

Quoted 3 lines

A more radical solution would be to just drop the entire menu for 64-bit kernels and always default to "-march=x86_64 -mtune=generic" and 64 byte L1 cachelines.

would actually be perfectly acceptable. The non-generic choices are all entirely historical and not really very interesting.

Absolutely nobody sane cares about instruction scheduling for the old P4 cores.

In the bad old 32-bit days, we had real code generation issues with basic instruction set, ie the whole "some CPU's are P6-class, but don't actually support the CMOVxx instruction". Those days are gone.

And yes, on x86-64, we still have the whole cmpxchg16b issue, which really is a slight annoyance. But the emphasis is on "slight" - we basically have one back for this in the SLAB code, and a couple of dynamic tests for one particular driver (iommu 128-bit IRTE mode).

So yeah, the cmpxchg16b thing is annoying, but _realistically_ I don't think we care.

And some day we will forget about it, notice that those (few) AMD early 64-bit CPU's can't possibly have been working for the last year or two, and we'll finally just kill that code, but in the meantime the cost of maintaining it is so slight that it's not worth actively going out to kill it.

I do think that the *one* option we might have is "optimize for the current CPU" for people who just want to build their own kernel for their own machine. That's a nice easy choice to give people, and '-march=native' is kind of simple to use.

Will that work when you cross-compile? No. Do we care? Also no. It's basically a simple "you want to optimize for your own local machine" switch.

Maybe that could replace some of the 32-bit choices too?

Linus

#62 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 1 line · Linus Torvalds

On Wed, 4 Dec 2024 at 11:44, Arnd Bergmann <[email protected]> wrote:

...

Quoted 3 lines

Will that work when you cross-compile? No. Do we care? Also no. It's basically a simple "you want to optimize for your own local machine" switch.

Maybe it's okay for 64-bit machines, but for cross-compiling for 32-bit on 64-bit. I dunno what '-march=native -m32' (or equivalent) will give in such cases.

Quoted 1 line

Maybe that could replace some of the 32-bit choices too?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#63 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Linus Torvalds

On Wed, 4 Dec 2024 at 11:44, Arnd Bergmann <[email protected]> wrote:

...

Quoted 7 lines
Quoted 3 lines

Will that work when you cross-compile? No. Do we care? Also no. It's basically a simple "you want to optimize for your own local machine" switch.

Maybe it's okay for 64-bit machines, but for cross-compiling for 32-bit on 64-bit. I dunno what '-march=native -m32' (or equivalent) will give in such cases.

From the compiler's perspective this is nothing special, it just builds a 32-bit binary that can use any instruction supported in 32-bit mode of that 64-bit CPU, the same as the 32-bit CONFIG_MCORE2 option that I disallow in patch 04/11.

Arnd

#64 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 3 lines · Arnd Bergmann
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Linus Torvalds

On Wed, 4 Dec 2024 at 11:44, Arnd Bergmann <[email protected]> wrote:

...

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

Will that work when you cross-compile? No. Do we care? Also no. It's basically a simple "you want to optimize for your own local machine" switch.

Maybe it's okay for 64-bit machines, but for cross-compiling for 32-bit on 64-bit. I dunno what '-march=native -m32' (or equivalent) will give in such cases.

From the compiler's perspective this is nothing special, it just builds a 32-bit binary that can use any instruction supported in 32-bit mode of that 64-bit CPU,

But does this affect building, e.g., for Quark on my Skylake desktop?

Quoted 1 line

the same as the 32-bit CONFIG_MCORE2 option that I disallow in patch 04/11.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#65 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 13 lines · Andy Shevchenko
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Andy Shevchenko
Quoted 5 lines · Linus Torvalds

On Wed, 4 Dec 2024 at 11:44, Arnd Bergmann <[email protected]> wrote:

Will that work when you cross-compile? No. Do we care? Also no. It's basically a simple "you want to optimize for your own local machine" switch.

Maybe it's okay for 64-bit machines, but for cross-compiling for 32-bit on 64-bit. I dunno what '-march=native -m32' (or equivalent) will give in such cases.

Quoted 5 lines
Quoted 3 lines

From the compiler's perspective this is nothing special, it just builds a 32-bit binary that can use any instruction supported in 32-bit mode of that 64-bit CPU,

But does this affect building, e.g., for Quark on my Skylake desktop?

Not at the moment:

- the bug I'm fixing in the patch at hand is currently only present when building 64-bit kernels

- For a 64-bit target such as a Pineview Atom, it's only a problem if the toolchain default is -arch=native and you build with CONFIG_GENERIC_CPU

- If we add support for configuring -march=native and you build using that option on a Skylake host, that would be equally broken for 32-bit Quark or 64-bit Pineview targets that are lacking some of the instructions present in Skylake.

As I said earlier, I don't think we should offer the 'native' option for 32-bit targets at all. For 64-bit, we either decide it's a user error to enable -march=native, or change it to -mtune=native to avoid the problem.

Arnd

#66 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 4 lines · Arnd Bergmann

As I said earlier, I don't think we should offer the 'native' option for 32-bit targets at all. For 64-bit, we either decide it's a user error to enable -march=native, or change it to -mtune=native to avoid the problem.

I've been building my laptop's kernel with -march=native for years, and I'd be happy if this capability were upstream.

Jason

#67 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

In reply to Linus Torvalds
Quoted 9 lines · Linus Torvalds
Quoted 5 lines · Arnd Bergmann

I guess the other side of it is that the current selection between pentium4/core2/k8/bonnell/generic is not much better, given that in practice nobody has any of the pentium4/core2/k8/bonnell variants any more.

So I suspect:

Quoted 8 lines
Quoted 3 lines

A more radical solution would be to just drop the entire menu for 64-bit kernels and always default to "-march=x86_64 -mtune=generic" and 64 byte L1 cachelines.

would actually be perfectly acceptable. The non-generic choices are all entirely historical and not really very interesting.

Absolutely nobody sane cares about instruction scheduling for the old P4 cores.

Ok, I'll do that instead then. This also means I can drop the patch for CONFIG_MATOM.

Quoted 3 lines

In the bad old 32-bit days, we had real code generation issues with basic instruction set, ie the whole "some CPU's are P6-class, but don't actually support the CMOVxx instruction". Those days are gone.

I did come across a remaining odd problem with this, as Crusoe and GeodeLX both identify as Family 5 but have CMOV. Trying to use a CONFIG_M686+CONFIG_X86_GENERIC on these runs fails with a boot error "This kernel requires a 686 CPU but only detected a 586 CPU".

As a result, the Debian 686 kernel binary gets built with CONFIG_MGEODE_LX , which seems mildly wrong but harmful enough to require a change in how we handle the levels.

Quoted 5 lines

And yes, on x86-64, we still have the whole cmpxchg16b issue, which really is a slight annoyance. But the emphasis is on "slight" - we basically have one back for this in the SLAB code, and a couple of dynamic tests for one particular driver (iommu 128-bit IRTE mode).

Quoted 8 lines

So yeah, the cmpxchg16b thing is annoying, but _realistically_ I don't think we care.

And some day we will forget about it, notice that those (few) AMD early 64-bit CPU's can't possibly have been working for the last year or two, and we'll finally just kill that code, but in the meantime the cost of maintaining it is so slight that it's not worth actively going out to kill it.

Right, in particular my hope of turning the runtime detection into always using compile-time configuration for cmpxchg16b is no longer works as I noticed that risc-v has also gained a runtime detection for system_has_cmpxchg128().

Besides cmpxchg16b, I can also see compile-time configuration for some instructions (popcnt, tzcnt, movbe) and for 5-level paging being useful, but not enough so to make up for the configuration complexity.

I still think we will end up needing more compile time configurability like this on arm64 to deal with small-memory embedded systems, e.g. with a specialized cortex-a55 kernel that leaves out support for other CPUs, but this is quite different from the situation on x86-64.

Quoted 8 lines

I do think that the *one* option we might have is "optimize for the current CPU" for people who just want to build their own kernel for their own machine. That's a nice easy choice to give people, and '-march=native' is kind of simple to use.

Will that work when you cross-compile? No. Do we care? Also no. It's basically a simple "you want to optimize for your own local machine" switch.

Sure, I'll add that as a separate patch. Should it be -march=native or -mtune=native though? Using -march= can be faster if it picks up newer instructions, but it will eventually lead to users running into a boot panic if it is accidentally turned on for a kernel that runs on an older machine than it was built on.

Quoted 1 line

Maybe that could replace some of the 32-bit choices too?

Probably not. I spent hours looking through the 32-bit choices in the hope of finding a way that is less of a mess. The current menu mixes up instruction set level (486/586/686), optimization (atom/k7/m3/pentiumm) and platform (elan/geode/pc) options. This is needlessly confusing, but any change to the status quo is going to cause more problems for existing users than it solves. All the "interesting" embedded ones are likely to be cross-compiled anyway, so mtune=native or -march=native wouldn't help them either.

Arnd

#68 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 2 lines · Arnd Bergmann
Quoted 1 line · Linus Torvalds

On Wed, 4 Dec 2024 at 11:44, Arnd Bergmann <[email protected]> wrote:

...

Quoted 4 lines

I did come across a remaining odd problem with this, as Crusoe and GeodeLX both identify as Family 5 but have CMOV. Trying to use a CONFIG_M686+CONFIG_X86_GENERIC on these runs fails with a boot error "This kernel requires a 686 CPU but only detected a 586 CPU".

It might be also that Intel Quark is affected same way.

Quoted 3 lines

As a result, the Debian 686 kernel binary gets built with CONFIG_MGEODE_LX , which seems mildly wrong but harmful enough to require a change in how we handle the levels.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#69 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · Arnd Bergmann
Quoted 1 line · Linus Torvalds

On Wed, 4 Dec 2024 at 11:44, Arnd Bergmann <[email protected]> wrote:

Quoted 8 lines

...

Quoted 4 lines

I did come across a remaining odd problem with this, as Crusoe and GeodeLX both identify as Family 5 but have CMOV. Trying to use a CONFIG_M686+CONFIG_X86_GENERIC on these runs fails with a boot error "This kernel requires a 686 CPU but only detected a 586 CPU".

It might be also that Intel Quark is affected same way.

No, as far as I can tell, Quark correctly identifies as Family 5 and is lacking CMOV. It does seem though that it's currently impossible to configure a kernel for Quark that uses PAE/NX, because there is no CONFIG_MQUARK and it relies on building with CONFIG_M586TSC. If anyone still cared enough about it, they could probably add an MQUARK option that has lets you build the kernel with -march=i586 -mtune=i486 and optional PAE.

The only other one that perhaps gets misidentified is the IDT Winchip that is claimed to support cmpxchg64b but only identifies as Family 4. It's even less likely that anyone cares about this one than the Quark.

Arnd

#70 lore raw

Re: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

In reply to Arnd Bergmann
Quoted 1 line · Arnd Bergmann

On Wed, Dec 4, 2024, at 19:10, Linus Torvalds wrote:

...

Quoted 4 lines

I guess the other side of it is that the current selection between pentium4/core2/k8/bonnell/generic is not much better, given that in practice nobody has any of the pentium4/core2/k8/bonnell variants any more.

Just booted Bonnell device a day ago (WeTab), pity that it has old kernel and I have no time to try anything recent on it...

(Just saying :-)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#71 lore raw

RE: [PATCH 09/11] x86: rework CONFIG_GENERIC_CPU compiler flags

In reply to Arnd Bergmann

From: Arnd Bergmann

Quoted 51 lines

Sent: 04 December 2024 10:31
Building an x86-64 kernel with CONFIG_GENERIC_CPU is documented to run on all CPUs, but the Makefile does not actually pass an -march= argument, instead relying on the default that was used to configure the toolchain.

In many cases, gcc will be configured to -march=x86-64 or -march=k8 for maximum compatibility, but in other cases a distribution default may be either raised to a more recent ISA, or set to -march=native to build for the CPU used for compilation. This still works in the case of building a custom kernel for the local machine.

The point where it breaks down is building a kernel for another machine that is older the the default target. Changing the default to -march=x86-64 would make it work reliable, but possibly produce worse code on distros that intentionally default to a newer ISA.

To allow reliably building a kernel for either the oldest x86-64 CPUs or a more recent level, add three separate options for v1, v2 and v3 of the architecture as defined by gcc and clang and make them all turn on CONFIG_GENERIC_CPU. Based on this it should be possible to change runtime feature detection into build-time detection for things like cmpxchg16b, or possibly gate features that are only available on older architectures.

---
 arch/x86/Kconfig.cpu | 39 ++++++++++++++++++++++++++++++++++-----
 arch/x86/Makefile    |  6 ++++++
 2 files changed, 40 insertions(+), 5 deletions(-)
arch/x86/Kconfig.cpu +1 -3
index 139db904e564..1461a739237b 100644
@@ -260,7 +260,7 @@ endchoice
 choice
 	prompt "x86-64 Processor family"
 	depends on X86_64
-	default GENERIC_CPU
+	default X86_64_V2
 	help
 	  This is the processor type of your CPU. This information is
 	  used for optimizing purposes. In order to compile a kernel
@@ -314,15 +314,44 @@ config MSILVERMONT
 	  early Atom CPUs based on the Bonnell microarchitecture,
 	  such as Atom 230/330, D4xx/D5xx, D2xxx, N2xxx or Z2xxx.
 
-config GENERIC_CPU
-	bool "Generic-x86-64"

arch/x86/Kconfig.cpu config MSILVERMONT · line 324

Quoted 10 lines
arch/x86/Kconfig.cpu +6 -2
+config X86_64_V1
+	bool "Generic x86-64"
 	depends on X86_64
 	help
-	  Generic x86-64 CPU.
-	  Run equally well on all x86-64 CPUs.
+	  Generic x86-64-v1 CPU.
+	  Run equally well on all x86-64 CPUs, including early Pentium-4
+	  variants lacking the sahf and cmpxchg16b instructions as well
+	  as the AMD K8 and Intel Core 2 lacking popcnt.

The 'equally well' text was clearly always wrong (equally badly?) but is now just 'plain wrong'.
Perhaps:
Runs on all x86-64 CPUs including early cpu that lack the sahf, cmpxchg16b and popcnt instructions.

Then for V2 (or whatever it gets called)
Requires support for the sahf, cmpxchg16b and popcnt instructions. This will not run on AMD K8 or Intel before Sandy bridge.

I think someone suggested that run-time detect of AVX/AVX2/AVX512 is fine?

David

Quoted 58 lines
arch/x86/Kconfig.cpu +27 -0
+
+config X86_64_V2
+	bool "Generic x86-64 v2"
+	depends on X86_64
+	help
+	  Generic x86-64-v2 CPU.
+	  Run equally well on all x86-64 CPUs that meet the x86-64-v2
+	  definition as well as those that only miss the optional
+	  SSE3/SSSE3/SSE4.1 portions.
+	  Examples of this include Intel Nehalem and Silvermont,
+	  AMD Bulldozer (K10) and Jaguar as well as VIA Nano that
+	  include popcnt, cmpxchg16b and sahf.
+
+config X86_64_V3
+	bool "Generic x86-64 v3"
+	depends on X86_64
+	help
+	  Generic x86-64-v3 CPU.
+	  Run equally well on all x86-64 CPUs that meet the x86-64-v3
+	  definition as well as those that only miss the optional
+	  AVX/AVX2 portions.
+	  Examples of this include the Intel Haswell and AMD Excavator
+	  microarchitectures that include the bmi1/bmi2, lzncnt, movbe
+	  and xsave instruction set extensions.
 
 endchoice
 
+config GENERIC_CPU
+	def_bool X86_64_V1 || X86_64_V2 || X86_64_V3
+
 config X86_GENERIC
 	bool "Generic x86 support"
 	depends on X86_32
arch/x86/Makefile +6 -1
index 05887ae282f5..1fdc3fc6a54e 100644
@@ -183,6 +183,9 @@ else
         cflags-$(CONFIG_MPSC)		+= -march=nocona
         cflags-$(CONFIG_MCORE2)		+= -march=core2
         cflags-$(CONFIG_MSILVERMONT)	+= -march=silvermont
+        cflags-$(CONFIG_MX86_64_V1)	+= -march=x86-64
+        cflags-$(CONFIG_MX86_64_V2)	+= $(call cc-option,-march=x86-64-v2,-march=x86-64)
+        cflags-$(CONFIG_MX86_64_V3)	+= $(call cc-option,-march=x86-64-v3,-march=x86-64)
         cflags-$(CONFIG_GENERIC_CPU)	+= -mtune=generic
         KBUILD_CFLAGS += $(cflags-y)
 
@@ -190,6 +193,9 @@ else
         rustflags-$(CONFIG_MPSC)	+= -Ctarget-cpu=nocona
         rustflags-$(CONFIG_MCORE2)	+= -Ctarget-cpu=core2
         rustflags-$(CONFIG_MSILVERMONT)	+= -Ctarget-cpu=silvermont
+        rustflags-$(CONFIG_MX86_64_V1)	+= -Ctarget-cpu=x86-64
+        rustflags-$(CONFIG_MX86_64_V2)	+= -Ctarget-cpu=x86-64-v2
+        rustflags-$(CONFIG_MX86_64_V3)	+= -Ctarget-cpu=x86-64-v3
         rustflags-$(CONFIG_GENERIC_CPU)	+= -Ztune-cpu=generic
         KBUILD_RUSTFLAGS += $(rustflags-y)
 
--
Quoted 2 lines

2.39.5

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#72 lore raw

PATCH 10/11 x86: remove old STA2x11 support

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

ST ConneXt STA2x11 was an interface chip for Atom E6xx processors, using a number of components usually found on Arm SoCs. Most of this was merged upstream, but it was never complete enough to actually work and has been abandoned for many years.

We already had an agreement on removing it in 2022, but nobody ever submitted the patch to do it.

Without STA2x11, the CONFIG_X86_32_NON_STANDARD no longer has any use.

---
 arch/x86/Kconfig               |  30 +----
 arch/x86/include/asm/sta2x11.h |  13 --
 arch/x86/pci/Makefile          |   2 -
 arch/x86/pci/sta2x11-fixup.c   | 233 ---------------------------------
 4 files changed, 3 insertions(+), 275 deletions(-)
 delete mode 100644 arch/x86/include/asm/sta2x11.h
 delete mode 100644 arch/x86/pci/sta2x11-fixup.c
arch/x86/Kconfig +3 -27
index fa6dd9ec4bdf..6b5144f10ad7 100644
@@ -543,7 +543,6 @@ config X86_EXTENDED_PLATFORM
 		AMD Elan
 		RDC R-321x SoC
 		SGI 320/540 (Visual Workstation)
-		STA2X11-based (e.g. Northville)
 
 	  64-bit platforms (CONFIG_64BIT=y):
 		Numascale NumaChip
@@ -723,16 +722,6 @@ config X86_RDC321X
 	  as R-8610-(G).
 	  If you don't have one of these chips, you should say N here.
 
-config X86_32_NON_STANDARD
-	bool "Support non-standard 32-bit SMP architectures"
-	depends on X86_32 && SMP
-	depends on X86_EXTENDED_PLATFORM
-	help
-	  This option compiles in the STA2X11 default
-	  subarchitecture.  It is intended for a generic binary
-	  kernel. If you select them all, kernel will probe it one by
-	  one and will fallback to default.
-
 # Alphabetically sorted list of Non standard 32 bit platforms
 
 config X86_SUPPORTS_MEMORY_FAILURE
@@ -744,19 +733,6 @@ config X86_SUPPORTS_MEMORY_FAILURE
 	depends on X86_64 || !SPARSEMEM
 	select ARCH_SUPPORTS_MEMORY_FAILURE
 
-config STA2X11
-	bool "STA2X11 Companion Chip Support"
-	depends on X86_32_NON_STANDARD && PCI
-	select SWIOTLB
-	select MFD_STA2X11
-	select GPIOLIB
-	help
-	  This adds support for boards based on the STA2X11 IO-Hub,
-	  a.k.a. "ConneXt". The chip is used in place of the standard
-	  PC chipset, so all "standard" peripherals are missing. If this
-	  option is selected the kernel will still be able to boot on
-	  standard PC machines.
-
 config X86_32_IRIS
 	tristate "Eurobraille/Iris poweroff module"
 	depends on X86_32
@@ -1094,7 +1070,7 @@ config UP_LATE_INIT
 config X86_UP_APIC
 	bool "Local APIC support on uniprocessors" if !PCI_MSI
 	default PCI_MSI
-	depends on X86_32 && !SMP && !X86_32_NON_STANDARD
+	depends on X86_32 && !SMP
 	help
 	  A local APIC (Advanced Programmable Interrupt Controller) is an
 	  integrated interrupt controller in the CPU. If you have a single-CPU
@@ -1119,7 +1095,7 @@ config X86_UP_IOAPIC
 
 config X86_LOCAL_APIC
 	def_bool y
-	depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI
+	depends on X86_64 || SMP || X86_UP_APIC || PCI_MSI
 	select IRQ_DOMAIN_HIERARCHY
 
 config ACPI_MADT_WAKEUP
@@ -1579,7 +1555,7 @@ config ARCH_FLATMEM_ENABLE
 
 config ARCH_SPARSEMEM_ENABLE
 	def_bool y
-	depends on X86_64 || NUMA || X86_32 || X86_32_NON_STANDARD
+	depends on X86_64 || NUMA || X86_32
 	select SPARSEMEM_STATIC if X86_32
 	select SPARSEMEM_VMEMMAP_ENABLE if X86_64
 
arch/x86/include/asm/sta2x11.h deleted +0 -13
deleted file mode 100644
index e0975e9c4f47..000000000000
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Header file for STMicroelectronics ConneXt (STA2X11) IOHub
- */
-#ifndef __ASM_STA2X11_H
-#define __ASM_STA2X11_H
-
-#include <linux/pci.h>
-
-/* This needs to be called from the MFD to configure its sub-devices */
-struct sta2x11_instance *sta2x11_get_instance(struct pci_dev *pdev);
-
-#endif /* __ASM_STA2X11_H */
arch/x86/pci/Makefile +0 -2
index 48bcada5cabe..4933fb337983 100644
@@ -12,8 +12,6 @@ obj-$(CONFIG_X86_INTEL_CE)      += ce4100.o
 obj-$(CONFIG_ACPI)		+= acpi.o
 obj-y				+= legacy.o irq.o
 
-obj-$(CONFIG_STA2X11)           += sta2x11-fixup.o
-
 obj-$(CONFIG_X86_NUMACHIP)	+= numachip.o
 
 obj-$(CONFIG_X86_INTEL_MID)	+= intel_mid_pci.o
arch/x86/pci/sta2x11-fixup.c deleted +0 -233

233 lines not on this page · raw message

Signature · 1 line
2.39.5
#73 lore raw

Re: [PATCH 10/11] x86: remove old STA2x11 support

Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

ST ConneXt STA2x11 was an interface chip for Atom E6xx processors, using a number of components usually found on Arm SoCs. Most of this was merged upstream, but it was never complete enough to actually work and has been abandoned for many years.

We already had an agreement on removing it in 2022, but nobody ever submitted the patch to do it.

yes sorry for that, I've never found the time to do it.

Thanks a lot
Davide Ciminaghi

#74 lore raw

PATCH 11/11 x86: drop 32-bit KVM host support

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

There are very few 32-bit machines that support KVM, the main exceptions are the "Yonah" Generation Xeon-LV and Core Duo from 2006 and the Atom Z5xx "Silverthorne" from 2008 that were all release just before their 64-bit counterparts.

Using KVM as a host on a 64-bit CPU using a 32-bit kernel generally works fine, but is rather pointless since 64-bit kernels are much better supported and deal better with the memory requirements of VM guests.

Drop all the 32-bit-only portions and the "#ifdef CONFIG_X86_64" checks of the x86 KVM code and add a Kconfig dependency to only allow building this on 64-bit kernels.

Support for 32-bit guests is of course untouched by this.

---
 arch/x86/kvm/Kconfig            |   6 +-
 arch/x86/kvm/Makefile           |   4 +-
 arch/x86/kvm/cpuid.c            |   9 +--
 arch/x86/kvm/emulate.c          |  34 ++------
 arch/x86/kvm/fpu.h              |   4 -
 arch/x86/kvm/hyperv.c           |   5 +-
 arch/x86/kvm/i8254.c            |   4 -
 arch/x86/kvm/kvm_cache_regs.h   |   2 -
 arch/x86/kvm/kvm_emulate.h      |   8 --
 arch/x86/kvm/lapic.c            |   4 -
 arch/x86/kvm/mmu.h              |   4 -
 arch/x86/kvm/mmu/mmu.c          | 134 --------------------------------
 arch/x86/kvm/mmu/mmu_internal.h |   9 ---
 arch/x86/kvm/mmu/paging_tmpl.h  |   9 ---
 arch/x86/kvm/mmu/spte.h         |   5 --
 arch/x86/kvm/mmu/tdp_mmu.h      |   4 -
 arch/x86/kvm/smm.c              |  19 -----
 arch/x86/kvm/svm/sev.c          |   2 -
 arch/x86/kvm/svm/svm.c          |  23 +-----
 arch/x86/kvm/svm/vmenter.S      |  20 -----
 arch/x86/kvm/trace.h            |   4 -
 arch/x86/kvm/vmx/main.c         |   2 -
 arch/x86/kvm/vmx/nested.c       |  24 +-----
 arch/x86/kvm/vmx/vmcs.h         |   2 -
 arch/x86/kvm/vmx/vmenter.S      |  25 +-----
 arch/x86/kvm/vmx/vmx.c          | 117 +---------------------------
 arch/x86/kvm/vmx/vmx.h          |  23 +-----
 arch/x86/kvm/vmx/vmx_ops.h      |   7 --
 arch/x86/kvm/vmx/x86_ops.h      |   2 -
 arch/x86/kvm/x86.c              |  74 ++----------------
 arch/x86/kvm/x86.h              |   4 -
 arch/x86/kvm/xen.c              |  61 ++++++---------
 32 files changed, 54 insertions(+), 600 deletions(-)
arch/x86/kvm/Kconfig +3 -3
index ea2c4f21c1ca..7bdc7639aa8d 100644
@@ -7,6 +7,7 @@ source "virt/kvm/Kconfig"
 
 menuconfig VIRTUALIZATION
 	bool "Virtualization"
+	depends on X86_64
 	default y
 	help
 	  Say Y here to get to see options for using your Linux host to run other
@@ -50,7 +51,6 @@ config KVM_X86
 
 config KVM
 	tristate "Kernel-based Virtual Machine (KVM) support"
-	depends on X86_LOCAL_APIC
 	help
 	  Support hosting fully virtualized guest machines using hardware
 	  virtualization extensions.  You will need a fairly recent
@@ -82,7 +82,7 @@ config KVM_WERROR
 config KVM_SW_PROTECTED_VM
 	bool "Enable support for KVM software-protected VMs"
 	depends on EXPERT
-	depends on KVM && X86_64
+	depends on KVM
 	help
 	  Enable support for KVM software-protected VMs.  Currently, software-
 	  protected VMs are purely a development and testing vehicle for
@@ -141,7 +141,7 @@ config KVM_AMD
 config KVM_AMD_SEV
 	bool "AMD Secure Encrypted Virtualization (SEV) support"
 	default y
-	depends on KVM_AMD && X86_64
+	depends on KVM_AMD
 	depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y && CRYPTO_DEV_CCP_DD=m)
 	select ARCH_HAS_CC_PLATFORM
 	select KVM_GENERIC_PRIVATE_MEM
arch/x86/kvm/Makefile +1 -3
index f9dddb8cb466..46654dc0428f 100644
@@ -8,9 +8,7 @@ include $(srctree)/virt/kvm/Makefile.kvm
 kvm-y			+= x86.o emulate.o i8259.o irq.o lapic.o \
 			   i8254.o ioapic.o irq_comm.o cpuid.o pmu.o mtrr.o \
 			   debugfs.o mmu/mmu.o mmu/page_track.o \
-			   mmu/spte.o
-
-kvm-$(CONFIG_X86_64) += mmu/tdp_iter.o mmu/tdp_mmu.o
+			   mmu/spte.o mmu/tdp_iter.o mmu/tdp_mmu.o
 kvm-$(CONFIG_KVM_HYPERV) += hyperv.o
 kvm-$(CONFIG_KVM_XEN)	+= xen.o
 kvm-$(CONFIG_KVM_SMM)	+= smm.o
arch/x86/kvm/cpuid.c +2 -7
index 097bdc022d0f..d34b6e276ba1 100644
@@ -606,15 +606,10 @@ static __always_inline void kvm_cpu_cap_mask(enum cpuid_leafs leaf, u32 mask)
 
 void kvm_set_cpu_caps(void)
 {
-#ifdef CONFIG_X86_64
 	unsigned int f_gbpages = F(GBPAGES);
 	unsigned int f_lm = F(LM);
 	unsigned int f_xfd = F(XFD);
-#else
-	unsigned int f_gbpages = 0;
-	unsigned int f_lm = 0;
-	unsigned int f_xfd = 0;
-#endif
+
 	memset(kvm_cpu_caps, 0, sizeof(kvm_cpu_caps));
 
 	BUILD_BUG_ON(sizeof(kvm_cpu_caps) - (NKVMCAPINTS * sizeof(*kvm_cpu_caps)) >
@@ -746,7 +741,7 @@ void kvm_set_cpu_caps(void)
 		0 /* Reserved */ | f_lm | F(3DNOWEXT) | F(3DNOW)
 	);
 
-	if (!tdp_enabled && IS_ENABLED(CONFIG_X86_64))
+	if (!tdp_enabled)
 		kvm_cpu_cap_set(X86_FEATURE_GBPAGES);
 
 	kvm_cpu_cap_init_kvm_defined(CPUID_8000_0007_EDX,
arch/x86/kvm/emulate.c +8 -26
index 60986f67c35a..ebac76a10fbd 100644
@@ -265,12 +265,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
 #define EFLAGS_MASK (X86_EFLAGS_OF|X86_EFLAGS_SF|X86_EFLAGS_ZF|X86_EFLAGS_AF|\
 		     X86_EFLAGS_PF|X86_EFLAGS_CF)
 
-#ifdef CONFIG_X86_64
-#define ON64(x) x
-#else
-#define ON64(x)
-#endif
-
 /*
  * fastop functions have a special calling convention:
  *
@@ -341,7 +335,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOP1E(op##b, al) \
 	FOP1E(op##w, ax) \
 	FOP1E(op##l, eax) \
-	ON64(FOP1E(op##q, rax))	\
+	FOP1E(op##q, rax) \
 	FOP_END
 
 /* 1-operand, using src2 (for MUL/DIV r/m) */
@@ -350,7 +344,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOP1E(op, cl) \
 	FOP1E(op, cx) \
 	FOP1E(op, ecx) \
-	ON64(FOP1E(op, rcx)) \
+	FOP1E(op, rcx) \
 	FOP_END
 
 /* 1-operand, using src2 (for MUL/DIV r/m), with exceptions */
@@ -359,7 +353,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOP1EEX(op, cl) \
 	FOP1EEX(op, cx) \
 	FOP1EEX(op, ecx) \
-	ON64(FOP1EEX(op, rcx)) \
+	FOP1EEX(op, rcx) \
 	FOP_END
 
 #define FOP2E(op,  dst, src)	   \
@@ -372,7 +366,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOP2E(op##b, al, dl) \
 	FOP2E(op##w, ax, dx) \
 	FOP2E(op##l, eax, edx) \
-	ON64(FOP2E(op##q, rax, rdx)) \
+	FOP2E(op##q, rax, rdx) \
 	FOP_END
 
 /* 2 operand, word only */
@@ -381,7 +375,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOPNOP() \
 	FOP2E(op##w, ax, dx) \
 	FOP2E(op##l, eax, edx) \
-	ON64(FOP2E(op##q, rax, rdx)) \
+	FOP2E(op##q, rax, rdx) \
 	FOP_END
 
 /* 2 operand, src is CL */
@@ -390,7 +384,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOP2E(op##b, al, cl) \
 	FOP2E(op##w, ax, cl) \
 	FOP2E(op##l, eax, cl) \
-	ON64(FOP2E(op##q, rax, cl)) \
+	FOP2E(op##q, rax, cl) \
 	FOP_END
 
 /* 2 operand, src and dest are reversed */
@@ -399,7 +393,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOP2E(op##b, dl, al) \
 	FOP2E(op##w, dx, ax) \
 	FOP2E(op##l, edx, eax) \
-	ON64(FOP2E(op##q, rdx, rax)) \
+	FOP2E(op##q, rdx, rax) \
 	FOP_END
 
 #define FOP3E(op,  dst, src, src2) \
@@ -413,7 +407,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
 	FOPNOP() \
 	FOP3E(op##w, ax, dx, cl) \
 	FOP3E(op##l, eax, edx, cl) \
-	ON64(FOP3E(op##q, rax, rdx, cl)) \
+	FOP3E(op##q, rax, rdx, cl) \
 	FOP_END
 
 /* Special case for SETcc - 1 instruction per cc */
@@ -1508,7 +1502,6 @@ static int get_descriptor_ptr(struct x86_emulate_ctxt *ctxt,
 
 	addr = dt.address + index * 8;
 
-#ifdef CONFIG_X86_64
 	if (addr >> 32 != 0) {
 		u64 efer = 0;
 
@@ -1516,7 +1509,6 @@ static int get_descriptor_ptr(struct x86_emulate_ctxt *ctxt,
 		if (!(efer & EFER_LMA))
 			addr &= (u32)-1;
 	}
-#endif
 
 	*desc_addr_p = addr;
 	return X86EMUL_CONTINUE;
@@ -2399,7 +2391,6 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt)
 
 	*reg_write(ctxt, VCPU_REGS_RCX) = ctxt->_eip;
 	if (efer & EFER_LMA) {
-#ifdef CONFIG_X86_64
 		*reg_write(ctxt, VCPU_REGS_R11) = ctxt->eflags;
 
 		ops->get_msr(ctxt,
@@ -2410,7 +2401,6 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt)
 		ops->get_msr(ctxt, MSR_SYSCALL_MASK, &msr_data);
 		ctxt->eflags &= ~msr_data;
 		ctxt->eflags |= X86_EFLAGS_FIXED;
-#endif
 	} else {
 		/* legacy mode */
 		ops->get_msr(ctxt, MSR_STAR, &msr_data);
@@ -2575,9 +2565,7 @@ static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt,
 	if (desc_limit_scaled(&tr_seg) < 103)
 		return false;
 	base = get_desc_base(&tr_seg);
-#ifdef CONFIG_X86_64
 	base |= ((u64)base3) << 32;
-#endif
 	r = ops->read_std(ctxt, base + 102, &io_bitmap_ptr, 2, NULL, true);
 	if (r != X86EMUL_CONTINUE)
 		return false;
@@ -2612,7 +2600,6 @@ static void string_registers_quirk(struct x86_emulate_ctxt *ctxt)
 	 * Intel CPUs mask the counter and pointers in quite strange
 	 * manner when ECX is zero due to REP-string optimizations.
 	 */
-#ifdef CONFIG_X86_64
 	u32 eax, ebx, ecx, edx;
 
 	if (ctxt->ad_bytes != 4)
@@ -2634,7 +2621,6 @@ static void string_registers_quirk(struct x86_emulate_ctxt *ctxt)
 	case 0xab:	/* stosd/w */
 		*reg_rmw(ctxt, VCPU_REGS_RDI) &= (u32)-1;
 	}
-#endif
 }
 
 static void save_state_to_tss16(struct x86_emulate_ctxt *ctxt,
@@ -3641,11 +3627,9 @@ static int em_lahf(struct x86_emulate_ctxt *ctxt)
 static int em_bswap(struct x86_emulate_ctxt *ctxt)
 {
 	switch (ctxt->op_bytes) {
-#ifdef CONFIG_X86_64
 	case 8:
 		asm("bswap %0" : "+r"(ctxt->dst.val));
 		break;
-#endif
 	default:
 		asm("bswap %0" : "+r"(*(u32 *)&ctxt->dst.val));
 		break;
@@ -4767,12 +4751,10 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int
 	case X86EMUL_MODE_PROT32:
 		def_op_bytes = def_ad_bytes = 4;
 		break;
-#ifdef CONFIG_X86_64
 	case X86EMUL_MODE_PROT64:
 		def_op_bytes = 4;
 		def_ad_bytes = 8;
 		break;
-#endif
 	default:
 		return EMULATION_FAILED;
 	}
arch/x86/kvm/fpu.h +0 -4
index 3ba12888bf66..56a402dbf24a 100644
@@ -26,7 +26,6 @@ static inline void _kvm_read_sse_reg(int reg, sse128_t *data)
 	case 5: asm("movdqa %%xmm5, %0" : "=m"(*data)); break;
 	case 6: asm("movdqa %%xmm6, %0" : "=m"(*data)); break;
 	case 7: asm("movdqa %%xmm7, %0" : "=m"(*data)); break;
-#ifdef CONFIG_X86_64
 	case 8: asm("movdqa %%xmm8, %0" : "=m"(*data)); break;
 	case 9: asm("movdqa %%xmm9, %0" : "=m"(*data)); break;
 	case 10: asm("movdqa %%xmm10, %0" : "=m"(*data)); break;
@@ -35,7 +34,6 @@ static inline void _kvm_read_sse_reg(int reg, sse128_t *data)
 	case 13: asm("movdqa %%xmm13, %0" : "=m"(*data)); break;
 	case 14: asm("movdqa %%xmm14, %0" : "=m"(*data)); break;
 	case 15: asm("movdqa %%xmm15, %0" : "=m"(*data)); break;
-#endif
 	default: BUG();
 	}
 }
@@ -51,7 +49,6 @@ static inline void _kvm_write_sse_reg(int reg, const sse128_t *data)
 	case 5: asm("movdqa %0, %%xmm5" : : "m"(*data)); break;
 	case 6: asm("movdqa %0, %%xmm6" : : "m"(*data)); break;
 	case 7: asm("movdqa %0, %%xmm7" : : "m"(*data)); break;
-#ifdef CONFIG_X86_64
 	case 8: asm("movdqa %0, %%xmm8" : : "m"(*data)); break;
 	case 9: asm("movdqa %0, %%xmm9" : : "m"(*data)); break;
 	case 10: asm("movdqa %0, %%xmm10" : : "m"(*data)); break;
@@ -60,7 +57,6 @@ static inline void _kvm_write_sse_reg(int reg, const sse128_t *data)
 	case 13: asm("movdqa %0, %%xmm13" : : "m"(*data)); break;
 	case 14: asm("movdqa %0, %%xmm14" : : "m"(*data)); break;
 	case 15: asm("movdqa %0, %%xmm15" : : "m"(*data)); break;
-#endif
 	default: BUG();
 	}
 }
arch/x86/kvm/hyperv.c +1 -4
index 4f0a94346d00..8fb9f45c7465 100644
@@ -2532,14 +2532,11 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 		return 1;
 	}
 
-#ifdef CONFIG_X86_64
 	if (is_64_bit_hypercall(vcpu)) {
 		hc.param = kvm_rcx_read(vcpu);
 		hc.ingpa = kvm_rdx_read(vcpu);
 		hc.outgpa = kvm_r8_read(vcpu);
-	} else
-#endif
-	{
+	} else {
 		hc.param = ((u64)kvm_rdx_read(vcpu) << 32) |
 			    (kvm_rax_read(vcpu) & 0xffffffff);
 		hc.ingpa = ((u64)kvm_rbx_read(vcpu) << 32) |
arch/x86/kvm/i8254.c +0 -4
index cd57a517d04a..b2b63a835797 100644
@@ -40,11 +40,7 @@
 #include "i8254.h"
 #include "x86.h"
 
-#ifndef CONFIG_X86_64
-#define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
-#else
 #define mod_64(x, y) ((x) % (y))
-#endif
 
 #define RW_STATE_LSB 1
 #define RW_STATE_MSB 2
arch/x86/kvm/kvm_cache_regs.h +0 -2
index 36a8786db291..66d12dc5b243 100644
@@ -32,7 +32,6 @@ BUILD_KVM_GPR_ACCESSORS(rdx, RDX)
 BUILD_KVM_GPR_ACCESSORS(rbp, RBP)
 BUILD_KVM_GPR_ACCESSORS(rsi, RSI)
 BUILD_KVM_GPR_ACCESSORS(rdi, RDI)
-#ifdef CONFIG_X86_64
 BUILD_KVM_GPR_ACCESSORS(r8,  R8)
 BUILD_KVM_GPR_ACCESSORS(r9,  R9)
 BUILD_KVM_GPR_ACCESSORS(r10, R10)
@@ -41,7 +40,6 @@ BUILD_KVM_GPR_ACCESSORS(r12, R12)
 BUILD_KVM_GPR_ACCESSORS(r13, R13)
 BUILD_KVM_GPR_ACCESSORS(r14, R14)
 BUILD_KVM_GPR_ACCESSORS(r15, R15)
-#endif
 
 /*
  * Using the register cache from interrupt context is generally not allowed, as
arch/x86/kvm/kvm_emulate.h +0 -8
index 10495fffb890..970761100e26 100644
@@ -305,11 +305,7 @@ typedef void (*fastop_t)(struct fastop *);
  * also uses _eip, RIP cannot be a register operand nor can it be an operand in
  * a ModRM or SIB byte.
  */
-#ifdef CONFIG_X86_64
 #define NR_EMULATOR_GPRS	16
-#else
-#define NR_EMULATOR_GPRS	8
-#endif
 
 struct x86_emulate_ctxt {
 	void *vcpu;
@@ -501,11 +497,7 @@ enum x86_intercept {
 };
 
 /* Host execution mode. */
-#if defined(CONFIG_X86_32)
-#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32
-#elif defined(CONFIG_X86_64)
 #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64
-#endif
 
 int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int emulation_type);
 bool x86_page_table_writing_insn(struct x86_emulate_ctxt *ctxt);
arch/x86/kvm/lapic.c +0 -4
index 3c83951c619e..53a10a0ca03b 100644
@@ -46,11 +46,7 @@
 #include "hyperv.h"
 #include "smm.h"
 
-#ifndef CONFIG_X86_64
-#define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
-#else
 #define mod_64(x, y) ((x) % (y))
-#endif
 
 /* 14 is the version for Xeon and Pentium 8.4.8*/
 #define APIC_VERSION			0x14UL
arch/x86/kvm/mmu.h +0 -4
index e9322358678b..91e0969d23d7 100644
@@ -238,11 +238,7 @@ static inline bool kvm_shadow_root_allocated(struct kvm *kvm)
 	return smp_load_acquire(&kvm->arch.shadow_root_allocated);
 }
 
-#ifdef CONFIG_X86_64
 extern bool tdp_mmu_enabled;
-#else
-#define tdp_mmu_enabled false
-#endif
 
 static inline bool kvm_memslots_have_rmaps(struct kvm *kvm)
 {
arch/x86/kvm/mmu/mmu.c +0 -134

210 lines not on this page · raw message

arch/x86/kvm/mmu/mmu_internal.h +0 -9
index b00abbe3f6cf..34cfffc32476 100644
@@ -116,21 +116,12 @@ struct kvm_mmu_page {
 	 * isn't properly aligned, etc...
 	 */
 	struct list_head possible_nx_huge_page_link;
-#ifdef CONFIG_X86_32
-	/*
-	 * Used out of the mmu-lock to avoid reading spte values while an
-	 * update is in progress; see the comments in __get_spte_lockless().
-	 */
-	int clear_spte_count;
-#endif
 
 	/* Number of writes since the last time traversal visited this page.  */
 	atomic_t write_flooding_count;
 
-#ifdef CONFIG_X86_64
 	/* Used for freeing the page asynchronously if it is a TDP MMU page. */
 	struct rcu_head rcu_head;
-#endif
 };
 
 extern struct kmem_cache *mmu_page_header_cache;
arch/x86/kvm/mmu/paging_tmpl.h +0 -9
index f4711674c47b..fa6493641429 100644
@@ -29,11 +29,7 @@
 	#define PT_GUEST_DIRTY_SHIFT PT_DIRTY_SHIFT
 	#define PT_GUEST_ACCESSED_SHIFT PT_ACCESSED_SHIFT
 	#define PT_HAVE_ACCESSED_DIRTY(mmu) true
-	#ifdef CONFIG_X86_64
 	#define PT_MAX_FULL_LEVELS PT64_ROOT_MAX_LEVEL
-	#else
-	#define PT_MAX_FULL_LEVELS 2
-	#endif
 #elif PTTYPE == 32
 	#define pt_element_t u32
 	#define guest_walker guest_walker32
@@ -862,11 +858,6 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
 	gpa_t gpa = INVALID_GPA;
 	int r;
 
-#ifndef CONFIG_X86_64
-	/* A 64-bit GVA should be impossible on 32-bit KVM. */
-	WARN_ON_ONCE((addr >> 32) && mmu == vcpu->arch.walk_mmu);
-#endif
-
 	r = FNAME(walk_addr_generic)(&walker, vcpu, mmu, addr, access);
 
 	if (r) {
arch/x86/kvm/mmu/spte.h +0 -5
index f332b33bc817..fd776ab25cc3 100644
@@ -160,13 +160,8 @@ static_assert(MMIO_SPTE_GEN_LOW_BITS == 8 && MMIO_SPTE_GEN_HIGH_BITS == 11);
  * For VMX EPT, bit 63 is ignored if #VE is disabled. (EPT_VIOLATION_VE=0)
  *              bit 63 is #VE suppress if #VE is enabled. (EPT_VIOLATION_VE=1)
  */
-#ifdef CONFIG_X86_64
 #define SHADOW_NONPRESENT_VALUE	BIT_ULL(63)
 static_assert(!(SHADOW_NONPRESENT_VALUE & SPTE_MMU_PRESENT_MASK));
-#else
-#define SHADOW_NONPRESENT_VALUE	0ULL
-#endif
-
 
 /*
  * True if A/D bits are supported in hardware and are enabled by KVM.  When
arch/x86/kvm/mmu/tdp_mmu.h +0 -4
index f03ca0dd13d9..c137fdd6b347 100644
@@ -67,10 +67,6 @@ int kvm_tdp_mmu_get_walk(struct kvm_vcpu *vcpu, u64 addr, u64 *sptes,
 u64 *kvm_tdp_mmu_fast_pf_get_last_sptep(struct kvm_vcpu *vcpu, gfn_t gfn,
 					u64 *spte);
 
-#ifdef CONFIG_X86_64
 static inline bool is_tdp_mmu_page(struct kvm_mmu_page *sp) { return sp->tdp_mmu_page; }
-#else
-static inline bool is_tdp_mmu_page(struct kvm_mmu_page *sp) { return false; }
-#endif
 
 #endif /* __KVM_X86_MMU_TDP_MMU_H */
arch/x86/kvm/smm.c +0 -19
index 85241c0c7f56..ad764adac3de 100644
@@ -165,7 +165,6 @@ static void enter_smm_save_seg_32(struct kvm_vcpu *vcpu,
 	state->flags = enter_smm_get_segment_flags(&seg);
 }
 
-#ifdef CONFIG_X86_64
 static void enter_smm_save_seg_64(struct kvm_vcpu *vcpu,
 				  struct kvm_smm_seg_state_64 *state,
 				  int n)
@@ -178,7 +177,6 @@ static void enter_smm_save_seg_64(struct kvm_vcpu *vcpu,
 	state->limit = seg.limit;
 	state->base = seg.base;
 }
-#endif
 
 static void enter_smm_save_state_32(struct kvm_vcpu *vcpu,
 				    struct kvm_smram_state_32 *smram)
@@ -223,7 +221,6 @@ static void enter_smm_save_state_32(struct kvm_vcpu *vcpu,
 	smram->int_shadow = kvm_x86_call(get_interrupt_shadow)(vcpu);
 }
 
-#ifdef CONFIG_X86_64
 static void enter_smm_save_state_64(struct kvm_vcpu *vcpu,
 				    struct kvm_smram_state_64 *smram)
 {
@@ -269,7 +266,6 @@ static void enter_smm_save_state_64(struct kvm_vcpu *vcpu,
 
 	smram->int_shadow = kvm_x86_call(get_interrupt_shadow)(vcpu);
 }
-#endif
 
 void enter_smm(struct kvm_vcpu *vcpu)
 {
@@ -282,11 +278,9 @@ void enter_smm(struct kvm_vcpu *vcpu)
 
 	memset(smram.bytes, 0, sizeof(smram.bytes));
 
-#ifdef CONFIG_X86_64
 	if (guest_cpuid_has(vcpu, X86_FEATURE_LM))
 		enter_smm_save_state_64(vcpu, &smram.smram64);
 	else
-#endif
 		enter_smm_save_state_32(vcpu, &smram.smram32);
 
 	/*
@@ -352,11 +346,9 @@ void enter_smm(struct kvm_vcpu *vcpu)
 	kvm_set_segment(vcpu, &ds, VCPU_SREG_GS);
 	kvm_set_segment(vcpu, &ds, VCPU_SREG_SS);
 
-#ifdef CONFIG_X86_64
 	if (guest_cpuid_has(vcpu, X86_FEATURE_LM))
 		if (kvm_x86_call(set_efer)(vcpu, 0))
 			goto error;
-#endif
 
 	kvm_update_cpuid_runtime(vcpu);
 	kvm_mmu_reset_context(vcpu);
@@ -394,8 +386,6 @@ static int rsm_load_seg_32(struct kvm_vcpu *vcpu,
 	return X86EMUL_CONTINUE;
 }
 
-#ifdef CONFIG_X86_64
-
 static int rsm_load_seg_64(struct kvm_vcpu *vcpu,
 			   const struct kvm_smm_seg_state_64 *state,
 			   int n)
@@ -409,7 +399,6 @@ static int rsm_load_seg_64(struct kvm_vcpu *vcpu,
 	kvm_set_segment(vcpu, &desc, n);
 	return X86EMUL_CONTINUE;
 }
-#endif
 
 static int rsm_enter_protected_mode(struct kvm_vcpu *vcpu,
 				    u64 cr0, u64 cr3, u64 cr4)
@@ -507,7 +496,6 @@ static int rsm_load_state_32(struct x86_emulate_ctxt *ctxt,
 	return r;
 }
 
-#ifdef CONFIG_X86_64
 static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt,
 			     const struct kvm_smram_state_64 *smstate)
 {
@@ -559,7 +547,6 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt,
 
 	return X86EMUL_CONTINUE;
 }
-#endif
 
 int emulator_leave_smm(struct x86_emulate_ctxt *ctxt)
 {
@@ -585,7 +572,6 @@ int emulator_leave_smm(struct x86_emulate_ctxt *ctxt)
 	 * CR0/CR3/CR4/EFER.  It's all a bit more complicated if the vCPU
 	 * supports long mode.
 	 */
-#ifdef CONFIG_X86_64
 	if (guest_cpuid_has(vcpu, X86_FEATURE_LM)) {
 		struct kvm_segment cs_desc;
 		unsigned long cr4;
@@ -601,14 +587,12 @@ int emulator_leave_smm(struct x86_emulate_ctxt *ctxt)
 		cs_desc.s = cs_desc.g = cs_desc.present = 1;
 		kvm_set_segment(vcpu, &cs_desc, VCPU_SREG_CS);
 	}
-#endif
 
 	/* For the 64-bit case, this will clear EFER.LMA.  */
 	cr0 = kvm_read_cr0(vcpu);
 	if (cr0 & X86_CR0_PE)
 		kvm_set_cr0(vcpu, cr0 & ~(X86_CR0_PG | X86_CR0_PE));
 
-#ifdef CONFIG_X86_64
 	if (guest_cpuid_has(vcpu, X86_FEATURE_LM)) {
 		unsigned long cr4, efer;
 
@@ -621,7 +605,6 @@ int emulator_leave_smm(struct x86_emulate_ctxt *ctxt)
 		efer = 0;
 		kvm_set_msr(vcpu, MSR_EFER, efer);
 	}
-#endif
 
 	/*
 	 * FIXME: When resuming L2 (a.k.a. guest mode), the transition to guest
@@ -633,11 +616,9 @@ int emulator_leave_smm(struct x86_emulate_ctxt *ctxt)
 	if (kvm_x86_call(leave_smm)(vcpu, &smram))
 		return X86EMUL_UNHANDLEABLE;
 
-#ifdef CONFIG_X86_64
 	if (guest_cpuid_has(vcpu, X86_FEATURE_LM))
 		ret = rsm_load_state_64(ctxt, &smram.smram64);
 	else
-#endif
 		ret = rsm_load_state_32(ctxt, &smram.smram32);
 
 	/*
arch/x86/kvm/svm/sev.c +0 -2
index 943bd074a5d3..a78cdb1a9314 100644
@@ -830,7 +830,6 @@ static int sev_es_sync_vmsa(struct vcpu_svm *svm)
 	save->rbp = svm->vcpu.arch.regs[VCPU_REGS_RBP];
 	save->rsi = svm->vcpu.arch.regs[VCPU_REGS_RSI];
 	save->rdi = svm->vcpu.arch.regs[VCPU_REGS_RDI];
-#ifdef CONFIG_X86_64
 	save->r8  = svm->vcpu.arch.regs[VCPU_REGS_R8];
 	save->r9  = svm->vcpu.arch.regs[VCPU_REGS_R9];
 	save->r10 = svm->vcpu.arch.regs[VCPU_REGS_R10];
@@ -839,7 +838,6 @@ static int sev_es_sync_vmsa(struct vcpu_svm *svm)
 	save->r13 = svm->vcpu.arch.regs[VCPU_REGS_R13];
 	save->r14 = svm->vcpu.arch.regs[VCPU_REGS_R14];
 	save->r15 = svm->vcpu.arch.regs[VCPU_REGS_R15];
-#endif
 	save->rip = svm->vcpu.arch.regs[VCPU_REGS_RIP];
 
 	/* Sync some non-GPR registers before encrypting */
arch/x86/kvm/svm/svm.c +1 -22
index dd15cc635655..aeb24495cf64 100644
@@ -89,14 +89,12 @@ static const struct svm_direct_access_msrs {
 	{ .index = MSR_IA32_SYSENTER_CS,		.always = true  },
 	{ .index = MSR_IA32_SYSENTER_EIP,		.always = false },
 	{ .index = MSR_IA32_SYSENTER_ESP,		.always = false },
-#ifdef CONFIG_X86_64
 	{ .index = MSR_GS_BASE,				.always = true  },
 	{ .index = MSR_FS_BASE,				.always = true  },
 	{ .index = MSR_KERNEL_GS_BASE,			.always = true  },
 	{ .index = MSR_LSTAR,				.always = true  },
 	{ .index = MSR_CSTAR,				.always = true  },
 	{ .index = MSR_SYSCALL_MASK,			.always = true  },
-#endif
 	{ .index = MSR_IA32_SPEC_CTRL,			.always = false },
 	{ .index = MSR_IA32_PRED_CMD,			.always = false },
 	{ .index = MSR_IA32_FLUSH_CMD,			.always = false },
@@ -288,11 +286,7 @@ static void svm_flush_tlb_current(struct kvm_vcpu *vcpu);
 
 static int get_npt_level(void)
 {
-#ifdef CONFIG_X86_64
 	return pgtable_l5_enabled() ? PT64_ROOT_5LEVEL : PT64_ROOT_4LEVEL;
-#else
-	return PT32E_ROOT_LEVEL;
-#endif
 }
 
 int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
@@ -1860,7 +1854,6 @@ void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 	u64 hcr0 = cr0;
 	bool old_paging = is_paging(vcpu);
 
-#ifdef CONFIG_X86_64
 	if (vcpu->arch.efer & EFER_LME) {
 		if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) {
 			vcpu->arch.efer |= EFER_LMA;
@@ -1874,7 +1867,6 @@ void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 				svm->vmcb->save.efer &= ~(EFER_LMA | EFER_LME);
 		}
 	}
-#endif
 	vcpu->arch.cr0 = cr0;
 
 	if (!npt_enabled) {
@@ -2871,7 +2863,6 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 	case MSR_STAR:
 		msr_info->data = svm->vmcb01.ptr->save.star;
 		break;
-#ifdef CONFIG_X86_64
 	case MSR_LSTAR:
 		msr_info->data = svm->vmcb01.ptr->save.lstar;
 		break;
@@ -2890,7 +2881,6 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 	case MSR_SYSCALL_MASK:
 		msr_info->data = svm->vmcb01.ptr->save.sfmask;
 		break;
-#endif
 	case MSR_IA32_SYSENTER_CS:
 		msr_info->data = svm->vmcb01.ptr->save.sysenter_cs;
 		break;
@@ -3102,7 +3092,6 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
 	case MSR_STAR:
 		svm->vmcb01.ptr->save.star = data;
 		break;
-#ifdef CONFIG_X86_64
 	case MSR_LSTAR:
 		svm->vmcb01.ptr->save.lstar = data;
 		break;
@@ -3121,7 +3110,6 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
 	case MSR_SYSCALL_MASK:
 		svm->vmcb01.ptr->save.sfmask = data;
 		break;
-#endif
 	case MSR_IA32_SYSENTER_CS:
 		svm->vmcb01.ptr->save.sysenter_cs = data;
 		break;
@@ -5323,14 +5311,6 @@ static __init int svm_hardware_setup(void)
 		kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE);
 	}
 
-	/*
-	 * KVM's MMU doesn't support using 2-level paging for itself, and thus
-	 * NPT isn't supported if the host is using 2-level paging since host
-	 * CR4 is unchanged on VMRUN.
-	 */
-	if (!IS_ENABLED(CONFIG_X86_64) && !IS_ENABLED(CONFIG_X86_PAE))
-		npt_enabled = false;
-
 	if (!boot_cpu_has(X86_FEATURE_NPT))
 		npt_enabled = false;
 
@@ -5378,8 +5358,7 @@ static __init int svm_hardware_setup(void)
 
 	if (vls) {
 		if (!npt_enabled ||
-		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
-		    !IS_ENABLED(CONFIG_X86_64)) {
+		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD)) {
 			vls = false;
 		} else {
 			pr_info("Virtual VMLOAD VMSAVE supported\n");
arch/x86/kvm/svm/vmenter.S +0 -20
index 2ed80aea3bb1..2e8c0f5a238a 100644
@@ -19,7 +19,6 @@
 #define VCPU_RSI	(SVM_vcpu_arch_regs + __VCPU_REGS_RSI * WORD_SIZE)
 #define VCPU_RDI	(SVM_vcpu_arch_regs + __VCPU_REGS_RDI * WORD_SIZE)
 
-#ifdef CONFIG_X86_64
 #define VCPU_R8		(SVM_vcpu_arch_regs + __VCPU_REGS_R8  * WORD_SIZE)
 #define VCPU_R9		(SVM_vcpu_arch_regs + __VCPU_REGS_R9  * WORD_SIZE)
 #define VCPU_R10	(SVM_vcpu_arch_regs + __VCPU_REGS_R10 * WORD_SIZE)
@@ -28,7 +27,6 @@
 #define VCPU_R13	(SVM_vcpu_arch_regs + __VCPU_REGS_R13 * WORD_SIZE)
 #define VCPU_R14	(SVM_vcpu_arch_regs + __VCPU_REGS_R14 * WORD_SIZE)
 #define VCPU_R15	(SVM_vcpu_arch_regs + __VCPU_REGS_R15 * WORD_SIZE)
-#endif
 
 #define SVM_vmcb01_pa	(SVM_vmcb01 + KVM_VMCB_pa)
 
@@ -101,15 +99,10 @@
 SYM_FUNC_START(__svm_vcpu_run)
 	push %_ASM_BP
 	mov  %_ASM_SP, %_ASM_BP
-#ifdef CONFIG_X86_64
 	push %r15
 	push %r14
 	push %r13
 	push %r12
-#else
-	push %edi
-	push %esi
-#endif
 	push %_ASM_BX
 
 	/*
@@ -157,7 +150,6 @@ SYM_FUNC_START(__svm_vcpu_run)
 	mov VCPU_RBX(%_ASM_DI), %_ASM_BX
 	mov VCPU_RBP(%_ASM_DI), %_ASM_BP
 	mov VCPU_RSI(%_ASM_DI), %_ASM_SI
-#ifdef CONFIG_X86_64
 	mov VCPU_R8 (%_ASM_DI),  %r8
 	mov VCPU_R9 (%_ASM_DI),  %r9
 	mov VCPU_R10(%_ASM_DI), %r10
@@ -166,7 +158,6 @@ SYM_FUNC_START(__svm_vcpu_run)
 	mov VCPU_R13(%_ASM_DI), %r13
 	mov VCPU_R14(%_ASM_DI), %r14
 	mov VCPU_R15(%_ASM_DI), %r15
-#endif
 	mov VCPU_RDI(%_ASM_DI), %_ASM_DI
 
 	/* Enter guest mode */
@@ -186,7 +177,6 @@ SYM_FUNC_START(__svm_vcpu_run)
 	mov %_ASM_BP,   VCPU_RBP(%_ASM_AX)
 	mov %_ASM_SI,   VCPU_RSI(%_ASM_AX)
 	mov %_ASM_DI,   VCPU_RDI(%_ASM_AX)
-#ifdef CONFIG_X86_64
 	mov %r8,  VCPU_R8 (%_ASM_AX)
 	mov %r9,  VCPU_R9 (%_ASM_AX)
 	mov %r10, VCPU_R10(%_ASM_AX)
@@ -195,7 +185,6 @@ SYM_FUNC_START(__svm_vcpu_run)
 	mov %r13, VCPU_R13(%_ASM_AX)
 	mov %r14, VCPU_R14(%_ASM_AX)
 	mov %r15, VCPU_R15(%_ASM_AX)
-#endif
 
 	/* @svm can stay in RDI from now on.  */
 	mov %_ASM_AX, %_ASM_DI
@@ -239,7 +228,6 @@ SYM_FUNC_START(__svm_vcpu_run)
 	xor %ebp, %ebp
 	xor %esi, %esi
 	xor %edi, %edi
-#ifdef CONFIG_X86_64
 	xor %r8d,  %r8d
 	xor %r9d,  %r9d
 	xor %r10d, %r10d
@@ -248,22 +236,16 @@ SYM_FUNC_START(__svm_vcpu_run)
 	xor %r13d, %r13d
 	xor %r14d, %r14d
 	xor %r15d, %r15d
-#endif
 
 	/* "Pop" @spec_ctrl_intercepted.  */
 	pop %_ASM_BX
 
 	pop %_ASM_BX
 
-#ifdef CONFIG_X86_64
 	pop %r12
 	pop %r13
 	pop %r14
 	pop %r15
-#else
-	pop %esi
-	pop %edi
-#endif
 	pop %_ASM_BP
 	RET
 
@@ -293,7 +275,6 @@ SYM_FUNC_END(__svm_vcpu_run)
 #ifdef CONFIG_KVM_AMD_SEV
 
 
-#ifdef CONFIG_X86_64
 #define SEV_ES_GPRS_BASE 0x300
 #define SEV_ES_RBX	(SEV_ES_GPRS_BASE + __VCPU_REGS_RBX * WORD_SIZE)
 #define SEV_ES_RBP	(SEV_ES_GPRS_BASE + __VCPU_REGS_RBP * WORD_SIZE)
@@ -303,7 +284,6 @@ SYM_FUNC_END(__svm_vcpu_run)
 #define SEV_ES_R13	(SEV_ES_GPRS_BASE + __VCPU_REGS_R13 * WORD_SIZE)
 #define SEV_ES_R14	(SEV_ES_GPRS_BASE + __VCPU_REGS_R14 * WORD_SIZE)
 #define SEV_ES_R15	(SEV_ES_GPRS_BASE + __VCPU_REGS_R15 * WORD_SIZE)
-#endif
 
 /**
  * __svm_sev_es_vcpu_run - Run a SEV-ES vCPU via a transition to SVM guest mode
arch/x86/kvm/trace.h +0 -4
index d3aeffd6ae75..0bceb33e1d2c 100644
@@ -897,8 +897,6 @@ TRACE_EVENT(kvm_write_tsc_offset,
 		  __entry->previous_tsc_offset, __entry->next_tsc_offset)
 );
 
-#ifdef CONFIG_X86_64
-
 #define host_clocks					\
 	{VDSO_CLOCKMODE_NONE, "none"},			\
 	{VDSO_CLOCKMODE_TSC,  "tsc"}			\
@@ -955,8 +953,6 @@ TRACE_EVENT(kvm_track_tsc,
 		  __print_symbolic(__entry->host_clock, host_clocks))
 );
 
-#endif /* CONFIG_X86_64 */
-
 /*
  * Tracepoint for PML full VMEXIT.
  */
arch/x86/kvm/vmx/main.c +0 -2
index 92d35cc6cd15..32a8dc508cd7 100644
@@ -134,10 +134,8 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
 	.pi_update_irte = vmx_pi_update_irte,
 	.pi_start_assignment = vmx_pi_start_assignment,
 
-#ifdef CONFIG_X86_64
 	.set_hv_timer = vmx_set_hv_timer,
 	.cancel_hv_timer = vmx_cancel_hv_timer,
-#endif
 
 	.setup_mce = vmx_setup_mce,
 
arch/x86/kvm/vmx/nested.c +2 -22
index aa78b6f38dfe..3e7f004d1788 100644
@@ -86,11 +86,7 @@ static void init_vmcs_shadow_fields(void)
 
 		clear_bit(field, vmx_vmread_bitmap);
 		if (field & 1)
-#ifdef CONFIG_X86_64
 			continue;
-#else
-			entry.offset += sizeof(u32);
-#endif
 		shadow_read_only_fields[j++] = entry;
 	}
 	max_shadow_read_only_fields = j;
@@ -134,11 +130,7 @@ static void init_vmcs_shadow_fields(void)
 		clear_bit(field, vmx_vmwrite_bitmap);
 		clear_bit(field, vmx_vmread_bitmap);
 		if (field & 1)
-#ifdef CONFIG_X86_64
 			continue;
-#else
-			entry.offset += sizeof(u32);
-#endif
 		shadow_read_write_fields[j++] = entry;
 	}
 	max_shadow_read_write_fields = j;
@@ -283,10 +275,8 @@ static void vmx_sync_vmcs_host_state(struct vcpu_vmx *vmx,
 
 	vmx_set_host_fs_gs(dest, src->fs_sel, src->gs_sel, src->fs_base, src->gs_base);
 	dest->ldt_sel = src->ldt_sel;
-#ifdef CONFIG_X86_64
 	dest->ds_sel = src->ds_sel;
 	dest->es_sel = src->es_sel;
-#endif
 }
 
 static void vmx_switch_vmcs(struct kvm_vcpu *vcpu, struct loaded_vmcs *vmcs)
@@ -695,7 +685,6 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
 	 * Always check vmcs01's bitmap to honor userspace MSR filters and any
 	 * other runtime changes to vmcs01's bitmap, e.g. dynamic pass-through.
 	 */
-#ifdef CONFIG_X86_64
 	nested_vmx_set_intercept_for_msr(vmx, msr_bitmap_l1, msr_bitmap_l0,
 					 MSR_FS_BASE, MSR_TYPE_RW);
 
@@ -704,7 +693,7 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
 
 	nested_vmx_set_intercept_for_msr(vmx, msr_bitmap_l1, msr_bitmap_l0,
 					 MSR_KERNEL_GS_BASE, MSR_TYPE_RW);
-#endif
+
 	nested_vmx_set_intercept_for_msr(vmx, msr_bitmap_l1, msr_bitmap_l0,
 					 MSR_IA32_SPEC_CTRL, MSR_TYPE_RW);
 
@@ -2375,11 +2364,9 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct loaded_vmcs *vmcs0
 	vmx->nested.l1_tpr_threshold = -1;
 	if (exec_control & CPU_BASED_TPR_SHADOW)
 		vmcs_write32(TPR_THRESHOLD, vmcs12->tpr_threshold);
-#ifdef CONFIG_X86_64
 	else
 		exec_control |= CPU_BASED_CR8_LOAD_EXITING |
 				CPU_BASED_CR8_STORE_EXITING;
-#endif
 
 	/*
 	 * A vmexit (to either L1 hypervisor or L0 userspace) is always needed
@@ -3002,11 +2989,10 @@ static int nested_vmx_check_controls(struct kvm_vcpu *vcpu,
 static int nested_vmx_check_address_space_size(struct kvm_vcpu *vcpu,
 				       struct vmcs12 *vmcs12)
 {
-#ifdef CONFIG_X86_64
 	if (CC(!!(vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE) !=
 		!!(vcpu->arch.efer & EFER_LMA)))
 		return -EINVAL;
-#endif
+
 	return 0;
 }
 
@@ -6979,9 +6965,7 @@ static void nested_vmx_setup_exit_ctls(struct vmcs_config *vmcs_conf,
 
 	msrs->exit_ctls_high = vmcs_conf->vmexit_ctrl;
 	msrs->exit_ctls_high &=
-#ifdef CONFIG_X86_64
 		VM_EXIT_HOST_ADDR_SPACE_SIZE |
-#endif
 		VM_EXIT_LOAD_IA32_PAT | VM_EXIT_SAVE_IA32_PAT |
 		VM_EXIT_CLEAR_BNDCFGS;
 	msrs->exit_ctls_high |=
@@ -7002,9 +6986,7 @@ static void nested_vmx_setup_entry_ctls(struct vmcs_config *vmcs_conf,
 
 	msrs->entry_ctls_high = vmcs_conf->vmentry_ctrl;
 	msrs->entry_ctls_high &=
-#ifdef CONFIG_X86_64
 		VM_ENTRY_IA32E_MODE |
-#endif
 		VM_ENTRY_LOAD_IA32_PAT | VM_ENTRY_LOAD_BNDCFGS;
 	msrs->entry_ctls_high |=
 		(VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER |
@@ -7027,9 +7009,7 @@ static void nested_vmx_setup_cpubased_ctls(struct vmcs_config *vmcs_conf,
 		CPU_BASED_HLT_EXITING | CPU_BASED_INVLPG_EXITING |
 		CPU_BASED_MWAIT_EXITING | CPU_BASED_CR3_LOAD_EXITING |
 		CPU_BASED_CR3_STORE_EXITING |
-#ifdef CONFIG_X86_64
 		CPU_BASED_CR8_LOAD_EXITING | CPU_BASED_CR8_STORE_EXITING |
-#endif
 		CPU_BASED_MOV_DR_EXITING | CPU_BASED_UNCOND_IO_EXITING |
 		CPU_BASED_USE_IO_BITMAPS | CPU_BASED_MONITOR_TRAP_FLAG |
 		CPU_BASED_MONITOR_EXITING | CPU_BASED_RDPMC_EXITING |
arch/x86/kvm/vmx/vmcs.h +0 -2
index b25625314658..487137da7860 100644
@@ -39,9 +39,7 @@ struct vmcs_host_state {
 	unsigned long rsp;
 
 	u16           fs_sel, gs_sel, ldt_sel;
-#ifdef CONFIG_X86_64
 	u16           ds_sel, es_sel;
-#endif
 };
 
 struct vmcs_controls_shadow {
arch/x86/kvm/vmx/vmenter.S +1 -24
index f6986dee6f8c..5a548724ca1f 100644
@@ -20,7 +20,6 @@
 #define VCPU_RSI	__VCPU_REGS_RSI * WORD_SIZE
 #define VCPU_RDI	__VCPU_REGS_RDI * WORD_SIZE
 
-#ifdef CONFIG_X86_64
 #define VCPU_R8		__VCPU_REGS_R8  * WORD_SIZE
 #define VCPU_R9		__VCPU_REGS_R9  * WORD_SIZE
 #define VCPU_R10	__VCPU_REGS_R10 * WORD_SIZE
@@ -29,7 +28,6 @@
 #define VCPU_R13	__VCPU_REGS_R13 * WORD_SIZE
 #define VCPU_R14	__VCPU_REGS_R14 * WORD_SIZE
 #define VCPU_R15	__VCPU_REGS_R15 * WORD_SIZE
-#endif
 
 .macro VMX_DO_EVENT_IRQOFF call_insn call_target
 	/*
@@ -40,7 +38,6 @@
 	push %_ASM_BP
 	mov %_ASM_SP, %_ASM_BP
 
-#ifdef CONFIG_X86_64
 	/*
 	 * Align RSP to a 16-byte boundary (to emulate CPU behavior) before
 	 * creating the synthetic interrupt stack frame for the IRQ/NMI.
@@ -48,7 +45,6 @@
 	and  $-16, %rsp
 	push $__KERNEL_DS
 	push %rbp
-#endif
 	pushf
 	push $__KERNEL_CS
 	\call_insn \call_target
@@ -79,15 +75,10 @@
 SYM_FUNC_START(__vmx_vcpu_run)
 	push %_ASM_BP
 	mov  %_ASM_SP, %_ASM_BP
-#ifdef CONFIG_X86_64
 	push %r15
 	push %r14
 	push %r13
 	push %r12
-#else
-	push %edi
-	push %esi
-#endif
 	push %_ASM_BX
 
 	/* Save @vmx for SPEC_CTRL handling */
@@ -148,7 +139,6 @@ SYM_FUNC_START(__vmx_vcpu_run)
 	mov VCPU_RBP(%_ASM_AX), %_ASM_BP
 	mov VCPU_RSI(%_ASM_AX), %_ASM_SI
 	mov VCPU_RDI(%_ASM_AX), %_ASM_DI
-#ifdef CONFIG_X86_64
 	mov VCPU_R8 (%_ASM_AX),  %r8
 	mov VCPU_R9 (%_ASM_AX),  %r9
 	mov VCPU_R10(%_ASM_AX), %r10
@@ -157,7 +147,7 @@ SYM_FUNC_START(__vmx_vcpu_run)
 	mov VCPU_R13(%_ASM_AX), %r13
 	mov VCPU_R14(%_ASM_AX), %r14
 	mov VCPU_R15(%_ASM_AX), %r15
-#endif
+
 	/* Load guest RAX.  This kills the @regs pointer! */
 	mov VCPU_RAX(%_ASM_AX), %_ASM_AX
 
@@ -210,7 +200,6 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
 	mov %_ASM_BP, VCPU_RBP(%_ASM_AX)
 	mov %_ASM_SI, VCPU_RSI(%_ASM_AX)
 	mov %_ASM_DI, VCPU_RDI(%_ASM_AX)
-#ifdef CONFIG_X86_64
 	mov %r8,  VCPU_R8 (%_ASM_AX)
 	mov %r9,  VCPU_R9 (%_ASM_AX)
 	mov %r10, VCPU_R10(%_ASM_AX)
@@ -219,7 +208,6 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
 	mov %r13, VCPU_R13(%_ASM_AX)
 	mov %r14, VCPU_R14(%_ASM_AX)
 	mov %r15, VCPU_R15(%_ASM_AX)
-#endif
 
 	/* Clear return value to indicate VM-Exit (as opposed to VM-Fail). */
 	xor %ebx, %ebx
@@ -244,7 +232,6 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
 	xor %ebp, %ebp
 	xor %esi, %esi
 	xor %edi, %edi
-#ifdef CONFIG_X86_64
 	xor %r8d,  %r8d
 	xor %r9d,  %r9d
 	xor %r10d, %r10d
@@ -253,7 +240,6 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
 	xor %r13d, %r13d
 	xor %r14d, %r14d
 	xor %r15d, %r15d
-#endif
 
 	/*
 	 * IMPORTANT: RSB filling and SPEC_CTRL handling must be done before
@@ -281,15 +267,10 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
 	mov %_ASM_BX, %_ASM_AX
 
 	pop %_ASM_BX
-#ifdef CONFIG_X86_64
 	pop %r12
 	pop %r13
 	pop %r14
 	pop %r15
-#else
-	pop %esi
-	pop %edi
-#endif
 	pop %_ASM_BP
 	RET
 
@@ -325,14 +306,12 @@ SYM_FUNC_START(vmread_error_trampoline)
 	push %_ASM_AX
 	push %_ASM_CX
 	push %_ASM_DX
-#ifdef CONFIG_X86_64
 	push %rdi
 	push %rsi
 	push %r8
 	push %r9
 	push %r10
 	push %r11
-#endif
 
 	/* Load @field and @fault to arg1 and arg2 respectively. */
 	mov 3*WORD_SIZE(%_ASM_BP), %_ASM_ARG2
@@ -343,14 +322,12 @@ SYM_FUNC_START(vmread_error_trampoline)
 	/* Zero out @fault, which will be popped into the result register. */
 	_ASM_MOV $0, 3*WORD_SIZE(%_ASM_BP)
 
-#ifdef CONFIG_X86_64
 	pop %r11
 	pop %r10
 	pop %r9
 	pop %r8
 	pop %rsi
 	pop %rdi
-#endif
 	pop %_ASM_DX
 	pop %_ASM_CX
 	pop %_ASM_AX
arch/x86/kvm/vmx/vmx.c +4 -113

377 lines not on this page · raw message

arch/x86/kvm/vmx/vmx.h +2 -21
index 43f573f6ca46..ba9428728f99 100644
@@ -19,11 +19,7 @@
 
 #define X2APIC_MSR(r) (APIC_BASE_MSR + ((r) >> 4))
 
-#ifdef CONFIG_X86_64
 #define MAX_NR_USER_RETURN_MSRS	7
-#else
-#define MAX_NR_USER_RETURN_MSRS	4
-#endif
 
 #define MAX_NR_LOADSTORE_MSRS	8
 
@@ -272,10 +268,8 @@ struct vcpu_vmx {
 	 */
 	struct vmx_uret_msr   guest_uret_msrs[MAX_NR_USER_RETURN_MSRS];
 	bool                  guest_uret_msrs_loaded;
-#ifdef CONFIG_X86_64
 	u64		      msr_host_kernel_gs_base;
 	u64		      msr_guest_kernel_gs_base;
-#endif
 
 	u64		      spec_ctrl;
 	u32		      msr_ia32_umwait_control;
@@ -470,14 +464,10 @@ static inline u8 vmx_get_rvi(void)
 
 #define __KVM_REQUIRED_VMX_VM_ENTRY_CONTROLS				\
 	(VM_ENTRY_LOAD_DEBUG_CONTROLS)
-#ifdef CONFIG_X86_64
 	#define KVM_REQUIRED_VMX_VM_ENTRY_CONTROLS			\
 		(__KVM_REQUIRED_VMX_VM_ENTRY_CONTROLS |			\
 		 VM_ENTRY_IA32E_MODE)
-#else
-	#define KVM_REQUIRED_VMX_VM_ENTRY_CONTROLS			\
-		__KVM_REQUIRED_VMX_VM_ENTRY_CONTROLS
-#endif
+
 #define KVM_OPTIONAL_VMX_VM_ENTRY_CONTROLS				\
 	(VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL |				\
 	 VM_ENTRY_LOAD_IA32_PAT |					\
@@ -489,14 +479,10 @@ static inline u8 vmx_get_rvi(void)
 #define __KVM_REQUIRED_VMX_VM_EXIT_CONTROLS				\
 	(VM_EXIT_SAVE_DEBUG_CONTROLS |					\
 	 VM_EXIT_ACK_INTR_ON_EXIT)
-#ifdef CONFIG_X86_64
 	#define KVM_REQUIRED_VMX_VM_EXIT_CONTROLS			\
 		(__KVM_REQUIRED_VMX_VM_EXIT_CONTROLS |			\
 		 VM_EXIT_HOST_ADDR_SPACE_SIZE)
-#else
-	#define KVM_REQUIRED_VMX_VM_EXIT_CONTROLS			\
-		__KVM_REQUIRED_VMX_VM_EXIT_CONTROLS
-#endif
+
 #define KVM_OPTIONAL_VMX_VM_EXIT_CONTROLS				\
 	      (VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL |			\
 	       VM_EXIT_SAVE_IA32_PAT |					\
@@ -529,15 +515,10 @@ static inline u8 vmx_get_rvi(void)
 	 CPU_BASED_RDPMC_EXITING |					\
 	 CPU_BASED_INTR_WINDOW_EXITING)
 
-#ifdef CONFIG_X86_64
 	#define KVM_REQUIRED_VMX_CPU_BASED_VM_EXEC_CONTROL		\
 		(__KVM_REQUIRED_VMX_CPU_BASED_VM_EXEC_CONTROL |		\
 		 CPU_BASED_CR8_LOAD_EXITING |				\
 		 CPU_BASED_CR8_STORE_EXITING)
-#else
-	#define KVM_REQUIRED_VMX_CPU_BASED_VM_EXEC_CONTROL		\
-		__KVM_REQUIRED_VMX_CPU_BASED_VM_EXEC_CONTROL
-#endif
 
 #define KVM_OPTIONAL_VMX_CPU_BASED_VM_EXEC_CONTROL			\
 	(CPU_BASED_RDTSC_EXITING |					\
arch/x86/kvm/vmx/vmx_ops.h +0 -7
index 633c87e2fd92..72031b669925 100644
@@ -171,11 +171,7 @@ static __always_inline u64 vmcs_read64(unsigned long field)
 	vmcs_check64(field);
 	if (kvm_is_using_evmcs())
 		return evmcs_read64(field);
-#ifdef CONFIG_X86_64
 	return __vmcs_readl(field);
-#else
-	return __vmcs_readl(field) | ((u64)__vmcs_readl(field+1) << 32);
-#endif
 }
 
 static __always_inline unsigned long vmcs_readl(unsigned long field)
@@ -250,9 +246,6 @@ static __always_inline void vmcs_write64(unsigned long field, u64 value)
 		return evmcs_write64(field, value);
 
 	__vmcs_writel(field, value);
-#ifndef CONFIG_X86_64
-	__vmcs_writel(field+1, value >> 32);
-#endif
 }
 
 static __always_inline void vmcs_writel(unsigned long field, unsigned long value)
arch/x86/kvm/vmx/x86_ops.h +0 -2
index a55981c5216e..8573f1e401be 100644
@@ -111,11 +111,9 @@ u64 vmx_get_l2_tsc_multiplier(struct kvm_vcpu *vcpu);
 void vmx_write_tsc_offset(struct kvm_vcpu *vcpu);
 void vmx_write_tsc_multiplier(struct kvm_vcpu *vcpu);
 void vmx_update_cpu_dirty_logging(struct kvm_vcpu *vcpu);
-#ifdef CONFIG_X86_64
 int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc,
 		     bool *expired);
 void vmx_cancel_hv_timer(struct kvm_vcpu *vcpu);
-#endif
 void vmx_setup_mce(struct kvm_vcpu *vcpu);
 
 #endif /* __KVM_X86_VMX_X86_OPS_H */
arch/x86/kvm/x86.c +6 -68

363 lines not on this page · raw message

arch/x86/kvm/x86.h +0 -4
index ec623d23d13d..0b2e03f083a7 100644
@@ -166,11 +166,7 @@ static inline bool is_protmode(struct kvm_vcpu *vcpu)
 
 static inline bool is_long_mode(struct kvm_vcpu *vcpu)
 {
-#ifdef CONFIG_X86_64
 	return !!(vcpu->arch.efer & EFER_LMA);
-#else
-	return false;
-#endif
 }
 
 static inline bool is_64_bit_mode(struct kvm_vcpu *vcpu)
arch/x86/kvm/xen.c +23 -38

171 lines not on this page · raw message

Signature · 1 line
2.39.5
#75 lore raw

Re: [PATCH 11/11] x86: drop 32-bit KVM host support

Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

There are very few 32-bit machines that support KVM, the main exceptions are the "Yonah" Generation Xeon-LV and Core Duo from 2006 and the Atom Z5xx "Silverthorne" from 2008 that were all release just before their 64-bit counterparts.

Quoted 7 lines

Using KVM as a host on a 64-bit CPU using a 32-bit kernel generally works fine, but is rather pointless since 64-bit kernels are much better supported and deal better with the memory requirements of VM guests.

Drop all the 32-bit-only portions and the "#ifdef CONFIG_X86_64" checks of the x86 KVM code and add a Kconfig dependency to only allow building this on 64-bit kernels.

While 32-bit KVM doesn't need to be a thing for x86 usage, Paolo expressed concerns that dropping 32-bit support on x86 would cause general 32-bit KVM support to bitrot horribly. 32-bit x86 doesn't get much testing, but I do at least boot VMs with it on a semi-regular basis. I don't think we can say the same for other architectures with 32-bit variants.

PPC apparently still has 32-bit users[1][2], and 32-bit RISC-V is a thing, so I think we're stuck with 32-bit x86 for the time being. :-(

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

#76 lore raw

Re: [PATCH 11/11] x86: drop 32-bit KVM host support

Quoted 16 lines · Sean Christopherson
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

There are very few 32-bit machines that support KVM, the main exceptions are the "Yonah" Generation Xeon-LV and Core Duo from 2006 and the Atom Z5xx "Silverthorne" from 2008 that were all release just before their 64-bit counterparts.

Quoted 7 lines

Using KVM as a host on a 64-bit CPU using a 32-bit kernel generally works fine, but is rather pointless since 64-bit kernels are much better supported and deal better with the memory requirements of VM guests.

Drop all the 32-bit-only portions and the "#ifdef CONFIG_X86_64" checks of the x86 KVM code and add a Kconfig dependency to only allow building this on 64-bit kernels.

Quoted 9 lines

While 32-bit KVM doesn't need to be a thing for x86 usage, Paolo expressed concerns
that dropping 32-bit support on x86 would cause general 32-bit KVM support to
bitrot horribly. 32-bit x86 doesn't get much testing, but I do at least boot VMs
with it on a semi-regular basis. I don't think we can say the same for other
architectures with 32-bit variants.

I see.

Quoted 1 line

PPC apparently still has 32-bit users[1][2],

I looked at the links but only see 64-bit users there.

There is KVM support for 32-bit BookE (e500v2, e500mc) in the PPC85xx and QorIQ P1/P2/P3/P4, and Crystal mentioned that there might be users, but did not point to anyone in particular.

The A-EON AmigaOne X5000 and Powerboard Tyche that were mentioned in the thread as being actively used are both 64-bit QorIQ P5/T2 (e5500, e6500) based. These are the same platform ("85xx" in Linux, "e500" in qemu), so it's easy to confuse. We can probably ask again if anyone cares about removing the 32-bit side of this.

Quoted 1 line

and 32-bit RISC-V is a thing,

There are many 32-bit RISC-V chips, but all RISC-V SoCs supported by Linux today are in fact 64-bit.

While there is still talk of adding support for 32-bit SoCs, the only usecase for those is really to allow machines with smaller amounts of physical RAM, which tends to rule out virtualization.

There is one more platform that supports virtualization on 32-bit CPUs, which is the MIPS P5600 core in the Baikal T1.

I still think it makes sense to just drop KVM support for all 32-bit hosts, but I agree that it also makes sense to keep x86-32 as the last one of those for testing purposes.

Arnd