Message ID | 1312059539.22074.16.camel@i7.infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 07/30/2011 01:58 PM, David Woodhouse wrote: > > In the context of a kernel build that's meaningless though. One kernel > can support *many* types of userspace. > It isn't meaningless for exactly that reason. For example, "make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both make sense. Similarly, "make ARCH=um USERARCH=i386" is different from "make ARCH=um USERARCH=x86_64". -hpa
On Sat, 2011-07-30 at 15:03 -0700, H. Peter Anvin wrote: > It isn't meaningless for exactly that reason. For example, > "make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both > make sense. Similarly, "make ARCH=um USERARCH=i386" is different from > "make ARCH=um USERARCH=x86_64". In that case it's redundant with CONFIG_64BIT, isn't it?
On 07/30/2011 03:17 PM, David Woodhouse wrote: > On Sat, 2011-07-30 at 15:03 -0700, H. Peter Anvin wrote: >> It isn't meaningless for exactly that reason. For example, >> "make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both >> make sense. Similarly, "make ARCH=um USERARCH=i386" is different from >> "make ARCH=um USERARCH=x86_64". > > In that case it's redundant with CONFIG_64BIT, isn't it? Yes, but some architectures have more than one ABI for a particular bitness. -hpa
Hi, On Sat, Jul 30, 2011 at 4:58 PM, David Woodhouse <dwmw2@infradead.org> wrote: > On Sat, 2011-07-30 at 11:59 -0700, H. Peter Anvin wrote: >> For klibc integration, we ran into this problem as well: the set of >> architectures for the kernel simply isn't the same set as the >> architectures for userspace. For the kernel, x86 is an architecture, >> for userspace the architectures are x86_64 or i386 and they are >> fundamentally different in many, many ways. >> >> The main problem with SUBARCH is that it is ill-defined in the general >> case if SUBARCH contains a user space or a kernel space architecture. >> In that sense I would much prefer it if was called, say, USERARCH and >> was always available. It could even be set by Kconfig >> (CONFIG_USERARCH?) > > In the context of a kernel build that's meaningless though. One kernel > can support *many* types of userspace. > > I've just been playing with ARCH=um. It looks like the current state, > even before my patch, is that 'make ARCH=um SUBARCH=x86' is broken. > I fail to see how, to my understanding, something that has not been thought to be used that way can be broken ... > I'll work on a patch to fix that, and then it will be fine when the > default for SUBARCH changes to be "x86". > I still fail to see why you want it that way... You want both ARCH and SUBARCH to be 'x86' ? This starts to be a hell lots of deep changes just to fix i386 build under a fast x86-64 without having to specify ARCH=i386. That job alone can be done a lot easier. - Arnaud > (Another option is to make SUBARCH default to x86 *only* if ARCH!=um, > and still use the legacy SUBARCH values when ARCH=um. But I'm not overly > keen on that approach.) > > Fixing um to work with ARCH=x86 *ought* to be as simple as doing > something like this: > > --- a/arch/um/Makefile > +++ b/arch/um/Makefile > @@ -12,6 +12,15 @@ OS := $(shell uname -s) > # features. > SHELL := /bin/bash > > +# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it. > +ifeq ($(SUBARCH),x86) > +ifeq ($(CONFIG_64BIT),y) > +SUBARCH := x86_64 > +else > +SUBARCH := i386 > +endif > +endif > + > filechk_gen_header = $< > > core-y += $(ARCH_DIR)/kernel/ \ > > .. but that gives me weird behaviour where it just keeps running > silentoldconfig over and over again. > > This patch *does* work, but I'll see if I can make it simpler... > > diff --git a/arch/um/Kconfig.x86 b/arch/um/Kconfig.x86 > index d31ecf3..576b732 100644 > --- a/arch/um/Kconfig.x86 > +++ b/arch/um/Kconfig.x86 > @@ -19,8 +19,8 @@ config UML_X86 > select GENERIC_FIND_FIRST_BIT > > config 64BIT > - bool > - default SUBARCH = "x86_64" > + bool "64-bit kernel" if SUBARCH = "x86" > + default SUBARCH != "i386" > > config X86_32 > def_bool !64BIT > diff --git a/arch/um/Makefile b/arch/um/Makefile > index fab8121..562c6cb 100644 > --- a/arch/um/Makefile > +++ b/arch/um/Makefile > @@ -12,6 +12,17 @@ OS := $(shell uname -s) > # features. > SHELL := /bin/bash > > +# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it. > +ifeq ($(SUBARCH),x86) > +ifeq ($(CONFIG_64BIT),y) > +UMSUBARCH := x86_64 > +else > +UMSUBARCH := i386 > +endif > +else > +UMSUBARCH := $(SUBARCH) > +endif > + > filechk_gen_header = $< > > core-y += $(ARCH_DIR)/kernel/ \ > @@ -24,11 +35,11 @@ include $(srctree)/$(ARCH_DIR)/Makefile-skas > > SHARED_HEADERS := $(ARCH_DIR)/include/shared > ARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS) > -ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared > +ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH)/shared > ifneq ($(KBUILD_SRC),) > ARCH_INCLUDE += -I$(SHARED_HEADERS) > endif > -KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) > +KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH) > > # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so > # named - it's a common symbol in libpcap, so we get a binary which crashes. > @@ -38,7 +49,7 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) > # > # These apply to USER_CFLAGS to. > > -KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ > +KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(UMSUBARCH)\" \ > $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ > -Din6addr_loopback=kernel_in6addr_loopback \ > -Din6addr_any=kernel_in6addr_any > @@ -49,7 +60,7 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\ > $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \ > $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 > > -include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) > +include $(srctree)/$(ARCH_DIR)/Makefile-$(UMSUBARCH) > > #This will adjust *FLAGS accordingly to the platform. > include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) > @@ -128,8 +139,8 @@ archclean: > > # Generated files > > -$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE > - $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@ > +$(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s: FORCE > + $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(UMSUBARCH) $@ > > define filechk_gen-asm-offsets > (set -e; \ > @@ -144,11 +155,11 @@ define filechk_gen-asm-offsets > echo ""; ) > endef > > -$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s > +$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s > $(call filechk,gen-asm-offsets) > > $(SHARED_HEADERS)/kern_constants.h: > $(Q)mkdir -p $(dir $@) > $(Q)echo '#include "../../../../include/generated/asm-offsets.h"' >$@ > > -export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH > +export SUBARCH UMSUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH > diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386 > index 302cbe5..b66063b 100644 > --- a/arch/um/Makefile-i386 > +++ b/arch/um/Makefile-i386 > @@ -5,22 +5,22 @@ TOP_ADDR := $(CONFIG_TOP_ADDR) > START := 0x8048000 > > LDFLAGS += -m elf_i386 > -ELF_ARCH := $(SUBARCH) > -ELF_FORMAT := elf32-$(SUBARCH) > +ELF_ARCH := $(UMSUBARCH) > +ELF_FORMAT := elf32-$(UMSUBARCH) > OBJCOPYFLAGS := -O binary -R .note -R .comment -S > HEADER_ARCH := x86 > CHECKFLAGS += -D__i386__ > > -ifeq ("$(origin SUBARCH)", "command line") > -ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") > +#ifeq ("$(origin SUBARCH)", "command line") > +#ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") > KBUILD_CFLAGS += $(call cc-option,-m32) > KBUILD_AFLAGS += $(call cc-option,-m32) > LINK-y += $(call cc-option,-m32) > UML_OBJCOPYFLAGS += -F $(ELF_FORMAT) > > export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS > -endif > -endif > +#endif > +#endif > > # First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. > include $(srctree)/arch/x86/Makefile_32.cpu > diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile > index b33f4df..c1a2ca3 100644 > --- a/arch/um/os-Linux/Makefile > +++ b/arch/um/os-Linux/Makefile > @@ -5,7 +5,7 @@ > > obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ > registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ > - umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ > + umid.o tls.o user_syms.o util.o drivers/ sys-$(UMSUBARCH)/ skas/ > > obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o > > > -- > dwmw2 > > -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi, On Sat, Jul 30, 2011 at 6:17 PM, David Woodhouse <dwmw2@infradead.org> wrote: > On Sat, 2011-07-30 at 15:03 -0700, H. Peter Anvin wrote: >> It isn't meaningless for exactly that reason. For example, >> "make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both >> make sense. Similarly, "make ARCH=um USERARCH=i386" is different from >> "make ARCH=um USERARCH=x86_64". > > In that case it's redundant with CONFIG_64BIT, isn't it? > How do you plan to handle x32, if it ever makes it to mainline ? - Arnaud -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, 2011-07-30 at 18:24 -0400, Arnaud Lacombe wrote:
> How do you plan to handle x32, if it ever makes it to mainline ?
I was pondering that. Surely it would involve porting the kernel itself
to x32? And there's never going to be any motivation for that *other*
than UML, so I can't really see it happening.
What does 'uname -m' give under x32, anyway?
On 07/30/2011 03:34 PM, David Woodhouse wrote: > On Sat, 2011-07-30 at 18:24 -0400, Arnaud Lacombe wrote: >> How do you plan to handle x32, if it ever makes it to mainline ? > > I was pondering that. Surely it would involve porting the kernel itself > to x32? And there's never going to be any motivation for that *other* > than UML, so I can't really see it happening. > > What does 'uname -m' give under x32, anyway? Right now is gives x86_64, but that should probably be changed before mainlining. -hpa
On Sat, 2011-07-30 at 18:21 -0400, Arnaud Lacombe wrote: > > I'll work on a patch to fix that, and then it will be fine when the > > default for SUBARCH changes to be "x86". > > > I still fail to see why you want it that way... You want both ARCH and > SUBARCH to be 'x86' ? See the way that SUBARCH is inferred in the Makefile, and then ARCH is set to match it (unless ARCH is set by the user). To change the default setting of ARCH, we actually change the inference of *SUBARCH*. And yes, in the common case they are both the *same*; the SUBARCH variable doesn't really do anything except work as a temporary variable holding the default setting for ARCH. In an ARCH=um build, of course they *are* different, and SUBARCH is actually used for more than that. > This starts to be a hell lots of deep changes just to fix i386 build > under a fast x86-64 without having to specify ARCH=i386. That job > alone can be done a lot easier. It's not just that. It's also about making things work properly as config options — so we can finally complete the merge of arch/i386 and arch/x86_64, which directories we deleted almost four years ago, into the single 'x86' architecture. After a few 'unrelated' cleanups to how $(SUBARCH) is handled, the patch to make SUBARCH=x86 work in um really isn't that intrusive at all; I'll post the sequence shortly. We *could* preserve the legacy inference of SUBARCH={i386,x86_64} *just* for the ARCH=um case, but I think it's better not to.
--- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -12,6 +12,15 @@ OS := $(shell uname -s) # features. SHELL := /bin/bash +# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it. +ifeq ($(SUBARCH),x86) +ifeq ($(CONFIG_64BIT),y) +SUBARCH := x86_64 +else +SUBARCH := i386 +endif +endif + filechk_gen_header = $< core-y += $(ARCH_DIR)/kernel/ \ .. but that gives me weird behaviour where it just keeps running silentoldconfig over and over again. This patch *does* work, but I'll see if I can make it simpler... diff --git a/arch/um/Kconfig.x86 b/arch/um/Kconfig.x86 index d31ecf3..576b732 100644 --- a/arch/um/Kconfig.x86 +++ b/arch/um/Kconfig.x86 @@ -19,8 +19,8 @@ config UML_X86 select GENERIC_FIND_FIRST_BIT config 64BIT - bool - default SUBARCH = "x86_64" + bool "64-bit kernel" if SUBARCH = "x86" + default SUBARCH != "i386" config X86_32 def_bool !64BIT diff --git a/arch/um/Makefile b/arch/um/Makefile index fab8121..562c6cb 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -12,6 +12,17 @@ OS := $(shell uname -s) # features. SHELL := /bin/bash +# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it. +ifeq ($(SUBARCH),x86) +ifeq ($(CONFIG_64BIT),y) +UMSUBARCH := x86_64 +else +UMSUBARCH := i386 +endif +else +UMSUBARCH := $(SUBARCH) +endif + filechk_gen_header = $< core-y += $(ARCH_DIR)/kernel/ \ @@ -24,11 +35,11 @@ include $(srctree)/$(ARCH_DIR)/Makefile-skas SHARED_HEADERS := $(ARCH_DIR)/include/shared ARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS) -ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared +ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH)/shared ifneq ($(KBUILD_SRC),) ARCH_INCLUDE += -I$(SHARED_HEADERS) endif -KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) +KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH) # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so # named - it's a common symbol in libpcap, so we get a binary which crashes. @@ -38,7 +49,7 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) # # These apply to USER_CFLAGS to. -KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ +KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(UMSUBARCH)\" \ $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ -Din6addr_loopback=kernel_in6addr_loopback \ -Din6addr_any=kernel_in6addr_any @@ -49,7 +60,7 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\ $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \ $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) +include $(srctree)/$(ARCH_DIR)/Makefile-$(UMSUBARCH) #This will adjust *FLAGS accordingly to the platform. include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) @@ -128,8 +139,8 @@ archclean: # Generated files -$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE - $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@ +$(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s: FORCE + $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(UMSUBARCH) $@ define filechk_gen-asm-offsets (set -e; \ @@ -144,11 +155,11 @@ define filechk_gen-asm-offsets echo ""; ) endef -$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s +$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s $(call filechk,gen-asm-offsets) $(SHARED_HEADERS)/kern_constants.h: $(Q)mkdir -p $(dir $@) $(Q)echo '#include "../../../../include/generated/asm-offsets.h"' >$@ -export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH +export SUBARCH UMSUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386 index 302cbe5..b66063b 100644 --- a/arch/um/Makefile-i386 +++ b/arch/um/Makefile-i386 @@ -5,22 +5,22 @@ TOP_ADDR := $(CONFIG_TOP_ADDR) START := 0x8048000 LDFLAGS += -m elf_i386 -ELF_ARCH := $(SUBARCH) -ELF_FORMAT := elf32-$(SUBARCH) +ELF_ARCH := $(UMSUBARCH) +ELF_FORMAT := elf32-$(UMSUBARCH) OBJCOPYFLAGS := -O binary -R .note -R .comment -S HEADER_ARCH := x86 CHECKFLAGS += -D__i386__ -ifeq ("$(origin SUBARCH)", "command line") -ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") +#ifeq ("$(origin SUBARCH)", "command line") +#ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") KBUILD_CFLAGS += $(call cc-option,-m32) KBUILD_AFLAGS += $(call cc-option,-m32) LINK-y += $(call cc-option,-m32) UML_OBJCOPYFLAGS += -F $(ELF_FORMAT) export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS -endif -endif +#endif +#endif # First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. include $(srctree)/arch/x86/Makefile_32.cpu diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index b33f4df..c1a2ca3 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -5,7 +5,7 @@ obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ - umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ + umid.o tls.o user_syms.o util.o drivers/ sys-$(UMSUBARCH)/ skas/ obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o