1. 30 Mar, 2018 4 commits
    • Naveen N. Rao's avatar
      powerpc/kprobes: Fix call trace due to incorrect preempt count · e6e133c4
      Naveen N. Rao authored
      Michael Ellerman reported the following call trace when running
      ftracetest:
      
        BUG: using __this_cpu_write() in preemptible [00000000] code: ftracetest/6178
        caller is opt_pre_handler+0xc4/0x110
        CPU: 1 PID: 6178 Comm: ftracetest Not tainted 4.15.0-rc7-gcc6x-gb2cd1df6 #1
        Call Trace:
        [c0000000f9ec39c0] [c000000000ac4304] dump_stack+0xb4/0x100 (unreliable)
        [c0000000f9ec3a00] [c00000000061159c] check_preemption_disabled+0x15c/0x170
        [c0000000f9ec3a90] [c000000000217e84] opt_pre_handler+0xc4/0x110
        [c0000000f9ec3af0] [c00000000004cf68] optimized_callback+0x148/0x170
        [c0000000f9ec3b40] [c00000000004d954] optinsn_slot+0xec/0x10000
        [c0000000f9ec3e30] [c00000000004bae0] kretprobe_trampoline+0x0/0x10
      
      This is showing up since OPTPROBES is now enabled with CONFIG_PREEMPT.
      
      trampoline_probe_handler() considers itself to be a special kprobe
      handler for kretprobes. In doing so, it expects to be called from
      kprobe_handler() on a trap, and re-enables preemption before returning a
      non-zero return value so as to suppress any subsequent processing of the
      trap by the kprobe_handler().
      
      However, with optprobes, we don't deal with special handlers (we ignore
      the return code) and just try to re-enable preemption causing the above
      trace.
      
      To address this, modify trampoline_probe_handler() to not be special.
      The only additional processing done in kprobe_handler() is to emulate
      the instruction (in this case, a 'nop'). We adjust the value of
      regs->nip for the purpose and delegate the job of re-enabling
      preemption and resetting current kprobe to the probe handlers
      (kprobe_handler() or optimized_callback()).
      
      Fixes: 8a2d71a3 ("powerpc/kprobes: Disable preemption before invoking probe handler for optprobes")
      Cc: stable@vger.kernel.org # v4.15+
      Reported-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Acked-by: default avatarAnanth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      e6e133c4
    • Finn Thain's avatar
      macintosh/adb: Use C99 initializers for struct adb_driver instances · 3a52f6f9
      Finn Thain authored
      No change to object files.
      
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      3a52f6f9
    • Nicholas Piggin's avatar
      powerpc/powernv: Handle unknown OPAL errors in opal_nvram_write() · 741de617
      Nicholas Piggin authored
      opal_nvram_write currently just assumes success if it encounters an
      error other than OPAL_BUSY or OPAL_BUSY_EVENT. Have it return -EIO
      on other errors instead.
      
      Fixes: 628daa8d ("powerpc/powernv: Add RTC and NVRAM support plus RTAS fallbacks")
      Cc: stable@vger.kernel.org # v3.2+
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Reviewed-by: default avatarVasant Hegde <hegdevasant@linux.vnet.ibm.com>
      Acked-by: default avatarStewart Smith <stewart@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      741de617
    • Mauricio Faria de Oliveira's avatar
      powerpc/pseries: Fix clearing of security feature flags · 0f9bdfe3
      Mauricio Faria de Oliveira authored
      The H_CPU_BEHAV_* flags should be checked for in the 'behaviour' field
      of 'struct h_cpu_char_result' -- 'character' is for H_CPU_CHAR_*
      flags.
      
      Found by playing around with QEMU's implementation of the hypercall:
      
        H_CPU_CHAR=0xf000000000000000
        H_CPU_BEHAV=0x0000000000000000
      
        This clears H_CPU_BEHAV_FAVOUR_SECURITY and H_CPU_BEHAV_L1D_FLUSH_PR
        so pseries_setup_rfi_flush() disables 'rfi_flush'; and it also
        clears H_CPU_CHAR_L1D_THREAD_PRIV flag. So there is no RFI flush
        mitigation at all for cpu_show_meltdown() to report; but currently
        it does:
      
        Original kernel:
      
          # cat /sys/devices/system/cpu/vulnerabilities/meltdown
          Mitigation: RFI Flush
      
        Patched kernel:
      
          # cat /sys/devices/system/cpu/vulnerabilities/meltdown
          Not affected
      
        H_CPU_CHAR=0x0000000000000000
        H_CPU_BEHAV=0xf000000000000000
      
        This sets H_CPU_BEHAV_BNDS_CHK_SPEC_BAR so cpu_show_spectre_v1() should
        report vulnerable; but currently it doesn't:
      
        Original kernel:
      
          # cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
          Not affected
      
        Patched kernel:
      
          # cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
          Vulnerable
      Brown-paper-bag-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Fixes: f636c147 ("powerpc/pseries: Set or clear security feature flags")
      Signed-off-by: default avatarMauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      0f9bdfe3
  2. 28 Mar, 2018 1 commit
    • Michael Ellerman's avatar
      Merge branch 'fixes' into next · 95dff480
      Michael Ellerman authored
      Merge our fixes branch from the 4.16 cycle.
      
      There were a number of important fixes merged, in particular some Power9
      workarounds that we want in next for testing purposes. There's also been
      some conflicting changes in the CPU features code which are best merged
      and tested before going upstream.
      95dff480
  3. 27 Mar, 2018 35 commits