1. 10 Aug, 2018 22 commits
  2. 08 Aug, 2018 1 commit
    • Breno Leitao's avatar
      selftests/powerpc: Kill child processes on SIGINT · 7c27a26e
      Breno Leitao authored
      There are some powerpc selftests, as tm/tm-unavailable, that run for a long
      period (>120 seconds), and if it is interrupted, as pressing CRTL-C
      (SIGINT), the foreground process (harness) dies but the child process and
      threads continue to execute (with PPID = 1 now) in background.
      
      In this case, you'd think the whole test exited, but there are remaining
      threads and processes being executed in background. Sometimes these
      zombies processes are doing annoying things, as consuming the whole CPU or
      dumping things to STDOUT.
      
      This patch fixes this problem by attaching an empty signal handler to
      SIGINT in the harness process. This handler will interrupt (EINTR) the
      parent process waitpid() call, letting the code to follow through the
      normal flow, which will kill all the processes in the child process group.
      
      This patch also fixes a typo.
      Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarGustavo Romero <gromero@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      7c27a26e
  3. 07 Aug, 2018 17 commits
    • Benjamin Herrenschmidt's avatar
      powerpc/powernv/opal: Use standard interrupts property when available · 77b5f703
      Benjamin Herrenschmidt authored
      For (bad) historical reasons, OPAL used to create a non-standard pair
      of properties "opal-interrupts" and "opal-interrupts-names" for
      representing the list of interrupts it wants Linux to request on its
      behalf.
      
      Among other issues, the opal-interrupts doesn't have a way to carry
      the type of interrupts, and they were assumed to be all level
      sensitive.
      
      This is wrong on some recent systems where some of them are edge
      sensitive causing warnings in the XIVE code and possible misbehaviours
      if they need to be retriggered (typically the NPU2 TCE error
      interrupts).
      
      This makes Linux switch to using the standard "interrupts" and
      "interrupt-names" properties instead when they are available, using
      standard of_irq helpers, which can carry all the desired type
      information.
      
      Newer versions of OPAL will generate those properties in addition to
      the legacy ones.
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      [mpe: Fixup prefix logic to check strlen(r->name). Reinstate setting
       of start = 0 in opal_event_shutdown() to avoid double free warnings]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      77b5f703
    • Christophe Leroy's avatar
      powerpc: Allow CPU selection of e300core variants · d6690b1a
      Christophe Leroy authored
      GCC supports -mcpu=e300c2 and -mcpu=e300c3
      
      This patch gives the opportunity to tune kernel to one of
      those two types.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      d6690b1a
    • Christophe Leroy's avatar
      powerpc: Allow CPU selection also on PPC32 · 0e00a8c9
      Christophe Leroy authored
      This patch extends to PPC32 the capability to select the exact
      CPU type.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      0e00a8c9
    • Christophe Leroy's avatar
      powerpc: Make CPU selection logic generic in Makefile · cc62d20c
      Christophe Leroy authored
      At the time being, when adding a new CPU for selection, both
      Kconfig.cputype and Makefile have to be modified.
      
      This patch moves into Kconfig.cputype the name of the CPU to me
      passed to the -mcpu= argument.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
      [mpe: Rename the option to TARGET_CPU to echo the gcc documentation]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      cc62d20c
    • Rodrigo R. Galvao's avatar
      powerpc/Makefiles: Convert ifeq to ifdef where possible · badf436f
      Rodrigo R. Galvao authored
      In Makefiles if we're testing a CONFIG_FOO symbol for equality with 'y'
      we can instead just use ifdef. The latter reads easily, so convert to
      it where possible.
      Signed-off-by: default avatarRodrigo R. Galvao <rosattig@linux.vnet.ibm.com>
      Reviewed-by: default avatarMauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      badf436f
    • Paul Mackerras's avatar
      powerpc/64: Copy as much as possible in __copy_tofrom_user · f8db2007
      Paul Mackerras authored
      In __copy_tofrom_user, if we encounter an exception on a store, we
      stop copying and return the number of bytes not copied.  However,
      if the store is wider than one byte and is to an unaligned address,
      it is possible that the store operand overlaps a page boundary
      and the exception occurred on the latter part of the store operand,
      meaning that it would be possible to copy a few more bytes.  Since
      copy_to_user is generally expected to copy as much as possible,
      it would be better to copy those extra few bytes.  This adds code
      to do that.  Since this edge case is not performance-critical,
      the code has been written to be compact rather than as fast as
      possible.
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      f8db2007
    • Michael Ellerman's avatar
      selftests/powerpc/64: Test exception cases in copy_tofrom_user · 2679f63f
      Michael Ellerman authored
      This adds a set of test cases to test the behaviour of
      copy_tofrom_user when exceptions are encountered accessing the
      source or destination.  Currently, copy_tofrom_user does not always
      copy as many bytes as possible when an exception occurs on a store
      to the destination, and that is reflected in failures in these tests.
      
      Based on a test program from Anton Blanchard.
      
      [paulus@ozlabs.org - test all three paths, wrote commit description,
       made EX_TABLE create an exception table.]
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      2679f63f
    • Paul Mackerras's avatar
      selftests/powerpc/64: Test all paths through copy routines · 98c45f51
      Paul Mackerras authored
      The hand-coded assembler 64-bit copy routines include feature sections
      that select one code path or another depending on which CPU we are
      executing on.  The self-tests for these copy routines end up testing
      just one path.  This adds a mechanism for selecting any desired code
      path at compile time, and makes 2 or 3 versions of each test, each
      using a different code path, so as to cover all the possible paths.
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      [mpe: Add -mcpu=power4 to CFLAGS for older compilers]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      98c45f51
    • Paul Mackerras's avatar
      powerpc/64: Make exception table clearer in __copy_tofrom_user_base · a7c81ce3
      Paul Mackerras authored
      This aims to make the generation of exception table entries for the
      loads and stores in __copy_tofrom_user_base clearer and easier to
      verify.  Instead of having a series of local labels on the loads and
      stores, with a series of corresponding labels later for the exception
      handlers, we now use macros to generate exception table entries at the
      point of each load and store that could potentially trap.  We do this
      with the macros lex (load exception) and stex (store exception).
      These macros are used right before the load or store to which they
      apply.
      
      Some complexity is introduced by the fact that we have some more work
      to do after hitting an exception, because we need to calculate and
      return the number of bytes not copied.  The code uses r3 as the
      current pointer into the destination buffer, that is, the address of
      the first byte of the destination that has not been modified.
      However, at various points in the copy loops, r3 can be 4, 8, 16 or 24
      bytes behind that point.
      
      To express this offset in an understandable way, we define a symbol
      r3_offset which is updated at various points so that it equal to the
      difference between the address of the first unmodified byte of the
      destination and the value in r3.  (In fact it only needs to be
      accurate at the point of each lex or stex macro invocation.)
      
      The rules for updating r3_offset are as follows:
      
      * It starts out at 0
      * An addi r3,r3,N instruction decreases r3_offset by N
      * A store instruction (stb, sth, stw, std) to N(r3)
        increases r3_offset by the width of the store (1, 2, 4, 8)
      * A store with update instruction (stbu, sthu, stwu, stdu) to N(r3)
        sets r3_offset to the width of the store.
      
      There is some trickiness to the way that the lex and stex macros and
      the associated exception handlers work.  I would have liked to use
      the current value of r3_offset in the name of the symbol used as
      the exception handler, as in ".Lld_exc_$(r3_offset)" and then
      have symbols .Lld_exc_0, .Lld_exc_8, .Lld_exc_16 etc. corresponding
      to the offsets that needed to be added to r3.  However, I couldn't
      see a way to do that with gas.
      
      Instead, the exception handler address is .Lld_exc - r3_offset or
      .Lst_exc - r3_offset, that is, the distance ahead of .Lld_exc/.Lst_exc
      that we start executing is equal to the amount that we need to add to
      r3.  This works because r3_offset is always a small multiple of 4,
      and our instructions are 4 bytes long.  This means that before
      .Lld_exc and .Lst_exc, we have a sequence of instructions that
      increments r3 by 4, 8, 16 or 24 depending on where we start.  The
      sequence increments r3 by 4 per instruction (on average).
      
      We also replace the exception table for the 4k copy loop by a
      macro per load or store.  These loads and stores all use exactly
      the same exception handler, which simply resets the argument registers
      r3, r4 and r5 to there original values and re-does the whole copy
      using the slower loop.
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a7c81ce3
    • zhong jiang's avatar
      powerpc/powermac: of_node_put() is not needed after iterator · 81d7b08b
      zhong jiang authored
      for_each_node_by_name() iterators only exit normally when the loop
      cursor is NULL, So there is no need to call of_node_put().
      Signed-off-by: default avatarzhong jiang <zhongjiang@huawei.com>
      Reviewed-by: default avatarTyrel Datwyler <tyreld@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      81d7b08b
    • Haren Myneni's avatar
      crypto/nx: Initialize 842 high and normal RxFIFO control registers · 656ecc16
      Haren Myneni authored
      NX increments readOffset by FIFO size in receive FIFO control register
      when CRB is read. But the index in RxFIFO has to match with the
      corresponding entry in FIFO maintained by VAS in kernel. Otherwise NX
      may be processing incorrect CRBs and can cause CRB timeout.
      
      VAS FIFO offset is 0 when the receive window is opened during
      initialization. When the module is reloaded or in kexec boot, readOffset
      in FIFO control register may not match with VAS entry. This patch adds
      nx_coproc_init OPAL call to reset readOffset and queued entries in FIFO
      control register for both high and normal FIFOs.
      Signed-off-by: default avatarHaren Myneni <haren@us.ibm.com>
      [mpe: Fixup uninitialized variable warning]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      656ecc16
    • Haren Myneni's avatar
      powerpc/powernv: Export opal_check_token symbol · 6e708000
      Haren Myneni authored
      Export opal_check_token symbol for modules to check the availability
      of OPAL calls before using them.
      Signed-off-by: default avatarHaren Myneni <haren@us.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      6e708000
    • Randy Dunlap's avatar
      powerpc/platforms/85xx: fix t1042rdb_diu.c build errors & warning · f5daf77a
      Randy Dunlap authored
      Fix build errors and warnings in t1042rdb_diu.c by adding header files
      and MODULE_LICENSE().
      
      ../arch/powerpc/platforms/85xx/t1042rdb_diu.c:152:1: warning: data definition has no type or storage class
       early_initcall(t1042rdb_diu_init);
      ../arch/powerpc/platforms/85xx/t1042rdb_diu.c:152:1: error: type defaults to 'int' in declaration of 'early_initcall' [-Werror=implicit-int]
      ../arch/powerpc/platforms/85xx/t1042rdb_diu.c:152:1: warning: parameter names (without types) in function declaration
      
      and
      WARNING: modpost: missing MODULE_LICENSE() in arch/powerpc/platforms/85xx/t1042rdb_diu.o
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Scott Wood <oss@buserror.net>
      Cc: Kumar Gala <galak@kernel.crashing.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      f5daf77a
    • Anju T Sudhakar's avatar
      powerpc/perf: Remove sched_task function defined for thread-imc · 7ccc4fe5
      Anju T Sudhakar authored
      Call trace observed while running perf-fuzzer:
      
        CPU: 43 PID: 9088 Comm: perf_fuzzer Not tainted 4.13.0-32-generic #35~lp1746225
        task: c000003f776ac900 task.stack: c000003f77728000
        NIP: c000000000299b70 LR: c0000000002a4534 CTR: c00000000029bb80
        REGS: c000003f7772b760 TRAP: 0700   Not tainted  (4.13.0-32-generic)
        MSR: 900000000282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>
          CR: 24008822  XER: 00000000
        CFAR: c000000000299a70 SOFTE: 0
        GPR00: c0000000002a4534 c000003f7772b9e0 c000000001606200 c000003fef858908
        GPR04: c000003f776ac900 0000000000000001 ffffffffffffffff 0000003fee730000
        GPR08: 0000000000000000 0000000000000000 c0000000011220d8 0000000000000002
        GPR12: c00000000029bb80 c000000007a3d900 0000000000000000 0000000000000000
        GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
        GPR20: 0000000000000000 0000000000000000 c000003f776ad090 c000000000c71354
        GPR24: c000003fef716780 0000003fee730000 c000003fe69d4200 c000003f776ad330
        GPR28: c0000000011220d8 0000000000000001 c0000000014c6108 c000003fef858900
        NIP [c000000000299b70] perf_pmu_sched_task+0x170/0x180
        LR [c0000000002a4534] __perf_event_task_sched_in+0xc4/0x230
        Call Trace:
          perf_iterate_sb+0x158/0x2a0 (unreliable)
          __perf_event_task_sched_in+0xc4/0x230
          finish_task_switch+0x21c/0x310
          __schedule+0x304/0xb80
          schedule+0x40/0xc0
          do_wait+0x254/0x2e0
          kernel_wait4+0xa0/0x1a0
          SyS_wait4+0x64/0xc0
          system_call+0x58/0x6c
        Instruction dump:
        3beafea0 7faa4800 409eff18 e8010060 eb610028 ebc10040 7c0803a6 38210050
        eb81ffe0 eba1ffe8 ebe1fff8 4e800020 <0fe00000> 4bffffbc 60000000 60420000
        ---[ end trace 8c46856d314c1811 ]---
      
      The context switch call-backs for thread-imc are defined in sched_task function.
      So when thread-imc events are grouped with software pmu events,
      perf_pmu_sched_task hits the WARN_ON_ONCE condition, since software PMUs are
      assumed not to have a sched_task defined.
      
      Patch to move the thread_imc enable/disable opal call back from sched_task to
      event_[add/del] function
      
      Fixes: f74c89bd ("powerpc/perf: Add thread IMC PMU support")
      Signed-off-by: default avatarAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Tested-by: default avatarJoel Stanley <joel@jms.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      7ccc4fe5
    • Nicholas Piggin's avatar
      powerpc/64s: Fix page table fragment refcount race vs speculative references · 4231aba0
      Nicholas Piggin authored
      The page table fragment allocator uses the main page refcount racily
      with respect to speculative references. A customer observed a BUG due
      to page table page refcount underflow in the fragment allocator. This
      can be caused by the fragment allocator set_page_count stomping on a
      speculative reference, and then the speculative failure handler
      decrements the new reference, and the underflow eventually pops when
      the page tables are freed.
      
      Fix this by using a dedicated field in the struct page for the page
      table fragment allocator.
      
      Fixes: 5c1f6ee9 ("powerpc: Reduce PTE table memory wastage")
      Cc: stable@vger.kernel.org # v3.10+
      Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      4231aba0
    • Parth Y Shah's avatar
      misc: cxl: changed asterisk position · a0ac3687
      Parth Y Shah authored
      Resolved <"foo* bar" should be "foo *bar"> error
      Signed-off-by: default avatarParth Y Shah <sparth1292@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a0ac3687
    • Darren Stevens's avatar
      powerpc/pasemi: Use pr_err/pr_warn... for kernel messages · e13606d7
      Darren Stevens authored
      Pasemi code still uses printk(KERN_ERR/KERN_WARN ... change these to
      pr_err(, pr_warn(... to match other powerpc arch code.
      
      No functional changes.
      Signed-off-by: default avatarDarren Stevens <darren@stevens-zone.net>
      [mpe: Unsplit some strings while we're at it]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      e13606d7