Message ID | 0-v2-d035a1842d81+1bf-vfio_group_locking_jgg@nvidia.com (mailing list archive) |
---|---|
Headers | show |
Series | Fully lock the container members of struct vfio_group | expand |
On Mon, May 16, 2022 at 08:41:16PM -0300, Jason Gunthorpe wrote: > The atomic based scheme for tracking the group->container and group->kvm > has two race conditions, simplify it by adding a rwsem to protect those > values and related and remove the atomics. > > This is on github: https://github.com/jgunthorpe/linux/commits/vfio_group_locking > > v2: > - Updated comments and commit messages > - Rebased on vfio next > - Left the dev_warn in place, will adjust it later > - s/singleton_file/opened_file/ > v1: https://lore.kernel.org/r/0-v1-c1d14aae2e8f+2f4-vfio_group_locking_jgg@nvidia.com > > Cc: Nicolin Chen <nicolinc@nvidia.com> Sanity tested on x86_64 and ARM64. Tested-by: Nicolin Chen <nicolinc@nvidia.com>
On 5/17/22 1:11 AM, Nicolin Chen wrote: > On Mon, May 16, 2022 at 08:41:16PM -0300, Jason Gunthorpe wrote: >> The atomic based scheme for tracking the group->container and group->kvm >> has two race conditions, simplify it by adding a rwsem to protect those >> values and related and remove the atomics. >> >> This is on github: https://github.com/jgunthorpe/linux/commits/vfio_group_locking >> >> v2: >> - Updated comments and commit messages >> - Rebased on vfio next >> - Left the dev_warn in place, will adjust it later >> - s/singleton_file/opened_file/ >> v1: https://lore.kernel.org/r/0-v1-c1d14aae2e8f+2f4-vfio_group_locking_jgg@nvidia.com >> >> Cc: Nicolin Chen <nicolinc@nvidia.com> > > Sanity tested on x86_64 and ARM64. > > Tested-by: Nicolin Chen <nicolinc@nvidia.com> Also sanity tested this series on s390x (vfio-pci and vfio-ap) Tested-by: Matthew Rosato <mjrosato@linux.ibm.com>
On Mon, 16 May 2022 20:41:16 -0300 Jason Gunthorpe <jgg@nvidia.com> wrote: > The atomic based scheme for tracking the group->container and group->kvm > has two race conditions, simplify it by adding a rwsem to protect those > values and related and remove the atomics. > > This is on github: https://github.com/jgunthorpe/linux/commits/vfio_group_locking > > v2: > - Updated comments and commit messages > - Rebased on vfio next > - Left the dev_warn in place, will adjust it later > - s/singleton_file/opened_file/ > v1: https://lore.kernel.org/r/0-v1-c1d14aae2e8f+2f4-vfio_group_locking_jgg@nvidia.com > > Cc: Nicolin Chen <nicolinc@nvidia.com> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > > Jason Gunthorpe (6): > vfio: Add missing locking for struct vfio_group::kvm > vfio: Change struct vfio_group::opened from an atomic to bool > vfio: Split up vfio_group_get_device_fd() > vfio: Fully lock struct vfio_group::container > vfio: Simplify the life cycle of the group FD > vfio: Change struct vfio_group::container_users to a non-atomic int > > drivers/vfio/vfio.c | 266 +++++++++++++++++++++++++++----------------- > 1 file changed, 163 insertions(+), 103 deletions(-) > > > base-commit: 6a985ae80befcf2c00e7c889336bfe9e9739e2ef Applied to vfio next branch for v5.19. Thanks! Alex
The atomic based scheme for tracking the group->container and group->kvm has two race conditions, simplify it by adding a rwsem to protect those values and related and remove the atomics. This is on github: https://github.com/jgunthorpe/linux/commits/vfio_group_locking v2: - Updated comments and commit messages - Rebased on vfio next - Left the dev_warn in place, will adjust it later - s/singleton_file/opened_file/ v1: https://lore.kernel.org/r/0-v1-c1d14aae2e8f+2f4-vfio_group_locking_jgg@nvidia.com Cc: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Jason Gunthorpe (6): vfio: Add missing locking for struct vfio_group::kvm vfio: Change struct vfio_group::opened from an atomic to bool vfio: Split up vfio_group_get_device_fd() vfio: Fully lock struct vfio_group::container vfio: Simplify the life cycle of the group FD vfio: Change struct vfio_group::container_users to a non-atomic int drivers/vfio/vfio.c | 266 +++++++++++++++++++++++++++----------------- 1 file changed, 163 insertions(+), 103 deletions(-) base-commit: 6a985ae80befcf2c00e7c889336bfe9e9739e2ef