From: Jason Gunthorpe <jgg@ziepe.ca>
To: Anthony DeRossi <ajderossi@gmail.com>
Cc: kvm@vger.kernel.org, alex.williamson@redhat.com,
cohuck@redhat.com, yishaih@nvidia.com, kevin.tian@intel.com
Subject: Re: [PATCH] vfio: Decrement open_count before close_device()
Date: Wed, 26 Oct 2022 08:24:00 -0300 [thread overview]
Message-ID: <Y1kY0I4lr7KntbWp@ziepe.ca> (raw)
In-Reply-To: <20221025193820.4412-1-ajderossi@gmail.com>
On Tue, Oct 25, 2022 at 12:38:20PM -0700, Anthony DeRossi wrote:
> The implementation of close_device() for vfio-pci inspects the
> open_count of every device in the device set to determine whether a
> reset is needed. Unless open_count is decremented before invoking
> close_device(), the device set will always contain a device with
> open_count > 0, effectively disabling the reset logic.
This seems to miss the reason why this was done:
Eliminate the calls to vfio_group_add_container_user() and add
vfio_assert_device_open() to detect driver mis-use. This causes the
close_device() op to check device->open_count so always leave it elevated
while calling the op.
If we let it be zero then vfio_assert_device_open() will trigger on
other drivers.
I think the best approach is to change vfio_pci to understand that
open_count == 1 means it is the last close.
Thanks,
Jason
next prev parent reply other threads:[~2022-10-26 11:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 19:38 [PATCH] vfio: Decrement open_count before close_device() Anthony DeRossi
2022-10-26 11:24 ` Jason Gunthorpe [this message]
2022-10-26 19:57 ` Anthony DeRossi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1kY0I4lr7KntbWp@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=ajderossi@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=yishaih@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox