1. 18 May, 2018 1 commit
    • Finn Thain's avatar
      powerpc/lib: Fix "integer constant is too large" build failure · 20acf7fc
      Finn Thain authored
      My powerpc-linux-gnu-gcc v4.4.5 compiler can't build a 32-bit kernel
      any more:
      
      arch/powerpc/lib/sstep.c: In function 'do_popcnt':
      arch/powerpc/lib/sstep.c:1068: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1069: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1069: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1070: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1079: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c: In function 'do_prty':
      arch/powerpc/lib/sstep.c:1117: error: integer constant is too large for 'long' type
      
      This file gets compiled with -std=gnu89 which means a constant can be
      given the type 'long' even if it won't fit. Fix the errors with a 'ULL'
      suffix on the relevant constants.
      
      Fixes: 2c979c48 ("powerpc/lib/sstep: Add prty instruction emulation")
      Fixes: dcbd19b4 ("powerpc/lib/sstep: Add popcnt instruction emulation")
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      20acf7fc
  2. 17 May, 2018 5 commits
    • Nicholas Piggin's avatar
      powerpc/powernv: Fix opal_event_shutdown() called with interrupts disabled · c0beffc4
      Nicholas Piggin authored
      A kernel crash in process context that calls emergency_restart from
      panic will end up calling opal_event_shutdown with interrupts disabled
      but not in interrupt. This causes a sleeping function to be called
      which gives the following warning with sysrq+c:
      
          Rebooting in 10 seconds..
          BUG: sleeping function called from invalid context at kernel/locking/mutex.c:238
          in_atomic(): 0, irqs_disabled(): 1, pid: 7669, name: bash
          CPU: 20 PID: 7669 Comm: bash Tainted: G      D W         4.17.0-rc5+ #3
          Call Trace:
          dump_stack+0xb0/0xf4 (unreliable)
          ___might_sleep+0x174/0x1a0
          mutex_lock+0x38/0xb0
          __free_irq+0x68/0x460
          free_irq+0x70/0xc0
          opal_event_shutdown+0xb4/0xf0
          opal_shutdown+0x24/0xa0
          pnv_shutdown+0x28/0x40
          machine_shutdown+0x44/0x60
          machine_restart+0x28/0x80
          emergency_restart+0x30/0x50
          panic+0x2a0/0x328
          oops_end+0x1ec/0x1f0
          bad_page_fault+0xe8/0x154
          handle_page_fault+0x34/0x38
          --- interrupt: 300 at sysrq_handle_crash+0x44/0x60
          LR = __handle_sysrq+0xfc/0x260
          flag_spec.62335+0x12b844/0x1e8db4 (unreliable)
          __handle_sysrq+0xfc/0x260
          write_sysrq_trigger+0xa8/0xb0
          proc_reg_write+0xac/0x110
          __vfs_write+0x6c/0x240
          vfs_write+0xd0/0x240
          ksys_write+0x6c/0x110
      
      Fixes: 9f0fd049 ("powerpc/powernv: Add a virtual irqchip for opal events")
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      c0beffc4
    • Christophe Leroy's avatar
      powerpc/32: Use stmw/lmw for registers save/restore in asm · a1f3ae3f
      Christophe Leroy authored
      arch/powerpc/Makefile activates -mmultiple on BE PPC32 configs
      in order to use multiple word instructions in functions entry/exit.
      
      The patch does the same for the asm parts, for consistency.
      
      On processors like the 8xx on which insn fetching is pretty slow,
      this speeds up registers save/restore.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      [mpe: PPC32 is BE only, so drop the endian checks]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a1f3ae3f
    • Christophe Leroy's avatar
      powerpc: Avoid an unnecessary test and branch in longjmp() · 24c78586
      Christophe Leroy authored
      Doing the test at exit of the function avoids an unnecessary
      test and branch inside longjmp().
      
      Semantics are unchanged.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Reviewed-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      24c78586
    • Christophe Leroy's avatar
      Revert "powerpc/64: Fix checksum folding in csum_add()" · 96f391cf
      Christophe Leroy authored
      This reverts commit 6ad966d7.
      
      That commit was pointless, because csum_add() sums two 32 bits
      values, so the sum is 0x1fffffffe at the maximum.
      And then when adding upper part (1) and lower part (0xfffffffe),
      the result is 0xffffffff which doesn't carry.
      Any lower value will not carry either.
      
      And behind the fact that this commit is useless, it also kills the
      whole purpose of having an arch specific inline csum_add()
      because the resulting code gets even worse than what is obtained
      with the generic implementation of csum_add()
      
      0000000000000240 <.csum_add>:
       240:	38 00 ff ff 	li      r0,-1
       244:	7c 84 1a 14 	add     r4,r4,r3
       248:	78 00 00 20 	clrldi  r0,r0,32
       24c:	78 89 00 22 	rldicl  r9,r4,32,32
       250:	7c 80 00 38 	and     r0,r4,r0
       254:	7c 09 02 14 	add     r0,r9,r0
       258:	78 09 00 22 	rldicl  r9,r0,32,32
       25c:	7c 00 4a 14 	add     r0,r0,r9
       260:	78 03 00 20 	clrldi  r3,r0,32
       264:	4e 80 00 20 	blr
      
      In comparison, the generic implementation of csum_add() gives:
      
      0000000000000290 <.csum_add>:
       290:	7c 63 22 14 	add     r3,r3,r4
       294:	7f 83 20 40 	cmplw   cr7,r3,r4
       298:	7c 10 10 26 	mfocrf  r0,1
       29c:	54 00 ef fe 	rlwinm  r0,r0,29,31,31
       2a0:	7c 60 1a 14 	add     r3,r0,r3
       2a4:	78 63 00 20 	clrldi  r3,r3,32
       2a8:	4e 80 00 20 	blr
      
      And the reverted implementation for PPC64 gives:
      
      0000000000000240 <.csum_add>:
       240:	7c 84 1a 14 	add     r4,r4,r3
       244:	78 80 00 22 	rldicl  r0,r4,32,32
       248:	7c 80 22 14 	add     r4,r0,r4
       24c:	78 83 00 20 	clrldi  r3,r4,32
       250:	4e 80 00 20 	blr
      
      Fixes: 6ad966d7 ("powerpc/64: Fix checksum folding in csum_add()")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Acked-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      96f391cf
    • Christophe Leroy's avatar
      powerpc: get rid of PMD_PAGE_SIZE() and _PMD_SIZE · 5279821a
      Christophe Leroy authored
      PMD_PAGE_SIZE() is nowhere used and _PMD_SIZE is only
      used by PMD_PAGE_SIZE().
      
      This patch removes them.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      5279821a
  3. 15 May, 2018 14 commits
  4. 14 May, 2018 5 commits
  5. 11 May, 2018 5 commits
    • Michael Ellerman's avatar
      powerpc/prom: Drop support for old FDT versions · 89c19062
      Michael Ellerman authored
      In commit e6a6928c ("of/fdt: Convert FDT functions to use
      libfdt") (Apr 2014), the generic flat device tree code dropped support
      for flat device tree's older than version 0x10 (16).
      
      We still have code in our CPU scanning to cope with flat device tree
      versions earlier than 2, which can now never trigger, so drop it.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      89c19062
    • Michael Ellerman's avatar
      powerpc/lib: Add alt patching test of branching past the last instruction · 6158faed
      Michael Ellerman authored
      Add a test of the relative branch patching logic in the alternate
      section feature fixup code. This tests that if we branch past the last
      instruction of the alternate section, the branch is not patched.
      That's because the assembler will have created a branch that already
      points to the first instruction after the patched section, which is
      correct and needs no further patching.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      6158faed
    • Michael Ellerman's avatar
      powerpc/lib: Rename ftr_fixup_test7 to ftr_fixup_test_too_big · b58e7987
      Michael Ellerman authored
      We want this to remain the last test (because it's disabled by
      default), so give it a non-numbered name so we don't have to renumber
      it when adding new tests before it.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      b58e7987
    • Michael Ellerman's avatar
      powerpc/lib: Fix the feature fixup tests to actually work · cad0e390
      Michael Ellerman authored
      The code patching code has always been a bit confused about whether
      it's best to use void *, unsigned int *, char *, etc. to point to
      instructions. In fact in the feature fixups tests we use both unsigned
      int[] and u8[] in different places.
      
      Unfortunately the tests that use unsigned int[] calculate the size of
      the code blocks using subtraction of those unsigned int pointers, and
      then pass the result to memcmp(). This means we're only comparing 1/4
      of the bytes we need to, because we need to multiply by
      sizeof(unsigned int) to get the number of *bytes*.
      
      The result is that the tests do all the patching and then only compare
      some of the resulting code, so patching bugs that only effect that
      last 3/4 of the code could slip through undetected. It turns out that
      hasn't been happening, although one test had a bad expected case (see
      previous commit).
      
      Fix it for now by multiplying the size by 4 in the affected functions.
      
      Fixes: 362e7701 ("powerpc: Add self-tests of the feature fixup code")
      Epic-brown-paper-bag-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      cad0e390
    • Michael Ellerman's avatar
      powerpc/lib: Fix feature fixup test of external branch · 32810d91
      Michael Ellerman authored
      The expected case for this test was wrong, the source of the alternate
      code sequence is:
      
        FTR_SECTION_ELSE
        2:	or	2,2,2
        	PPC_LCMPI	r3,1
        	beq	3f
        	blt	2b
        	b	3f
        	b	1b
        ALT_FTR_SECTION_END(0, 1)
        3:	or	1,1,1
        	or	2,2,2
        4:	or	3,3,3
      
      So when it's patched the '3' label should still be on the 'or 1,1,1',
      and the 4 label is irrelevant and can be removed.
      
      Fixes: 362e7701 ("powerpc: Add self-tests of the feature fixup code")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      32810d91
  6. 10 May, 2018 10 commits