1. 06 11月, 2017 1 次提交
  2. 22 10月, 2017 1 次提交
  3. 28 9月, 2017 1 次提交
  4. 02 8月, 2017 3 次提交
  5. 26 7月, 2017 1 次提交
    • B
      powerpc/mm/radix: Workaround prefetch issue with KVM · a25bd72b
      Benjamin Herrenschmidt 提交于
      There's a somewhat architectural issue with Radix MMU and KVM.
      
      When coming out of a guest with AIL (Alternate Interrupt Location, ie,
      MMU enabled), we start executing hypervisor code with the PID register
      still containing whatever the guest has been using.
      
      The problem is that the CPU can (and will) then start prefetching or
      speculatively load from whatever host context has that same PID (if
      any), thus bringing translations for that context into the TLB, which
      Linux doesn't know about.
      
      This can cause stale translations and subsequent crashes.
      
      Fixing this in a way that is neither racy nor a huge performance
      impact is difficult. We could just make the host invalidations always
      use broadcast forms but that would hurt single threaded programs for
      example.
      
      We chose to fix it instead by partitioning the PID space between guest
      and host. This is possible because today Linux only use 19 out of the
      20 bits of PID space, so existing guests will work if we make the host
      use the top half of the 20 bits space.
      
      We additionally add support for a property to indicate to Linux the
      size of the PID register which will be useful if we eventually have
      processors with a larger PID space available.
      
      There is still an issue with malicious guests purposefully setting the
      PID register to a value in the hosts PID range. Hopefully future HW
      can prevent that, but in the meantime, we handle it with a pair of
      kludges:
      
       - On the way out of a guest, before we clear the current VCPU in the
         PACA, we check the PID and if it's outside of the permitted range
         we flush the TLB for that PID.
      
       - When context switching, if the mm is "new" on that CPU (the
         corresponding bit was set for the first time in the mm cpumask), we
         check if any sibling thread is in KVM (has a non-NULL VCPU pointer
         in the PACA). If that is the case, we also flush the PID for that
         CPU (core).
      
      This second part is needed to handle the case where a process is
      migrated (or starts a new pthread) on a sibling thread of the CPU
      coming out of KVM, as there's a window where stale translations can
      exist before we detect it and flush them out.
      
      A future optimization could be added by keeping track of whether the
      PID has ever been used and avoid doing that for completely fresh PIDs.
      We could similarily mark PIDs that have been the subject of a global
      invalidation as "fresh". But for now this will do.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      [mpe: Rework the asm to build with CONFIG_PPC_RADIX_MMU=n, drop
            unneeded include of kvm_book3s_asm.h]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      a25bd72b
  6. 23 6月, 2017 1 次提交
    • B
      powerpc/mm: Trace tlbie(l) instructions · 0428491c
      Balbir Singh 提交于
      Add a trace point for tlbie(l) (Translation Lookaside Buffer Invalidate
      Entry (Local)) instructions.
      
      The tlbie instruction has changed over the years, so not all versions
      accept the same operands. Use the ISA v3 field operands because they are
      the most verbose, we may change them in future.
      
      Example output:
      
        qemu-system-ppc-5371  [016]  1412.369519: tlbie:
        	tlbie with lpid 0, local 1, rb=67bd8900174c11c1, rs=0, ric=0 prs=0 r=0
      Signed-off-by: NBalbir Singh <bsingharora@gmail.com>
      [mpe: Add some missing trace_tlbie()s, reword change log]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      0428491c
  7. 03 5月, 2017 1 次提交
    • M
      powerpc/mm/radix: Drop support for CPUs without lockless tlbie · 3c9ac2bc
      Michael Ellerman 提交于
      Currently the radix TLB code includes support for CPUs that do *not*
      have MMU_FTR_LOCKLESS_TLBIE. On those CPUs we are required to take a
      global spinlock before issuing a tlbie.
      
      Radix can only be built for 64-bit Book3s CPUs, and of those, only
      POWER4, 970, Cell and PA6T do not have MMU_FTR_LOCKLESS_TLBIE. Although
      it's possible to build a kernel with Radix support that can also boot on
      those CPUs, we happen to know that in reality none of those CPUs support
      the Radix MMU, so the code can never actually run on those CPUs.
      
      So remove the native_tlbie_lock in the Radix TLB code.
      
      Note that there is another lock of the same name in the hash code, which
      is unaffected by this patch.
      Reviewed-by: NNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      3c9ac2bc
  8. 27 4月, 2017 2 次提交
    • A
      powerpc/mm/radix: Optimise tlbiel flush all case · a5998fcb
      Aneesh Kumar K.V 提交于
      _tlbiel_pid() is called with a ric (Radix Invalidation Control) argument of
      either RIC_FLUSH_TLB or RIC_FLUSH_ALL.
      
      RIC_FLUSH_ALL says to invalidate the entire TLB and the Page Walk Cache (PWC).
      
      To flush the whole TLB, we have to iterate over each set (congruence class) of
      the TLB. Currently we do that and pass RIC_FLUSH_ALL each time. That is not
      incorrect but it means we flush the PWC 128 times, when once would suffice.
      
      Fix it by doing the first flush with the ric value we're passed, and then if it
      was RIC_FLUSH_ALL, we downgrade it to RIC_FLUSH_TLB, because we know we have
      just flushed the PWC and don't need to do it again.
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [mpe: Split out of combined patch, tweak logic, rewrite change log]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      a5998fcb
    • A
      powerpc/mm/radix: Optimise Page Walk Cache flush · cf4f08be
      Aneesh Kumar K.V 提交于
      Currently we implement flushing of the page walk cache (PWC) by calling
      _tlbiel_pid() with a RIC (Radix Invalidation Control) value of 1 which says to
      only flush the PWC.
      
      But _tlbiel_pid() loops over each set (congruence class) of the TLB, which is
      not necessary when we're just flushing the PWC.
      
      In fact the set argument is ignored for a PWC flush, so essentially we're just
      flushing the PWC 127 extra times for no benefit.
      
      Fix it by adding tlbiel_pwc() which just does a single flush of the PWC.
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [mpe: Split out of combined patch, drop _ in name, rewrite change log]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      cf4f08be
  9. 11 4月, 2017 2 次提交
  10. 31 3月, 2017 1 次提交
  11. 09 2月, 2017 1 次提交
  12. 28 11月, 2016 1 次提交
  13. 18 11月, 2016 1 次提交
  14. 27 10月, 2016 1 次提交
    • A
      powerpc/mm/radix: Use tlbiel only if we ever ran on the current cpu · bd77c449
      Aneesh Kumar K.V 提交于
      Before this patch, we used tlbiel, if we ever ran only on this core.
      That was mostly derived from the nohash usage of the same. But is
      incorrect, the ISA 3.0 clarifies tlbiel such that:
      
      "All TLB entries that have all of the following properties are made
      invalid on the thread executing the tlbiel instruction"
      
      ie. tlbiel only invalidates TLB entries on the current thread. So if the
      mm has been used on any other thread (aka. cpu) then we must broadcast
      the invalidate.
      
      This bug could lead to invalid TLB entries if a program runs on multiple
      threads of a core.
      
      Hence use tlbiel, if we only ever ran on only the current cpu.
      
      Fixes: 1a472c9d ("powerpc/mm/radix: Add tlbflush routines")
      Cc: stable@vger.kernel.org # v4.7+
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      bd77c449
  15. 23 9月, 2016 1 次提交
  16. 01 8月, 2016 5 次提交
  17. 17 7月, 2016 2 次提交
  18. 10 6月, 2016 2 次提交
  19. 08 6月, 2016 1 次提交
  20. 11 5月, 2016 1 次提交
  21. 01 5月, 2016 1 次提交