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