1. 20 May, 2020 1 commit
  2. 19 May, 2020 3 commits
  3. 18 May, 2020 2 commits
  4. 17 May, 2020 6 commits
  5. 15 May, 2020 5 commits
  6. 13 May, 2020 7 commits
  7. 12 May, 2020 6 commits
    • Thomas Bogendoerfer's avatar
      MIPS: Only include the platform file needed · 26bff9eb
      Thomas Bogendoerfer authored
      Instead of including all Platform files, we simply include the
      needed one and avoid clashes with makefile variables.
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      26bff9eb
    • Nathan Chancellor's avatar
      MIPS: VDSO: Allow ld.lld to link the VDSO · 22235ef3
      Nathan Chancellor authored
      Currently, when linking with ld.lld, this warning pops up:
      
          arch/mips/vdso/Makefile:70: MIPS VDSO requires binutils >= 2.25
      
      CONFIG_LD_VERSION is set with scripts/ld-version.sh, which is specific
      to GNU ld. It returns 0 for ld.lld so CONFIG_MIPS_LD_CAN_LINK_VDSO does
      not set.
      
      ld.lld has a completely different versioning scheme (as it follows
      LLVM's versioning) and it does not have the issue mentioned in the
      comment block so it should be allowed to link the VDSO.
      
      With this patch, the VDSO successfully links and shows P_MIPS_PC32 in
      vgettimeofday.o.
      
      $ llvm-objdump -Dr arch/mips/vdso/vgettimeofday.o | grep R_MIPS_PC32
      			00000024:  R_MIPS_PC32	_start
      			000000b0:  R_MIPS_PC32	_start
      			000002bc:  R_MIPS_PC32	_start
      			0000036c:  R_MIPS_PC32	_start
      			00000468:  R_MIPS_PC32	_start
      Reported-by: default avatarDmitry Golovin <dima@golovin.in>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Link: https://github.com/ClangBuiltLinux/linux/issues/785
      Link: https://github.com/llvm/llvm-project/commit/e364e2e9ce50c12eb2bf093560e1a1a8544d455aSigned-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      22235ef3
    • Nathan Chancellor's avatar
      MIPS: VDSO: Use $(LD) instead of $(CC) to link VDSO · 2ff90699
      Nathan Chancellor authored
      Currently, the VDSO is being linked through $(CC). This does not match
      how the rest of the kernel links objects, which is through the $(LD)
      variable.
      
      When clang is built in a default configuration, it first attempts to use
      the target triple's default linker then the system's default linker,
      unless told otherwise through -fuse-ld=... We do not use -fuse-ld=
      because it can be brittle and we have support for invoking $(LD)
      directly. See commit fe00e50b ("ARM: 8858/1: vdso: use $(LD)
      instead of $(CC) to link VDSO") and commit 691efbed ("arm64: vdso:
      use $(LD) instead of $(CC) to link VDSO") for examples of doing this in
      the VDSO.
      
      Do the same thing here. Replace the custom linking logic with $(cmd_ld)
      and ldflags-y so that $(LD) is respected. We need to explicitly add two
      flags to the linker that were implicitly passed by the compiler:
      -G 0 (which comes from ccflags-vdso) and --eh-frame-hdr.
      
      Before this patch (generated by adding '-v' to VDSO_LDFLAGS):
      
      <gcc_prefix>/libexec/gcc/mips64-linux/9.3.0/collect2 \
      -plugin <gcc_prefix>/libexec/gcc/mips64-linux/9.3.0/liblto_plugin.so \
      -plugin-opt=<gcc_prefix>/libexec/gcc/mips64-linux/9.3.0/lto-wrapper \
      -plugin-opt=-fresolution=/tmp/ccGEi5Ka.res \
      --eh-frame-hdr \
      -G 0 \
      -EB \
      -mips64r2 \
      -shared \
      -melf64btsmip \
      -o arch/mips/vdso/vdso.so.dbg.raw \
      -L<gcc_prefix>/lib/gcc/mips64-linux/9.3.0/64 \
      -L<gcc_prefix>/lib/gcc/mips64-linux/9.3.0 \
      -L<gcc_prefix>/lib/gcc/mips64-linux/9.3.0/../../../../mips64-linux/lib \
      -Bsymbolic \
      --no-undefined \
      -soname=linux-vdso.so.1 \
      -EB \
      --hash-style=sysv \
      --build-id \
      -T arch/mips/vdso/vdso.lds \
      arch/mips/vdso/elf.o \
      arch/mips/vdso/vgettimeofday.o \
      arch/mips/vdso/sigreturn.o
      
      After this patch:
      
      <gcc_prefix>/bin/mips64-linux-ld \
      -m elf64btsmip \
      -Bsymbolic \
      --no-undefined \
      -soname=linux-vdso.so.1 \
      -EB \
      -nostdlib \
      -shared \
      -G 0 \
      --eh-frame-hdr \
      --hash-style=sysv \
      --build-id \
      -T  arch/mips/vdso/vdso.lds \
      arch/mips/vdso/elf.o \
      arch/mips/vdso/vgettimeofday.o
      arch/mips/vdso/sigreturn.o \
      -o arch/mips/vdso/vdso.so.dbg.raw
      
      Note that we leave behind -mips64r2. Turns out that ld ignores it (see
      get_emulation in ld/ldmain.c). This is true of current trunk and 2.23,
      which is the minimum supported version for the kernel:
      
      https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/ldmain.c;hb=aa4209e7b679afd74a3860ce25659e71cc4847d5#l593
      https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/ldmain.c;hb=a55e30b51bc6227d8d41f707654d0a5620978dcf#l641
      
      Before this patch, LD=ld.lld did nothing:
      
      $ llvm-readelf -p.comment arch/mips/vdso/vdso.so.dbg | sed 's/(.*//'
      String dump of section '.comment':
      [     0] ClangBuiltLinux clang version 11.0.0
      
      After this patch, it does:
      
      $ llvm-readelf -p.comment arch/mips/vdso/vdso.so.dbg | sed 's/(.*//'
      String dump of section '.comment':
      [     0] Linker: LLD 11.0.0
      [    62] ClangBuiltLinux clang version 11.0.0
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/785Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      2ff90699
    • Nathan Chancellor's avatar
      MIPS: Unconditionally specify '-EB' or '-EL' · fd9d0ca2
      Nathan Chancellor authored
      This was all done to work around a GCC bug that has been fixed after
      4.2. The kernel requires GCC 4.6 or newer so remove all of these hacks
      and just use the traditional flags.
      
       $ mips64-linux-gcc --version | head -n1
       mips64-linux-gcc (GCC) 4.6.3
      
       $ mips64-linux-gcc -EB -dM -E -C -x c /dev/null | grep MIPSE
       #define MIPSEB 1
       #define __MIPSEB__ 1
       #define _MIPSEB 1
       #define __MIPSEB 1
      
       $ mips64-linux-gcc -EL -dM -E -C -x c /dev/null | grep MIPSE
       #define __MIPSEL__ 1
       #define MIPSEL 1
       #define _MIPSEL 1
       #define __MIPSEL 1
      
      This is necessary when converting the MIPS VDSO to use $(LD) instead of
      $(CC) to link because the OUTPUT_FORMAT is defaulted to little endian
      and only flips to big endian when '-EB' is set on the command line.
      There is no issue currently because the compiler explicitly passes
      '-EB' or '-EL' to the linker regardless of whether or not it was
      provided by the user. Passing '-v' to VDSO_LDFLAGS shows:
      
      <gcc_prefix>/libexec/gcc/mips64-linux/9.3.0/collect2 ... -EB ...
      
      even though '-EB' is nowhere to be found in KBUILD_CFLAGS. The VDSO
      Makefile already supports getting '-EB' or '-EL' from KBUILD_CFLAGS
      through a filter directive but '-EB' or '-EL' is not always present.
      
      If we do not do this, we will see the following error when compiling
      for big endian:
      
      $ make -j$(nproc) ARCH=mips CROSS_COMPILE=mips64-linux- \
        64r2el_defconfig arch/mips/vdso/
      ...
      mips64-linux-ld: arch/mips/vdso/elf.o: compiled for a big endian system
      and target is little endian
      mips64-linux-ld: arch/mips/vdso/elf.o: endianness incompatible with that
      of the selected emulation
      mips64-linux-ld: failed to merge target specific data of file
      arch/mips/vdso/elf.o
      ...
      
      Remove this legacy hack and just use '-EB' and '-EL' unconditionally.
      Reported-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      fd9d0ca2
    • Nathan Chancellor's avatar
      MIPS: VDSO: Move disabling the VDSO logic to Kconfig · e91946d6
      Nathan Chancellor authored
      After commit 9553d16f ("init/kconfig: Add LD_VERSION Kconfig"), we
      have access to GNU ld's version at configuration time. As a result, we
      can make it clearer under what configuration circumstances the MIPS VDSO
      needs to be disabled.
      
      This is a prerequisite for getting rid of the MIPS VDSO binutils
      warning and linking the VDSO when LD is ld.lld. Wrapping the call to
      ld-ifversion with CONFIG_LD_IS_LLD does not work because the config
      values are wiped away during 'make clean'.
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      e91946d6
    • Sami Tolvanen's avatar
      kbuild: add CONFIG_LD_IS_LLD · b744b43f
      Sami Tolvanen authored
      Similarly to the CC_IS_CLANG config, add LD_IS_LLD to avoid GNU ld
      specific logic such as ld-version or ld-ifversion and gain the
      ability to select potential features that depend on the linker at
      configuration time such as LTO.
      Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Acked-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      [nc: Reword commit message]
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Reviewed-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      b744b43f
  8. 11 May, 2020 1 commit
  9. 09 May, 2020 3 commits
  10. 08 May, 2020 3 commits
    • Gustavo A. R. Silva's avatar
      MIPS: Replace zero-length array with flexible-array · c4ad6ea9
      Gustavo A. R. Silva authored
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type[1]. There are some instances of code in
      which the sizeof operator is being incorrectly/erroneously applied to
      zero-length arrays and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also
      help to get completely rid of those sorts of issues.
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      c4ad6ea9
    • Tiezhu Yang's avatar
      MIPS: Loongson: Add DMA support for LS7A · 68fbb972
      Tiezhu Yang authored
      In the current market, the most used bridge chip on the Loongson platform
      are RS780E and LS7A, the RS780E bridge chip is already supported by the
      mainline kernel.
      
      If use the default implementation of __phys_to_dma() and __dma_to_phys()
      in dma-direct.h when CONFIG_ARCH_HAS_PHYS_TO_DMA is not set, it works
      well used with LS7A on the Loongson single-way and multi-way platform,
      and also works well used with RS780E on the Loongson single-way platform,
      but the DMA address will be wrong on the non-node0 used with RS780E on
      the Loongson multi-way platform.
      
      Just as the description in the code comment, the devices get node id from
      40 bit of HyperTransport bus, so we extract 2 bit node id (bit 44~45) from
      48 bit address space of Loongson CPU and embed it into HyperTransport bus
      (bit 37-38), this operation can be done only at the software level used
      with RS780E on the Loongson multi-way platform, because it has no hardware
      function to translate address of node id, this is a hardware compatibility
      problem.
      
      Device
          |
          | DMA address
          |
      Host Bridge
          |
          | HT bus address (40 bit)
          |
         CPU
          |
          | physical address (48 bit)
          |
         RAM
      
      The LS7A has dma_node_id_offset field in the DMA route config register,
      the hardware can use the dma_node_id_offset to translate address of
      node id automatically, so we can get correct address when just use the
      dma_pfn_offset field in struct device.
      
      For the above reasons, in order to maintain downward compatibility
      to support the RS780E bridge chip, it is better to use the platform
      dependent implementation of __phys_to_dma() and __dma_to_phys().
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      68fbb972
    • Huacai Chen's avatar
      MIPS: inst.h: Stop including asm.h to avoid various build failures · e701656e
      Huacai Chen authored
      Commit d339cd02 ("MIPS: Move unaligned load/store helpers to
      inst.h") causes a lot of build failures because macros in asm.h conflict
      with various subsystems. Some of these conflictions has been fixed (such
      as LONG, PANIC and PRINT) by adjusting asm.h, but some of them is nearly
      impossible to fix (such as PTR and END). The only reason of including
      asm.h in inst.h is that we need the PTR macro which is used by unaligned
      load/store helpers. So in this patch we define a new PTR_STR macro and
      use it to replace STR(PTR), then we can stop including asm.h to avoid
      various build failures.
      
      Fixes: d339cd02 ("MIPS: Move unaligned load/store helpers to inst.h")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      e701656e
  11. 07 May, 2020 3 commits