1. 05 Nov, 2019 4 commits
    • Anthony Steinhauser's avatar
      powerpc/security/book3s64: Report L1TF status in sysfs · 8e6b6da9
      Anthony Steinhauser authored
      Some PowerPC CPUs are vulnerable to L1TF to the same extent as to
      Meltdown. It is also mitigated by flushing the L1D on privilege
      transition.
      
      Currently the sysfs gives a false negative on L1TF on CPUs that I
      verified to be vulnerable, a Power9 Talos II Boston 004e 1202, PowerNV
      T2P9D01.
      Signed-off-by: default avatarAnthony Steinhauser <asteinhauser@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      [mpe: Just have cpu_show_l1tf() call cpu_show_meltdown() directly]
      Link: https://lore.kernel.org/r/20191029190759.84821-1-asteinhauser@google.com
      8e6b6da9
    • Nathan Lynch's avatar
      powerpc/pseries: safely roll back failed DLPAR cpu add · 80c78428
      Nathan Lynch authored
      dlpar_online_cpu() attempts to online all threads of a core that has
      been added to an LPAR. If onlining a non-primary thread
      fails (e.g. due to an allocation failure), the core is left with at
      least one thread online. dlpar_cpu_add() attempts to roll back the
      whole operation, releasing the core back to the platform. However,
      since some threads of the core being removed are still online, the
      BUG_ON(cpu_online(cpu)) in pseries_remove_processor() strikes:
      
      LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
      Modules linked in:
      CPU: 3 PID: 8587 Comm: drmgr Not tainted 5.3.0-rc2-00190-g9b123d1e-dirty #46
      NIP:  c0000000000eeb2c LR: c0000000000eeac4 CTR: c0000000000ee9e0
      REGS: c0000001f745b6c0 TRAP: 0700   Not tainted  (5.3.0-rc2-00190-g9b123d1e-dirty)
      MSR:  800000010282b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]>  CR: 44002448  XER: 00000000
      CFAR: c00000000195d718 IRQMASK: 0
      GPR00: c0000000000eeac4 c0000001f745b950 c0000000032f6200 0000000000000008
      GPR04: 0000000000000008 c000000003349c78 0000000000000040 00000000000001ff
      GPR08: 0000000000000008 0000000000000000 0000000000000001 0007ffffffffffff
      GPR12: 0000000084002844 c00000001ecacb80 0000000000000000 0000000000000000
      GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000008
      GPR24: c000000003349ee0 c00000000334a2e4 c0000000fca4d7a8 c000000001d20048
      GPR28: 0000000000000001 ffffffffffffffff ffffffffffffffff c0000000fca4d7c4
      NIP [c0000000000eeb2c] pseries_smp_notifier+0x14c/0x2e0
      LR [c0000000000eeac4] pseries_smp_notifier+0xe4/0x2e0
      Call Trace:
      [c0000001f745b950] [c0000000000eeac4] pseries_smp_notifier+0xe4/0x2e0 (unreliable)
      [c0000001f745ba10] [c0000000001ac774] notifier_call_chain+0xb4/0x190
      [c0000001f745bab0] [c0000000001ad62c] blocking_notifier_call_chain+0x7c/0xb0
      [c0000001f745baf0] [c00000000167bda0] of_detach_node+0xc0/0x110
      [c0000001f745bb50] [c0000000000e7ae4] dlpar_detach_node+0x64/0xa0
      [c0000001f745bb80] [c0000000000edefc] dlpar_cpu_add+0x31c/0x360
      [c0000001f745bc10] [c0000000000ee980] dlpar_cpu_probe+0x50/0xb0
      [c0000001f745bc50] [c00000000002cf70] arch_cpu_probe+0x40/0x70
      [c0000001f745bc70] [c000000000ccd808] cpu_probe_store+0x48/0x80
      [c0000001f745bcb0] [c000000000cbcef8] dev_attr_store+0x38/0x60
      [c0000001f745bcd0] [c00000000059c980] sysfs_kf_write+0x70/0xb0
      [c0000001f745bd10] [c00000000059afb8] kernfs_fop_write+0xf8/0x280
      [c0000001f745bd60] [c0000000004b437c] __vfs_write+0x3c/0x70
      [c0000001f745bd80] [c0000000004b8710] vfs_write+0xd0/0x220
      [c0000001f745bdd0] [c0000000004b8acc] ksys_write+0x7c/0x140
      [c0000001f745be20] [c00000000000bbd8] system_call+0x5c/0x68
      
      Move dlpar_offline_cpu() up in the file so that dlpar_online_cpu() can
      use it to re-offline any threads that have been onlined when an error
      is encountered.
      Signed-off-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      Fixes: e666ae0b ("powerpc/pseries: Update CPU hotplug error recovery")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191016183611.10867-3-nathanl@linux.ibm.com
      80c78428
    • Nathan Lynch's avatar
      powerpc/pseries: address checkpatch warnings in dlpar_offline_cpu · 3366ebe9
      Nathan Lynch authored
      Remove some stray blank lines, convert a printk to pr_warn, and
      address a line length violation.
      
      One functional change: use WARN_ON instead of BUG_ON in case H_PROD of
      a ceded thread yields an unexpected result from the platform. We can
      expect this code path to get uninterruptibly stuck in __cpu_die() if
      this happens, but that's more desirable than crashing.
      Signed-off-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      Fixes: b6db63d1 ("pseries/pseries: Add code to online/offline CPUs of a DLPAR node")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191016183611.10867-2-nathanl@linux.ibm.com
      3366ebe9
    • Michael Ellerman's avatar
      selftests/powerpc: Skip tm-signal-sigreturn-nt if TM not available · 50512706
      Michael Ellerman authored
      On systems where TM (Transactional Memory) is disabled the
      tm-signal-sigreturn-nt test causes a SIGILL:
      
        test: tm_signal_sigreturn_nt
        tags: git_version:7c202575
        !! child died by signal 4
        failure: tm_signal_sigreturn_nt
      
      We should skip the test if TM is not available.
      
      Fixes: 34642d70 ("selftests/powerpc: Add checks for transactional sigreturn")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191104233524.24348-1-mpe@ellerman.id.au
      50512706
  2. 04 Nov, 2019 1 commit
  3. 30 Oct, 2019 4 commits
    • Michael Ellerman's avatar
      powerpc/tools: Don't quote $objdump in scripts · e44ff9ea
      Michael Ellerman authored
      Some of our scripts are passed $objdump and then call it as
      "$objdump". This doesn't work if it contains spaces because we're
      using ccache, for example you get errors such as:
      
        ./arch/powerpc/tools/relocs_check.sh: line 48: ccache ppc64le-objdump: No such file or directory
        ./arch/powerpc/tools/unrel_branch_check.sh: line 26: ccache ppc64le-objdump: No such file or directory
      
      Fix it by not quoting the string when we expand it, allowing the shell
      to do the right thing for us.
      
      Fixes: a71aa05e ("powerpc: Convert relocs_check to a shell script using grep")
      Fixes: 4ea80652 ("powerpc/64s: Tool to flag direct branches from unrelocated interrupt vectors")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191024004730.32135-1-mpe@ellerman.id.au
      e44ff9ea
    • Michael Ellerman's avatar
      powerpc: Add build-time check of ptrace PT_xx defines · b9e0805a
      Michael Ellerman authored
      As part of the uapi we export a lot of PT_xx defines for each register
      in struct pt_regs. These are expressed as an index from gpr[0], in
      units of unsigned long.
      
      Currently there's nothing tying the values of those defines to the
      actual layout of the struct.
      
      But we *don't* want to change the uapi defines to derive the PT_xx
      values based on the layout of the struct, those values are ABI and
      must never change.
      
      Instead we want to do the reverse, make sure that the layout of the
      struct never changes vs the PT_xx defines. So add build time checks of
      that.
      
      This probably seems paranoid, but at least once in the past someone
      has sent a patch that would have broken the ABI if it hadn't been
      spotted. Although it probably would have been detected via testing,
      it's preferable to just quash any issues at the source.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191030111231.22720-1-mpe@ellerman.id.au
      b9e0805a
    • Mathieu Malaterre's avatar
      powerpc/ptrace: Add prototype for function pt_regs_check · 5c74f799
      Mathieu Malaterre authored
      `pt_regs_check` is a dummy function, its purpose is to break the build
      if struct pt_regs and struct user_pt_regs don't match.
      
      This function has no functionnal purpose, and will get eliminated at
      link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
      
      This commit adds a prototype to fix warning at W=1:
      
        arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for ‘pt_regs_check’ [-Werror=missing-prototypes]
      Suggested-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20181208154624.6504-1-malat@debian.org
      5c74f799
    • Michael Ellerman's avatar
      selftests/powerpc: Add a test of spectre_v2 mitigations · c790c3d2
      Michael Ellerman authored
      This test uses the PMU to count branch prediction hits/misses for a
      known loop, and compare the result to the reported spectre v2
      mitigation.
      
      This gives us a way of sanity checking that the reported mitigation is
      actually in effect.
      
      Sample output for some cases, eg:
      
        Power9:
          sysfs reports: 'Vulnerable'
           PM_BR_PRED_CCACHE: result        368 running/enabled 5792777124
          PM_BR_MPRED_CCACHE: result        319 running/enabled 5792775546
           PM_BR_PRED_PCACHE: result 2147483281 running/enabled 5792773128
          PM_BR_MPRED_PCACHE: result  213604201 running/enabled 5792771640
          Miss percent 9 %
          OK - Measured branch prediction rates match reported spectre v2 mitigation.
      
          sysfs reports: 'Mitigation: Indirect branch serialisation (kernel only)'
           PM_BR_PRED_CCACHE: result        895 running/enabled 5780320920
          PM_BR_MPRED_CCACHE: result        822 running/enabled 5780312414
           PM_BR_PRED_PCACHE: result 2147482754 running/enabled 5780308836
          PM_BR_MPRED_PCACHE: result  213639731 running/enabled 5780307912
          Miss percent 9 %
          OK - Measured branch prediction rates match reported spectre v2 mitigation.
      
          sysfs reports: 'Mitigation: Indirect branch cache disabled'
           PM_BR_PRED_CCACHE: result 2147483649 running/enabled 20540186160
          PM_BR_MPRED_CCACHE: result 2147483649 running/enabled 20540180056
           PM_BR_PRED_PCACHE: result          0 running/enabled 20540176090
          PM_BR_MPRED_PCACHE: result          0 running/enabled 20540174182
          Miss percent 100 %
          OK - Measured branch prediction rates match reported spectre v2 mitigation.
      
        Power8:
          sysfs reports: 'Vulnerable'
           PM_BR_PRED_CCACHE: result 2147483649 running/enabled 3505888142
          PM_BR_MPRED_CCACHE: result          9 running/enabled 3505882788
          Miss percent 0 %
          OK - Measured branch prediction rates match reported spectre v2 mitigation.
      
          sysfs reports: 'Mitigation: Indirect branch cache disabled'
           PM_BR_PRED_CCACHE: result 2147483649 running/enabled 16931421988
          PM_BR_MPRED_CCACHE: result 2147483649 running/enabled 16931416478
          Miss percent 100 %
          OK - Measured branch prediction rates match reported spectre v2 mitigation.
          success: spectre_v2
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190520105520.22274-1-mpe@ellerman.id.au
      c790c3d2
  4. 29 Oct, 2019 3 commits
  5. 28 Oct, 2019 9 commits
  6. 25 Oct, 2019 1 commit
    • Frederic Barrat's avatar
      powerpc/powernv/eeh: Fix oops when probing cxl devices · a8a30219
      Frederic Barrat authored
      Recent cleanup in the way EEH support is added to a device causes a
      kernel oops when the cxl driver probes a device and creates virtual
      devices discovered on the FPGA:
      
        BUG: Kernel NULL pointer dereference at 0x000000a0
        Faulting instruction address: 0xc000000000048070
        Oops: Kernel access of bad area, sig: 7 [#1]
        ...
        NIP eeh_add_device_late.part.9+0x50/0x1e0
        LR  eeh_add_device_late.part.9+0x3c/0x1e0
        Call Trace:
          _dev_info+0x5c/0x6c (unreliable)
          pnv_pcibios_bus_add_device+0x60/0xb0
          pcibios_bus_add_device+0x40/0x60
          pci_bus_add_device+0x30/0x100
          pci_bus_add_devices+0x64/0xd0
          cxl_pci_vphb_add+0xe0/0x130 [cxl]
          cxl_probe+0x504/0x5b0 [cxl]
          local_pci_probe+0x6c/0x110
          work_for_cpu_fn+0x38/0x60
      
      The root cause is that those cxl virtual devices don't have a
      representation in the device tree and therefore no associated pci_dn
      structure. In eeh_add_device_late(), pdn is NULL, so edev is NULL and
      we oops.
      
      We never had explicit support for EEH for those virtual devices.
      Instead, EEH events are reported to the (real) pci device and handled
      by the cxl driver. Which can then forward to the virtual devices and
      handle dependencies. The fact that we try adding EEH support for the
      virtual devices is new and a side-effect of the recent cleanup.
      
      This patch fixes it by skipping adding EEH support on powernv for
      devices which don't have a pci_dn structure.
      
      The cxl driver doesn't create virtual devices on pseries so this patch
      doesn't fix it there intentionally.
      
      Fixes: b905f8cd ("powerpc/eeh: EEH for pSeries hot plug")
      Signed-off-by: default avatarFrederic Barrat <fbarrat@linux.ibm.com>
      Reviewed-by: default avatarSam Bobroff <sbobroff@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191016162833.22509-1-fbarrat@linux.ibm.com
      a8a30219
  7. 24 Oct, 2019 1 commit
  8. 16 Oct, 2019 1 commit
  9. 13 Oct, 2019 1 commit
  10. 11 Oct, 2019 7 commits
  11. 10 Oct, 2019 1 commit
  12. 09 Oct, 2019 4 commits
  13. 06 Oct, 2019 3 commits
    • Linus Torvalds's avatar
      Linux 5.4-rc2 · da0c9ea1
      Linus Torvalds authored
      da0c9ea1
    • Linus Torvalds's avatar
      elf: don't use MAP_FIXED_NOREPLACE for elf executable mappings · b212921b
      Linus Torvalds authored
      In commit 4ed28639 ("fs, elf: drop MAP_FIXED usage from elf_map") we
      changed elf to use MAP_FIXED_NOREPLACE instead of MAP_FIXED for the
      executable mappings.
      
      Then, people reported that it broke some binaries that had overlapping
      segments from the same file, and commit ad55eac7 ("elf: enforce
      MAP_FIXED on overlaying elf segments") re-instated MAP_FIXED for some
      overlaying elf segment cases.  But only some - despite the summary line
      of that commit, it only did it when it also does a temporary brk vma for
      one obvious overlapping case.
      
      Now Russell King reports another overlapping case with old 32-bit x86
      binaries, which doesn't trigger that limited case.  End result: we had
      better just drop MAP_FIXED_NOREPLACE entirely, and go back to MAP_FIXED.
      
      Yes, it's a sign of old binaries generated with old tool-chains, but we
      do pride ourselves on not breaking existing setups.
      
      This still leaves MAP_FIXED_NOREPLACE in place for the load_elf_interp()
      and the old load_elf_library() use-cases, because nobody has reported
      breakage for those. Yet.
      
      Note that in all the cases seen so far, the overlapping elf sections
      seem to be just re-mapping of the same executable with different section
      attributes.  We could possibly introduce a new MAP_FIXED_NOFILECHANGE
      flag or similar, which acts like NOREPLACE, but allows just remapping
      the same executable file using different protection flags.
      
      It's not clear that would make a huge difference to anything, but if
      people really hate that "elf remaps over previous maps" behavior, maybe
      at least a more limited form of remapping would alleviate some concerns.
      
      Alternatively, we should take a look at our elf_map() logic to see if we
      end up not mapping things properly the first time.
      
      In the meantime, this is the minimal "don't do that then" patch while
      people hopefully think about it more.
      Reported-by: default avatarRussell King <linux@armlinux.org.uk>
      Fixes: 4ed28639 ("fs, elf: drop MAP_FIXED usage from elf_map")
      Fixes: ad55eac7 ("elf: enforce  MAP_FIXED on overlaying elf segments")
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b212921b
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-5.4-1' of git://git.infradead.org/users/hch/dma-mapping · 7cdb85df
      Linus Torvalds authored
      Pull dma-mapping regression fix from Christoph Hellwig:
       "Revert an incorret hunk from a patch that caused problems on various
        arm boards (Andrey Smirnov)"
      
      * tag 'dma-mapping-5.4-1' of git://git.infradead.org/users/hch/dma-mapping:
        dma-mapping: fix false positive warnings in dma_common_free_remap()
      7cdb85df