Skip to content
  1. Apr 22, 2021
  2. Apr 21, 2021
  3. Apr 20, 2021
    • Michael Ellerman's avatar
      powerpc/kvm: Fix PR KVM with KUAP/MEM_KEYS enabled · e4e8bc1d
      Michael Ellerman authored
      The changes to add KUAP support with the hash MMU broke booting of KVM
      PR guests. The symptom is no visible progress of the guest, or possibly
      just "SLOF" being printed to the qemu console.
      
      Host code is still executing, but breaking into xmon might show a stack
      trace such as:
      
        __might_fault+0x84/0xe0 (unreliable)
        kvm_read_guest+0x1c8/0x2f0 [kvm]
        kvmppc_ld+0x1b8/0x2d0 [kvm]
        kvmppc_load_last_inst+0x50/0xa0 [kvm]
        kvmppc_exit_pr_progint+0x178/0x220 [kvm_pr]
        kvmppc_handle_exit_pr+0x31c/0xe30 [kvm_pr]
        after_sprg3_load+0x80/0x90 [kvm_pr]
        kvmppc_vcpu_run_pr+0x104/0x260 [kvm_pr]
        kvmppc_vcpu_run+0x34/0x48 [kvm]
        kvm_arch_vcpu_ioctl_run+0x340/0x450 [kvm]
        kvm_vcpu_ioctl+0x2ac/0x8c0 [kvm]
        sys_ioctl+0x320/0x1060
        system_call_exception+0x160/0x270
        system_call_common+0xf0/0x27c
      
      Bisect points to commit b2ff33a1 ("powerpc/book3s64/hash/kuap:
      Enable kuap on hash"), but that's just the commit that enabled KUAP with
      hash and made the bug visible.
      
      The root cause seems to be that KVM PR is creating kernel mappings that
      don't use the correct key, since we switched to using key 3.
      
      We have a helper for adding the right key value, however it's designed
      to take a pteflags variable, which the KVM code doesn't have. But we can
      make it work by passing 0 for the pteflags, and tell it explicitly that
      it should use the kernel key.
      
      With that changed guests boot successfully.
      
      Fixes: d94b827e
      
       ("powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation")
      Cc: stable@vger.kernel.org # v5.11+
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210419120139.1455937-1-mpe@ellerman.id.au
      e4e8bc1d
    • Michael Ellerman's avatar
      powerpc/pseries: Stop calling printk in rtas_stop_self() · ed8029d7
      Michael Ellerman authored
      
      
      RCU complains about us calling printk() from an offline CPU:
      
        =============================
        WARNING: suspicious RCU usage
        5.12.0-rc7-02874-g7cf90e481cb8 #1 Not tainted
        -----------------------------
        kernel/locking/lockdep.c:3568 RCU-list traversed in non-reader section!!
      
        other info that might help us debug this:
      
        RCU used illegally from offline CPU!
        rcu_scheduler_active = 2, debug_locks = 1
        no locks held by swapper/0/0.
      
        stack backtrace:
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.12.0-rc7-02874-g7cf90e481cb8 #1
        Call Trace:
          dump_stack+0xec/0x144 (unreliable)
          lockdep_rcu_suspicious+0x124/0x144
          __lock_acquire+0x1098/0x28b0
          lock_acquire+0x128/0x600
          _raw_spin_lock_irqsave+0x6c/0xc0
          down_trylock+0x2c/0x70
          __down_trylock_console_sem+0x60/0x140
          vprintk_emit+0x1a8/0x4b0
          vprintk_func+0xcc/0x200
          printk+0x40/0x54
          pseries_cpu_offline_self+0xc0/0x120
          arch_cpu_idle_dead+0x54/0x70
          do_idle+0x174/0x4a0
          cpu_startup_entry+0x38/0x40
          rest_init+0x268/0x388
          start_kernel+0x748/0x790
          start_here_common+0x1c/0x614
      
      Which happens because by the time we get to rtas_stop_self() we are
      already offline. In addition the message can be spammy, and is not that
      helpful for users, so remove it.
      
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210418135413.1204031-1-mpe@ellerman.id.au
      ed8029d7
    • Michael Ellerman's avatar
      powerpc: Only define _TASK_CPU for 32-bit · 3027a37c
      Michael Ellerman authored
      
      
      We have some interesting code in our Makefile to define _TASK_CPU, based
      on awk'ing the value out of asm-offsets.h. It exists to circumvent some
      circular header dependencies that prevent us from referring to
      task_struct in the relevant code. See the comment around _TASK_CPU in
      smp.h for more detail.
      
      Maybe one day we can come up with a better solution, but for now we can
      at least limit that logic to 32-bit, because it's not needed for 64-bit.
      
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210418131641.1186227-1-mpe@ellerman.id.au
      3027a37c
    • Tyrel Datwyler's avatar
      powerpc/pseries: Add shutdown() to vio_driver and vio_bus · 39d0099f
      Tyrel Datwyler authored
      
      
      Currently, neither the vio_bus or vio_driver structures provide support
      for a shutdown() routine.
      
      Add support for shutdown() by allowing drivers to provide a
      implementation via function pointer in their vio_driver struct and
      provide a proper implementation in the driver template for the vio_bus
      that calls a vio drivers shutdown() if defined.
      
      In the case that no shutdown() is defined by a vio driver and a kexec is
      in progress we implement a big hammer that calls remove() to ensure no
      further DMA for the devices is possible.
      
      Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210402001325.939668-1-tyreld@linux.ibm.com
      39d0099f
    • Athira Rajeev's avatar
      powerpc/perf: Expose processor pipeline stage cycles using PERF_SAMPLE_WEIGHT_STRUCT · af31fd0c
      Athira Rajeev authored
      
      
      Performance Monitoring Unit (PMU) registers in powerpc provides
      information on cycles elapsed between different stages in the
      pipeline. This can be used for application tuning. On ISA v3.1
      platform, this information is exposed by sampling registers.
      Patch adds kernel support to capture two of the cycle counters
      as part of perf sample using the sample type:
      PERF_SAMPLE_WEIGHT_STRUCT.
      
      The power PMU function 'get_mem_weight' currently uses 64 bit weight
      field of perf_sample_data to capture memory latency. But following the
      introduction of PERF_SAMPLE_WEIGHT_TYPE, weight field could contain
      64-bit or 32-bit value depending on the architexture support for
      PERF_SAMPLE_WEIGHT_STRUCT. Patches uses WEIGHT_STRUCT to expose the
      pipeline stage cycles info. Hence update the ppmu functions to work for
      64-bit and 32-bit weight values.
      
      If the sample type is PERF_SAMPLE_WEIGHT, use the 64-bit weight field.
      if the sample type is PERF_SAMPLE_WEIGHT_STRUCT, memory subsystem
      latency is stored in the low 32bits of perf_sample_weight structure.
      Also for CPU_FTR_ARCH_31, capture the two cycle counter information in
      two 16 bit fields of perf_sample_weight structure.
      
      Signed-off-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Reviewed-by: default avatarMadhavan Srinivasan <maddy@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1616425047-1666-2-git-send-email-atrajeev@linux.vnet.ibm.com
      af31fd0c
    • Haren Myneni's avatar
      Documentation/powerpc: Add proper links for manual and tests · 2886e2df
      Haren Myneni authored
      
      
      The links that are mentioned in this document are no longer
      valid. So changed the proper links for NXGZIP user manual and
      test cases.
      
      Reported-by: default avatarBulent Abali <abali@us.ibm.com>
      Signed-off-by: default avatarHaren Myneni <haren@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/08511c1e92ac239f20ac88c73c59d1f8cf02e6ad.camel@linux.ibm.com
      2886e2df
    • Daniel Henrique Barboza's avatar
      powerpc/pseries: Set UNISOLATE on dlpar_cpu_remove() failure · 29c9a269
      Daniel Henrique Barboza authored
      
      
      The RTAS set-indicator call, when attempting to UNISOLATE a DRC that is
      already UNISOLATED or CONFIGURED, returns RTAS_OK and does nothing else
      for both QEMU and phyp. This gives us an opportunity to use this
      behavior to signal the hypervisor layer when an error during device
      removal happens, allowing it to do a proper error handling, while not
      breaking QEMU/phyp implementations that don't have this support.
      
      This patch introduces this idea by unisolating all CPU DRCs that failed
      to be removed by dlpar_cpu_remove_by_index(), when handling the
      PSERIES_HP_ELOG_ID_DRC_INDEX event. This is being done for this event
      only because its the only CPU removal event QEMU uses, and there's no
      need at this moment to add this mechanism for phyp only code.
      
      Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210416210216.380291-3-danielhb413@gmail.com
      29c9a269