lkml.org 
[lkml]   [2011]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patches in this message
    /
    SubjectRe: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
    From
    Date
    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'll work on a patch to fix that, and then it will be fine when the
    default for SUBARCH changes to be "x86".

    (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



    \
     
     \ /
      Last update: 2011-07-30 23:03    [W:4.274 / U:0.180 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site