[PATCH 04/15] x86/kbuild: Introduce the 'x86_32' subarchitecture

Ingo Molnar posted 15 patches 9 months, 1 week ago
There is a newer version of this series
[PATCH 04/15] x86/kbuild: Introduce the 'x86_32' subarchitecture
Posted by Ingo Molnar 9 months, 1 week ago
These days the canonical counterpart to the x86_64 architecture
is the x86_32 architecture - except our Makefiles don't accept it
as an ARCH target.

Make it so.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michal Marek <michal.lkml@markovi.net>
---
 Makefile                                              |  7 +++++--
 arch/x86/Kconfig                                      |  2 +-
 arch/x86/Makefile                                     | 10 +++++++---
 arch/x86/configs/{defconfig.i386 => defconfig.x86_32} |  0
 tools/scripts/Makefile.arch                           |  7 +++++--
 5 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index b29cc321ffd9..84a4912f3343 100644
--- a/Makefile
+++ b/Makefile
@@ -407,10 +407,13 @@ UTS_MACHINE 	:= $(ARCH)
 SRCARCH 	:= $(ARCH)
 
 # Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
+ifeq ($(ARCH),x86_64)
         SRCARCH := x86
 endif
-ifeq ($(ARCH),x86_64)
+ifeq ($(ARCH),x86_32)
+        SRCARCH := x86
+endif
+ifeq ($(ARCH),i386)
         SRCARCH := x86
 endif
 
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 4b9f378e05f6..3282638072b9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2,7 +2,7 @@
 # Select 32 or 64 bit
 config 64BIT
 	bool "64-bit kernel" if "$(ARCH)" = "x86"
-	default "$(ARCH)" != "i386"
+	default "$(ARCH)" != "i386" && "$(ARCH)" != "x86_32"
 	help
 	  Say yes to build a 64-bit kernel - formerly known as x86_64
 	  Say no to build a 32-bit kernel - formerly known as i386
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index bae2c7bbb8db..fb4f0f15d1df 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -1,15 +1,19 @@
 # SPDX-License-Identifier: GPL-2.0
-# Unified Makefile for i386 and x86_64
+# Unified Makefile for x86_64 and x86_32
 
-# select defconfig based on actual architecture
+# When in doubt, select defconfig based on host architecture:
 ifeq ($(ARCH),x86)
   ifeq ($(shell uname -m | sed -e 's/i.86/i386/'),i386)
-        KBUILD_DEFCONFIG := defconfig.i386
+        KBUILD_DEFCONFIG := defconfig.x86_32
   else
         KBUILD_DEFCONFIG := defconfig.x86_64
   endif
 else
+  ifeq ($(ARCH),i386)
+        KBUILD_DEFCONFIG := defconfig.x86_32
+  else
         KBUILD_DEFCONFIG := defconfig.$(ARCH)
+  endif
 endif
 
 ifdef CONFIG_CC_IS_GCC
diff --git a/arch/x86/configs/defconfig.i386 b/arch/x86/configs/defconfig.x86_32
similarity index 100%
rename from arch/x86/configs/defconfig.i386
rename to arch/x86/configs/defconfig.x86_32
diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch
index eabfe9f411d9..9aedca27ac9a 100644
--- a/tools/scripts/Makefile.arch
+++ b/tools/scripts/Makefile.arch
@@ -14,10 +14,13 @@ endif
 SRCARCH := $(ARCH)
 
 # Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
+ifeq ($(ARCH),x86_64)
         SRCARCH := x86
 endif
-ifeq ($(ARCH),x86_64)
+ifeq ($(ARCH),x86_32)
+        SRCARCH := x86
+endif
+ifeq ($(ARCH),i386)
         SRCARCH := x86
 endif
 
-- 
2.45.2