1. 29 Jan, 2021 1 commit
  2. 15 Dec, 2020 1 commit
  3. 03 Dec, 2020 2 commits
  4. 01 Dec, 2020 1 commit
    • Nathan Chancellor's avatar
      kbuild: Hoist '--orphan-handling' into Kconfig · 59612b24
      Nathan Chancellor authored
      Currently, '--orphan-handling=warn' is spread out across four different
      architectures in their respective Makefiles, which makes it a little
      unruly to deal with in case it needs to be disabled for a specific
      linker version (in this case, ld.lld 10.0.1).
      
      To make it easier to control this, hoist this warning into Kconfig and
      the main Makefile so that disabling it is simpler, as the warning will
      only be enabled in a couple places (main Makefile and a couple of
      compressed boot folders that blow away LDFLAGS_vmlinx) and making it
      conditional is easier due to Kconfig syntax. One small additional
      benefit of this is saving a call to ld-option on incremental builds
      because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.
      
      To keep the list of supported architectures the same, introduce
      CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
      gain this automatically after all of the sections are specified and size
      asserted. A special thanks to Kees Cook for the help text on this
      config.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1187
      
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      59612b24
  5. 17 Nov, 2020 1 commit
  6. 08 Oct, 2020 1 commit
  7. 24 Sep, 2020 1 commit
  8. 22 Jun, 2020 1 commit
  9. 01 Apr, 2020 2 commits
  10. 04 Mar, 2020 1 commit
  11. 25 Nov, 2019 1 commit
    • Nathan Chancellor's avatar
      powerpc: Don't add -mabi= flags when building with Clang · 465bfd9c
      Nathan Chancellor authored
      When building pseries_defconfig, building vdso32 errors out:
      
        error: unknown target ABI 'elfv1'
      
      This happens because -m32 in clang changes the target to 32-bit,
      which does not allow the ABI to be changed.
      
      Commit 4dc831aa ("powerpc: Fix compiling a BE kernel with a
      powerpc64le toolchain") added these flags to fix building big endian
      kernels with a little endian GCC.
      
      Clang doesn't need -mabi because the target triple controls the
      default value. -mlittle-endian and -mbig-endian manipulate the triple
      into either powerpc64-* or powerpc64le-*, which properly sets the
      default ABI.
      
      Adding a debug print out in the PPC64TargetInfo constructor after line
      383 above shows this:
      
        $ echo | ./clang -E --target=powerpc64-linux -mbig-endian -o /dev/null -
        Default ABI: elfv1
      
        $ echo | ./clang -E --target=powerpc64-linux -mlittle-endian -o /dev/null -
        Default ABI: elfv2
      
        $ echo | ./clang -E --target=powerpc64le-linux -mbig-endian -o /dev/null -
        Default ABI: elfv1
      
        $ echo | ./clang -E --target=powerpc64le-linux -mlittle-endian -o /dev/null -
        Default ABI: elfv2
      
      Don't specify -mabi when building with clang to avoid the build error
      with -m32 and not change any code generation.
      
      -mcall-aixdesc is not an implemented flag in clang so it can be safely
      excluded as well, see commit 238abecd
      
       ("powerpc: Don't use gcc
      specific options on clang").
      
      pseries_defconfig successfully builds after this patch and
      powernv_defconfig and ppc44x_defconfig don't regress.
      Reviewed-by: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      [mpe: Trim clang links in change log]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191119045712.39633-2-natechancellor@gmail.com
      465bfd9c
  12. 28 Oct, 2019 1 commit
  13. 22 Aug, 2019 1 commit
  14. 21 Aug, 2019 1 commit
  15. 20 Aug, 2019 1 commit
    • Michael Ellerman's avatar
      powerpc/Makefile: Always pass --synthetic to nm if supported · 117acf5c
      Michael Ellerman authored
      
      Back in 2004 we added logic to arch/ppc64/Makefile to pass
      the --synthetic option to nm, if it was supported by nm.
      
      Then in 2005 when arch/ppc64 and arch/ppc were merged, the logic to
      add --synthetic was moved inside an #ifdef CONFIG_PPC64 block within
      arch/powerpc/Makefile, and has remained there since.
      
      That was fine, though crufty, until recently when a change to
      init/Kconfig added a config time check that uses $(NM). On powerpc
      that leads to an infinite loop because Kconfig uses $(NM) to calculate
      some values, then the powerpc Makefile changes $(NM), which Kconfig
      notices and restarts.
      
      The original commit that added --synthetic simply said:
        On new toolchains we need to use nm --synthetic or we miss code
        symbols.
      
      And the nm man page says that the --synthetic option causes nm to:
        Include synthetic symbols in the output. These are special symbols
        created by the linker for various purposes.
      
      So it seems safe to always pass --synthetic if nm supports it, ie. on
      32-bit and 64-bit, it just means 32-bit kernels might have more
      symbols reported (and in practice I see no extra symbols). Making it
      unconditional avoids the #ifdef CONFIG_PPC64, which in turn avoids the
      infinite loop.
      Debugged-by: default avatarPeter Collingbourne <pcc@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      117acf5c
  16. 18 May, 2019 1 commit
  17. 20 Apr, 2019 3 commits
  18. 23 Feb, 2019 2 commits
    • Christophe Leroy's avatar
      powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU · f7354cca
      Christophe Leroy authored
      
      Now that thread_info is similar to task_struct, its address is in r2
      so CURRENT_THREAD_INFO() macro is useless. This patch removes it.
      
      This patch also moves the 'tovirt(r2, r2)' down just before the
      reactivation of MMU translation, so that we keep the physical address
      of 'current' in r2 until then. It avoids a few calls to tophys().
      
      At the same time, as the 'cpu' field is not anymore in thread_info,
      TI_CPU is renamed TASK_CPU by this patch.
      
      It also allows to get rid of a couple of
      '#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE' as ACCOUNT_CPU_USER_ENTRY()
      and ACCOUNT_CPU_USER_EXIT() are empty when
      CONFIG_VIRT_CPU_ACCOUNTING_NATIVE is not defined.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      [mpe: Fix a missed conversion of TI_CPU idle_6xx.S]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      f7354cca
    • Christophe Leroy's avatar
      powerpc: Activate CONFIG_THREAD_INFO_IN_TASK · ed1cd6de
      Christophe Leroy authored
      
      This patch activates CONFIG_THREAD_INFO_IN_TASK which
      moves the thread_info into task_struct.
      
      Moving thread_info into task_struct has the following advantages:
        - It protects thread_info from corruption in the case of stack
          overflows.
        - Its address is harder to determine if stack addresses are leaked,
          making a number of attacks more difficult.
      
      This has the following consequences:
        - thread_info is now located at the beginning of task_struct.
        - The 'cpu' field is now in task_struct, and only exists when
          CONFIG_SMP is active.
        - thread_info doesn't have anymore the 'task' field.
      
      This patch:
        - Removes all recopy of thread_info struct when the stack changes.
        - Changes the CURRENT_THREAD_INFO() macro to point to current.
        - Selects CONFIG_THREAD_INFO_IN_TASK.
        - Modifies raw_smp_processor_id() to get ->cpu from current without
          including linux/sched.h to avoid circular inclusion and without
          including asm/asm-offsets.h to avoid symbol names duplication
          between ASM constants and C constants.
        - Modifies klp_init_thread_info() to take a task_struct pointer
          argument.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
      [mpe: Add task_stack.h to livepatch.h to fix build fails]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ed1cd6de
  19. 14 Jan, 2019 1 commit
  20. 21 Dec, 2018 1 commit
    • Firoz Khan's avatar
      powerpc: generate uapi header and system call table files · ab66dcc7
      Firoz Khan authored
      
      System call table generation script must be run to gener-
      ate unistd_32/64.h and syscall_table_32/64/c32/spu.h files.
      This patch will have changes which will invokes the script.
      
      This patch will generate unistd_32/64.h and syscall_table-
      _32/64/c32/spu.h files by the syscall table generation
      script invoked by parisc/Makefile and the generated files
      against the removed files must be identical.
      
      The generated uapi header file will be included in uapi/-
      asm/unistd.h and generated system call table header file
      will be included by kernel/systbl.S file.
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ab66dcc7
  21. 20 Dec, 2018 1 commit
    • Joel Stanley's avatar
      powerpc/32: Avoid unsupported flags with clang · 72e7bcc2
      Joel Stanley authored
      When building for ppc32 with clang these flags are unsupported:
      
        -ffixed-r2 and -mmultiple
      
      llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on
      when building for SVR4ABI and !ppc64:
      
        // The SVR4 ABI reserves r2 and r13
        if (Subtarget.isSVR4ABI()) {
          // We only reserve r2 if we need to use the TOC pointer. If we have no
          // explicit uses of the TOC pointer (meaning we're a leaf function with
          // no constant-pool loads, etc.) and we have no potential uses inside an
          // inline asm block, then we can treat r2 has an ordinary callee-saved
          // register.
          const PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
          if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
            markSuperRegs(Reserved, PPC::R2);  // System-reserved register
          markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
        }
      
      This means we can safely omit -ffixed-r2 when building for 32-bit
      targets.
      
      The -mmultiple/-mno-multiple flags are not supported by clang, so
      platforms that might support multiple miss out on using multiple word
      instructions.
      
      We wrap these flags in cc-option so that when Clang gains support the
      kernel will be able use these flags.
      
      Clang 8 can then build a ppc44x_defconfig which boots in Qemu:
      
        make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  ppc44x_defconfig
        ./scripts/config -e CONFIG_DEVTMPFS -d DEVTMPFS_MOUNT
        make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
      
        qemu-system-ppc -M bamboo \
         -kernel arch/powerpc/boot/zImage \
         -dtb arch/powerpc/boot/dts/bamboo.dtb \
         -initrd ~/ppc32-440-rootfs.cpio \
         -nographic -serial stdio -monitor pty -append "console=ttyS0"
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/261
      Link: https://bugs.llvm.org/show_bug.cgi?id=39556
      Link: https://bugs.llvm.org/show_bug.cgi?id=39555
      
      Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      72e7bcc2
  22. 17 Dec, 2018 1 commit
    • Mathieu Malaterre's avatar
      powerpc/32: Move the old 6xx -mcpu logic before the TARGET_CPU logic · ebd1d3b7
      Mathieu Malaterre authored
      The code:
      
        ifdef CONFIG_6xx
        KBUILD_CFLAGS          += -mcpu=powerpc
        endif
      
      was added in 2006 in commit f48b8296 ("[PATCH] powerpc32: Set cpu
      explicitly in kernel compiles"). This change was acceptable since the
      TARGET_CPU logic was 64-bit only.
      
      Since commit 0e00a8c9 ("powerpc: Allow CPU selection
      also on PPC32") this logic is no longer acceptable after the TARGET_CPU
      specific. It currently appends -mcpu=powerpc at the end of the command
      line, after any TARGET_CPU specific:
      
        gcc -Wp,-MD,init/.do_mounts.o.d ...
          -mcpu=powerpc -mbig-endian -m32 ...
          -mcpu=e300c2 ...
          -mcpu=powerpc ...
          ../init/do_mounts.c
      
      Fixes: 0e00a8c9
      
       ("powerpc: Allow CPU selection also on PPC32")
      Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ebd1d3b7
  23. 09 Dec, 2018 1 commit
  24. 26 Nov, 2018 2 commits
  25. 02 Nov, 2018 1 commit
  26. 18 Oct, 2018 1 commit
    • Michael Ellerman's avatar
      powerpc: Move core kernel logic into arch/powerpc/Kbuild · c47ca98d
      Michael Ellerman authored
      
      This is a nice cleanup, arch/powerpc/Makefile is long and messy so
      moving this out helps a little.
      
      It also allows us to do:
      
        $ make arch/powerpc
      
      Which can be helpful if you just want to compile test some changes to
      arch code and not link everything.
      
      Finally it also gives us a single place to do subdir-cc-flags
      assignments which affect the whole of arch/powerpc, which we will do
      in a future patch.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      c47ca98d
  27. 13 Oct, 2018 1 commit
    • Joel Stanley's avatar
      powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS · 960e3002
      Joel Stanley authored
      Ever since commit 15a3204d
      
       ("powerpc/64s: Set assembler machine type
      to POWER4") we force -mpower4 to be passed to the assembler
      irrespective of the CFLAGS used (for Book3s 64).
      
      When building a powerpc64 kernel with clang, clang will not add -many
      to the assembler flags, so any instructions that the compiler has
      generated that are not available on power4 will cause an error:
      
        /usr/bin/as -a64 -mppc64 -mlittle-endian -mpower8 \
         -I ./arch/powerpc/include -I ./arch/powerpc/include/generated \
         -I ./include -I ./arch/powerpc/include/uapi \
         -I ./arch/powerpc/include/generated/uapi -I ./include/uapi \
         -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc \
         -maltivec -mpower4 -o init/do_mounts.o /tmp/do_mounts-3b0a3d.s
        /tmp/do_mounts-51ce54.s:748: Error: unrecognized opcode: `isel'
      
      GCC does include -many, so the GCC driven gas call will succeed:
      
        as -v -I ./arch/powerpc/include -I ./arch/powerpc/include/generated -I
        ./include -I ./arch/powerpc/include/uapi
        -I ./arch/powerpc/include/generated/uapi -I ./include/uapi
        -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc
         -a64 -mpower8 -many -mlittle -maltivec -mpower4 -o init/do_mounts.o
      
      Note that isel is power7 and above for IBM CPUs. GCC only generates it
      for Power9 and above, but the above test was run against the clang
      generated assembly.
      
      Peter Bergner explains:
      
        When using -many -mpower4, gas will first try and find a matching
        power4 mnemonic and failing that, it will then allow any valid
        mnemonic that gas knows about. GCC's use of -many predates me
        though.
      
        IIRC, Alan looked at trying to remove it, but I forget why he
        didn't. Could be either a gcc or gas issue at the time. I'm not sure
        whether issue still exists or not. He and I have modified how gas
        works internally a fair amount since he tried removing gcc use of
        -many.
      
        I will also note that when using -many, gas will choose the first
        mnemonic that matches in the mnemonic table and we have (mostly)
        sorted the table so that server mnemonics show up earlier in the
        table than other mnemonics, so they'll be seen/chosen first.
      
      By explicitly setting -many we can build with Clang and GCC while
      retaining the -mpower4 option.
      Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      960e3002
  28. 04 Oct, 2018 1 commit
  29. 03 Oct, 2018 2 commits
    • Christophe Leroy's avatar
      powerpc/64: add stack protector support · 06ec27ae
      Christophe Leroy authored
      
      On PPC64, as register r13 points to the paca_struct at all time,
      this patch adds a copy of the canary there, which is copied at
      task_switch.
      That new canary is then used by using the following GCC options:
      -mstack-protector-guard=tls
      -mstack-protector-guard-reg=r13
      -mstack-protector-guard-offset=offsetof(struct paca_struct, canary))
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      06ec27ae
    • Christophe Leroy's avatar
      powerpc/32: add stack protector support · c3ff2a51
      Christophe Leroy authored
      This functionality was tentatively added in the past
      (commit 6533b7c1 ("powerpc: Initial stack protector
      (-fstack-protector) support")) but had to be reverted
      (commit f2574030
      
       ("powerpc: Revert the initial stack
      protector support") because of GCC implementing it differently
      whether it had been built with libc support or not.
      
      Now, GCC offers the possibility to manually set the
      stack-protector mode (global or tls) regardless of libc support.
      
      This time, the patch selects HAVE_STACKPROTECTOR only if
      -mstack-protector-guard=tls is supported by GCC.
      
      On PPC32, as register r2 points to current task_struct at
      all time, the stack_canary located inside task_struct can be
      used directly by using the following GCC options:
      -mstack-protector-guard=tls
      -mstack-protector-guard-reg=r2
      -mstack-protector-guard-offset=offsetof(struct task_struct, stack_canary))
      
      The protector is disabled for prom_init and bootx_init as
      it is too early to handle it properly.
      
       $ echo CORRUPT_STACK > /sys/kernel/debug/provoke-crash/DIRECT
      [  134.943666] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: lkdtm_CORRUPT_STACK+0x64/0x64
      [  134.943666]
      [  134.955414] CPU: 0 PID: 283 Comm: sh Not tainted 4.18.0-s3k-dev-12143-ga3272be41209 #835
      [  134.963380] Call Trace:
      [  134.965860] [c6615d60] [c001f76c] panic+0x118/0x260 (unreliable)
      [  134.971775] [c6615dc0] [c001f654] panic+0x0/0x260
      [  134.976435] [c6615dd0] [c032c368] lkdtm_CORRUPT_STACK_STRONG+0x0/0x64
      [  134.982769] [c6615e00] [ffffffff] 0xffffffff
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      c3ff2a51
  30. 02 Oct, 2018 2 commits
    • Rob Herring's avatar
      kbuild: consolidate Devicetree dtb build rules · 37c8a5fa
      Rob Herring authored
      
      There is nothing arch specific about building dtb files other than their
      location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
      The dependencies and supported targets are all slightly different.
      Also, a cross-compiler for each arch is needed, but really the host
      compiler preprocessor is perfectly fine for building dtbs. Move the
      build rules to a common location and remove the arch specific ones. This
      is done in a single step to avoid warnings about overriding rules.
      
      The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
      These pull in several dependencies some of which need a target compiler
      (specifically devicetable-offsets.h) and aren't needed to build dtbs.
      All that is really needed is dtc, so adjust the dependencies to only be
      dtc.
      
      This change enables support 'dtbs_install' on some arches which were
      missing the target.
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarPaul Burton <paul.burton@mips.com>
      Acked-by: default avatarLey Foon Tan <ley.foon.tan@intel.com>
      Acked-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Michal Marek <michal.lkml@markovi.net>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: linux-kbuild@vger.kernel.org
      Cc: linux-snps-arc@lists.infradead.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: uclinux-h8-devel@lists.sourceforge.jp
      Cc: linux-mips@linux-mips.org
      Cc: nios2-dev@lists.rocketboards.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-xtensa@linux-xtensa.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      37c8a5fa
    • Rob Herring's avatar
      powerpc: build .dtb files in dts directory · 1acf1cf8
      Rob Herring authored
      
      Align powerpc with other architectures which build the dtb files in the
      same directory as the dts files. This is also in line with most other
      build targets which are located in the same directory as the source.
      This move will help enable the 'dtbs' target which builds all the dtbs
      regardless of kernel config.
      
      This transition could break some scripts if they expect dtb files in the
      old location.
      
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      1acf1cf8
  31. 19 Sep, 2018 2 commits