1. 18 Jan, 2021 2 commits
  2. 15 Jan, 2021 13 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
    • Alexander Lobakin's avatar
      MIPS: vmlinux.lds.S: explicitly catch .rel.dyn symbols · 008c3cbd
      Alexander Lobakin authored
      According to linker warnings, both GCC and LLVM generate '.rel.dyn'
      symbols:
      
      mips-alpine-linux-musl-ld: warning: orphan section `.rel.dyn'
      from `init/main.o' being placed in section `.rel.dyn'
      
      Link-time assertion shows that this section is sometimes empty,
      sometimes not, depending on machine bitness and the compiler [0]:
      
        LD      .tmp_vmlinux.kallsyms1
      mips64-linux-gnu-ld: Unexpected run-time relocations (.rel) detected!
      
      Just use the ARM64 approach and declare it in vmlinux.lds.S closer
      to __init_end.
      
      [0] https://lore.kernel.org/linux-mips/20210109111259.GA4213@alpha.franken.deReported-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      008c3cbd
    • Alexander Lobakin's avatar
      MIPS: properly stop .eh_frame generation · 894ef530
      Alexander Lobakin authored
      Commit 866b6a89 ("MIPS: Add DWARF unwinding to assembly") added
      -fno-asynchronous-unwind-tables to KBUILD_CFLAGS to prevent compiler
      from emitting .eh_frame symbols.
      However, as MIPS heavily uses CFI, that's not enough. Use the
      approach taken for x86 (as it also uses CFI) and explicitly put CFI
      symbols into the .debug_frame section (except for VDSO).
      This allows us to drop .eh_frame from DISCARDS as it's no longer
      being generated.
      
      Fixes: 866b6a89 ("MIPS: Add DWARF unwinding to assembly")
      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>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      894ef530
    • Alexander Lobakin's avatar
      MIPS: vmlinux.lds.S: add ".gnu.attributes" to DISCARDS · 5629d418
      Alexander Lobakin authored
      Discard GNU attributes (MIPS FP type, GNU Hash etc.) at link time
      as kernel doesn't use it at all.
      Solves a dozen of the following ld warnings (one per every file):
      
      mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes'
      from `arch/mips/kernel/head.o' being placed in section
      `.gnu.attributes'
      mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes'
      from `init/main.o' being placed in section `.gnu.attributes'
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      5629d418
    • Alexander Lobakin's avatar
      MIPS: CPS: don't create redundant .text.cps-vec section · ee90fef1
      Alexander Lobakin authored
      A number of symbols from arch/mips/kernel/cps-vec.S is explicitly
      placed into '.text.cps-vec' section.
      There are no direct references to this section, so there's no need
      to form it. '.balign 0x1000' directive will work anyway.
      
      Moreover, this section was being placed in vmlinux differently
      depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION:
       - with this option enabled, '.text.cps-vec' was being caught
         by '.text.[0-9a-zA-Z_]*' from include/asm-generic/vmlinux.lds.h;
       - without this option, '.text.cps-vec' was being caught
         by discouraging '.text.*' from arch/mips/kernel/vmlinux.lds.S.
      
      '.text.*' should not be used in vmlinux linker scripts at all as it
      silently catches any orphan text sections.
      So, remove both '.section .text.cps-vec' and '.text.*' from cps-vec.S
      and vmlinux.lds.S respectively. As said, this does not affect related
      functions alignment:
      
      80116000 T mips_cps_core_entry
      80116028 t not_nmi
      80116200 T excep_tlbfill
      80116280 T excep_xtlbfill
      80116300 T excep_cache
      80116380 T excep_genex
      80116400 T excep_intex
      80116480 T excep_ejtag
      80116490 T mips_cps_core_init
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      ee90fef1
    • Alexander Lobakin's avatar
      MIPS: vmlinux.lds.S: add missing PAGE_ALIGNED_DATA() section · 8ac7c87a
      Alexander Lobakin authored
      MIPS uses its own declaration of rwdata, and thus it should be kept
      in sync with the asm-generic one. Currently PAGE_ALIGNED_DATA() is
      missing from the linker script, which emits the following ld
      warnings:
      
      mips-alpine-linux-musl-ld: warning: orphan section
      `.data..page_aligned' from `arch/mips/kernel/vdso.o' being placed
      in section `.data..page_aligned'
      mips-alpine-linux-musl-ld: warning: orphan section
      `.data..page_aligned' from `arch/mips/vdso/vdso-image.o' being placed
      in section `.data..page_aligned'
      
      Add the necessary declaration, so the mentioned structures will be
      placed in vmlinux as intended:
      
      ffffffff80630580 D __end_once
      ffffffff80630580 D __start___dyndbg
      ffffffff80630580 D __start_once
      ffffffff80630580 D __stop___dyndbg
      ffffffff80634000 d mips_vdso_data
      ffffffff80638000 d vdso_data
      ffffffff80638580 D _gp
      ffffffff8063c000 T __init_begin
      ffffffff8063c000 D _edata
      ffffffff8063c000 T _sinittext
      
      ->
      
      ffffffff805a4000 D __end_init_task
      ffffffff805a4000 D __nosave_begin
      ffffffff805a4000 D __nosave_end
      ffffffff805a4000 d mips_vdso_data
      ffffffff805a8000 d vdso_data
      ffffffff805ac000 D mmlist_lock
      ffffffff805ac080 D tasklist_lock
      
      Fixes: ebb5e78c ("MIPS: Initial implementation of a VDSO")
      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>
      Cc: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      8ac7c87a
  3. 13 Jan, 2021 5 commits
  4. 09 Jan, 2021 1 commit
  5. 07 Jan, 2021 7 commits
  6. 04 Jan, 2021 7 commits
  7. 28 Dec, 2020 3 commits
  8. 27 Dec, 2020 2 commits