From: Joao Martins <joao.m.martins@oracle.com>
To: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "Liu, Yi L" <yi.l.liu@intel.com>,
Eric Auger <eric.auger@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
Cedric Le Goater <clg@redhat.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Avihai Horon <avihaih@nvidia.com>
Subject: Re: [PATCH v3 01/10] vfio/iommufd: Don't fail to realize on IOMMU_GET_HW_INFO failure
Date: Wed, 10 Jul 2024 10:56:05 +0100 [thread overview]
Message-ID: <9bebf131-a465-48d7-a52a-15094576ca01@oracle.com> (raw)
In-Reply-To: <SJ0PR11MB674411EFA02886F23B1222C392A42@SJ0PR11MB6744.namprd11.prod.outlook.com>
On 10/07/2024 10:54, Duan, Zhenzhong wrote:
>
>
>> -----Original Message-----
>> From: Joao Martins <joao.m.martins@oracle.com>
>> Subject: Re: [PATCH v3 01/10] vfio/iommufd: Don't fail to realize on
>> IOMMU_GET_HW_INFO failure
>>
>> On 10/07/2024 03:53, Duan, Zhenzhong wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Joao Martins <joao.m.martins@oracle.com>
>>>> Subject: Re: [PATCH v3 01/10] vfio/iommufd: Don't fail to realize on
>>>> IOMMU_GET_HW_INFO failure
>>>>
>>>> On 09/07/2024 12:45, Joao Martins wrote:
>>>>> On 09/07/2024 09:56, Joao Martins wrote:
>>>>>> On 09/07/2024 04:43, Duan, Zhenzhong wrote:
>>>>>>> Hi Joao,
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Joao Martins <joao.m.martins@oracle.com>
>>>>>>>> Subject: [PATCH v3 01/10] vfio/iommufd: Don't fail to realize on
>>>>>>>> IOMMU_GET_HW_INFO failure
>>>>>>>>
>>>>>>>> mdevs aren't "physical" devices and when asking for backing
>> IOMMU
>>>> info, it
>>>>>>>> fails the entire provisioning of the guest. Fix that by filling caps info
>>>>>>>> when IOMMU_GET_HW_INFO succeeds plus discarding the error we
>>>> would
>>>>>>>> get into
>>>>>>>> iommufd_backend_get_device_info().
>>>>>>>>
>>>>>>>> Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>
>>>>>>>> Fixes: 930589520128 ("vfio/iommufd: Implement
>>>>>>>> HostIOMMUDeviceClass::realize() handler")
>>>>>>>> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
>>>>>>>> ---
>>>>>>>> hw/vfio/iommufd.c | 12 +++++-------
>>>>>>>> 1 file changed, 5 insertions(+), 7 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
>>>>>>>> index c2f158e60386..a4d23f488b01 100644
>>>>>>>> --- a/hw/vfio/iommufd.c
>>>>>>>> +++ b/hw/vfio/iommufd.c
>>>>>>>> @@ -631,15 +631,13 @@ static bool
>>>>>>>> hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void
>> *opaque,
>>>>>>>>
>>>>>>>> hiod->agent = opaque;
>>>>>>>>
>>>>>>>> - if (!iommufd_backend_get_device_info(vdev->iommufd, vdev-
>>>>> devid,
>>>>>>>> - &type, &data, sizeof(data), errp)) {
>>>>>>>> - return false;
>>>>>>>> + if (iommufd_backend_get_device_info(vdev->iommufd, vdev-
>>>>> devid,
>>>>>>>> + &type, &data, sizeof(data), NULL)) {
>>>>>>>
>>>>>>> This will make us miss the real error. What about bypassing host
>>>> IOMMU device
>>>>>>> creation for mdev as it's not "physical device", passing corresponding
>>>> host IOMMU
>>>>>>> device to vIOMMU make no sense.
>>>>>>
>>>>>> Yeap -- This was my second alternative.
>>>>>>
>>>>>> I can add an helper for vfio_is_mdev()) and just call
>>>>>> iommufd_backend_get_device_info() if !vfio_is_mdev(). I am
>> assuming
>>>> you meant
>>>>>> to skip the initialization of HostIOMMUDeviceCaps::caps as I think that
>>>>>> initializing hiod still makes sense as we are still using a
>>>>>> TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO somewhat?
>>>>>>
>>>>> Something like this is what I've done with this patch, see below. I think it
>>>>> matches what you suggested? Naturally there's a precedent patch that
>>>> introduces
>>>>> vfio_is_mdev().
>>>>>
>>>>
>>>> Sorry ignore the previous snip, it was the wrong version, see below
>> instead.
>>>>
>>>> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
>>>> index c2f158e60386..987dd9779f94 100644
>>>> --- a/hw/vfio/iommufd.c
>>>> +++ b/hw/vfio/iommufd.c
>>>> @@ -631,6 +631,10 @@ static bool
>>>> hiod_iommufd_vfio_realize(HostIOMMUDevice
>>>> *hiod, void *opaque,
>>>>
>>>> hiod->agent = opaque;
>>>>
>>>> + if (vfio_is_mdev(vdev)) {
>>>> + return true;
>>>> + }
>>>> +
>>>
>>> Not necessary to create a dummy object.
>>> What about bypassing object_new(ops->hiod_typename) in
>> vfio_attach_device()?
>>>
>> Not sure I am parsing this. What dummy object you refer to here if it's not
>> vbasedev::hiod that remains unused? Also in a suggestion by Cedric, and
>> pre-seeding vbasedev::hiod during attach_device()[0]. So I will sort of do that
>> already, but your comments means we are allocating a dummy object
>> anyways too?
>
> Yes, with your snip change, it's allocated by object_new(ops->hiod_typename) but not realized
> and never used else where.
>
>>
>> Or are you perhaps suggesting something like:
>>
>> @@ -1552,17 +1552,20 @@ bool vfio_attach_device(char *name,
>> VFIODevice *vbasedev,
>>
>> assert(ops);
>>
>> if (!ops->attach_device(name, vbasedev, as, errp)) {
>> return false;
>> }
>>
>> if (!vfio_mdev(vbasedev) &&
>> !HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev,
>> errp)) {
>>
>> ?
>
> I mean bypass host IOMMU device thoroughly for mdev, like:
>
/me facepalm.
Makes sense!
I read your comment in my head as "What about by passing
object_new(ops->hiod_typename)", when it was 'bypassing' that you wrote.
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1548,6 +1548,10 @@ bool vfio_attach_device(char *name, VFIODevice *vbasedev,
> return false;
> }
>
> + if (vfio_is_mdev(vdev)) {
> + return true;
> + }
> +
> hiod = HOST_IOMMU_DEVICE(object_new(ops->hiod_typename));
> if (!HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp)) {
> object_unref(hiod);
>
>
>>
>>
>> [0]
>> https://lore.kernel.org/qemu-devel/4e85db04-fbaa-4a6b-b133-
>> 59170c471e24@oracle.com/
>
next prev parent reply other threads:[~2024-07-10 9:56 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 14:34 [PATCH v3 00/10] hw/vfio: IOMMUFD Dirty Tracking Joao Martins
2024-07-08 14:34 ` [PATCH v3 01/10] vfio/iommufd: Don't fail to realize on IOMMU_GET_HW_INFO failure Joao Martins
2024-07-09 3:43 ` Duan, Zhenzhong
2024-07-09 8:56 ` Joao Martins
2024-07-09 11:45 ` Joao Martins
2024-07-09 11:50 ` Joao Martins
2024-07-10 2:53 ` Duan, Zhenzhong
2024-07-10 9:29 ` Joao Martins
2024-07-10 9:54 ` Duan, Zhenzhong
2024-07-10 9:56 ` Joao Martins [this message]
2024-07-08 14:34 ` [PATCH v3 02/10] backends/iommufd: Extend iommufd_backend_get_device_info() to fetch HW capabilities Joao Martins
2024-07-09 6:13 ` Duan, Zhenzhong
2024-07-08 14:34 ` [PATCH v3 03/10] vfio/iommufd: Return errno in iommufd_cdev_attach_ioas_hwpt() Joao Martins
2024-07-08 15:28 ` Cédric Le Goater
2024-07-08 15:32 ` Joao Martins
2024-07-08 16:28 ` Joao Martins
2024-07-09 6:20 ` Cédric Le Goater
2024-07-09 8:56 ` Joao Martins
2024-07-08 14:34 ` [PATCH v3 04/10] vfio/iommufd: Introduce auto domain creation Joao Martins
2024-07-09 6:26 ` Duan, Zhenzhong
2024-07-09 9:00 ` Joao Martins
2024-07-09 6:50 ` Cédric Le Goater
2024-07-09 9:09 ` Joao Martins
2024-07-08 14:34 ` [PATCH v3 05/10] vfio/iommufd: Probe and request hwpt dirty tracking capability Joao Martins
2024-07-09 6:28 ` Cédric Le Goater
2024-07-09 9:04 ` Joao Martins
2024-07-09 12:47 ` Joao Martins
2024-07-09 16:53 ` Joao Martins
2024-07-08 14:34 ` [PATCH v3 06/10] vfio/iommufd: Implement VFIOIOMMUClass::set_dirty_tracking support Joao Martins
2024-07-09 7:07 ` Cédric Le Goater
2024-07-09 9:13 ` Joao Martins
2024-07-08 14:34 ` [PATCH v3 07/10] vfio/iommufd: Implement VFIOIOMMUClass::query_dirty_bitmap support Joao Martins
2024-07-09 7:05 ` Cédric Le Goater
2024-07-09 9:13 ` Joao Martins
2024-07-09 12:41 ` Joao Martins
2024-07-08 14:34 ` [PATCH v3 08/10] vfio/iommufd: Parse hw_caps and store dirty tracking support Joao Martins
2024-07-08 14:34 ` [PATCH v3 09/10] vfio/migration: Don't block migration device dirty tracking is unsupported Joao Martins
2024-07-09 7:02 ` Cédric Le Goater
2024-07-09 9:09 ` Joao Martins
2024-07-10 10:38 ` Duan, Zhenzhong
2024-07-10 10:59 ` Joao Martins
2024-07-08 14:34 ` [PATCH v3 10/10] vfio/common: Allow disabling device dirty page tracking Joao Martins
2024-07-10 10:42 ` Duan, Zhenzhong
2024-07-10 10:51 ` Joao Martins
2024-07-11 7:41 ` [PATCH v3 00/10] hw/vfio: IOMMUFD Dirty Tracking Cédric Le Goater
2024-07-11 8:33 ` Joao Martins
2024-07-11 10:22 ` Duan, Zhenzhong
2024-07-11 10:44 ` Joao Martins
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=9bebf131-a465-48d7-a52a-15094576ca01@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=alex.williamson@redhat.com \
--cc=avihaih@nvidia.com \
--cc=clg@redhat.com \
--cc=eric.auger@redhat.com \
--cc=jgg@nvidia.com \
--cc=qemu-devel@nongnu.org \
--cc=yi.l.liu@intel.com \
--cc=zhenzhong.duan@intel.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;
as well as URLs for NNTP newsgroup(s).