1. 05 6月, 2017 1 次提交
    • B
      powerpc/kernel: Fix FP and vector register restoration · 1195892c
      Breno Leitao 提交于
      Currently tsk->thread->load_vec and load_fp are not initialized during
      task creation, which can lead to garbage values in these variables (non-zero
      values).
      
      These variables will be checked later in restore_math() to validate if the
      FP and vector registers are being utilized. Since these values might be
      non-zero, the restore_math() will continue to save the FP and vectors even if
      they were never utilized by the userspace application. load_fp and load_vec
      counters will then overflow (they wrap at 255) and the FP and Altivec will be
      finally disabled, but before that condition is reached (counter overflow)
      several context switches will have restored FP and vector registers without
      need, causing a performance degradation.
      
      Fixes: 70fe3d98 ("powerpc: Restore FPU/VEC/VSX if previously used")
      Cc: stable@vger.kernel.org # v4.6+
      Signed-off-by: NBreno Leitao <leitao@debian.org>
      Signed-off-by: NGustavo Romero <gusbromero@gmail.com>
      Acked-by: NAnton Blanchard <anton@samba.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      1195892c
  2. 01 6月, 2017 2 次提交
    • M
      powerpc/64: Reclaim CPU_FTR_SUBCORE · 0e5e7f5e
      Michael Ellerman 提交于
      We are running low on CPU feature bits, so we only want to use them when
      it's really necessary.
      
      CPU_FTR_SUBCORE is only used in one place, and only in C, so we don't
      need it in order to make asm patching work. It can only be set on
      "Power8" CPUs, which in practice means POWER8, POWER8E and POWER8NVL.
      There are no plans to implement it on future CPUs, but if there ever
      were we could retrofit it then.
      
      Although KVM uses subcores, it never looks at the CPU feature, it either
      looks at the ISA level or the threads_per_subcore value.
      
      So drop the CPU feature and do a PVR check instead. Drop the device tree
      "subcore" feature as we no longer support doing anything with it, and we
      will drop it from skiboot too.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      0e5e7f5e
    • N
      powerpc/64s: Add dt_cpu_ftrs boot time setup option · a2b05b7a
      Nicholas Piggin 提交于
      Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
      feature discovery, and fall back to the "cputable" based version.
      
      Also allow control of advertising unknown features to userspace and
      with this parameter, and remove the clunky CONFIG option.
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      [mpe: Add explicit early check of bootargs in dt_cpu_ftrs_init()]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      a2b05b7a
  3. 25 5月, 2017 2 次提交
  4. 16 5月, 2017 2 次提交
  5. 15 5月, 2017 1 次提交
    • M
      powerpc/tm: Fix FP and VMX register corruption · f48e91e8
      Michael Neuling 提交于
      In commit dc310669 ("powerpc: tm: Always use fp_state and vr_state
      to store live registers"), a section of code was removed that copied
      the current state to checkpointed state. That code should not have been
      removed.
      
      When an FP (Floating Point) unavailable is taken inside a transaction,
      we need to abort the transaction. This is because at the time of the
      tbegin, the FP state is bogus so the state stored in the checkpointed
      registers is incorrect. To fix this, we treclaim (to get the
      checkpointed GPRs) and then copy the thread_struct FP live state into
      the checkpointed state. We then trecheckpoint so that the FP state is
      correctly restored into the CPU.
      
      The copying of the FP registers from live to checkpointed is what was
      missing.
      
      This simplifies the logic slightly from the original patch.
      tm_reclaim_thread() will now always write the checkpointed FP
      state. Either the checkpointed FP state will be written as part of
      the actual treclaim (in tm.S), or it'll be a copy of the live
      state. Which one we use is based on MSR[FP] from userspace.
      
      Similarly for VMX.
      
      Fixes: dc310669 ("powerpc: tm: Always use fp_state and vr_state to store live registers")
      Cc: stable@vger.kernel.org # 4.9+
      Signed-off-by: NMichael Neuling <mikey@neuling.org>
      Reviewed-by: cyrilbur@gmail.com
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      f48e91e8
  6. 09 5月, 2017 5 次提交
  7. 03 5月, 2017 4 次提交
  8. 02 5月, 2017 2 次提交
  9. 30 4月, 2017 1 次提交
    • L
      powerpc/64e: Fix hang when debugging programs with relocated kernel · fd615f69
      LiuHailong 提交于
      Debug interrupts can be taken during interrupt entry, since interrupt
      entry does not automatically turn them off.  The kernel will check
      whether the faulting instruction is between [interrupt_base_book3e,
      __end_interrupts], and if so clear MSR[DE] and return.
      
      However, when the kernel is built with CONFIG_RELOCATABLE, it can't use
      LOAD_REG_IMMEDIATE(r14,interrupt_base_book3e) and
      LOAD_REG_IMMEDIATE(r15,__end_interrupts), as they ignore relocation.
      Thus, if the kernel is actually running at a different address than it
      was built at, the address comparison will fail, and the exception entry
      code will hang at kernel_dbg_exc.
      
      r2(toc) is also not usable here, as r2 still holds data from the
      interrupted context, so LOAD_REG_ADDR() doesn't work either.  So we use
      the *name@got* to get the EV of two labels directly.
      
      Test programs test.c shows as follows:
      int main(int argc, char *argv[])
      {
      	if (access("/proc/sys/kernel/perf_event_paranoid", F_OK) == -1)
      		printf("Kernel doesn't have perf_event support\n");
      }
      
      Steps to reproduce the bug, for example:
       1) ./gdb ./test
       2) (gdb) b access
       3) (gdb) r
       4) (gdb) s
      Signed-off-by: NLiu Hailong <liu.hailong6@zte.com.cn>
      Signed-off-by: NJiang Xuexin <jiang.xuexin@zte.com.cn>
      Reviewed-by: NJiang Biao <jiang.biao2@zte.com.cn>
      Reviewed-by: NLiu Song <liu.song11@zte.com.cn>
      Reviewed-by: NHuang Jian <huang.jian@zte.com.cn>
      [scottwood: cleaned up commit message, and specified bad behavior
       as a hang rather than an oops to correspond to mainline kernel behavior]
      Fixes: 1cb6e064 ("powerpc/book3e: support CONFIG_RELOCATABLE")
      Cc: <stable@vger.kernel.org> # 4.4.x-
      Signed-off-by: NScott Wood <oss@buserror.net>
      fd615f69
  10. 28 4月, 2017 9 次提交
  11. 27 4月, 2017 3 次提交
  12. 26 4月, 2017 1 次提交
    • N
      powerpc/64s: Revert setting of LPCR[LPES] on POWER9 · 8bf8f2e8
      Nicholas Piggin 提交于
      The XIVE enablement patches included a change to set the LPES (Logical
      Partitioning Environment Selector) bit (bit # 3) in LPCR (Logical Partitioning
      Control Register) on POWER9 hosts. This bit sets external interrupts to guest
      delivery mode, which uses SRR0/1. The host's EE interrupt handler is written to
      expect HSRR0/1 (for earlier CPUs). This should be fine because XIVE is
      configured not to deliver EEs to the host (Hypervisor Virtulization Interrupt is
      used instead) so the EE handler should never be executed.
      
      However a bug in interrupt controller code, hardware, or odd configuration of a
      simulator could result in the host getting an EE incorrectly. Keeping the EE
      delivery mode matching the host EE handler prevents strange crashes due to using
      the wrong exception registers.
      
      KVM will configure the LPCR to set LPES prior to running a guest so that EEs are
      delivered to the guest using SRR0/1.
      
      Fixes: 08a1e650 ("powerpc: Fixup LPCR:PECE and HEIC setting on POWER9")
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      [mpe: Massage change log to avoid referring to LPES0 which is now renamed LPES]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      8bf8f2e8
  13. 24 4月, 2017 5 次提交
  14. 23 4月, 2017 2 次提交
    • N
      powerpc/kprobes: Blacklist exception handlers · 7aa5b018
      Naveen N. Rao 提交于
      Introduce __head_end to mark end of the early fixed sections and use it to
      blacklist all exception handlers from kprobes.
      
      mpe: We do not need to do anything special for relocatable kernels, where the
      exception vectors are split from the main kernel, as the split vectors are
      already excluded by the check for kernel_text_address().
      Signed-off-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      [mpe: Move __head_end outside #ifdef 64-bit to unbreak the 32-bit build]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      7aa5b018
    • N
      powerpc/kprobes: Convert __kprobes to NOKPROBE_SYMBOL() · 71f6e58e
      Naveen N. Rao 提交于
      Along similar lines as commit 9326638c ("kprobes, x86: Use NOKPROBE_SYMBOL()
      instead of __kprobes annotation"), convert __kprobes annotation to either
      NOKPROBE_SYMBOL() or nokprobe_inline. The latter forces inlining, in which case
      the caller needs to be added to NOKPROBE_SYMBOL().
      
      Also:
       - blacklist arch_deref_entry_point(), and
       - convert a few regular inlines to nokprobe_inline in lib/sstep.c
      
      A key benefit is the ability to detect such symbols as being
      blacklisted. Before this patch:
      
        $ cat /sys/kernel/debug/kprobes/blacklist | grep read_mem
        $ perf probe read_mem
        Failed to write event: Invalid argument
          Error: Failed to add events.
        $ dmesg | tail -1
        [ 3736.112815] Could not insert probe at _text+10014968: -22
      
      After patch:
        $ cat /sys/kernel/debug/kprobes/blacklist | grep read_mem
        0xc000000000072b50-0xc000000000072d20	read_mem
        $ perf probe read_mem
        read_mem is blacklisted function, skip it.
        Added new events:
          (null):(null)        (on read_mem)
          probe:read_mem       (on read_mem)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe:read_mem -aR sleep 1
      
        $ grep " read_mem" /proc/kallsyms
        c000000000072b50 t read_mem
        c0000000005f3b40 t read_mem
        $ cat /sys/kernel/debug/kprobes/list
        c0000000005f3b48  k  read_mem+0x8    [DISABLED]
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      [mpe: Minor change log formatting, fix up some conflicts]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      71f6e58e