1. 04 Feb, 2021 3 commits
  2. 03 Feb, 2021 4 commits
  3. 27 Jan, 2021 6 commits
  4. 25 Jan, 2021 6 commits
  5. 22 Jan, 2021 7 commits
  6. 19 Jan, 2021 2 commits
  7. 18 Jan, 2021 4 commits
    • Alexander Lobakin's avatar
      MIPS: relocatable: optimize the relocation process · d9e84fb1
      Alexander Lobakin authored
      For now, vmlinux relocation functions for relocatable kernel are
      implemented as an array of handlers of a particular type.
      
      Convert that array into a single switch-case function to:
       - remove unused arguments;
       - change the return type of simple handlers to void;
       - remove the array and don't use any data at all;
       - avoid using indirect calls;
       - allow the compiler to inline and greatly optimize
         the relocation function[s];
      
      and also mark do_relocations() and show_kernel_relocation() static
      as they aren't used anywhere else.
      
      The result on MIPS32 R2 with GCC 10.2 -O2 is:
      
      scripts/bloat-o-meter -c arch/mips/kernel/__relocate.o arch/mips/kernel/relocate.o
      add/remove: 0/6 grow/shrink: 1/0 up/down: 356/-640 (-284)
      Function                                     old     new   delta
      relocate_kernel                              852    1208    +356
      apply_r_mips_32_rel                           20       -     -20
      apply_r_mips_hi16_rel                         40       -     -40
      apply_r_mips_64_rel                           44       -     -44
      apply_r_mips_26_rel                          144       -    -144
      show_kernel_relocation                       164       -    -164
      do_relocations                               228       -    -228
      Total: Before=1780, After=1496, chg -15.96%
      add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-76 (-76)
      Data                                         old     new   delta
      reloc_handlers_rel                            76       -     -76
      Total: Before=92, After=16, chg -82.61%
      add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
      RO Data                                      old     new   delta
      Total: Before=0, After=0, chg +0.00%
      
      All functions were collapsed into the main one, relocate_kernel().
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      d9e84fb1
    • Alexander Lobakin's avatar
      MIPS: module: optimize module relocations processing · 049a68ef
      Alexander Lobakin authored
      For now, module relocation functions are implemented as an array
      of handlers of type reloc_handler_t.
      
      Convert that array into a single switch-case function to:
       - remove unused arguments;
       - change the return type of simple handlers to void;
       - remove the array and don't use any data at all;
       - avoid using indirect calls;
       - allow the compiler to inline and greatly optimize
         the relocation function[s].
      
      The result on MIPS32 R2 with GCC 10.2 -O2 is:
      
      scripts/bloat-o-meter -c arch/mips/kernel/__module.o arch/mips/kernel/module.o
      add/remove: 1/11 grow/shrink: 1/0 up/down: 876/-1436 (-560)
      Function                                     old     new   delta
      apply_relocate                               456    1148    +692
      apply_r_mips_pc                                -     184    +184
      apply_r_mips_none                              8       -      -8
      apply_r_mips_32                               16       -     -16
      apply_r_mips_64                               76       -     -76
      apply_r_mips_highest                          88       -     -88
      apply_r_mips_higher                          108       -    -108
      apply_r_mips_26                              132       -    -132
      apply_r_mips_pc26                            160       -    -160
      apply_r_mips_pc21                            160       -    -160
      apply_r_mips_pc16                            160       -    -160
      apply_r_mips_hi16                            172       -    -172
      apply_r_mips_lo16                            356       -    -356
      Total: Before=2608, After=2048, chg -21.47%
      add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
      Data                                         old     new   delta
      Total: Before=12, After=12, chg +0.00%
      add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-248 (-248)
      RO Data                                      old     new   delta
      reloc_handlers                               248       -    -248
      Total: Before=248, After=0, chg -100.00%
      
      All functions were collapsed into a single one that is called
      directly by $(srctree)/kernel/module.c.
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      049a68ef
    • Nathan Chancellor's avatar
      MIPS: VDSO: Use CLANG_FLAGS instead of filtering out '--target=' · 76d7fff2
      Nathan Chancellor authored
      Commit ee67855e ("MIPS: vdso: Allow clang's --target flag in VDSO
      cflags") allowed the '--target=' flag from the main Makefile to filter
      through to the vDSO. However, it did not bring any of the other clang
      specific flags for controlling the integrated assembler and the GNU
      tools locations (--prefix=, --gcc-toolchain=, and -no-integrated-as).
      Without these, we will get a warning (visible with tinyconfig):
      
      arch/mips/vdso/elf.S:14:1: warning: DWARF2 only supports one section per
      compilation unit
      .pushsection .note.Linux, "a",@note ; .balign 4 ; .long 2f - 1f ; .long
      4484f - 3f ; .long 0 ; 1:.asciz "Linux" ; 2:.balign 4 ; 3:
      ^
      arch/mips/vdso/elf.S:34:2: warning: DWARF2 only supports one section per
      compilation unit
       .section .mips_abiflags, "a"
       ^
      
      All of these flags are bundled up under CLANG_FLAGS in the main Makefile
      and exported so that they can be added to Makefiles that set their own
      CFLAGS. Use this value instead of filtering out '--target=' so there is
      no warning and all of the tools are properly used.
      
      Cc: stable@vger.kernel.org
      Fixes: ee67855e ("MIPS: vdso: Allow clang's --target flag in VDSO cflags")
      Link: https://github.com/ClangBuiltLinux/linux/issues/1256Reported-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      76d7fff2
    • Paul Cercueil's avatar
      MIPS: Ingenic: Disable HPTLB for D0 XBurst CPUs too · a5360958
      Paul Cercueil authored
      The JZ4760 has the HPTLB as well, but has a XBurst CPU with a D0 CPUID.
      
      Disable the HPTLB for all XBurst CPUs with a D0 CPUID. In the case where
      there is no HPTLB (e.g. for older SoCs), this won't have any side
      effect.
      
      Fixes: b02efeb0 ("MIPS: Ingenic: Disable abandoned HPTLB function.")
      Cc: <stable@vger.kernel.org> # 5.4
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Reviewed-by: default avatar周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      a5360958
  8. 15 Jan, 2021 8 commits
    • Aurelien Jarno's avatar
      MIPS: Support binutils configured with --enable-mips-fix-loongson3-llsc=yes · 5373ae67
      Aurelien Jarno authored
      From version 2.35, binutils can be configured with
      --enable-mips-fix-loongson3-llsc=yes, which means it defaults to
      -mfix-loongson3-llsc. This breaks labels which might then point at the
      wrong instruction.
      
      The workaround to explicitly pass -mno-fix-loongson3-llsc has been
      added in Linux version 5.1, but is only enabled when building a Loongson
      64 kernel. As vendors might use a common toolchain for building Loongson
      and non-Loongson kernels, just move that workaround to
      arch/mips/Makefile. At the same time update the comments to reflect the
      current status.
      
      Cc: stable@vger.kernel.org # 5.1+
      Cc: YunQiang Su <syq@debian.org>
      Signed-off-by: default avatarAurelien Jarno <aurelien@aurel32.net>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      5373ae67
    • Nathan Chancellor's avatar
      MIPS: Compare __SYNC_loongson3_war against 0 · 8790ccf8
      Nathan Chancellor authored
      When building with clang when CONFIG_CPU_LOONGSON3_WORKAROUNDS is
      enabled:
      
       In file included from lib/errseq.c:4:
       In file included from ./include/linux/atomic.h:7:
       ./arch/mips/include/asm/atomic.h:52:1: warning: converting the result of
       '<<' to a boolean always evaluates to true
       [-Wtautological-constant-compare]
       ATOMIC_OPS(atomic64, s64)
       ^
       ./arch/mips/include/asm/atomic.h:40:9: note: expanded from macro
       'ATOMIC_OPS'
               return cmpxchg(&v->counter, o, n);
                      ^
       ./arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro
       'cmpxchg'
               if (!__SYNC_loongson3_war)
                    ^
       ./arch/mips/include/asm/sync.h:147:34: note: expanded from macro
       '__SYNC_loongson3_war'
       # define __SYNC_loongson3_war   (1 << 31)
                                          ^
      
      While it is not wrong that the result of this shift is always true in a
      boolean context, it is not a problem here. Regardless, the warning is
      really noisy so rather than making the shift a boolean implicitly, use
      it in an equality comparison so the shift is used as an integer value.
      
      Fixes: 4d1dbfe6 ("MIPS: atomic: Emit Loongson3 sync workarounds within asm")
      Fixes: a91f2a1d ("MIPS: cmpxchg: Omit redundant barriers for Loongson3")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Acked-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      8790ccf8
    • Alexander Lobakin's avatar
      MIPS: pgtable: fix -Wshadow in asm/pgtable.h · cabcff9b
      Alexander Lobakin authored
      Solves the following repetitive warning when building with -Wshadow:
      
      In file included from ./include/linux/pgtable.h:6,
                       from ./include/linux/mm.h:33,
                       from ./include/linux/dax.h:6,
                       from ./include/linux/mempolicy.h:11,
                       from kernel/fork.c:34:
      ./arch/mips/include/asm/mmu_context.h: In function ‘switch_mm’:
      ./arch/mips/include/asm/pgtable.h:97:16: warning: declaration of ‘flags’ shadows a previous local [-Wshadow]
         97 |  unsigned long flags;      \
            |                ^~~~~
      ./arch/mips/include/asm/mmu_context.h:162:2: note: in expansion of macro ‘htw_stop’
        162 |  htw_stop();
            |  ^~~~~~~~
      In file included from kernel/fork.c:102:
      ./arch/mips/include/asm/mmu_context.h:159:16: note: shadowed declaration is here
        159 |  unsigned long flags;
            |                ^~~~~
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      cabcff9b
    • Alexander Lobakin's avatar
      MIPS: bitops: fix -Wshadow in asm/bitops.h · 97c97c6a
      Alexander Lobakin authored
      Solves the following repetitive warning when building with -Wshadow:
      
      In file included from ./include/linux/bitops.h:32,
                       from ./include/linux/kernel.h:11,
                       from ./include/linux/skbuff.h:13,
                       from ./include/linux/if_ether.h:19,
                       from ./include/linux/etherdevice.h:20:
      ./arch/mips/include/asm/bitops.h: In function ‘test_and_set_bit_lock’:
      ./arch/mips/include/asm/bitops.h:46:16: warning: declaration of ‘orig’ shadows a previous local [-Wshadow]
         46 |  unsigned long orig, temp;    \
            |                ^~~~
      ./arch/mips/include/asm/bitops.h:190:10: note: in expansion of macro ‘__test_bit_op’
        190 |   orig = __test_bit_op(*m, "%0",
            |          ^~~~~~~~~~~~~
      ./arch/mips/include/asm/bitops.h:185:21: note: shadowed declaration is here
        185 |  unsigned long res, orig;
            |                     ^~~~
      ./arch/mips/include/asm/bitops.h: In function ‘test_and_clear_bit’:
      ./arch/mips/include/asm/bitops.h:46:16: warning: declaration of ‘orig’ shadows a previous local [-Wshadow]
         46 |  unsigned long orig, temp;    \
            |                ^~~~
      ./arch/mips/include/asm/bitops.h:236:9: note: in expansion of macro ‘__test_bit_op’
        236 |   res = __test_bit_op(*m, "%1",
            |         ^~~~~~~~~~~~~
      ./arch/mips/include/asm/bitops.h:229:21: note: shadowed declaration is here
        229 |  unsigned long res, orig;
            |                     ^~~~
      ./arch/mips/include/asm/bitops.h:46:16: warning: declaration of ‘orig’ shadows a previous local [-Wshadow]
         46 |  unsigned long orig, temp;    \
            |                ^~~~
      ./arch/mips/include/asm/bitops.h:241:10: note: in expansion of macro ‘__test_bit_op’
        241 |   orig = __test_bit_op(*m, "%0",
            |          ^~~~~~~~~~~~~
      ./arch/mips/include/asm/bitops.h:229:21: note: shadowed declaration is here
        229 |  unsigned long res, orig;
            |                     ^~~~
      ./arch/mips/include/asm/bitops.h: In function ‘test_and_change_bit’:
      ./arch/mips/include/asm/bitops.h:46:16: warning: declaration of ‘orig’ shadows a previous local [-Wshadow]
         46 |  unsigned long orig, temp;    \
            |                ^~~~
      ./arch/mips/include/asm/bitops.h:273:10: note: in expansion of macro ‘__test_bit_op’
        273 |   orig = __test_bit_op(*m, "%0",
            |          ^~~~~~~~~~~~~
      ./arch/mips/include/asm/bitops.h:266:21: note: shadowed declaration is here
        266 |  unsigned long res, orig;
            |                     ^~~~
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      97c97c6a
    • Alexander Lobakin's avatar
      MIPS: select ARCH_WANT_LD_ORPHAN_WARN · d3a4e0f1
      Alexander Lobakin authored
      Now, after that all the sections are explicitly described and
      declared in vmlinux.lds.S, we can enable ld orphan warnings to
      prevent from missing any new sections in future.
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      d3a4e0f1
    • Alexander Lobakin's avatar
      vmlinux.lds.h: catch UBSAN's "unnamed data" into data · f41b233d
      Alexander Lobakin authored
      When building kernel with both LD_DEAD_CODE_DATA_ELIMINATION and
      UBSAN, LLVM stack generates lots of "unnamed data" sections:
      
      ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_2)
      is being placed in '.data.$__unnamed_2'
      ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_3)
      is being placed in '.data.$__unnamed_3'
      ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_4)
      is being placed in '.data.$__unnamed_4'
      ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_5)
      is being placed in '.data.$__unnamed_5'
      
      [...]
      
      Also handle this by adding the related sections to generic definitions.
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      f41b233d
    • Alexander Lobakin's avatar
      vmlinux.lds.h: catch compound literals into data and BSS · 9a427556
      Alexander Lobakin authored
      When building kernel with LD_DEAD_CODE_DATA_ELIMINATION, LLVM stack
      generates separate sections for compound literals, just like in case
      with enabled LTO [0]:
      
      ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
      (.data..compoundliteral.14) is being placed in
      '.data..compoundliteral.14'
      ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
      (.data..compoundliteral.15) is being placed in
      '.data..compoundliteral.15'
      ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
      (.data..compoundliteral.16) is being placed in
      '.data..compoundliteral.16'
      ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
      (.data..compoundliteral.17) is being placed in
      '.data..compoundliteral.17'
      
      [...]
      
      Handle this by adding the related sections to generic definitions
      as suggested by Sami [0].
      
      [0] https://lore.kernel.org/lkml/20201211184633.3213045-3-samitolvanen@google.comSuggested-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Suggested-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      9a427556
    • Alexander Lobakin's avatar
      MIPS: vmlinux.lds.S: explicitly declare .got table · 795b3a36
      Alexander Lobakin authored
      LLVM stack generates GOT table when building the kernel:
      
      ld.lld: warning: <internal>:(.got) is being placed in '.got'
      
      According to the debug assertions, it's not zero-sized and thus can't
      be handled the way it's done for x86.
      Also use the ARM64 path here and place it at the end of .text section.
      Reported-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      795b3a36