1. 13 4月, 2018 1 次提交
    • M
      powerpc/64s: Fix CPU_FTRS_ALWAYS vs DT CPU features · 81b654c2
      Michael Ellerman 提交于
      The cpu_has_feature() mechanism has an optimisation where at build
      time we construct a mask of the CPU feature bits that will always be
      true for the given .config, based on the platform/bitness/etc. that we
      are building for.
      
      That is incompatible with DT CPU features, where the set of CPU
      features is dependent on feature flags that are given to us by
      firmware.
      
      The result is that some feature bits can not be *disabled* by DT CPU
      features. Or more accurately, they can be disabled but they will still
      appear in the ALWAYS mask, meaning cpu_has_feature() will always
      return true for them.
      
      In the past this hasn't really been a problem because on Book3S
      64 (where we support DT CPU features), the set of ALWAYS bits has been
      very small. That was because we always built for POWER4 and later,
      meaning the set of common bits was small.
      
      The only bit that could be cleared by DT CPU features that was also in
      the ALWAYS mask was CPU_FTR_NODSISRALIGN, and that was only used in
      the alignment handler to create a fake DSISR. That code was itself
      deleted in 31bfdb03 ("powerpc: Use instruction emulation
      infrastructure to handle alignment faults") (Sep 2017).
      
      However the set of ALWAYS features changed with the recent commit
      db5ae1c1 ("powerpc/64s: Refine feature sets for little endian
      builds") which restricted the set of feature flags when building
      little endian to Power7 or later. That caused the ALWAYS mask to
      become much larger for little endian builds.
      
      The result is that the following feature bits can currently not
      be *disabled* by DT CPU features:
      
        CPU_FTR_REAL_LE, CPU_FTR_MMCRA, CPU_FTR_CTRL, CPU_FTR_SMT,
        CPU_FTR_PURR, CPU_FTR_SPURR, CPU_FTR_DSCR, CPU_FTR_PKEY,
        CPU_FTR_VMX_COPY, CPU_FTR_CFAR, CPU_FTR_HAS_PPR.
      
      To fix it we need to mask the set of ALWAYS features with the base set
      of DT CPU features, ie. the features that are always enabled by DT CPU
      features. That way there are no bits in the ALWAYS mask that are not
      also always set by DT CPU features.
      
      Fixes: db5ae1c1 ("powerpc/64s: Refine feature sets for little endian builds")
      Reviewed-by: NNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      81b654c2
  2. 05 4月, 2018 2 次提交
    • N
      powerpc/64s: Fix pkey support in dt_cpu_ftrs, add CPU_FTR_PKEY bit · c130153e
      Nicholas Piggin 提交于
      The pkey code added a CPU_FTR_PKEY bit, but did not add it to the
      dt_cpu_ftrs feature set. Although capability is supported by all
      processors in the base dt_cpu_ftrs set for 64s, it's a significant
      and sufficiently well defined feature to make it optional. So add
      it as a quirk for now, which can be versioned out then controlled
      by the firmware (once dt_cpu_ftrs gains versioning support).
      
      Fixes: cf43d3b2 ("powerpc: Enable pkey subsystem")
      Cc: stable@vger.kernel.org # v4.16+
      Cc: Ram Pai <linuxram@us.ibm.com>
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      c130153e
    • N
      powerpc/64s: Fix dt_cpu_ftrs to have restore_cpu clear unwanted LPCR bits · a57ac411
      Nicholas Piggin 提交于
      Presently the dt_cpu_ftrs restore_cpu will only add bits to the LPCR
      for secondaries, but some bits must be removed (e.g., UPRT for HPT).
      Not clearing these bits on secondaries causes checkstops when booting
      with disable_radix.
      
      restore_cpu can not just set LPCR, because it is also called by the
      idle wakeup code which relies on opal_slw_set_reg to restore the value
      of LPCR, at least on P8 which does not save LPCR to stack in the idle
      code.
      
      Fix this by including a mask of bits to clear from LPCR as well, which
      is used by restore_cpu.
      
      This is a little messy now, but it's a minimal fix that can be
      backported.  Longer term, the idle SPR save/restore code can be
      reworked to completely avoid calls to restore_cpu, then restore_cpu
      would be able to unconditionally set LPCR to match boot processor
      environment.
      
      Fixes: 5a61ef74 ("powerpc/64s: Support new device tree binding for discovering CPU features")
      Cc: stable@vger.kernel.org # v4.12+
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      a57ac411
  3. 31 3月, 2018 1 次提交
  4. 27 3月, 2018 1 次提交
  5. 23 3月, 2018 3 次提交
    • P
      powerpc: Add CPU feature bits for TM bug workarounds on POWER9 v2.2 · b5af4f27
      Paul Mackerras 提交于
      This adds a CPU feature bit which is set for POWER9 "Nimbus" DD2.2
      processors which will be used to enable the hypervisor to assist
      hardware with the handling of checkpointed register values while the
      CPU is in suspend state, in order to work around hardware bugs.  The
      hardware assistance for these workarounds introduced a new hardware
      bug relating to the XER[SO] bit.  We add a separate feature bit for
      this bug in case future chips fix it while still requiring the
      hypervisor assistance with suspend state.
      
      When the dt_cpu_ftrs subsystem is in use, the software assistance can
      be enabled using a "tm-suspend-hypervisor-assist" node in the device
      tree, and a "tm-suspend-xer-so-bug" node enables the workarounds for
      the XER[SO] bug.  In the absence of such nodes, a quirk enables both
      for POWER9 "Nimbus" DD2.2 processors.
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      b5af4f27
    • P
      powerpc: Use feature bit for RTC presence rather than timebase presence · c0d64cf9
      Paul Mackerras 提交于
      All PowerPC CPUs other than the original PPC601 have a timebase
      register rather than the "real-time clock" (RTC) register that the
      PPC601 (and the original POWER and POWER2 CPUs) had.  Currently
      we have a CPU feature bit to indicate the presence of the timebase,
      but it makes more sense to use a bit to indicate the unusual
      situation rather than the common situation.  This therefore defines
      a CPU_FTR_USE_RTC bit in place of the CPU_FTR_USE_TB bit, and
      arranges for it to be set on PPC601 systems.
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      c0d64cf9
    • A
      powerpc/mm: Fixup tlbie vs store ordering issue on POWER9 · a5d4b589
      Aneesh Kumar K.V 提交于
      On POWER9, under some circumstances, a broadcast TLB invalidation
      might complete before all previous stores have drained, potentially
      allowing stale stores from becoming visible after the invalidation.
      This works around it by doubling up those TLB invalidations which was
      verified by HW to be sufficient to close the risk window.
      
      This will be documented in a yet-to-be-published errata.
      
      Fixes: 1a472c9d ("powerpc/mm/radix: Add tlbflush routines")
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [mpe: Enable the feature in the DT CPU features code for all Power9,
            rename the feature to CPU_FTR_P9_TLBIE_BUG per benh.]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      a5d4b589
  6. 14 3月, 2018 1 次提交
    • M
      powerpc/64s: Fix NULL AT_BASE_PLATFORM when using DT CPU features · e4b79900
      Michael Ellerman 提交于
      When running virtualised the powerpc kernel is able to run the system
      in "compat mode" - which means the kernel and hardware are pretending
      to userspace that the CPU is an older version than it actually is.
      
      AT_BASE_PLATFORM is an AUXV entry that we export to userspace for use
      when we're running in that mode, which tells userspace the "platform"
      string for the real CPU version, as opposed to the faked version.
      
      Although we don't support compat mode when using DT CPU features, and
      arguably don't need to set AT_BASE_PLATFORM, the existing cputable
      based code always sets it even when we're running bare metal. That
      means the lack of AT_BASE_PLATFORM is a user-visible artifact of the
      fact that the kernel is using DT CPU features, which we don't want.
      
      So set it in the DT CPU features code also.
      
      This results in eg:
        $ LD_SHOW_AUXV=1 /bin/true | grep "AT_.*PLATFORM"
        AT_PLATFORM:     power9
        AT_BASE_PLATFORM:power9
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: NNicholas Piggin <npiggin@gmail.com>
      e4b79900
  7. 17 1月, 2018 1 次提交
    • N
      powerpc/64s: Improve local TLB flush for boot and MCE on POWER9 · d4748276
      Nicholas Piggin 提交于
      There are several cases outside the normal address space management
      where a CPU's entire local TLB is to be flushed:
      
        1. Booting the kernel, in case something has left stale entries in
           the TLB (e.g., kexec).
      
        2. Machine check, to clean corrupted TLB entries.
      
      One other place where the TLB is flushed, is waking from deep idle
      states. The flush is a side-effect of calling ->cpu_restore with the
      intention of re-setting various SPRs. The flush itself is unnecessary
      because in the first case, the TLB should not acquire new corrupted
      TLB entries as part of sleep/wake (though they may be lost).
      
      This type of TLB flush is coded inflexibly, several times for each CPU
      type, and they have a number of problems with ISA v3.0B:
      
      - The current radix mode of the MMU is not taken into account, it is
        always done as a hash flushn For IS=2 (LPID-matching flush from host)
        and IS=3 with HV=0 (guest kernel flush), tlbie(l) is undefined if
        the R field does not match the current radix mode.
      
      - ISA v3.0B hash must flush the partition and process table caches as
        well.
      
      - ISA v3.0B radix must flush partition and process scoped translations,
        partition and process table caches, and also the page walk cache.
      
      So consolidate the flushing code and implement it in C and inline asm
      under the mm/ directory with the rest of the flush code. Add ISA v3.0B
      cases for radix and hash, and use the radix flush in radix environment.
      
      Provide a way for IS=2 (LPID flush) to specify the radix mode of the
      partition. Have KVM pass in the radix mode of the guest.
      
      Take out the flushes from early cputable/dt_cpu_ftrs detection hooks,
      and move it later in the boot process after, the MMU registers are set
      up and before relocation is first turned on.
      
      The TLB flush is no longer called when restoring from deep idle states.
      This was not be done as a separate step because booting secondaries
      uses the same cpu_restore as idle restore, which needs the TLB flush.
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      d4748276
  8. 22 11月, 2017 1 次提交
  9. 15 11月, 2017 1 次提交
    • M
      powerpc/64s: Fix Power9 DD2.0 workarounds by adding DD2.1 feature · 3ffa9d9e
      Michael Ellerman 提交于
      Recently we added a CPU feature for Power9 DD2.0, to capture the fact
      that some workarounds are required only on Power9 DD1 and DD2.0 but
      not DD2.1 or later.
      
      Then in commit 9d2f510a ("powerpc/64s/idle: avoid POWER9 DD1 and
      DD2.0 ERAT workaround on DD2.1") and commit e3646330
      "powerpc/64s/idle: avoid POWER9 DD1 and DD2.0 PMU workaround on
      DD2.1") we changed CPU_FTR_SECTIONs to check for DD1 or DD20, eg:
      
        BEGIN_FTR_SECTION
                PPC_INVALIDATE_ERAT
        END_FTR_SECTION_IFSET(CPU_FTR_POWER9_DD1 | CPU_FTR_POWER9_DD20)
      
      Unfortunately although this reads as "if set DD1 or DD2.0", the or is
      a bitwise or and actually generates a mask of both bits. The code that
      does the feature patching then checks that the value of the CPU
      features masked with that mask are equal to the mask.
      
      So the end result is we're checking for DD1 and DD20 being set, which
      never happens. Yes the API is terrible.
      
      Removing the ERAT workaround on DD2.0 results in random SEGVs, the
      system tends to boot, but things randomly die including sometimes
      dhclient, udev etc.
      
      To fix the problem and hopefully avoid it in future, we remove the
      DD2.0 CPU feature and instead add a DD2.1 (or later) feature. This
      allows us to easily express that the workarounds are required if DD2.1
      is not set.
      
      At some point we will drop the DD1 workarounds entirely and some of
      this can be cleaned up.
      
      Fixes: 9d2f510a ("powerpc/64s/idle: avoid POWER9 DD1 and DD2.0 ERAT workaround on DD2.1")
      Fixes: e3646330 ("powerpc/64s/idle: avoid POWER9 DD1 and DD2.0 PMU workaround on DD2.1")
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      3ffa9d9e
  10. 06 11月, 2017 2 次提交
  11. 03 10月, 2017 1 次提交
  12. 11 7月, 2017 1 次提交
    • N
      powerpc/powernv: Fix local TLB flush for boot and MCE on POWER9 · 41d0c2ec
      Nicholas Piggin 提交于
      There are two cases outside the normal address space management
      where a CPU's local TLB is to be flushed:
      
        1. Host boot; in case something has left stale entries in the
           TLB (e.g., kexec).
      
        2. Machine check; to clean corrupted TLB entries.
      
      CPU state restore from deep idle states also flushes the TLB.
      However this seems to be a side effect of reusing the boot code to set
      CPU state, rather than a requirement itself.
      
      The current flushing has a number of problems with ISA v3.0B:
      
      - The current radix mode of the MMU is not taken into account. tlbiel
        is undefined if the R field does not match the current radix mode.
      
      - ISA v3.0B hash must flush the partition and process table caches.
      
      - ISA v3.0B radix must flush partition and process scoped translations,
        partition and process table caches, and also the page walk cache.
      
      Add POWER9 cases to handle these, with radix vs hash determined by the
      host MMU mode.
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      Reviewed-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      41d0c2ec
  13. 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
  14. 09 5月, 2017 1 次提交