Merge commit 'f4bcd8ccddb02833340652e9f46f5127828eb79d' into x86/build
authorH. Peter Anvin <hpa@linux.intel.com>
Wed, 29 Jan 2014 17:07:00 +0000 (09:07 -0800)
committerH. Peter Anvin <hpa@linux.intel.com>
Wed, 29 Jan 2014 17:07:00 +0000 (09:07 -0800)
Bring in upstream merge of x86/kaslr for future patches.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
1  2 
arch/x86/Makefile
arch/x86/boot/Makefile
arch/x86/tools/relocs.c

diff --combined arch/x86/Makefile
index 83e67d5c9db3663f337017dad4b22f326204aadf,13b22e0f681dbeff951dde5055e7f594778a98a1..9ecbc1c46c74c21fbff82e0281f54684b0e1ce43
@@@ -11,20 -11,6 +11,20 @@@ els
          KBUILD_DEFCONFIG := $(ARCH)_defconfig
  endif
  
 +# How to compile the 16-bit code.  Note we always compile for -march=i386;
 +# that way we can complain to the user if the CPU is insufficient.
 +REALMODE_CFLAGS       := -m32 -g -Os -D__KERNEL__ -DDISABLE_BRANCH_PROFILING \
 +                 -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
 +                 -include $(srctree)/arch/x86/boot/code16gcc.h \
 +                 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
 +                 -mno-mmx -mno-sse \
 +                 $(call cc-option, -ffreestanding) \
 +                 $(call cc-option, -fno-toplevel-reorder,\
 +                 $(call cc-option, -fno-unit-at-a-time)) \
 +                 $(call cc-option, -fno-stack-protector) \
 +                 $(call cc-option, -mpreferred-stack-boundary=2)
 +export REALMODE_CFLAGS
 +
  # BITS is used as extension for files which are available in a 32 bit
  # and a 64 bit version to simplify shared Makefiles.
  # e.g.: obj-y += foo_$(BITS).o
@@@ -103,13 -89,11 +103,11 @@@ els
          KBUILD_CFLAGS += -maccumulate-outgoing-args
  endif
  
+ # Make sure compiler does not have buggy stack-protector support.
  ifdef CONFIG_CC_STACKPROTECTOR
        cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
-         ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
-                 stackp-y := -fstack-protector
-                 KBUILD_CFLAGS += $(stackp-y)
-         else
-                 $(warning stack protector enabled but no compiler support)
+         ifneq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
+                 $(warning stack-protector enabled but compiler support broken)
          endif
  endif
  
diff --combined arch/x86/boot/Makefile
index 7c2b0a18a6ea7a4c1a697b3f2dfae0bdc4a71aff,de70669180052163de7a34a21e92302b4c50128e..878df7e88cd4d9c4293d9540432fdd3d7c78fc6e
@@@ -20,7 -20,7 +20,7 @@@ targets               := vmlinux.bin setup.bin setup
  targets               += fdimage fdimage144 fdimage288 image.iso mtools.conf
  subdir-               := compressed
  
- setup-y               += a20.o bioscall.o cmdline.o copy.o cpu.o cpucheck.o
+ setup-y               += a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
  setup-y               += early_serial_console.o edd.o header.o main.o mca.o memory.o
  setup-y               += pm.o pmjump.o printf.o regs.o string.o tty.o video.o
  setup-y               += video-mode.o version.o
@@@ -51,7 -51,20 +51,7 @@@ $(obj)/cpustr.h: $(obj)/mkcpustr FORC
  
  # ---------------------------------------------------------------------------
  
 -# How to compile the 16-bit code.  Note we always compile for -march=i386,
 -# that way we can complain to the user if the CPU is insufficient.
 -KBUILD_CFLAGS := $(USERINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
 -                 -DDISABLE_BRANCH_PROFILING \
 -                 -Wall -Wstrict-prototypes \
 -                 -march=i386 -mregparm=3 \
 -                 -include $(srctree)/$(src)/code16gcc.h \
 -                 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
 -                 -mno-mmx -mno-sse \
 -                 $(call cc-option, -ffreestanding) \
 -                 $(call cc-option, -fno-toplevel-reorder,\
 -                 $(call cc-option, -fno-unit-at-a-time)) \
 -                 $(call cc-option, -fno-stack-protector) \
 -                 $(call cc-option, -mpreferred-stack-boundary=2)
 +KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
  KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  GCOV_PROFILE := n
  
diff --combined arch/x86/tools/relocs.c
index 9c2ab06dc4f2a6fcac6d1940288138ed4c5f132b,11f9285a2ff66726b6c62c7eb608e03f516dcc27..cfbdbdb4e1737c3b2461456e48573c75fb4ec6ef
@@@ -722,15 -722,25 +722,25 @@@ static void percpu_init(void
  
  /*
   * Check to see if a symbol lies in the .data..percpu section.
-  * For some as yet not understood reason the "__init_begin"
-  * symbol which immediately preceeds the .data..percpu section
-  * also shows up as it it were part of it so we do an explict
-  * check for that symbol name and ignore it.
+  *
+  * The linker incorrectly associates some symbols with the
+  * .data..percpu section so we also need to check the symbol
+  * name to make sure that we classify the symbol correctly.
+  *
+  * The GNU linker incorrectly associates:
+  *    __init_begin
+  *    __per_cpu_load
+  *
+  * The "gold" linker incorrectly associates:
+  *    init_per_cpu__irq_stack_union
+  *    init_per_cpu__gdt_page
   */
  static int is_percpu_sym(ElfW(Sym) *sym, const char *symname)
  {
        return (sym->st_shndx == per_cpu_shndx) &&
-               strcmp(symname, "__init_begin");
+               strcmp(symname, "__init_begin") &&
+               strcmp(symname, "__per_cpu_load") &&
+               strncmp(symname, "init_per_cpu_", 13);
  }
  
  
@@@ -1015,29 -1025,6 +1025,29 @@@ static void emit_relocs(int as_text, in
        }
  }
  
 +/*
 + * As an aid to debugging problems with different linkers
 + * print summary information about the relocs.
 + * Since different linkers tend to emit the sections in
 + * different orders we use the section names in the output.
 + */
 +static int do_reloc_info(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym,
 +                              const char *symname)
 +{
 +      printf("%s\t%s\t%s\t%s\n",
 +              sec_name(sec->shdr.sh_info),
 +              rel_type(ELF_R_TYPE(rel->r_info)),
 +              symname,
 +              sec_name(sym->st_shndx));
 +      return 0;
 +}
 +
 +static void print_reloc_info(void)
 +{
 +      printf("reloc section\treloc type\tsymbol\tsymbol section\n");
 +      walk_relocs(do_reloc_info);
 +}
 +
  #if ELF_BITS == 64
  # define process process_64
  #else
  #endif
  
  void process(FILE *fp, int use_real_mode, int as_text,
 -           int show_absolute_syms, int show_absolute_relocs)
 +           int show_absolute_syms, int show_absolute_relocs,
 +           int show_reloc_info)
  {
        regex_init(use_real_mode);
        read_ehdr(fp);
                print_absolute_relocs();
                return;
        }
 +      if (show_reloc_info) {
 +              print_reloc_info();
 +              return;
 +      }
        emit_relocs(as_text, use_real_mode);
  }