Re: [PATCH v1 03/17] intel_iommu: Add a placeholder variable for scalable modern mode

2024-07-18 Thread Yi Liu
initialization, compatibility check and block host device passthrough until nesting is supported. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 2 ++ include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c | 34

Re: [PATCH 6/7] backends/iommufd: Get rid of qemu_open_old()

2024-07-16 Thread Yi Liu
On 2024/7/15 16:21, Zhao Liu wrote: For qemu_open_old(), osdep.h said: Don't introduce new usage of this function, prefer the following qemu_open/qemu_create that take an "Error **errp". So replace qemu_open_old() with qemu_open(). Cc: Yi Liu Cc: Eric Auger Cc: Zhenzhong Duan

Re: [PATCH v6 3/4] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo

2024-07-09 Thread Yi Liu
member to refine the commit message a bit. Reviewed-by: Yi Liu Signed-off-by: Clément Mathieu--Drif Reviewed-by: Minwoo Im --- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h

Re: [PATCH v6 2/4] intel_iommu: move VTD_FRCD_PV and VTD_FRCD_PP declarations

2024-07-09 Thread Yi Liu
changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Yi Liu diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index cbc4030031..faea23e8d6 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -264,10 +264,10 @@ #define VTD_FRCD_FR

Re: [PATCH v4 1/4] intel_iommu: fix FRCD construction macro

2024-07-09 Thread Yi Liu
On 2024/7/9 10:51, Jason Wang wrote: On Mon, Jul 8, 2024 at 3:04 PM Yi Liu wrote: On 2024/7/5 19:01, CLEMENT MATHIEU--DRIF wrote: From: Clément Mathieu--Drif The constant must be unsigned, otherwise the two's complement overrides the other fields when a PASID is present. Fixes

Re: [PATCH v5 4/4] intel_iommu: make type match

2024-07-09 Thread Yi Liu
*vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, { struct vtd_iotlb_key key; VTDIOTLBEntry *entry; -int level; +unsigned level; for (level = VTD_SL_PT_LEVEL; level < VTD_SL_PML4_LEVEL; level++) { key.gfn = vtd_get_iotlb_gfn(addr, level); Reviewed-by: Yi

Re: [PATCH v5 3/4] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo

2024-07-09 Thread Yi Liu
nt32_t pasid; uint64_t addr; -uint8_t mask; +uint64_t mask; }; typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo; -- Regards, Yi Liu

Re: [PATCH v4 4/4] intel_iommu: make types match

2024-07-08 Thread Yi Liu
TD_SL_PML4_LEVEL; level++) { key.gfn = vtd_get_iotlb_gfn(addr, level); -- Regards, Yi Liu

Re: [PATCH v4 3/4] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo

2024-07-08 Thread Yi Liu
nt64_t mask; }; typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo; -- Regards, Yi Liu

Re: [PATCH v4 1/4] intel_iommu: fix FRCD construction macro

2024-07-08 Thread Yi Liu
"Fixes tag" is not needed. Signed-off-by: Clément Mathieu--Drif Reviewed-by: Yi Liu Reviewed-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index f8cf99bdd

[PATCH] MAINTAINERS: Add myself as a VT-d reviewer

2024-07-07 Thread Yi Liu
Signed-off-by: Yi Liu --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6725913c8b..61724b91d8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3656,6 +3656,7 @@ F: tests/uefi-test-tools/ VT-d Emulation M: Michael S. Tsirkin R: Jason Wang +R

Re: [PATCH v1 0/8] PRI support for VT-d

2024-07-05 Thread Yi Liu
On 2024/7/5 13:13, CLEMENT MATHIEU--DRIF wrote: On 05/07/2024 05:03, Yi Liu wrote: Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe. On 2024/5/30 20:24, CLEMENT MATHIEU--DRIF wrote: This series

Re: [PATCH v2 1/3] intel_iommu: fix FRCD construction macro.

2024-07-04 Thread Yi Liu
) Fixes: 1b2b12376c ("intel-iommu: PASID support") you need more digits per the result of "grep Fixes docs/devel/submitting-a-patch.rst". docs/devel/submitting-a-patch.rst:add an additional line with "Fixes: Signed-off-by: Clément Mathieu--Drif Reviewed-by: Yi Liu ---

Re: [PATCH v1 0/8] PRI support for VT-d

2024-07-04 Thread Yi Liu
| 4 + system/memory.c| 49 ++ 10 files changed, 604 insertions(+), 2 deletions(-) -- Regards, Yi Liu

Re: [PATCH v2 3/3] intel_iommu: Bypass barrier wait descriptor

2024-07-04 Thread Yi Liu
" (unknown type)", __func__, inv_desc->hi, -- Regards, Yi Liu

Re: [PATCH v2 2/3] intel_iommu: make types match

2024-07-04 Thread Yi Liu
vInfo VTDIOTLBPageInvInfo; -- 2.45.2 -- Regards, Yi Liu

Re: [PATCH ats_vtd v5 19/22] memory: add an API for ATS support

2024-07-04 Thread Yi Liu
On 2024/7/4 12:30, CLEMENT MATHIEU--DRIF wrote: On 03/07/2024 14:14, Yi Liu wrote: Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe. On 2024/7/2 13:52, CLEMENT MATHIEU--DRIF wrote: From: Clément

Re: [PATCH ats_vtd v5 00/22] ATS support for VT-d

2024-07-04 Thread Yi Liu
On 2024/7/4 12:36, CLEMENT MATHIEU--DRIF wrote: On 03/07/2024 14:32, Yi Liu wrote: Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe. Hi, thanks for your review! very efficient! Hi CMD, I've went

Re: [PATCH ats_vtd v5 00/22] ATS support for VT-d

2024-07-03 Thread Yi Liu
: Clement Mathieu--Drif This series belongs to a list of series that add SVM support for VT-d. As a starting point, we use the series called 'intel_iommu: Enable stage-1 translation' (rfc2) by Zhenzhong Duan and Yi Liu. Here we focus on the implementation of ATS support in the IOMMU and on a PCI

Re: [PATCH ats_vtd v5 19/22] memory: add an API for ATS support

2024-07-03 Thread Yi Liu
write, result, + result_length, err_count); +} + void memory_region_notify_iommu_one(IOMMUNotifier *notifier, IOMMUTLBEvent *event) { -- Regards, Yi Liu

Re: [PATCH ats_vtd v5 06/22] pcie: add helper to declare PASID capability for a pcie device

2024-07-03 Thread Yi Liu
AP_WIDTH_SHIFT 8 #define PCI_PASID_CTRL0x06/* PASID control register */ #define PCI_PASID_CTRL_ENABLE0x0001 /* Enable bit */ #define PCI_PASID_CTRL_EXEC 0x0002 /* Exec permissions Enable */ -- Regards, Yi Liu

Re: [PATCH ats_vtd v5 03/22] intel_iommu: return page walk level even when the translation fails

2024-07-03 Thread Yi Liu
tep = flpte; -*flpte_level = level; return 0; } addr = vtd_get_pte_addr(flpte, aw_bits); -level--; +(*flpte_level)--; } } -- Regards, Yi Liu

Re: [PATCH ats_vtd v5 04/22] intel_iommu: do not consider wait_desc as an invalid descriptor

2024-07-03 Thread Yi Liu
On 2024/7/2 23:29, CLEMENT MATHIEU--DRIF wrote: On 02/07/2024 15:33, Yi Liu wrote: Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe. On 2024/7/2 13:52, CLEMENT MATHIEU--DRIF wrote: From: Clément

Re: [PATCH ats_vtd v5 00/22] ATS support for VT-d

2024-07-02 Thread Yi Liu
On 2024/7/2 13:52, CLEMENT MATHIEU--DRIF wrote: From: Clement Mathieu--Drif This series belongs to a list of series that add SVM support for VT-d. As a starting point, we use the series called 'intel_iommu: Enable stage-1 translation' (rfc2) by Zhenzhong Duan and Yi Liu. Here we focus

Re: [PATCH ats_vtd v5 00/22] ATS support for VT-d

2024-07-02 Thread Yi Liu
stage-1 translation' (rfc2) by Zhenzhong Duan and Yi Liu. Here we focus on the implementation of ATS support in the IOMMU and on a PCI-level API for ATS to be used by virtual devices. This work is based on the VT-d specification version 4.1 (March 2023). Here is a link to a GitHub repository

Re: [PATCH ats_vtd v5 04/22] intel_iommu: do not consider wait_desc as an invalid descriptor

2024-07-02 Thread Yi Liu
t with FN flag. Is it? Have you already seen a wait descriptor that only has FN flag set but no SW nor IF flag? } else { error_report_once("%s: invalid wait desc: hi=%"PRIx64", lo=%"PRIx64 " (unknown type)", __func__, inv_desc->hi, -- Regards, Yi Liu

Re: [PATCH ats_vtd v5 02/22] intel_iommu: make types match

2024-07-02 Thread Yi Liu
On 2024/7/2 13:52, CLEMENT MATHIEU--DRIF wrote: From: Clément Mathieu--Drif The 'level' field in vtd_iotlb_key is an unsigned integer. We don't need to store level as an int in vtd_lookup_iotlb. VTDIOTLBPageInvInfo.mask is used in binary operations with addresses. Reviewed-by: Yi Liu

Re: [PATCH ats_vtd v5 01/22] intel_iommu: fix FRCD construction macro.

2024-07-02 Thread Yi Liu
On 2024/7/2 13:52, CLEMENT MATHIEU--DRIF wrote: From: Clément Mathieu--Drif The constant must be unsigned, otherwise the two's complement overrides the other fields when a PASID is present does it need a fix tag since it overrides the other fields? Reviewed-by: Yi Liu Signed-off

Re: [PATCH] intel_iommu: Use the latest fault reasons defined by spec

2024-07-02 Thread Yi Liu
apability via the cap/ecap registers. The new fault reasons in this patch is meaningful only when the ecap.SMTS bit is set. So bumping version does not mean too much about the introduction of new capabilities. @Jason, given the above statements, can we reconsider if it is necessary to bump up the version number? -- Regards, Yi Liu

Re: [PATCH] intel_iommu: Use the latest fault reasons defined by spec

2024-05-27 Thread Yi Liu
ation. But I'm not sure if there is a real scenario migrating to old qemu, why not just update qemu on destination? Thanks Zhenzhong -- Regards, Yi Liu

Re: [PATCH] vfio/iommufd: Fix memory leak

2024-03-13 Thread Yi Liu
On 2024/3/14 05:06, Cédric Le Goater wrote: Make sure variable contents is freed if scanf fails. Cc: Eric Auger Cc: Yi Liu Cc: Zhenzhong Duan Fixes: CID 1540007 Fixes: 5ee3dc7af785 ("vfio/iommufd: Implement the iommufd backend") Signed-off-by: Cédric Le Goater --- hw/vfio/iom

Re: [PATCH rfcv1 23/23] intel_iommu: modify x-scalable-mode to be string option

2024-01-31 Thread Yi Liu
On 2024/1/31 22:40, Joel Granados wrote: On Mon, Jan 15, 2024 at 06:37:35PM +0800, Zhenzhong Duan wrote: From: Yi Liu Intel VT-d 3.0 introduces scalable mode, and it has a bunch of capabilities related to scalable mode translation, thus there are multiple combinations. While this vIOMMU

Re: [PATCH rfcv1 4/6] vfio: initialize IOMMUFDDevice and pass to vIOMMU

2024-01-18 Thread Yi Liu
ommufd_device_init() are available in the new place. And remember to destroy it if the code failed after initializing iommufd_device. -- Regards, Yi Liu

Re: [PATCH V5 4/4] intel-iommu: PASID support

2022-10-31 Thread Yi Liu
On 2022/10/31 17:15, Jason Wang wrote: On Mon, Oct 31, 2022 at 2:43 PM Michael S. Tsirkin wrote: On Fri, Oct 28, 2022 at 09:49:36PM +0800, Yi Liu wrote: On 2022/10/28 14:14, Jason Wang wrote: This patch introduce ECAP_PASID via "x-pasid-mode". Based on the existing support for sca

Re: [PATCH V5 2/4] intel-iommu: drop VTDBus

2022-10-30 Thread Yi Liu
td_as = s->vtd_as_cache[bus_num]; + +if (vtd_as && +(sid == PCI_BUILD_BDF(pci_bus_num(vtd_as->bus), vtd_as->devfn))) { this checks sid as well. not sure if it can share the above helper.:-) Besides the above nits, this patch looks good to me. Reviewed-by: Yi Liu

Re: [PATCH V5 4/4] intel-iommu: PASID support

2022-10-28 Thread Yi Liu
ressSpace { PCIBus *bus; uint8_t devfn; +uint32_t pasid; AddressSpace as; IOMMUMemoryRegion iommu; MemoryRegion root; /* The root container of the device */ MemoryRegion nodmar;/* The alias of shared nodmar MR */ MemoryRegion iommu_ir; /* Interrupt region: 0xfeeX */ +MemoryRegion iommu_ir_fault; /* Interrupt region for catching fault */ IntelIOMMUState *iommu_state; VTDContextCacheEntry context_cache_entry; QLIST_ENTRY(VTDAddressSpace) next; @@ -113,6 +115,7 @@ struct VTDAddressSpace { struct VTDIOTLBEntry { uint64_t gfn; uint16_t domain_id; +uint32_t pasid; uint64_t slpte; uint64_t mask; uint8_t access_flags; @@ -261,6 +264,7 @@ struct IntelIOMMUState { uint8_t aw_bits;/* Host/IOVA address width (in bits) */ bool dma_drain; /* Whether DMA r/w draining enabled */ bool dma_translation; /* Whether DMA translation supported */ +bool pasid; /* Whether to support PASID */ /* * Protects IOMMU states in general. Currently it protects the @@ -272,6 +276,7 @@ struct IntelIOMMUState { /* Find the VTD Address space associated with the given bus pointer, * create a new one if none exists */ -VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn); +VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, + int devfn, unsigned int pasid); #endif diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index eb94e7e85c..5653175957 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -28,6 +28,8 @@ enum PCIBusFlags { PCI_BUS_CXL = 0x0004, }; +#define PCI_NO_PASID UINT32_MAX + struct PCIBus { BusState qbus; enum PCIBusFlags flags; -- Regards, Yi Liu

Re: [PATCH V5 3/4] intel-iommu: convert VTD_PE_GET_FPD_ERR() to be a function

2022-10-28 Thread Yi Liu
/intel_iommu.c | 42 -- 1 file changed, 28 insertions(+), 14 deletions(-) Reviewed-by: Yi Liu diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 9fe5a222eb..9029ee98f4 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -49,17 +49,6

Re: [PATCH V5 1/4] intel-iommu: don't warn guest errors when getting rid2pasid entry

2022-10-28 Thread Yi Liu
to avoid using ret variable --- hw/i386/intel_iommu.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) Reviewed-by: Yi Liu diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 6524c2ee32..271de995be 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c

Re: [PATCH V4 1/4] intel-iommu: don't warn guest errors when getting rid2pasid entry

2022-10-27 Thread Yi Liu
return (VTD_PE_GET_TYPE() == VTD_SM_PASID_ENTRY_PT); -- Regards, Yi Liu

Re: [PATCH V4 3/4] intel-iommu: convert VTD_PE_GET_FPD_ERR() to be a function

2022-10-27 Thread Yi Liu
evel_page_mask(level); access_flags = IOMMU_ACCESS_FLAG(reads, writes); -- Regards, Yi Liu

[RFC v2 15/15] vfio/as: Allow the selection of a given iommu backend

2022-06-08 Thread Yi Liu
the /dev/iommu device may have been pre-opened by a management tool such as libvirt. This mode is no more considered for the legacy backend. So let's remove the "TODO" comment. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Suggested-by: Alex Williamson --- hw/vfio/as.c | 9 ++--

[RFC v2 11/15] backends/iommufd: Introduce the iommufd object

2022-06-08 Thread Yi Liu
-by: Yi Liu Suggested-by: Alex Williamson --- MAINTAINERS | 7 ++ backends/Kconfig | 5 + backends/iommufd.c | 265 +++ backends/meson.build | 1 + backends/trace-events| 12 ++ include/sysemu/iommufd.h | 47 +++ qapi

[RFC v2 09/15] vfio/container-base: Introduce [attach/detach]_device container callbacks

2022-06-08 Thread Yi Liu
From: Eric Auger Let's turn attach/detach_device as container callbacks. That way, their implementation can be easily customized for a given backend. For the time being, only the legacy container is supported. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/as.c

[RFC v2 14/15] vfio/iommufd: Add IOAS_COPY_DMA support

2022-06-08 Thread Yi Liu
the first iommufd container to other iommufd containers within the address space. For legacy containers, IOVA mapping is done by VFIO_IOMMU_MAP_DMA. Signed-off-by: Yi Liu --- hw/vfio/as.c | 117 ++ hw/vfio/container-base.c | 13

[RFC v2 13/15] vfio/iommufd: Implement the iommufd backend

2022-06-08 Thread Yi Liu
that only a subset of the container class callbacks is implemented. Co-authored-by: Eric Auger Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- v1 -> v2: - arbitrarily set bcontainer->pgsizes to 4K to fix interoperability with virtio-iommu (Nicolin) - add tear down in iommufd_attach_device

[RFC v2 12/15] util/char_dev: Add open_cdev()

2022-06-08 Thread Yi Liu
/dev/vfio/devices/vfioX may not exist. In that case it is still possible to open /dev/char/$major:$minor instead. Add helper function to abstract the cdev open. Suggested-by: Jason Gunthorpe Signed-off-by: Yi Liu --- MAINTAINERS | 6 + include/qemu/char_dev.h | 16

[RFC v2 07/15] vfio/ap: Use vfio_[attach/detach]_device

2022-06-08 Thread Yi Liu
From: Eric Auger Let the vfio-ap device use vfio_attach_device() and vfio_detach_device(), hence hiding the details of the used IOMMU backend. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/ap.c | 62 1 file changed, 9

[RFC v2 05/15] vfio/container: Introduce vfio_[attach/detach]_device

2022-06-08 Thread Yi Liu
-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/container.c | 65 +++ hw/vfio/pci.c | 50 +++ include/hw/vfio/vfio-common.h | 2 ++ 3 files changed, 72 insertions(+), 45 deletions(-) diff --git a/hw/vfio/container.c b

[RFC v2 08/15] vfio/ccw: Use vfio_[attach/detach]_device

2022-06-08 Thread Yi Liu
functions, local to container.c. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/ccw.c | 118 -- hw/vfio/container.c | 8 +-- include/hw/vfio/vfio-common.h | 4 -- 3 files changed, 32 insertions(+), 98 deletions(-) diff --git

[RFC v2 10/15] vfio/container-base: Introduce VFIOContainer reset callback

2022-06-08 Thread Yi Liu
to a place that is not backend-specific (first vfio address space created instead of the first group). Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/as.c | 18 ++ hw/vfio/container-base.c | 9 + hw/vfio/container.c

[RFC v2 06/15] vfio/platform: Use vfio_[attach/detach]_device

2022-06-08 Thread Yi Liu
From: Eric Auger Let the vfio-platform device use vfio_attach_device() and vfio_detach_device(), hence hiding the details of the used IOMMU backend. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/platform.c | 42 ++ 1 file changed, 2

[RFC v2 00/15] vfio: Adopt iommufd

2022-06-08 Thread Yi Liu
tach/detach]_device container callbacks vfio/container-base: Introduce VFIOContainer reset callback backends/iommufd: Introduce the iommufd object vfio/as: Allow the selection of a given iommu backend Yi Liu (5): vfio/common: Split common.c into common.c, container.c and as.c vfio: Add b

[RFC v2 01/15] scripts/update-linux-headers: Add iommufd.h

2022-06-08 Thread Yi Liu
From: Eric Auger Update the script to import iommufd.h Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- scripts/update-linux-headers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh index 839a5ec614

[RFC v2 04/15] vfio: Add base container

2022-06-08 Thread Yi Liu
) group_list; }; Co-authored-by: Eric Auger Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- v1 -> v2: - Remove QOM for VFIOContainer object, use callback instead per David's comment. - Rename container-obj.c/.h to be container-base.c/.h --- hw/vfio/as.c | 48 +++---

[RFC v2 02/15] linux-headers: Import latest vfio.h and iommufd.h

2022-06-08 Thread Yi Liu
From: Eric Auger Imported from https://github.com/luxis1999/iommufd/tree/iommufd-v5.17-rc6 Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- linux-headers/linux/iommufd.h | 223 ++ linux-headers/linux/vfio.h| 84 + 2 files changed, 307

Re: [RFC 00/18] vfio: Adopt iommufd

2022-05-18 Thread Yi Liu
On 2022/5/18 15:22, zhangfei@foxmail.com wrote: On 2022/5/17 下午4:55, Yi Liu wrote: Hi Zhangfei, On 2022/5/12 17:01, zhangfei@foxmail.com wrote: Hi, Yi On 2022/5/11 下午10:17, zhangfei@foxmail.com wrote: On 2022/5/10 下午10:08, Yi Liu wrote: On 2022/5/10 20:45, Jason Gunthorpe

Re: [RFC 00/18] vfio: Adopt iommufd

2022-05-17 Thread Yi Liu
Hi Zhangfei, On 2022/5/12 17:01, zhangfei@foxmail.com wrote: Hi, Yi On 2022/5/11 下午10:17, zhangfei@foxmail.com wrote: On 2022/5/10 下午10:08, Yi Liu wrote: On 2022/5/10 20:45, Jason Gunthorpe wrote: On Tue, May 10, 2022 at 08:35:00PM +0800, Zhangfei Gao wrote: Thanks Yi and Eric

Re: [RFC 00/18] vfio: Adopt iommufd

2022-05-17 Thread Yi Liu
Hi Zhangfei, On 2022/5/11 22:17, zhangfei@foxmail.com wrote: On 2022/5/10 下午10:08, Yi Liu wrote: On 2022/5/10 20:45, Jason Gunthorpe wrote: On Tue, May 10, 2022 at 08:35:00PM +0800, Zhangfei Gao wrote: Thanks Yi and Eric, Then will wait for the updated iommufd kernel for the PCI MMIO

Re: [RFC 00/18] vfio: Adopt iommufd

2022-05-10 Thread Yi Liu
the hwpt) it should be returned by the vfio attach ioctl. yes, hwpt_id is returned by the vfio attach ioctl and recorded in qemu. You can query page table related capabilities with this id. https://lore.kernel.org/kvm/20220414104710.28534-16-yi.l@intel.com/ -- Regards, Yi Liu

Re: [RFC 00/18] vfio: Adopt iommufd

2022-05-09 Thread Yi Liu
Kolothum Thodi ; Yi Liu ; alex.william...@redhat.com; coh...@redhat.com; qemu-devel@nongnu.org Cc: da...@gibson.dropbear.id.au; th...@redhat.com; far...@linux.ibm.com; mjros...@linux.ibm.com; akrow...@linux.ibm.com; pa...@linux.ibm.com; jjhe...@linux.ibm.com; jasow...@redhat.com; k

Re: [RFC 07/18] vfio: Add base object for VFIOContainer

2022-05-03 Thread Yi Liu
On 2022/4/29 14:29, David Gibson wrote: On Thu, Apr 14, 2022 at 03:46:59AM -0700, Yi Liu wrote: Qomify the VFIOContainer object which acts as a base class for a container. This base class is derived into the legacy VFIO container and later on, into the new iommufd based container. You

[Patch 1/3] hw/vfio/pci: fix vfio_pci_hot_reset_result trace point

2022-05-02 Thread Yi Liu
From: Eric Auger Properly output the errno string. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 9fd9faee1d..4a66376be6 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c

[Patch 3/3] vfio/common: Rename VFIOGuestIOMMU::iommu into ::iommu_mr

2022-05-02 Thread Yi Liu
Rename VFIOGuestIOMMU iommu field into iommu_mr. Then it becomes clearer it is an IOMMU memory region. no functional change intended Signed-off-by: Yi Liu --- hw/vfio/common.c | 16 include/hw/vfio/vfio-common.h | 2 +- 2 files changed, 9 insertions(+), 9

[Patch 0/3] vfio: Misc cleanups

2022-05-02 Thread Yi Liu
The three patches were part of iommufd RFC series, sent separately per Kevin's suggestion. https://lore.kernel.org/kvm/bn9pr11mb5276085cdf750807005a775b8c...@bn9pr11mb5276.namprd11.prod.outlook.com/ Regards, Yi Liu Eric Auger (2): hw/vfio/pci: fix vfio_pci_hot_reset_result trace point vfio

[Patch 2/3] vfio/pci: Use vbasedev local variable in vfio_realize()

2022-05-02 Thread Yi Liu
From: Eric Auger Using a VFIODevice handle local variable to improve the code readability. no functional change intended Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/pci.c | 49 + 1 file changed, 25 insertions(+), 24 deletions

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Yi Liu
gt; can fail in a variety of ways." Though, it is not so important that it is urgent (and copy makes it work better anyhow), qemu can stay as it is. yes. as a start, keep it would be simpler. Jason -- Regards, Yi Liu

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Yi Liu
Hi Jason, On 2022/4/22 22:58, Jason Gunthorpe wrote: On Thu, Apr 14, 2022 at 03:47:07AM -0700, Yi Liu wrote: +static int vfio_get_devicefd(const char *sysfs_path, Error **errp) +{ +long int vfio_id = -1, ret = -ENOTTY; +char *path, *tmp = NULL; +DIR *dir; +struct dirent *dent

Re: [RFC 00/18] vfio: Adopt iommufd

2022-04-18 Thread Yi Liu
m/0-v1-a8faf768d202+125dd- vfio_mdev_no_group_...@nvidia.com/ Following is probably more relevant to [4]: https://lore.kernel.org/all/10-v1-33906a626da1+16b0-vfio_kvm_no_group_...@nvidia.com/ absolutely.:-) thanks. Thanks Kevin -- Regards, Yi Liu

[RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-14 Thread Yi Liu
that only a subset of the container class callbacks is implemented. Co-authored-by: Eric Auger Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/as.c | 2 +- hw/vfio/iommufd.c| 545 +++ hw/vfio/meson.build

[RFC 11/18] vfio/ccw: Use vfio_[attach/detach]_device

2022-04-14 Thread Yi Liu
functions, local to container.c. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/ccw.c | 118 -- hw/vfio/container.c | 8 +-- include/hw/vfio/vfio-common.h | 4 -- 3 files changed, 32 insertions(+), 98 deletions(-) diff --git

[RFC 10/18] vfio/ap: Use vfio_[attach/detach]_device

2022-04-14 Thread Yi Liu
From: Eric Auger Let the vfio-ap device use vfio_attach_device() and vfio_detach_device(), hence hiding the details of the used IOMMU backend. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/ap.c | 62 1 file changed, 9

[RFC 18/18] vfio/pci: Add an iommufd option

2022-04-14 Thread Yi Liu
From: Eric Auger This auto/on/off option allows the user to force a the select the iommu BE (iommufd or legacy). Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/pci.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c

[RFC 17/18] vfio/as: Allow the selection of a given iommu backend

2022-04-14 Thread Yi Liu
From: Eric Auger Now we support two types of iommu backends, let's add the capability to select one of them. This is based on a VFIODevice auto/on/off iommu_be field. This field is likely to be forced to a given value or set by a device option. Signed-off-by: Eric Auger Signed-off-by: Yi Liu

[RFC 07/18] vfio: Add base object for VFIOContainer

2022-04-14 Thread Yi Liu
; QLIST_HEAD(, VFIOGroup) group_list; }; Co-authored-by: Eric Auger Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/as.c | 48 +++--- hw/vfio/container-obj.c | 195 +++ hw/vfio/container.c | 224

[RFC 16/18] vfio/iommufd: Add IOAS_COPY_DMA support

2022-04-14 Thread Yi Liu
the first iommufd container to other iommufd containers within the address space. For legacy containers, IOVA mapping is done by VFIO_IOMMU_MAP_DMA. Signed-off-by: Yi Liu --- hw/vfio/as.c | 117 +++ hw/vfio/container-obj.c | 17

[RFC 14/18] hw/iommufd: Creation

2022-04-14 Thread Yi Liu
Introduce iommufd utility library which can be compiled out with CONFIG_IOMMUFD configuration. This code is bound to be called by several subsystems: vdpa, and vfio. Co-authored-by: Eric Auger Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- MAINTAINERS | 7 ++ hw

[RFC 09/18] vfio/platform: Use vfio_[attach/detach]_device

2022-04-14 Thread Yi Liu
From: Eric Auger Let the vfio-platform device use vfio_attach_device() and vfio_detach_device(), hence hiding the details of the used IOMMU backend. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/platform.c | 42 ++ 1 file changed, 2

[RFC 08/18] vfio/container: Introduce vfio_[attach/detach]_device

2022-04-14 Thread Yi Liu
-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/container.c | 65 +++ hw/vfio/pci.c | 50 +++ include/hw/vfio/vfio-common.h | 2 ++ 3 files changed, 72 insertions(+), 45 deletions(-) diff --git a/hw/vfio/container.c b

[RFC 12/18] vfio/container-obj: Introduce [attach/detach]_device container callbacks

2022-04-14 Thread Yi Liu
From: Eric Auger Let's turn attach/detach_device as container callbacks. That way, their implementation can be easily customized for a given backend. For the time being, only the legacy container is supported. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/as.c

[RFC 02/18] linux-headers: Import latest vfio.h and iommufd.h

2022-04-14 Thread Yi Liu
From: Eric Auger Imported from https://github.com/luxis1999/iommufd/tree/iommufd-v5.17-rc6 Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- linux-headers/linux/iommufd.h | 223 ++ linux-headers/linux/vfio.h| 84 + 2 files changed, 307

[RFC 04/18] vfio/pci: Use vbasedev local variable in vfio_realize()

2022-04-14 Thread Yi Liu
From: Eric Auger Using a VFIODevice handle local variable to improve the code readability. no functional change intended Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/pci.c | 49 + 1 file changed, 25 insertions(+), 24 deletions

[RFC 05/18] vfio/common: Rename VFIOGuestIOMMU::iommu into ::iommu_mr

2022-04-14 Thread Yi Liu
Rename VFIOGuestIOMMU iommu field into iommu_mr. Then it becomes clearer it is an IOMMU memory region. no functional change intended Signed-off-by: Yi Liu --- hw/vfio/common.c | 16 include/hw/vfio/vfio-common.h | 2 +- 2 files changed, 9 insertions(+), 9

[RFC 13/18] vfio/container-obj: Introduce VFIOContainer reset callback

2022-04-14 Thread Yi Liu
to a place that is not backend-specific (first vfio address space created instead of the first group). Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/as.c | 18 ++ hw/vfio/container-obj.c | 13 + hw/vfio/container.c

[RFC 00/18] vfio: Adopt iommufd

2022-04-14 Thread Yi Liu
iommufd option Yi Liu (6): vfio/common: Rename VFIOGuestIOMMU::iommu into ::iommu_mr vfio/common: Split common.c into common.c, container.c and as.c vfio: Add base object for VFIOContainer hw/iommufd: Creation vfio/iommufd: Implement iommufd backend vfio/iommufd: Add IOAS_COPY_DMA

[RFC 03/18] hw/vfio/pci: fix vfio_pci_hot_reset_result trace point

2022-04-14 Thread Yi Liu
From: Eric Auger Properly output the errno string. Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 67a183f17b..e26e65bb1f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c

[RFC 01/18] scripts/update-linux-headers: Add iommufd.h

2022-04-14 Thread Yi Liu
From: Eric Auger Update the script to import iommufd.h Signed-off-by: Eric Auger Signed-off-by: Yi Liu --- scripts/update-linux-headers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh index 839a5ec614

Re: [PATCH V2 4/4] intel-iommu: PASID support

2022-04-01 Thread Yi Liu
On 2022/3/29 12:54, Jason Wang wrote: 在 2022/3/28 下午4:45, Yi Liu 写道: On 2022/3/21 13:54, Jason Wang wrote: This patch introduce ECAP_PASID via "x-pasid-mode". Based on the existing support for scalable mode, we need to implement the following missing parts: 1) tag VTDAd

Re: [PATCH V2 1/4] intel-iommu: don't warn guest errors when getting rid2pasid entry

2022-03-28 Thread Yi Liu
IOMMU support was following 3.0 spec, while RPS is added in 3.1. Needs to be fixed. Thanks return false; } return (VTD_PE_GET_TYPE() == VTD_SM_PASID_ENTRY_PT); -- 2.25.1 -- Regards, Yi Liu

Re: [PATCH V2 4/4] intel-iommu: PASID support

2022-03-28 Thread Yi Liu
{ struct VTDIOTLBEntry { uint64_t gfn; uint16_t domain_id; +uint32_t pasid; uint64_t slpte; uint64_t mask; uint8_t access_flags; @@ -260,6 +263,7 @@ struct IntelIOMMUState { bool buggy_eim; /* Force buggy EIM unless eim=off */ uint8_t aw_bits;/* Host/IOVA address width (in bits) */ bool dma_drain; /* Whether DMA r/w draining enabled */ +bool pasid; /* Whether to support PASID */ /* * Protects IOMMU states in general. Currently it protects the @@ -271,6 +275,7 @@ struct IntelIOMMUState { /* Find the VTD Address space associated with the given bus pointer, * create a new one if none exists */ -VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn); +VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, + int devfn, unsigned int pasid); #endif diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index 347440d42c..cbfcf0b770 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -26,6 +26,8 @@ enum PCIBusFlags { PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002, }; +#define PCI_NO_PASID UINT32_MAX + struct PCIBus { BusState qbus; enum PCIBusFlags flags; -- Regards, Yi Liu