qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
	"Martins, Joao" <joao.m.martins@oracle.com>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"peterx@redhat.com" <peterx@redhat.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>,
	"Sun, Yi Y" <yi.y.sun@intel.com>,
	"Peng, Chao P" <chao.p.peng@intel.com>,
	Yi Sun <yi.y.sun@linux.intel.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v2 02/27] vfio: Introduce base object for VFIOContainer and targetted interface
Date: Thu, 19 Oct 2023 14:17:51 +0200	[thread overview]
Message-ID: <cf232093-a59c-49ef-9271-bb691860215b@redhat.com> (raw)
In-Reply-To: <PH7PR11MB67226A6A32A4655138CE1C8A92D4A@PH7PR11MB6722.namprd11.prod.outlook.com>

On 10/19/23 04:29, Duan, Zhenzhong wrote:
>> -----Original Message-----
>> From: Cédric Le Goater <clg@redhat.com>
>> Sent: Wednesday, October 18, 2023 4:04 PM
>> Subject: Re: [PATCH v2 02/27] vfio: Introduce base object for VFIOContainer and
>> targetted interface
>>
>> On 10/18/23 04:41, Duan, Zhenzhong wrote:
>>> Hi Cédric,
>>>
>>>> -----Original Message-----
>>>> From: Cédric Le Goater <clg@redhat.com>
>>>> Sent: Tuesday, October 17, 2023 11:51 PM
>>>> Subject: Re: [PATCH v2 02/27] vfio: Introduce base object for VFIOContainer
>> and
>>>> targetted interface
>>>>
>>>> On 10/16/23 10:31, Zhenzhong Duan wrote:
>>>>> From: Eric Auger <eric.auger@redhat.com>
>>>>>
>>>>> Introduce a dumb VFIOContainer base object and its targetted interface.
>>>>> This is willingly not a QOM object because we don't want it to be
>>>>> visible from the user interface.  The VFIOContainer will be smoothly
>>>>> populated in subsequent patches as well as interfaces.
>>>>>
>>>>> No fucntional change intended.
>>>>>
>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>>> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
>>>>> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
>>>>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>>>>> ---
>>>>>     include/hw/vfio/vfio-common.h         |  8 +--
>>>>>     include/hw/vfio/vfio-container-base.h | 82
>> +++++++++++++++++++++++++++
>>>>>     2 files changed, 84 insertions(+), 6 deletions(-)
>>>>>     create mode 100644 include/hw/vfio/vfio-container-base.h
>>>>>
>>>>> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-
>> common.h
>>>>> index 34648e518e..9651cf921c 100644
>>>>> --- a/include/hw/vfio/vfio-common.h
>>>>> +++ b/include/hw/vfio/vfio-common.h
>>>>> @@ -30,6 +30,7 @@
>>>>>     #include <linux/vfio.h>
>>>>>     #endif
>>>>>     #include "sysemu/sysemu.h"
>>>>> +#include "hw/vfio/vfio-container-base.h"
>>>>>
>>>>>     #define VFIO_MSG_PREFIX "vfio %s: "
>>>>>
>>>>> @@ -81,6 +82,7 @@ typedef struct VFIOAddressSpace {
>>>>>     struct VFIOGroup;
>>>>>
>>>>>     typedef struct VFIOLegacyContainer {
>>>>> +    VFIOContainer bcontainer;
>>>>
>>>> That's the parent class, right ?
>>>
>>> Right.
>>>
>>>>
>>>>>         VFIOAddressSpace *space;
>>>>>         int fd; /* /dev/vfio/vfio, empowered by the attached groups */
>>>>>         MemoryListener listener;
>>>>> @@ -200,12 +202,6 @@ typedef struct VFIODisplay {
>>>>>         } dmabuf;
>>>>>     } VFIODisplay;
>>>>>
>>>>> -typedef struct {
>>>>> -    unsigned long *bitmap;
>>>>> -    hwaddr size;
>>>>> -    hwaddr pages;
>>>>> -} VFIOBitmap;
>>>>> -
>>>>>     void vfio_host_win_add(VFIOLegacyContainer *container,
>>>>>                            hwaddr min_iova, hwaddr max_iova,
>>>>>                            uint64_t iova_pgsizes);
>>>>> diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-
>>>> container-base.h
>>>>> new file mode 100644
>>>>> index 0000000000..afc8543d22
>>>>> --- /dev/null
>>>>> +++ b/include/hw/vfio/vfio-container-base.h
>>>>> @@ -0,0 +1,82 @@
>>>>> +/*
>>>>> + * VFIO BASE CONTAINER
>>>>> + *
>>>>> + * Copyright (C) 2023 Intel Corporation.
>>>>> + * Copyright Red Hat, Inc. 2023
>>>>> + *
>>>>> + * Authors: Yi Liu <yi.l.liu@intel.com>
>>>>> + *          Eric Auger <eric.auger@redhat.com>
>>>>> + *
>>>>> + * This program is free software; you can redistribute it and/or modify
>>>>> + * it under the terms of the GNU General Public License as published by
>>>>> + * the Free Software Foundation; either version 2 of the License, or
>>>>> + * (at your option) any later version.
>>>>> +
>>>>> + * This program is distributed in the hope that it will be useful,
>>>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>>>> + * GNU General Public License for more details.
>>>>> +
>>>>> + * You should have received a copy of the GNU General Public License along
>>>>> + * with this program; if not, see <http://www.gnu.org/licenses/>.
>>>>> + */
>>>>> +
>>>>> +#ifndef HW_VFIO_VFIO_BASE_CONTAINER_H
>>>>> +#define HW_VFIO_VFIO_BASE_CONTAINER_H
>>>>> +
>>>>> +#include "exec/memory.h"
>>>>> +#ifndef CONFIG_USER_ONLY
>>>>> +#include "exec/hwaddr.h"
>>>>> +#endif
>>>>> +
>>>>> +typedef struct VFIOContainer VFIOContainer;
>>>>> +typedef struct VFIODevice VFIODevice;
>>>>> +typedef struct VFIOIOMMUBackendOpsClass VFIOIOMMUBackendOpsClass;
>>>>> +
>>>>> +typedef struct {
>>>>> +    unsigned long *bitmap;
>>>>> +    hwaddr size;
>>>>> +    hwaddr pages;
>>>>> +} VFIOBitmap;
>>>>> +
>>>>> +/*
>>>>> + * This is the base object for vfio container backends
>>>>> + */
>>>>> +struct VFIOContainer {
>>>>> +    VFIOIOMMUBackendOpsClass *ops;
>>>>
>>>> This is unexpected.
>>>>
>>>> I thought that an abstract QOM model for VFIOContainer was going
>>>> to be introduced with a VFIOContainerClass with the ops below
>>>> (VFIOIOMMUBackendOpsClass).
>>>>
>>>> Then, we would call :
>>>>
>>>>      VFIOContainerClass *vcc = VFIO_CONTAINER_GET_CLASS(container);
>>>>
>>>> to get the specific implementation for the current container.
>>>>
>>>> I don't understand the VFIOIOMMUBackendOpsClass pointer and
>>>> TYPE_VFIO_IOMMU_BACKEND_OPS. It seems redundant.
>>>
>>> The original implementation was abstract QOM model. But it wasn't accepted,
>>> see https://lore.kernel.org/all/YmuFv2s5TPuw7K%2Fu@yekko/ for details.
>>
>> I see the idea was challenged, not rejected. I need to dig in further and this
>> will take time.
> Thanks for help looking into it.
> 
> +David, Hi David, I'm digging into your concern of using QOM to abstract base
> container and legacy VFIOContainer:
> "The QOM class of things is visible to the user/config layer via QMP (and sometimes command line).
> It doesn't necessarily correspond to guest visible differences, but it often does."
> 
> AIUI, while it's true when the QOM type includes TYPE_USER_CREATABLE interface,
> otherwise, user can't create an object of this type. Only difference is user will see
> "object type '%s' isn't supported by object-add" instead of "invalid object type: %s".
> 
> Is your expectation to not permit user to create this object or only want user
> to see "invalid object type: %s".
> If you mean the first, then I think QOM could be suitable if we don't include
> TYPE_USER_CREATABLE interface?

I was imagining some kind of QOM hierarchy under the vfio device
with various QOM interfaces (similar to the ops) to define the
possible IOMMU backends. The fact that we use the IOMMUFD object
from the command line made it more plausible. I might be mistaking.

Anyhow, the series looks pretty good. There are other aspect to
check, like are all this iommu ops well suited for the need ?
Let's stress the models in parallel of the reviews. If we could get
some of it for 8.2 that'd be nice. It's on top of my list now.

Thanks,

C.


> Thanks
> Zhenzhong



  reply	other threads:[~2023-10-19 12:18 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-16  8:31 [PATCH v2 00/27] vfio: Adopt iommufd Zhenzhong Duan
2023-10-16  8:31 ` [PATCH v2 01/27] vfio: Rename VFIOContainer into VFIOLegacyContainer Zhenzhong Duan
2023-10-17 15:50   ` Cédric Le Goater
2023-10-18  2:33     ` Duan, Zhenzhong
2023-10-16  8:31 ` [PATCH v2 02/27] vfio: Introduce base object for VFIOContainer and targetted interface Zhenzhong Duan
2023-10-17 15:51   ` Cédric Le Goater
2023-10-18  2:41     ` Duan, Zhenzhong
2023-10-18  8:04       ` Cédric Le Goater
2023-10-19  2:29         ` Duan, Zhenzhong
2023-10-19 12:17           ` Cédric Le Goater [this message]
2023-10-20  5:48             ` Duan, Zhenzhong
2023-10-20  8:19               ` Eric Auger
2023-10-20  8:28                 ` Duan, Zhenzhong
2023-10-23 15:28                 ` Cédric Le Goater
2023-10-24  6:03                   ` Duan, Zhenzhong
2023-10-24  6:51                     ` Cédric Le Goater
2023-10-16  8:31 ` [PATCH v2 03/27] VFIO/container: Introduce dummy VFIOContainerClass implementation Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 04/27] vfio/container: Switch to dma_map|unmap API Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 05/27] vfio/common: Move giommu_list in base container Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 06/27] vfio/container: Move space field to " Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 07/27] vfio/container: switch to IOMMU BE add/del_section_window Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 08/27] vfio/container: Move hostwin_list in base container Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 09/27] vfio/container: Switch to IOMMU BE set_dirty_page_tracking/query_dirty_bitmap API Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 10/27] vfio/container: Move per container device list in base container Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 11/27] vfio/container: Convert functions to " Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 12/27] vfio/container: Move vrdl_list, pgsizes and dma_max_mappings " Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 13/27] vfio/container: Move listener " Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 14/27] vfio/container: Move dirty_pgsizes and max_dirty_bitmap_size " Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 15/27] vfio/container: Implement attach/detach_device Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 16/27] Add iommufd configure option Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 17/27] backends/iommufd: Introduce the iommufd object Zhenzhong Duan
2023-10-16 10:00   ` Markus Armbruster
2023-10-17  8:27     ` Duan, Zhenzhong
2023-10-16  8:32 ` [PATCH v2 18/27] util/char_dev: Add open_cdev() Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 19/27] vfio/iommufd: Implement the iommufd backend Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 20/27] vfio/container: Bypass EEH if " Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 21/27] vfio/pci: Adapt vfio pci hot reset support with iommufd BE Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 22/27] vfio/pci: Allow the selection of a given iommu backend Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 23/27] vfio/pci: Make vfio cdev pre-openable by passing a file handle Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 24/27] vfio: Allow the selection of a given iommu backend for platform ap and ccw Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 25/27] vfio/platform: Make vfio cdev pre-openable by passing a file handle Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 26/27] vfio/ap: " Zhenzhong Duan
2023-10-16  8:32 ` [PATCH v2 27/27] vfio/ccw: " Zhenzhong Duan

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=cf232093-a59c-49ef-9271-bb691860215b@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=chao.p.peng@intel.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=eric.auger@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=joao.m.martins@oracle.com \
    --cc=kevin.tian@intel.com \
    --cc=nicolinc@nvidia.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yi.l.liu@intel.com \
    --cc=yi.y.sun@intel.com \
    --cc=yi.y.sun@linux.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).