1. 27 Sep, 2022 2 commits
    • Longfang Liu's avatar
      hisi_acc_vfio_pci: Fixes error return code issue · 948f5ada
      Longfang Liu authored
      During the process of compatibility and matching of live migration
      device information, if the isolation status of the two devices is
      inconsistent, the live migration needs to be exited.
      
      The current driver does not return the error code correctly and
      needs to be fixed.
      Reviewed-by: default avatarShameer Kolothum <shameerali.kolothum.thodi@huawei.com>
      Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarLongfang Liu <liulongfang@huawei.com>
      Link: https://lore.kernel.org/r/20220926093332.28824-2-liulongfang@huawei.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      948f5ada
    • Jason Gunthorpe's avatar
      vfio: Follow a strict lifetime for struct iommu_group · ca5f21b2
      Jason Gunthorpe authored
      The iommu_group comes from the struct device that a driver has been bound
      to and then created a struct vfio_device against. To keep the iommu layer
      sane we want to have a simple rule that only an attached driver should be
      using the iommu API. Particularly only an attached driver should hold
      ownership.
      
      In VFIO's case since it uses the group APIs and it shares between
      different drivers it is a bit more complicated, but the principle still
      holds.
      
      Solve this by waiting for all users of the vfio_group to stop before
      allowing vfio_unregister_group_dev() to complete. This is done with a new
      completion to know when the users go away and an additional refcount to
      keep track of how many device drivers are sharing the vfio group. The last
      driver to be unregistered will clean up the group.
      
      This solves crashes in the S390 iommu driver that come because VFIO ends
      up racing releasing ownership (which attaches the default iommu_domain to
      the device) with the removal of that same device from the iommu
      driver. This is a side case that iommu drivers should not have to cope
      with.
      
         iommu driver failed to attach the default/blocking domain
         WARNING: CPU: 0 PID: 5082 at drivers/iommu/iommu.c:1961 iommu_detach_group+0x6c/0x80
         Modules linked in: macvtap macvlan tap vfio_pci vfio_pci_core irqbypass vfio_virqfd kvm nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set nf_tables nfnetlink mlx5_ib sunrpc ib_uverbs ism smc uvdevice ib_core s390_trng eadm_sch tape_3590 tape tape_class vfio_ccw mdev vfio_iommu_type1 vfio zcrypt_cex4 sch_fq_codel configfs ghash_s390 prng chacha_s390 libchacha aes_s390 mlx5_core des_s390 libdes sha3_512_s390 nvme sha3_256_s390 sha512_s390 sha256_s390 sha1_s390 sha_common nvme_core zfcp scsi_transport_fc pkey zcrypt rng_core autofs4
         CPU: 0 PID: 5082 Comm: qemu-system-s39 Tainted: G        W          6.0.0-rc3 #5
         Hardware name: IBM 3931 A01 782 (LPAR)
         Krnl PSW : 0704c00180000000 000000095bb10d28 (iommu_detach_group+0x70/0x80)
                    R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 RI:0 EA:3
         Krnl GPRS: 0000000000000001 0000000900000027 0000000000000039 000000095c97ffe0
                    00000000fffeffff 00000009fc290000 00000000af1fda50 00000000af590b58
                    00000000af1fdaf0 0000000135c7a320 0000000135e52258 0000000135e52200
                    00000000a29e8000 00000000af590b40 000000095bb10d24 0000038004b13c98
         Krnl Code: 000000095bb10d18: c020003d56fc        larl    %r2,000000095c2bbb10
                                000000095bb10d1e: c0e50019d901        brasl   %r14,000000095be4bf20
                               #000000095bb10d24: af000000            mc      0,0
                               >000000095bb10d28: b904002a            lgr     %r2,%r10
                                000000095bb10d2c: ebaff0a00004        lmg     %r10,%r15,160(%r15)
                                000000095bb10d32: c0f4001aa867        brcl    15,000000095be65e00
                                000000095bb10d38: c004002168e0        brcl    0,000000095bf3def8
                                000000095bb10d3e: eb6ff0480024        stmg    %r6,%r15,72(%r15)
         Call Trace:
          [<000000095bb10d28>] iommu_detach_group+0x70/0x80
         ([<000000095bb10d24>] iommu_detach_group+0x6c/0x80)
          [<000003ff80243b0e>] vfio_iommu_type1_detach_group+0x136/0x6c8 [vfio_iommu_type1]
          [<000003ff80137780>] __vfio_group_unset_container+0x58/0x158 [vfio]
          [<000003ff80138a16>] vfio_group_fops_unl_ioctl+0x1b6/0x210 [vfio]
         pci 0004:00:00.0: Removing from iommu group 4
          [<000000095b5b62e8>] __s390x_sys_ioctl+0xc0/0x100
          [<000000095be5d3b4>] __do_syscall+0x1d4/0x200
          [<000000095be6c072>] system_call+0x82/0xb0
         Last Breaking-Event-Address:
          [<000000095be4bf80>] __warn_printk+0x60/0x68
      
      It indicates that domain->ops->attach_dev() failed because the driver has
      already passed the point of destructing the device.
      
      Fixes: 9ac85451 ("iommu: Fix use-after-free in iommu_release_device")
      Reported-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Tested-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Reviewed-by: default avatarYi Liu <yi.l.liu@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Link: https://lore.kernel.org/r/0-v2-a3c5f4429e2a+55-iommu_group_lifetime_jgg@nvidia.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      ca5f21b2
  2. 22 Sep, 2022 8 commits
  3. 21 Sep, 2022 15 commits
  4. 08 Sep, 2022 10 commits
  5. 07 Sep, 2022 2 commits
  6. 04 Sep, 2022 3 commits
    • Linus Torvalds's avatar
      Linux 6.0-rc4 · 7e18e42e
      Linus Torvalds authored
      7e18e42e
    • Linus Torvalds's avatar
      Merge tag 'powerpc-6.0-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · 59954972
      Linus Torvalds authored
      Pull powerpc fixes from Michael Ellerman:
      
       - Fix handling of PCI domains in /proc on 32-bit systems using the
         recently added support for numbering buses from zero for each domain.
      
       - A fix and a revert for some changes to use READ/WRITE_ONCE() which
         caused problems with KASAN enabled due to sanitisation calls being
         introduced in low-level paths that can't cope with it.
      
       - Fix build errors on 32-bit caused by the syscall table being
         misaligned sometimes.
      
       - Two fixes to get IBM Cell native machines booting again, which had
         bit-rotted while my QS22 was temporarily out of action.
      
       - Fix the papr_scm driver to not assume the order of events returned by
         the hypervisor is stable, and a related compile fix.
      
      Thanks to Aneesh Kumar K.V, Christophe Leroy, Jordan Niethe, Kajol Jain,
      Masahiro Yamada, Nathan Chancellor, Pali Rohár, Vaibhav Jain, and Zhouyi
      Zhou.
      
      * tag 'powerpc-6.0-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        powerpc/papr_scm: Ensure rc is always initialized in papr_scm_pmu_register()
        Revert "powerpc/irq: Don't open code irq_soft_mask helpers"
        powerpc: Fix hard_irq_disable() with sanitizer
        powerpc/rtas: Fix RTAS MSR[HV] handling for Cell
        Revert "powerpc: Remove unused FW_FEATURE_NATIVE references"
        powerpc: align syscall table for ppc32
        powerpc/pci: Enable PCI domains in /proc when PCI bus numbers are not unique
        powerpc/papr_scm: Fix nvdimm event mappings
      59954972
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 685ed983
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "s390:
      
         - PCI interpretation compile fixes
      
        RISC-V:
      
         - fix unused variable warnings in vcpu_timer.c
      
         - move extern sbi_ext declarations to a header
      
        x86:
      
         - check validity of argument to KVM_SET_MP_STATE
      
         - use guest's global_ctrl to completely disable guest PEBS
      
         - fix a memory leak on memory allocation failure
      
         - mask off unsupported and unknown bits of IA32_ARCH_CAPABILITIES
      
         - fix build failure with Clang integrated assembler
      
         - fix MSR interception
      
         - always flush TLBs when enabling dirty logging"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: x86: check validity of argument to KVM_SET_MP_STATE
        perf/x86/core: Completely disable guest PEBS via guest's global_ctrl
        KVM: x86: fix memoryleak in kvm_arch_vcpu_create()
        KVM: x86: Mask off unsupported and unknown bits of IA32_ARCH_CAPABILITIES
        KVM: s390: pci: Hook to access KVM lowlevel from VFIO
        riscv: kvm: move extern sbi_ext declarations to a header
        riscv: kvm: vcpu_timer: fix unused variable warnings
        KVM: selftests: Fix ambiguous mov in KVM_ASM_SAFE()
        KVM: selftests: Fix KVM_EXCEPTION_MAGIC build with Clang
        KVM: VMX: Heed the 'msr' argument in msr_write_intercepted()
        kvm: x86: mmu: Always flush TLBs when enabling dirty logging
        kvm: x86: mmu: Drop the need_remote_flush() function
      685ed983