1. 17 5月, 2018 1 次提交
  2. 04 2月, 2017 1 次提交
    • A
      modversions: treat symbol CRCs as 32 bit quantities · 71810db2
      Ard Biesheuvel 提交于
      The modversion symbol CRCs are emitted as ELF symbols, which allows us
      to easily populate the kcrctab sections by relying on the linker to
      associate each kcrctab slot with the correct value.
      
      This has a couple of downsides:
      
       - Given that the CRCs are treated as memory addresses, we waste 4 bytes
         for each CRC on 64 bit architectures,
      
       - On architectures that support runtime relocation, a R_<arch>_RELATIVE
         relocation entry is emitted for each CRC value, which identifies it
         as a quantity that requires fixing up based on the actual runtime
         load offset of the kernel. This results in corrupted CRCs unless we
         explicitly undo the fixup (and this is currently being handled in the
         core module code)
      
       - Such runtime relocation entries take up 24 bytes of __init space
         each, resulting in a x8 overhead in [uncompressed] kernel size for
         CRCs.
      
      Switching to explicit 32 bit values on 64 bit architectures fixes most
      of these issues, given that 32 bit values are not treated as quantities
      that require fixing up based on the actual runtime load offset.  Note
      that on some ELF64 architectures [such as PPC64], these 32-bit values
      are still emitted as [absolute] runtime relocatable quantities, even if
      the value resolves to a build time constant.  Since relative relocations
      are always resolved at build time, this patch enables MODULE_REL_CRCS on
      powerpc when CONFIG_RELOCATABLE=y, which turns the absolute CRC
      references into relative references into .rodata where the actual CRC
      value is stored.
      
      So redefine all CRC fields and variables as u32, and redefine the
      __CRC_SYMBOL() macro for 64 bit builds to emit the CRC reference using
      inline assembler (which is necessary since 64-bit C code cannot use
      32-bit types to hold memory addresses, even if they are ultimately
      resolved using values that do not exceed 0xffffffff).  To avoid
      potential problems with legacy 32-bit architectures using legacy
      toolchains, the equivalent C definition of the kcrctab entry is retained
      for 32-bit architectures.
      
      Note that this mostly reverts commit d4703aef ("module: handle ppc64
      relocating kcrctabs when CONFIG_RELOCATABLE=y")
      Acked-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      71810db2
  3. 08 12月, 2016 1 次提交
    • L
      Revert "default exported asm symbols to zero" · f27c2f69
      Linus Torvalds 提交于
      This reverts commit 8ab2ae65.
      
      I loved that commit because of how it explained what the problem with
      newer versions of binutils were, but the actual patch itself turns out
      to not work very well.
      
      It has two problems:
      
       - a zero CRC value isn't actually right.  It happens to work for the
         case where both sides of the equation fail at giving the symbol a
         crc, but there are cases where the users of the exported symbol get
         the right crc (due to seeing the C declarations), but the actual
         exporting itself does not (due to the whole weak asm symbol issue).
      
         So then the module load fails after all - we did have a crc for the
         symbol, but we couldn't match it with the loaded module.
      
       - it seems that the alpha assembler has special semantics for the
         '.set' directive, and on alpha it doesn't actually set the value of
         the specified symbol at all, it is instead used to set various
         assembly modes (eg ".set noat" and ".set noreorder").
      
         So using ".set" to set the symbol value would just cause build
         failures on alpha.
      
      I'm sure we'll find some other workaround for these issues (hopefully
      that involves getting rid of modversions entirely some day, but people
      are also talking about just using smarter tools).  But for now we'll
      just fall back on commit faaae2a5 ("Re-enable CONFIG_MODVERSIONS in
      a slightly weaker form") that just let's a missing crc through.
      Reported-by: NJan Stancek <jstancek@redhat.com>
      Reported-by: NPhilip Müller <philm@manjaro.org>
      Reported-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f27c2f69
  4. 03 12月, 2016 1 次提交
    • A
      default exported asm symbols to zero · 8ab2ae65
      Arnd Bergmann 提交于
      With binutils-2.26 and before, a weak missing symbol was kept during the
      final link, and a missing CRC for an export would lead to that CRC being
      treated as zero implicitly.  With binutils-2.27, the crc symbol gets
      dropped, and any module trying to use it will fail to load.
      
      This sets the weak CRC symbol to zero explicitly, making it defined in
      vmlinux, which in turn lets us load the modules referring to that CRC.
      
      The comment above the __CRC_SYMBOL macro suggests that this was always
      the intention, although it also seems that all symbols defined in C have
      a correct CRC these days, and only the exports that are now done in
      assembly need this.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Tested-by: NAdam Borowski <kilobyte@angband.pl>
      Cc: stable@kernel.org
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8ab2ae65
  5. 28 10月, 2016 1 次提交
  6. 08 8月, 2016 1 次提交
    • A
      EXPORT_SYMBOL() for asm · 22823ab4
      Al Viro 提交于
      Add asm-usable variants of EXPORT_SYMBOL/EXPORT_SYMBOL_GPL.  This
      commit just adds the default implementation; most of the architectures
      can simply add export.h to asm/Kbuild and start using <asm/export.h>
      from assembler.  The rest needs to have their <asm/export.h> define
      everal macros and then explicitly include <asm-generic/export.h>
      
      One area where the things might diverge from default is the alignment;
      normally it's 8 bytes on 64bit targets and 4 on 32bit ones, both for
      unsigned long and for struct kernel_symbol.  Unfortunately, amd64 and
      m68k are unusual - m68k aligns to 2 bytes (for both) and amd64 aligns
      struct kernel_symbol to 16 bytes.  For those we'll need asm/export.h to
      override the constants used by generic version - KSYM_ALIGN and KCRC_ALIGN
      for kernel_symbol and unsigned long resp.  And no, __alignof__ would not
      do the trick - on amd64 __alignof__ of struct kernel_symbol is 8, not 16.
      
      More serious source of unpleasantness is treatment of function
      descriptors on architectures that have those.  Things like ppc64,
      parisc, ia64, etc.  need more than the address of the first insn to
      call an arbitrary function.  As the result, their representation of
      pointers to functions is not the typical "address of the entry point" -
      it's an address of a small static structure containing all the required
      information (including the entry point, of course).  Sadly, the asm-side
      conventions differ in what the function name refers to - entry point or
      the function descriptor.  On ppc64 we do the latter;
      	bar: .quad foo
      is what void (*bar)(void) = foo; turns into and the rare places where
      we need to explicitly work with the label of entry point are dealt with
      as DOTSYM(foo).  For our purposes it's ideal - generic macros are usable.
      However, parisc would have foo and P%foo used for label of entry point
      and address of the function descriptor and
      	bar: .long P%foo
      woudl be used instead.	ia64 goes similar to parisc in that respect,
      except that there it's @fptr(foo) rather than P%foo.  Such architectures
      need to define KSYM_FUNC that would turn a function name into whatever
      is needed to refer to function descriptor.
      
      What's more, on such architectures we need to know whether we are exporting
      a function or an object - in assembler we have to tell that explicitly, to
      decide whether we want EXPORT_SYMBOL(foo) produce e.g.
      	__ksymtab_foo: .quad foo
      or
      	__ksymtab_foo: .quad @fptr(foo)
      
      For that reason we introduce EXPORT_DATA_SYMBOL{,_GPL}(), to be used for
      exports of data objects.  On normal architectures it's the same thing
      as EXPORT_SYMBOL{,_GPL}(), but on parisc-like ones they differ and the
      right one needs to be used.  Most of the exports are functions, so we
      keep EXPORT_SYMBOL for those...
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      22823ab4