From: Eric Auger <eric.auger@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>,
"clg@redhat.com" <clg@redhat.com>,
"peterx@redhat.com" <peterx@redhat.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"mst@redhat.com" <mst@redhat.com>,
"jgg@nvidia.com" <jgg@nvidia.com>,
"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
"joao.m.martins@oracle.com" <joao.m.martins@oracle.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>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: Re: [PATCH rfcv2 14/18] intel_iommu: Add a framework to check and sync host IOMMU cap/ecap
Date: Tue, 27 Feb 2024 18:06:10 +0100 [thread overview]
Message-ID: <c50d9dda-5d4b-494d-86ed-74425a1fd315@redhat.com> (raw)
In-Reply-To: <SJ0PR11MB67441887EF4A8F6658DD86F5925A2@SJ0PR11MB6744.namprd11.prod.outlook.com>
Hi Zhenzhong,
On 2/26/24 08:36, Duan, Zhenzhong wrote:
>
>> -----Original Message-----
>> From: Eric Auger <eric.auger@redhat.com>
>> Subject: Re: [PATCH rfcv2 14/18] intel_iommu: Add a framework to check
>> and sync host IOMMU cap/ecap
>>
>>
>>
>> On 2/1/24 08:28, Zhenzhong Duan wrote:
>>> From: Yi Liu <yi.l.liu@intel.com>
>>>
>>> Add a framework to check and synchronize host IOMMU cap/ecap with
>>> vIOMMU cap/ecap.
>>>
>>> The sequence will be:
>>>
>>> vtd_cap_init() initializes iommu->cap/ecap.
>>> vtd_check_hdev() update iommu->cap/ecap based on host cap/ecap.
>>> iommu->cap_frozen set when machine create done, iommu->cap/ecap
>> become readonly.
>>> Implementation details for different backends will be in following patches.
>>>
>>> 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/i386/intel_iommu.h | 1 +
>>> hw/i386/intel_iommu.c | 41
>> ++++++++++++++++++++++++++++++++++-
>>> 2 files changed, 41 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/hw/i386/intel_iommu.h
>> b/include/hw/i386/intel_iommu.h
>>> index bbc7b96add..c71a133820 100644
>>> --- a/include/hw/i386/intel_iommu.h
>>> +++ b/include/hw/i386/intel_iommu.h
>>> @@ -283,6 +283,7 @@ struct IntelIOMMUState {
>>>
>>> uint64_t cap; /* The value of capability reg */
>>> uint64_t ecap; /* The value of extended capability reg */
>>> + bool cap_frozen; /* cap/ecap become read-only after frozen */
>>>
>>> uint32_t context_cache_gen; /* Should be in [1,MAX] */
>>> GHashTable *iotlb; /* IOTLB */
>>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>>> index ffa1ad6429..7ed2b79669 100644
>>> --- a/hw/i386/intel_iommu.c
>>> +++ b/hw/i386/intel_iommu.c
>>> @@ -3819,6 +3819,31 @@ VTDAddressSpace
>> *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus,
>>> return vtd_dev_as;
>>> }
>>>
>>> +static int vtd_check_legacy_hdev(IntelIOMMUState *s,
>>> + IOMMULegacyDevice *ldev,
>>> + Error **errp)
>>> +{
>>> + return 0;
>>> +}
>>> +
>>> +static int vtd_check_iommufd_hdev(IntelIOMMUState *s,
>>> + IOMMUFDDevice *idev,
>>> + Error **errp)
>>> +{
>>> + return 0;
>>> +}
>>> +
>>> +static int vtd_check_hdev(IntelIOMMUState *s, VTDHostIOMMUDevice
>> *vtd_hdev,
>>> + Error **errp)
>>> +{
>>> + HostIOMMUDevice *base_dev = vtd_hdev->dev;
>>> +
>>> + if (base_dev->type == HID_LEGACY) {
>>> + return vtd_check_legacy_hdev(s, vtd_hdev->ldev, errp);
>>> + }
>>> + return vtd_check_iommufd_hdev(s, vtd_hdev->idev, errp);
>> Couldn't we have HostIOMMUDevice ops instead of having this check here?
> Hmm, not sure if this is deserved. If we define such ops, it has only one function
> check_hdev and we still need to check base_dev->type to assign different
> function to HostIOMMUDevice.ops.check_hdev in vtd_dev_set_iommu_device().
OK maybe this is over engineered. Drop that comment for now
Thanks
Eric
>
> Thanks
> Zhenzhong
next prev parent reply other threads:[~2024-02-27 17:07 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 7:28 [PATCH rfcv2 00/18] Check and sync host IOMMU cap/ecap with vIOMMU Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 01/18] Introduce a common abstract struct HostIOMMUDevice Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 02/18] backends/iommufd: Introduce IOMMUFDDevice Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 03/18] vfio: Introduce IOMMULegacyDevice Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 04/18] vfio: Add host iommu device instance into VFIODevice Zhenzhong Duan
2024-02-19 15:34 ` Eric Auger
2024-02-19 15:45 ` Eric Auger
2024-02-26 6:16 ` Duan, Zhenzhong
2024-02-01 7:28 ` [PATCH rfcv2 05/18] vfio: Remove redundant iommufd and devid elements in VFIODevice Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 06/18] vfio: Introduce host_iommu_device_init callback Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 07/18] vfio/container: Implement host_iommu_device_init callback in legacy mode Zhenzhong Duan
2024-02-19 17:13 ` Eric Auger
2024-02-26 6:56 ` Duan, Zhenzhong
2024-02-01 7:28 ` [PATCH rfcv2 08/18] vfio/iommufd: Implement host_iommu_device_init callback in iommufd mode Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 09/18] vfio/pci: Initialize host iommu device instance after attachment Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 10/18] hw/pci: Introduce pci_device_set/unset_iommu_device() Zhenzhong Duan
2024-02-19 17:41 ` Eric Auger
2024-02-26 6:26 ` Duan, Zhenzhong
2024-02-01 7:28 ` [PATCH rfcv2 11/18] intel_iommu: Add set/unset_iommu_device callback Zhenzhong Duan
2024-02-19 17:46 ` Eric Auger
2024-02-26 6:52 ` Duan, Zhenzhong
2024-02-01 7:28 ` [PATCH rfcv2 12/18] vfio: Initialize host IOMMU device and pass to vIOMMU Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 13/18] intel_iommu: Extract out vtd_cap_init to initialize cap/ecap Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 14/18] intel_iommu: Add a framework to check and sync host IOMMU cap/ecap Zhenzhong Duan
2024-02-19 17:51 ` Eric Auger
2024-02-26 7:36 ` Duan, Zhenzhong
2024-02-27 17:06 ` Eric Auger [this message]
2024-02-01 7:28 ` [PATCH rfcv2 15/18] backends/iommufd: Introduce helper function iommufd_device_get_info() Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 16/18] intel_iommu: Implement check and sync mechanism in iommufd mode Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 17/18] intel_iommu: Use mgaw instead of s->aw_bits Zhenzhong Duan
2024-02-01 7:28 ` [PATCH rfcv2 18/18] intel_iommu: Block migration if cap is updated Zhenzhong Duan
2024-02-13 10:55 ` Joao Martins
2024-02-27 2:41 ` Duan, Zhenzhong
2024-02-27 11:08 ` Joao Martins
2024-02-28 2:14 ` Duan, Zhenzhong
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=c50d9dda-5d4b-494d-86ed-74425a1fd315@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@intel.com \
--cc=clg@redhat.com \
--cc=eduardo@habkost.net \
--cc=jasowang@redhat.com \
--cc=jgg@nvidia.com \
--cc=joao.m.martins@oracle.com \
--cc=kevin.tian@intel.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=nicolinc@nvidia.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).