1. 03 10月, 2018 2 次提交
    • C
      powerpc/64: add stack protector support · 06ec27ae
      Christophe Leroy 提交于
      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: NChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      06ec27ae
    • C
      powerpc/32: add stack protector support · c3ff2a51
      Christophe Leroy 提交于
      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: NChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      c3ff2a51
  2. 19 9月, 2018 3 次提交
  3. 24 8月, 2018 1 次提交
  4. 07 8月, 2018 2 次提交
  5. 24 7月, 2018 2 次提交
  6. 18 7月, 2018 1 次提交
  7. 19 6月, 2018 1 次提交
    • M
      powerpc/e500mc: Set assembler machine type to e500mc · 69a84059
      Michael Jeanson 提交于
      In binutils 2.26 a new opcode for the "wait" instruction was added for the
      POWER9 and has precedence over the one specific to the e500mc. Commit
      ebf714ff ("powerpc/e500mc: Add support for the wait instruction in
      e500_idle") uses this instruction specifically on the e500mc to work around
      an erratum.
      
      This results in an invalid instruction in idle_e500 when we build for the
      e500mc on bintutils >= 2.26 with the default assembler machine type.
      
      Since multiplatform between e500 and non-e500 is not supported, set the
      assembler machine type globaly when CONFIG_PPC_E500MC=y.
      Signed-off-by: NMichael Jeanson <mjeanson@efficios.com>
      Reviewed-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: Paul Mackerras <paulus@samba.org>
      CC: Michael Ellerman <mpe@ellerman.id.au>
      CC: Kumar Gala <galak@kernel.crashing.org>
      CC: Vakul Garg <vakul.garg@nxp.com>
      CC: Scott Wood <swood@redhat.com>
      CC: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: linuxppc-dev@lists.ozlabs.org
      CC: linux-kernel@vger.kernel.org
      CC: stable@vger.kernel.org
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      69a84059
  8. 11 6月, 2018 1 次提交
  9. 03 6月, 2018 1 次提交
    • C
      powerpc/Makefile: set -mcpu=860 flag for the 8xx · 1c389763
      Christophe Leroy 提交于
      When compiled with GCC 8.1, vmlinux is significantly bigger than
      with GCC 4.8.
      
      When looking at the generated code with objdump, we notice that
      all functions and loops when a 16 bytes alignment. This significantly
      increases the size of the kernel. It is pointless and even
      counterproductive as on the 8xx 'nop' also consumes one clock cycle.
      
      Size of vmlinux with GCC 4.8:
         text	   data	    bss	    dec	    hex	filename
      5801948	1626076	 457796	7885820	 7853fc	vmlinux
      
      Size of vmlinux with GCC 8.1:
         text	   data	    bss	    dec	    hex	filename
      6764592	1630652	 456476	8851720	 871108	vmlinux
      
      Size of vmlinux with GCC 8.1 and this patch:
         text	   data	    bss	    dec	    hex	filename
      6331544	1631756	 456476	8419776	 8079c0	vmlinux
      Signed-off-by: NChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      1c389763
  10. 01 6月, 2018 3 次提交
  11. 01 4月, 2018 2 次提交
  12. 31 3月, 2018 2 次提交
  13. 06 3月, 2018 1 次提交
  14. 11 12月, 2017 1 次提交
    • A
      powerpc/modules: Fix alignment of .toc section in kernel modules · 5c45b528
      Alan Modra 提交于
      powerpc64 gcc can generate code that offsets an address, to access
      part of an object in memory. If the address is a -mcmodel=medium toc
      pointer relative address then code like the following is possible.
      
        addis r9,r2,var@toc@ha
        ld r3,var@toc@l(r9)
        ld r4,(var+8)@toc@l(r9)
      
      This works fine so long as var is naturally aligned, *and* r2 is
      sufficiently aligned. If not, there is a possibility that the offset
      added to access var+8 wraps over a n*64k+32k boundary. Modules don't
      have any guarantee that r2 is sufficiently aligned. Moreover, code
      generated by older compilers generates a .toc section with 2**0
      alignment, which can result in relocation failures at module load time
      even without the wrap problem.
      
      Thus, this patch links modules with an aligned .toc section (Makefile
      and module.lds changes), and forces alignment for out of tree modules
      or those without a .toc section (module_64.c changes).
      Signed-off-by: NAlan Modra <amodra@gmail.com>
      [desnesn: updated patch to apply to powerpc-next kernel v4.15 ]
      Signed-off-by: NDesnes A. Nunes do Rosario <desnesn@linux.vnet.ibm.com>
      [mpe: Fix out-of-tree build, swap -256 for ~0xff, reflow comment]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      5c45b528
  15. 10 8月, 2017 1 次提交
  16. 31 7月, 2017 1 次提交
  17. 26 7月, 2017 1 次提交
    • M
      powerpc/Makefile: Fix ld version check with 64-bit LE-only toolchain · b40b2386
      Michael Ellerman 提交于
      In commit efe0160c ("powerpc/64: Linker on-demand sfpr functions
      for modules"), we added an ld version check early in the powerpc
      top-level Makefile.
      
      Because the Makefile runs before the kernel config is setup, the
      checks for CONFIG_CPU_LITTLE_ENDIAN etc. all take the default case. So
      we end up configuring ld for 32-bit big endian.
      
      That would be OK, except that for historical (or perhaps no) reason,
      we use 'override LD' to add the endian flags to the LD variable
      itself, rather than the normal approach of adding them to LDFLAGS.
      
      The end result is that when we check the ld version we run it as:
      
        $(CROSS_COMPILE)ld -EB -m elf32ppc --version
      
      This often works, unless you are using a 64-bit only and/or little
      endian only, toolchain. In which case you see something like:
      
        $ make defconfig
        powerpc64le-linux-ld: unrecognised emulation mode: elf32ppc
        Supported emulations: elf64lppc elf32lppc elf32lppclinux elf32lppcsim
        /bin/sh: 1: [: -ge: unexpected operator
      
      The proper fix is to stop using 'override LD', but that will require a
      fair bit of testing. Instead we can fix it for now just by reordering
      the Makefile to do the version check earlier.
      
      Fixes: efe0160c ("powerpc/64: Linker on-demand sfpr functions for modules")
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      b40b2386
  18. 30 5月, 2017 2 次提交
  19. 28 4月, 2017 2 次提交
  20. 03 3月, 2017 1 次提交
  21. 30 11月, 2016 1 次提交
  22. 29 11月, 2016 1 次提交
    • M
      powerpc: Stop passing ARCH=ppc64 to boot Makefile · 1196d7aa
      Michael Ellerman 提交于
      Back in 2005 when the ppc/ppc64 merge started, we used to build the
      kernel code in arch/powerpc but use the boot code from arch/ppc or
      arch/ppc64 depending on whether we were building for 32 or 64-bit.
      
      Originally we called the boot Makefile passing ARCH=$(OLDARCH), where
      OLDARCH was ppc or ppc64.
      
      In commit 20f62954 ("powerpc: Make building the boot image work for
      both 32-bit and 64-bit") (2005-10-11) we split the call for 32/64-bit
      using an ifeq check, because the two Makefiles took different targets,
      and explicitly passed ARCH=ppc64 for the 64-bit case and ARCH=ppc for
      the 32-bit case.
      
      Then in commit 94b212c2 ("powerpc: Move ppc64 boot wrapper code over
      to arch/powerpc") (2005-11-16) we moved the boot code into arch/powerpc
      and dropped the ppc case, but kept passing ARCH=ppc64 to
      arch/powerpc/boot/Makefile.
      
      Since then there have been several more boot targets added, all of which
      have copied the ARCH=ppc64 setting, such that now we have four targets
      using it.
      
      Currently it seems that nothing actually uses the ARCH value, but that's
      basically just luck, and in particular it prevents us from using the
      generic cpp_lds_S rule. It's also clearly wrong, ARCH=ppc64 is dead,
      buried and cremated.
      
      Fix it by dropping the setting of ARCH completely, the correct value is
      exported by the top level Makefile.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      1196d7aa
  23. 18 11月, 2016 1 次提交
  24. 14 11月, 2016 1 次提交
    • M
      powerpc/book3s64: Always build for power4 or later · 3a849815
      Michael Ellerman 提交于
      When we're not compiling for a specific CPU, ie. none of the
      CONFIG_POWERx_CPU options are set, and CONFIG_GENERIC_CPU *is* set, we
      currently don't pass any -mcpu option to the compiler. This means the
      compiler builds for a "generic" Power CPU.
      
      But back in 2014 we dropped support for pre power4 CPUs in commit
      468a3302 ("powerpc: Drop support for pre-POWER4 cpus").
      
      Given that, there's no point in building the kernel to run on pre power4
      cpus. So update the flags we pass to the compiler when
      CONFIG_GENERIC_CPU is set, to specify -mcpu=power4.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      3a849815
  25. 25 9月, 2016 1 次提交
  26. 13 9月, 2016 3 次提交
  27. 10 8月, 2016 1 次提交
    • M
      powerpc/Makefile: Use cflags-y/aflags-y for setting endian options · 164af597
      Michael Ellerman 提交于
      When we introduced the little endian support, we added the endian flags
      to CC directly using override. I don't know the history of why we did
      that, I suspect no one does.
      
      Although this mostly works, it has one bug, which is that CROSS32CC
      doesn't get -mbig-endian. That means when the compiler is little endian
      by default and the user is building big endian, vdso32 is incorrectly
      compiled as little endian and the kernel fails to build.
      
      Instead we can add the endian flags to cflags-y/aflags-y, and then
      append those to KBUILD_CFLAGS/KBUILD_AFLAGS.
      
      This has the advantage of being 1) less ugly, 2) the documented way of
      adding flags in the arch Makefile and 3) it fixes building vdso32 with a
      LE toolchain.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      164af597