1. 27 May, 2020 7 commits
    • Laurent Dufour's avatar
      KVM: PPC: Book3S HV: Relax check on H_SVM_INIT_ABORT · e3326ae3
      Laurent Dufour authored
      The commit 8c47b6ff ("KVM: PPC: Book3S HV: Check caller of H_SVM_*
      Hcalls") added checks of secure bit of SRR1 to filter out the Hcall
      reserved to the Ultravisor.
      
      However, the Hcall H_SVM_INIT_ABORT is made by the Ultravisor passing the
      context of the VM calling UV_ESM. This allows the Hypervisor to return to
      the guest without going through the Ultravisor. Thus the Secure bit of SRR1
      is not set in that particular case.
      
      In the case a regular VM is calling H_SVM_INIT_ABORT, this hcall will be
      filtered out in kvmppc_h_svm_init_abort() because kvm->arch.secure_guest is
      not set in that case.
      
      Fixes: 8c47b6ff ("KVM: PPC: Book3S HV: Check caller of H_SVM_* Hcalls")
      Signed-off-by: default avatarLaurent Dufour <ldufour@linux.ibm.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Reviewed-by: default avatarRam Pai <linuxram@us.ibm.com>
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      e3326ae3
    • Qian Cai's avatar
      KVM: PPC: Book3S: Fix some RCU-list locks · ab8b65be
      Qian Cai authored
      It is unsafe to traverse kvm->arch.spapr_tce_tables and
      stt->iommu_tables without the RCU read lock held. Also, add
      cond_resched_rcu() in places with the RCU read lock held that could take
      a while to finish.
      
       arch/powerpc/kvm/book3s_64_vio.c:76 RCU-list traversed in non-reader section!!
      
       other info that might help us debug this:
      
       rcu_scheduler_active = 2, debug_locks = 1
       no locks held by qemu-kvm/4265.
      
       stack backtrace:
       CPU: 96 PID: 4265 Comm: qemu-kvm Not tainted 5.7.0-rc4-next-20200508+ #2
       Call Trace:
       [c000201a8690f720] [c000000000715948] dump_stack+0xfc/0x174 (unreliable)
       [c000201a8690f770] [c0000000001d9470] lockdep_rcu_suspicious+0x140/0x164
       [c000201a8690f7f0] [c008000010b9fb48] kvm_spapr_tce_release_iommu_group+0x1f0/0x220 [kvm]
       [c000201a8690f870] [c008000010b8462c] kvm_spapr_tce_release_vfio_group+0x54/0xb0 [kvm]
       [c000201a8690f8a0] [c008000010b84710] kvm_vfio_destroy+0x88/0x140 [kvm]
       [c000201a8690f8f0] [c008000010b7d488] kvm_put_kvm+0x370/0x600 [kvm]
       [c000201a8690f990] [c008000010b7e3c0] kvm_vm_release+0x38/0x60 [kvm]
       [c000201a8690f9c0] [c0000000005223f4] __fput+0x124/0x330
       [c000201a8690fa20] [c000000000151cd8] task_work_run+0xb8/0x130
       [c000201a8690fa70] [c0000000001197e8] do_exit+0x4e8/0xfa0
       [c000201a8690fb70] [c00000000011a374] do_group_exit+0x64/0xd0
       [c000201a8690fbb0] [c000000000132c90] get_signal+0x1f0/0x1200
       [c000201a8690fcc0] [c000000000020690] do_notify_resume+0x130/0x3c0
       [c000201a8690fda0] [c000000000038d64] syscall_exit_prepare+0x1a4/0x280
       [c000201a8690fe20] [c00000000000c8f8] system_call_common+0xf8/0x278
      
       ====
       arch/powerpc/kvm/book3s_64_vio.c:368 RCU-list traversed in non-reader section!!
      
       other info that might help us debug this:
      
       rcu_scheduler_active = 2, debug_locks = 1
       2 locks held by qemu-kvm/4264:
        #0: c000201ae2d000d8 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0xdc/0x950 [kvm]
        #1: c000200c9ed0c468 (&kvm->srcu){....}-{0:0}, at: kvmppc_h_put_tce+0x88/0x340 [kvm]
      
       ====
       arch/powerpc/kvm/book3s_64_vio.c:108 RCU-list traversed in non-reader section!!
      
       other info that might help us debug this:
      
       rcu_scheduler_active = 2, debug_locks = 1
       1 lock held by qemu-kvm/4257:
        #0: c000200b1b363a40 (&kv->lock){+.+.}-{3:3}, at: kvm_vfio_set_attr+0x598/0x6c0 [kvm]
      
       ====
       arch/powerpc/kvm/book3s_64_vio.c:146 RCU-list traversed in non-reader section!!
      
       other info that might help us debug this:
      
       rcu_scheduler_active = 2, debug_locks = 1
       1 lock held by qemu-kvm/4257:
        #0: c000200b1b363a40 (&kv->lock){+.+.}-{3:3}, at: kvm_vfio_set_attr+0x598/0x6c0 [kvm]
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      ab8b65be
    • Qian Cai's avatar
      KVM: PPC: Book3S HV: Ignore kmemleak false positives · 0aca8a55
      Qian Cai authored
      kvmppc_pmd_alloc() and kvmppc_pte_alloc() allocate some memory but then
      pud_populate() and pmd_populate() will use __pa() to reference the newly
      allocated memory.
      
      Since kmemleak is unable to track the physical memory resulting in false
      positives, silence those by using kmemleak_ignore().
      
      unreferenced object 0xc000201c382a1000 (size 4096):
       comm "qemu-kvm", pid 124828, jiffies 4295733767 (age 341.250s)
       hex dump (first 32 bytes):
         c0 00 20 09 f4 60 03 87 c0 00 20 10 72 a0 03 87  .. ..`.... .r...
         c0 00 20 0e 13 a0 03 87 c0 00 20 1b dc c0 03 87  .. ....... .....
       backtrace:
         [<000000004cc2790f>] kvmppc_create_pte+0x838/0xd20 [kvm_hv]
         kvmppc_pmd_alloc at arch/powerpc/kvm/book3s_64_mmu_radix.c:366
         (inlined by) kvmppc_create_pte at arch/powerpc/kvm/book3s_64_mmu_radix.c:590
         [<00000000d123c49a>] kvmppc_book3s_instantiate_page+0x2e0/0x8c0 [kvm_hv]
         [<00000000bb549087>] kvmppc_book3s_radix_page_fault+0x1b4/0x2b0 [kvm_hv]
         [<0000000086dddc0e>] kvmppc_book3s_hv_page_fault+0x214/0x12a0 [kvm_hv]
         [<000000005ae9ccc2>] kvmppc_vcpu_run_hv+0xc5c/0x15f0 [kvm_hv]
         [<00000000d22162ff>] kvmppc_vcpu_run+0x34/0x48 [kvm]
         [<00000000d6953bc4>] kvm_arch_vcpu_ioctl_run+0x314/0x420 [kvm]
         [<000000002543dd54>] kvm_vcpu_ioctl+0x33c/0x950 [kvm]
         [<0000000048155cd6>] ksys_ioctl+0xd8/0x130
         [<0000000041ffeaa7>] sys_ioctl+0x28/0x40
         [<000000004afc4310>] system_call_exception+0x114/0x1e0
         [<00000000fb70a873>] system_call_common+0xf0/0x278
      unreferenced object 0xc0002001f0c03900 (size 256):
       comm "qemu-kvm", pid 124830, jiffies 4295735235 (age 326.570s)
       hex dump (first 32 bytes):
         c0 00 20 10 fa a0 03 87 c0 00 20 10 fa a1 03 87  .. ....... .....
         c0 00 20 10 fa a2 03 87 c0 00 20 10 fa a3 03 87  .. ....... .....
       backtrace:
         [<0000000023f675b8>] kvmppc_create_pte+0x854/0xd20 [kvm_hv]
         kvmppc_pte_alloc at arch/powerpc/kvm/book3s_64_mmu_radix.c:356
         (inlined by) kvmppc_create_pte at arch/powerpc/kvm/book3s_64_mmu_radix.c:593
         [<00000000d123c49a>] kvmppc_book3s_instantiate_page+0x2e0/0x8c0 [kvm_hv]
         [<00000000bb549087>] kvmppc_book3s_radix_page_fault+0x1b4/0x2b0 [kvm_hv]
         [<0000000086dddc0e>] kvmppc_book3s_hv_page_fault+0x214/0x12a0 [kvm_hv]
         [<000000005ae9ccc2>] kvmppc_vcpu_run_hv+0xc5c/0x15f0 [kvm_hv]
         [<00000000d22162ff>] kvmppc_vcpu_run+0x34/0x48 [kvm]
         [<00000000d6953bc4>] kvm_arch_vcpu_ioctl_run+0x314/0x420 [kvm]
         [<000000002543dd54>] kvm_vcpu_ioctl+0x33c/0x950 [kvm]
         [<0000000048155cd6>] ksys_ioctl+0xd8/0x130
         [<0000000041ffeaa7>] sys_ioctl+0x28/0x40
         [<000000004afc4310>] system_call_exception+0x114/0x1e0
         [<00000000fb70a873>] system_call_common+0xf0/0x278
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      0aca8a55
    • Tianjia Zhang's avatar
      KVM: PPC: Clean up redundant 'kvm_run' parameters · 8c99d345
      Tianjia Zhang authored
      In the current kvm version, 'kvm_run' has been included in the 'kvm_vcpu'
      structure. For historical reasons, many kvm-related function parameters
      retain the 'kvm_run' and 'kvm_vcpu' parameters at the same time. This
      patch does a unified cleanup of these remaining redundant parameters.
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Reviewed-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      8c99d345
    • Tianjia Zhang's avatar
      KVM: PPC: Remove redundant kvm_run from vcpu_arch · 2610a57f
      Tianjia Zhang authored
      The 'kvm_run' field already exists in the 'vcpu' structure, which
      is the same structure as the 'kvm_run' in the 'vcpu_arch' and
      should be deleted.
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Reviewed-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      2610a57f
    • Laurent Dufour's avatar
      KVM: PPC: Book3S HV: Read ibm,secure-memory nodes · 512721d2
      Laurent Dufour authored
      The newly introduced ibm,secure-memory nodes supersede the
      ibm,uv-firmware's property secure-memory-ranges.
      
      Firmware will no more expose the secure-memory-ranges property so first
      read the new one and if not found rollback to the older one.
      Signed-off-by: default avatarLaurent Dufour <ldufour@linux.ibm.com>
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      512721d2
    • Chen Zhou's avatar
      KVM: PPC: Book3S HV: Remove redundant NULL check · 32e594f9
      Chen Zhou authored
      Free function kfree() already does NULL check, so the additional
      check is unnecessary, just remove it.
      Signed-off-by: default avatarChen Zhou <chenzhou10@huawei.com>
      Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      32e594f9
  2. 20 May, 2020 2 commits
  3. 19 May, 2020 7 commits
  4. 15 May, 2020 24 commits