Re: [RFC v1 3/8] vhost: Add 3 new uapi to support iommufd

2023-11-05 Thread Jason Wang
On Sat, Nov 4, 2023 at 1:17 AM Cindy Lu  wrote:
>
> VHOST_VDPA_SET_IOMMU_FD: bind the device to iommufd device
>
> VDPA_DEVICE_ATTACH_IOMMUFD_AS: Attach a vdpa device to an iommufd
> address space specified by IOAS id.
>
> VDPA_DEVICE_DETACH_IOMMUFD_AS: Detach a vdpa device
> from the iommufd address space
>
> Signed-off-by: Cindy Lu 
> ---

[...]

> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index f5c48b61ab62..07e1b2c443ca 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
> @@ -219,4 +219,70 @@
>   */
>  #define VHOST_VDPA_RESUME  _IO(VHOST_VIRTIO, 0x7E)
>
> +/* vhost_vdpa_set_iommufd
> + * Input parameters:
> + * @iommufd: file descriptor from /dev/iommu; pass -1 to unset
> + * @iommufd_ioasid: IOAS identifier returned from ioctl(IOMMU_IOAS_ALLOC)
> + * Output parameters:
> + * @out_dev_id: device identifier
> + */
> +struct vhost_vdpa_set_iommufd {
> +   __s32 iommufd;
> +   __u32 iommufd_ioasid;
> +   __u32 out_dev_id;
> +};
> +
> +#define VHOST_VDPA_SET_IOMMU_FD \
> +   _IOW(VHOST_VIRTIO, 0x7F, struct vhost_vdpa_set_iommufd)
> +
> +/*
> + * VDPA_DEVICE_ATTACH_IOMMUFD_AS -
> + * _IOW(VHOST_VIRTIO, 0x7f, struct vdpa_device_attach_iommufd_as)
> + *
> + * Attach a vdpa device to an iommufd address space specified by IOAS
> + * id.
> + *
> + * Available only after a device has been bound to iommufd via
> + * VHOST_VDPA_SET_IOMMU_FD
> + *
> + * Undo by VDPA_DEVICE_DETACH_IOMMUFD_AS or device fd close.
> + *
> + * @argsz: user filled size of this data.
> + * @flags: must be 0.
> + * @ioas_id:   Input the target id which can represent an ioas
> + * allocated via iommufd subsystem.
> + *
> + * Return: 0 on success, -errno on failure.
> + */
> +struct vdpa_device_attach_iommufd_as {
> +   __u32 argsz;
> +   __u32 flags;
> +   __u32 ioas_id;
> +};

I think we need to map ioas to vDPA AS, so there should be an ASID
from the view of vDPA?

Thanks

> +
> +#define VDPA_DEVICE_ATTACH_IOMMUFD_AS \
> +   _IOW(VHOST_VIRTIO, 0x82, struct vdpa_device_attach_iommufd_as)
> +
> +/*
> + * VDPA_DEVICE_DETACH_IOMMUFD_AS
> + *
> + * Detach a vdpa device from the iommufd address space it has been
> + * attached to. After it, device should be in a blocking DMA state.
> + *
> + * Available only after a device has been bound to iommufd via
> + * VHOST_VDPA_SET_IOMMU_FD
> + *
> + * @argsz: user filled size of this data.
> + * @flags: must be 0.
> + *
> + * Return: 0 on success, -errno on failure.
> + */
> +struct vdpa_device_detach_iommufd_as {
> +   __u32 argsz;
> +   __u32 flags;
> +};
> +
> +#define VDPA_DEVICE_DETACH_IOMMUFD_AS \
> +   _IOW(VHOST_VIRTIO, 0x83, struct vdpa_device_detach_iommufd_as)
> +
>  #endif
> --
> 2.34.3
>

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [RFC v1 3/8] vhost: Add 3 new uapi to support iommufd

2023-11-05 Thread Jason Wang
On Sat, Nov 4, 2023 at 1:17 AM Cindy Lu  wrote:
>
> VHOST_VDPA_SET_IOMMU_FD: bind the device to iommufd device
>
> VDPA_DEVICE_ATTACH_IOMMUFD_AS: Attach a vdpa device to an iommufd
> address space specified by IOAS id.
>
> VDPA_DEVICE_DETACH_IOMMUFD_AS: Detach a vdpa device
> from the iommufd address space
>
> Signed-off-by: Cindy Lu 

As discussed in the previous version, any reason/advantages of this
compared to just having a single  VDPA_DEVICE_ATTACH_IOMMUFD_AS?

Thanks

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH RFC 01/17] iommu: Remove struct iommu_ops *iommu from arch_setup_dma_ops()

2023-11-05 Thread Christoph Hellwig
On Fri, Nov 03, 2023 at 01:44:46PM -0300, Jason Gunthorpe wrote:
> This is not being used to pass ops, it is just a way to tell if an
> iommu driver was probed. These days this can be detected directly via
> device_iommu_mapped(). Call device_iommu_mapped() in the two places that
> need to check it and remove the iommu parameter everywhere.

Yes, that's much better than exposing the iommu ops to a place that
should not care about them:

Acked-by: Christoph Hellwig 
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC v1 8/8] iommu: expose the function iommu_device_use_default_domain

2023-11-05 Thread Jason Wang
On Sat, Nov 4, 2023 at 1:18 AM Cindy Lu  wrote:
>
> Expose the function iommu_device_use_default_domain() and
> iommu_device_unuse_default_domain(),
> While vdpa bind the iommufd device and detach the iommu device,
> vdpa need to call the function
> iommu_device_unuse_default_domain() to release the owner
>
> Signed-off-by: Cindy Lu 

This is the end of the series, who is the user then?

Thanks

> ---
>  drivers/iommu/iommu.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 3bfc56df4f78..987cbf8c9a87 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -3164,6 +3164,7 @@ int iommu_device_use_default_domain(struct device *dev)
>
> return ret;
>  }
> +EXPORT_SYMBOL_GPL(iommu_device_use_default_domain);
>
>  /**
>   * iommu_device_unuse_default_domain() - Device driver stops handling device
> @@ -3187,6 +3188,7 @@ void iommu_device_unuse_default_domain(struct device 
> *dev)
> mutex_unlock(>mutex);
> iommu_group_put(group);
>  }
> +EXPORT_SYMBOL_GPL(iommu_device_unuse_default_domain);
>
>  static int __iommu_group_alloc_blocking_domain(struct iommu_group *group)
>  {
> --
> 2.34.3
>

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [RFC v1 7/8] vp_vdpa::Add support for iommufd

2023-11-05 Thread Jason Wang
On Sat, Nov 4, 2023 at 1:17 AM Cindy Lu  wrote:
>
> Add new vdpa_config_ops function to support iommufd
>
> Signed-off-by: Cindy Lu 
> ---
>  drivers/vdpa/virtio_pci/vp_vdpa.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c 
> b/drivers/vdpa/virtio_pci/vp_vdpa.c
> index 281287fae89f..dd2c372d36a6 100644
> --- a/drivers/vdpa/virtio_pci/vp_vdpa.c
> +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c
> @@ -460,6 +460,10 @@ static const struct vdpa_config_ops vp_vdpa_ops = {
> .set_config = vp_vdpa_set_config,
> .set_config_cb  = vp_vdpa_set_config_cb,
> .get_vq_irq = vp_vdpa_get_vq_irq,
> +   .bind_iommufd = vdpa_iommufd_physical_bind,
> +   .unbind_iommufd = vdpa_iommufd_physical_unbind,
> +   .attach_ioas = vdpa_iommufd_physical_attach_ioas,
> +   .detach_ioas = vdpa_iommufd_physical_detach_ioas,

For the device that depends on the platform IOMMU, any reason we still
bother a per device config ops here just as an indirection?

Thanks

>  };
>
>  static void vp_vdpa_free_irq_vectors(void *data)
> --
> 2.34.3
>

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[RFC PATCH 5/5] iommu/virtio-iommu: Support attaching VT-d IO pgtable

2023-11-05 Thread Tina Zhang
Add VT-d IO page table support to ATTACH_TABLE request.

Signed-off-by: Tina Zhang 
---
 drivers/iommu/virtio-iommu.c  | 23 +++
 include/uapi/linux/virtio_iommu.h | 26 ++
 2 files changed, 49 insertions(+)

diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
index b1ceaac974e2..b02eeb1d27a4 100644
--- a/drivers/iommu/virtio-iommu.c
+++ b/drivers/iommu/virtio-iommu.c
@@ -991,12 +991,25 @@ static int viommu_attach_pgtable(struct viommu_domain 
*vdomain,
};
 
/* TODO: bypass flag? */
+   if (vdomain->bypass == true)
+   return 0;
 
switch (fmt) {
case VIRT_IO_PGTABLE:
req.format = cpu_to_le16(VIRTIO_IOMMU_FORMAT_PGTF_VIRT);
req.pgd = cpu_to_le64((u64)cfg->virt.pgd);
break;
+   case INTEL_IOMMU: {
+   struct virtio_iommu_req_attach_pgt_vtd *vtd_req =
+   (struct virtio_iommu_req_attach_pgt_vtd *)
+
+   vtd_req->format = cpu_to_le16(VIRTIO_IOMMU_FORMAT_PGTF_VTD);
+   vtd_req->pgd = cpu_to_le64((u64)cfg->virt.pgd);
+   vtd_req->addr_width = cpu_to_le32(cfg->oas);
+   vtd_req->pasid = IOMMU_NO_PASID;
+   break;
+   }
+
default:
return -EINVAL;
};
@@ -1034,6 +1047,16 @@ static int viommu_setup_pgtable(struct viommu_domain 
*vdomain,
case VIRTIO_IOMMU_FORMAT_PGTF_VIRT:
fmt = VIRT_IO_PGTABLE;
break;
+   case VIRTIO_IOMMU_FORMAT_PGTF_VTD:
+   {
+   struct virtio_iommu_probe_pgt_vtd *vtd_desc =
+   (struct virtio_iommu_probe_pgt_vtd *)desc;
+
+   cfg.vtd_cfg.cap_reg = le64_to_cpu(vtd_desc->cap_reg);
+   cfg.vtd_cfg.ecap_reg = le64_to_cpu(vtd_desc->ecap_reg);
+   fmt = INTEL_IOMMU;
+   break;
+   }
default:
dev_warn(vdev->dev, "unsupported page table format 0x%x\n",
 le16_to_cpu(desc->format));
diff --git a/include/uapi/linux/virtio_iommu.h 
b/include/uapi/linux/virtio_iommu.h
index 656be1f3d926..17e0d5fcdd54 100644
--- a/include/uapi/linux/virtio_iommu.h
+++ b/include/uapi/linux/virtio_iommu.h
@@ -139,6 +139,22 @@ struct virtio_iommu_req_attach_pgt_virt {
struct virtio_iommu_req_tailtail;
 };
 
+/* Vt-d I/O Page Table Descriptor */
+struct virtio_iommu_req_attach_pgt_vtd {
+   struct virtio_iommu_req_headhead;
+   __le32  domain;
+   __le32  endpoint;
+   __le32  flags;
+   __le16  format;
+   __u8reserved[2];
+   __le32  pasid;
+   __le64  pgd;
+   __le64  fl_flags;
+   __le32  addr_width;
+   __u8reserved2[36];
+   struct virtio_iommu_req_tailtail;
+};
+
 #define VIRTIO_IOMMU_MAP_F_READ(1 << 0)
 #define VIRTIO_IOMMU_MAP_F_WRITE   (1 << 1)
 #define VIRTIO_IOMMU_MAP_F_MMIO(1 << 2)
@@ -224,6 +240,8 @@ struct virtio_iommu_probe_pasid_size {
 #define VIRTIO_IOMMU_FORMAT_PSTF_ARM_SMMU_V3   2
 /* Virt I/O page table format */
 #define VIRTIO_IOMMU_FORMAT_PGTF_VIRT  3
+/* VT-d I/O page table format */
+#define VIRTIO_IOMMU_FORMAT_PGTF_VTD   4
 
 struct virtio_iommu_probe_table_format {
struct virtio_iommu_probe_property  head;
@@ -231,6 +249,14 @@ struct virtio_iommu_probe_table_format {
__u8reserved[2];
 };
 
+struct virtio_iommu_probe_pgt_vtd {
+   struct virtio_iommu_probe_property  head;
+   __le16  format;
+   __u8reserved[2];
+   __le64  cap_reg;
+   __le64  ecap_reg;
+};
+
 struct virtio_iommu_req_probe {
struct virtio_iommu_req_headhead;
__le32  endpoint;
-- 
2.39.3

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[RFC PATCH 4/5] iommu/vt-d: Adapt alloc_pgtable interface to be used by others

2023-11-05 Thread Tina Zhang
The generic IO page table framework provides a set of interfaces for
invoking IO page table operations. Other entity (e.g., virtio-iommu
driver) can use the interface to ask VT-d driver to generate a VT-d
format IO page table. This patch adds the support.

Signed-off-by: Tina Zhang 
---
 drivers/iommu/intel/iommu.c | 69 +++--
 1 file changed, 66 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 80bd1993861c..d714e780a031 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -5248,17 +5248,80 @@ static phys_addr_t pgtable_iova_to_phys(struct 
io_pgtable_ops *ops,
return intel_iommu_iova_to_phys(_domain->domain, iova);
 }
 
+static void __iommu_calculate_cfg(struct io_pgtable_cfg *cfg)
+{
+   unsigned long fl_sagaw, sl_sagaw, sagaw;
+   int agaw, addr_width;
+
+   fl_sagaw = BIT(2) | (cap_fl5lp_support(cfg->vtd_cfg.cap_reg) ? BIT(3) : 
0);
+   sl_sagaw = cap_sagaw(cfg->vtd_cfg.cap_reg);
+   sagaw = fl_sagaw & sl_sagaw;
+
+   for (agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH); agaw >= 0; 
agaw--) {
+   if (test_bit(agaw, ))
+   break;
+   }
+
+   addr_width = agaw_to_width(agaw);
+   if (cfg->ias > addr_width)
+   cfg->ias = addr_width;
+   if (cfg->oas != addr_width)
+   cfg->oas = addr_width;
+}
+
 static struct io_pgtable *alloc_pgtable(struct io_pgtable_cfg *cfg, void 
*cookie)
 {
-   struct dmar_io_pgtable *pgtable = io_pgtable_cfg_to_dmar_pgtable(cfg);
+   struct dmar_io_pgtable *pgtable;
+   struct dmar_domain *domain;
+   int adjust_width;
+
+   /* Platform must have nested translation support */
+   if (!ecap_nest(cfg->vtd_cfg.ecap_reg))
+   return NULL;
+
+   domain = kzalloc(sizeof(*domain), GFP_KERNEL);
+   if (!domain)
+   return NULL;
+
+   domain->nid = NUMA_NO_NODE;
+   domain->use_first_level = true;
+   domain->has_iotlb_device = false;
+   INIT_LIST_HEAD(>devices);
+   spin_lock_init(>lock);
+   xa_init(>iommu_array);
+
+   /* calculate AGAW */
+   __iommu_calculate_cfg(cfg);
+   domain->gaw = cfg->ias;
+   adjust_width = guestwidth_to_adjustwidth(domain->gaw);
+   domain->agaw = width_to_agaw(adjust_width);
+
+   domain->iommu_coherency = ecap_smpwc(cfg->vtd_cfg.ecap_reg);
+   domain->force_snooping = true;
+   domain->iommu_superpage = cap_fl1gp_support(cfg->vtd_cfg.ecap_reg) ? 2 
: 1;
+   domain->max_addr = 0;
+
+   cfg->coherent_walk = domain->iommu_coherency;
+
+   pgtable = >dmar_iop;
 
+   /* always allocate the top pgd */
+   domain->pgd = alloc_pgtable_page(domain->nid, GFP_KERNEL);
+   if (!domain->pgd)
+   goto out_free_domain;
+   domain_flush_cache(domain, domain->pgd, PAGE_SIZE);
+
+   cfg->virt.pgd = virt_to_phys(domain->pgd);
+   cfg->tlb = _ops;
pgtable->iop.ops.map_pages = pgtable_map_pages;
pgtable->iop.ops.unmap_pages = pgtable_unmap_pages;
pgtable->iop.ops.iova_to_phys = pgtable_iova_to_phys;
 
-   cfg->tlb = _ops;
-
return >iop;
+
+out_free_domain:
+   kfree(domain);
+   return NULL;
 }
 
 struct io_pgtable_init_fns io_pgtable_intel_iommu_init_fns = {
-- 
2.39.3

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[RFC PATCH 3/5] iommu/io-pgtable: Introduce struct vtd_cfg

2023-11-05 Thread Tina Zhang
VT-d hardware cap/ecap information is needed for driver to generate VT-d
format IO page table. Add struct vtd_cfg to keep the info.

Signed-off-by: Tina Zhang 
---
 include/linux/io-pgtable.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h
index b2857c18f963..ae6a2e44b027 100644
--- a/include/linux/io-pgtable.h
+++ b/include/linux/io-pgtable.h
@@ -147,6 +147,11 @@ struct io_pgtable_cfg {
u32 n_ttbrs;
} apple_dart_cfg;
 
+   struct {
+   u64 cap_reg;
+   u64 ecap_reg;
+   } vtd_cfg;
+
struct {
dma_addr_t  pgd;
} virt;
-- 
2.39.3

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[RFC PATCH 1/5] iommu/virtio-iommu: Correct the values of granule and nr_pages

2023-11-05 Thread Tina Zhang
The value of granule is ilog2(pgsize). When the value of pgsize isn't
a power of two, granule would make pgsize less than the actual size of
pgsize. E.g., if pgsize = 0x6000 and granule = ilog2(gather->pgsize), then
granule = 0xe. 2^0xe = 0x4000 makes the pgsize (0x4000) smaller than the
actual pgsize (0x6000). Invalidating IOTLB with smaller range would lead
to cache incoherence. So, roundup pgsize value to the nearest power of 2
to make sure the granule won't make pgsize less than the actual size. The
value of "gather->end - gather->start + 1" also needs similar adjustment.

Signed-off-by: Tina Zhang 
---
 drivers/iommu/virtio-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
index 08e310672e57..b1ceaac974e2 100644
--- a/drivers/iommu/virtio-iommu.c
+++ b/drivers/iommu/virtio-iommu.c
@@ -1289,8 +1289,8 @@ static void viommu_iotlb_sync(struct iommu_domain *domain,
if (!gather->pgsize)
return;
 
-   granule = ilog2(gather->pgsize);
-   nr_pages = (gather->end - gather->start + 1) >> granule;
+   granule = ilog2(__roundup_pow_of_two(gather->pgsize));
+   nr_pages = __roundup_pow_of_two(gather->end - gather->start + 
1) >> granule;
req = (struct virtio_iommu_req_invalidate) {
.head.type  = VIRTIO_IOMMU_T_INVALIDATE,
.inv_gran   = cpu_to_le16(VIRTIO_IOMMU_INVAL_G_VA),
-- 
2.39.3

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[RFC PATCH 0/5] virtio-iommu: Add VT-d IO page table

2023-11-05 Thread Tina Zhang
The proposal about virtio-iommu support page tables is being discussed in
the virtio-comment mailing list[1]. This patch-set based on Jean's
virtio-iommu/pgtables branch[2] tries to follow the proposal and add the
basic VT-d IO page table support to virtio-iommu.

On Intel platform with VT-d nested translation enabled, there are two
main benefits for enabling virtual IOMMU support VT-d IO page table:
1) Allowing vSVM (aka vSVA) usage. Virtual Shared Virtual Addressing
   (vSVA) allows the virtual processor and virtual device to use the
   same virtual addresses.
2) Accelerating DMA buffer map operation for vIOVA usage by removing
   the context switch on DMA buffer map operation.
(Note: this patch-set doesn't include the whole patch-set for enabling
vSVM on virtio-iommu, only includes the part for vIOVA case. However,
the vSVM enabling patch-set needs to base on this patch-set.)

There are three changes in this patch-set:
1) The first patch is a bug fixing patch that tries to resolve an issue
   about IOTLB invalidation request with incorrect page size.
2) The next 3 patches are about adding generic IO page table support to
   VT-d driver.
3) The last one introduces the VT-d page format table to virtio-iommu
   driver.

The patch-set is also available at github:
https://github.com/TinaZhangZW/linux/tree/vt-d-pgtable

The QEMU part is available here:
https://github.com/TinaZhangZW/qemu/tree/virtio-iommu/vt-d-pgtable


[1]:https://lists.oasis-open.org/archives/virtio-comment/202310/msg00018.html
[2]:https://jpbrucker.net/git/linux/log/?h=virtio-iommu/pgtables

Tina Zhang (5):
  iommu/virtio-iommu: Correct the values of granule and nr_pages
  iommu/vt-d: Add generic IO page table support
  iommu/io-pgtable: Introduce struct vtd_cfg
  iommu/vt-d: Adapt alloc_pgtable interface to be used by others
  iommu/virtio-iommu: Support attaching VT-d IO pgtable

 drivers/iommu/intel/Kconfig   |   1 +
 drivers/iommu/intel/iommu.c   | 157 ++
 drivers/iommu/intel/iommu.h   |   7 ++
 drivers/iommu/io-pgtable.c|   3 +
 drivers/iommu/virtio-iommu.c  |  27 -
 include/linux/io-pgtable.h|   7 ++
 include/uapi/linux/virtio_iommu.h |  26 +
 7 files changed, 226 insertions(+), 2 deletions(-)

-- 
2.39.3

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[RFC PATCH 2/5] iommu/vt-d: Add generic IO page table support

2023-11-05 Thread Tina Zhang
Add basic hook up code to implement generic IO page table framework.

Signed-off-by: Tina Zhang 
---
 drivers/iommu/intel/Kconfig |  1 +
 drivers/iommu/intel/iommu.c | 94 +
 drivers/iommu/intel/iommu.h |  7 +++
 drivers/iommu/io-pgtable.c  |  3 ++
 include/linux/io-pgtable.h  |  2 +
 5 files changed, 107 insertions(+)

diff --git a/drivers/iommu/intel/Kconfig b/drivers/iommu/intel/Kconfig
index 2e56bd79f589..8334e7e50e69 100644
--- a/drivers/iommu/intel/Kconfig
+++ b/drivers/iommu/intel/Kconfig
@@ -15,6 +15,7 @@ config INTEL_IOMMU
select DMA_OPS
select IOMMU_API
select IOMMU_IOVA
+   select IOMMU_IO_PGTABLE
select NEED_DMA_MAP_STATE
select DMAR_TABLE
select SWIOTLB
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index dbcdf7b95b9f..80bd1993861c 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "iommu.h"
 #include "../dma-iommu.h"
@@ -67,6 +68,20 @@
 #define LEVEL_STRIDE   (9)
 #define LEVEL_MASK (((u64)1 << LEVEL_STRIDE) - 1)
 
+#define io_pgtable_cfg_to_dmar_pgtable(x) \
+   container_of((x), struct dmar_io_pgtable, pgtbl_cfg)
+
+#define io_pgtable_to_dmar_pgtable(x) \
+   container_of((x), struct dmar_io_pgtable, iop)
+
+#define io_pgtable_to_dmar_domain(x) \
+   container_of(io_pgtable_to_dmar_pgtable(x), \
+   struct dmar_domain, dmar_iop)
+
+#define io_pgtable_ops_to_dmar_domain(x) \
+   container_of(io_pgtable_to_dmar_pgtable(io_pgtable_ops_to_pgtable(x)), \
+   struct dmar_domain, dmar_iop)
+
 static inline int agaw_to_level(int agaw)
 {
return agaw + 2;
@@ -5171,3 +5186,82 @@ int ecmd_submit_sync(struct intel_iommu *iommu, u8 ecmd, 
u64 oa, u64 ob)
 
return ret;
 }
+
+static void flush_all(void *cookie)
+{
+}
+
+static void flush_walk(unsigned long iova, size_t size,
+  size_t granule, void *cookie)
+{
+}
+
+static void add_page(struct iommu_iotlb_gather *gather,
+unsigned long iova, size_t granule,
+void *cookie)
+{
+}
+
+static const struct iommu_flush_ops flush_ops = {
+   .tlb_flush_all  = flush_all,
+   .tlb_flush_walk = flush_walk,
+   .tlb_add_page   = add_page,
+};
+
+static void free_pgtable(struct io_pgtable *iop)
+{
+   struct dmar_domain *dmar_domain = io_pgtable_to_dmar_domain(iop);
+
+   if (dmar_domain->pgd) {
+   LIST_HEAD(freelist);
+
+   domain_unmap(dmar_domain, 0, DOMAIN_MAX_PFN(dmar_domain->gaw), 
);
+   put_pages_list();
+   }
+}
+
+static int pgtable_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
+phys_addr_t paddr, size_t pgsize, size_t pgcount,
+int iommu_prot, gfp_t gfp, size_t *mapped)
+{
+   struct dmar_domain *dmar_domain = io_pgtable_ops_to_dmar_domain(ops);
+
+   return intel_iommu_map_pages(_domain->domain, iova, paddr, pgsize,
+pgcount, iommu_prot, gfp, mapped);
+}
+
+static size_t pgtable_unmap_pages(struct io_pgtable_ops *ops, unsigned long 
iova,
+ size_t pgsize, size_t pgcount,
+ struct iommu_iotlb_gather *gather)
+{
+   struct dmar_domain *dmar_domain = io_pgtable_ops_to_dmar_domain(ops);
+
+   return intel_iommu_unmap_pages(_domain->domain, iova, pgsize,
+  pgcount, gather);
+}
+
+static phys_addr_t pgtable_iova_to_phys(struct io_pgtable_ops *ops,
+   unsigned long iova)
+{
+   struct dmar_domain *dmar_domain = io_pgtable_ops_to_dmar_domain(ops);
+
+   return intel_iommu_iova_to_phys(_domain->domain, iova);
+}
+
+static struct io_pgtable *alloc_pgtable(struct io_pgtable_cfg *cfg, void 
*cookie)
+{
+   struct dmar_io_pgtable *pgtable = io_pgtable_cfg_to_dmar_pgtable(cfg);
+
+   pgtable->iop.ops.map_pages = pgtable_map_pages;
+   pgtable->iop.ops.unmap_pages = pgtable_unmap_pages;
+   pgtable->iop.ops.iova_to_phys = pgtable_iova_to_phys;
+
+   cfg->tlb = _ops;
+
+   return >iop;
+}
+
+struct io_pgtable_init_fns io_pgtable_intel_iommu_init_fns = {
+   .alloc = alloc_pgtable,
+   .free  = free_pgtable,
+};
diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
index 8d0aac71c135..5207fea6477a 100644
--- a/drivers/iommu/intel/iommu.h
+++ b/drivers/iommu/intel/iommu.h
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -579,6 +580,11 @@ struct iommu_domain_info {
 * to VT-d spec, section 9.3 */
 };
 
+struct dmar_io_pgtable {
+   struct io_pgtable_cfg   pgtbl_cfg;
+   struct io_pgtable   iop;
+};
+
 struct dmar_domain {
int nid;/* 

Re: [PATCH net-next v2 4/5] virtio-net: support rx netdim

2023-11-05 Thread kernel test robot
Hi Heng,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:
https://github.com/intel-lab-lkp/linux/commits/Heng-Qi/virtio-net-returns-whether-napi-is-complete/20231103-040818
base:   net-next/main
patch link:
https://lore.kernel.org/r/12c77098b73313eea8fdc88a3d1d20611444827d.1698929590.git.hengqi%40linux.alibaba.com
patch subject: [PATCH net-next v2 4/5] virtio-net: support rx netdim
config: arm-vexpress_defconfig 
(https://download.01.org/0day-ci/archive/20231106/202311061237.i4bmaa06-...@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 
4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20231106/202311061237.i4bmaa06-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202311061237.i4bmaa06-...@intel.com/

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: net_dim_get_rx_moderation
   >>> referenced by virtio_net.c:3529 (drivers/net/virtio_net.c:3529)
   >>>   drivers/net/virtio_net.o:(virtnet_rx_dim_work) in archive 
vmlinux.a
--
>> ld.lld: error: undefined symbol: net_dim
   >>> referenced by virtio_net.c:2176 (drivers/net/virtio_net.c:2176)
   >>>   drivers/net/virtio_net.o:(virtnet_poll) in archive 
vmlinux.a

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC v1 0/8] vhost-vdpa: add support for iommufd

2023-11-05 Thread Jason Wang
On Sat, Nov 4, 2023 at 1:16 AM Cindy Lu  wrote:
>
>
> Hi All
> This code provides the iommufd support for vdpa device
> This code fixes the bugs from the last version and also add the asid support. 
> rebase on kernel
> v6,6-rc3
> Test passed in the physical device (vp_vdpa), but  there are still some 
> problems in the emulated device (vdpa_sim_net),
> I will continue working on it
>
> The kernel code is
> https://gitlab.com/lulu6/vhost/-/tree/iommufdRFC_v1
>
> Signed-off-by: Cindy Lu 

It would be better to have a change summary here.

Thanks

>
>
> Cindy Lu (8):
>   vhost/iommufd: Add the functions support iommufd
>   Kconfig: Add the new file vhost/iommufd
>   vhost: Add 3 new uapi to support iommufd
>   vdpa: Add new vdpa_config_ops to support iommufd
>   vdpa_sim :Add support for iommufd
>   vdpa: change the map/unmap process to support iommufd
>   vp_vdpa::Add support for iommufd
>   iommu: expose the function iommu_device_use_default_domain
>
>  drivers/iommu/iommu.c |   2 +
>  drivers/vdpa/vdpa_sim/vdpa_sim.c  |   8 ++
>  drivers/vdpa/virtio_pci/vp_vdpa.c |   4 +
>  drivers/vhost/Kconfig |   1 +
>  drivers/vhost/Makefile|   1 +
>  drivers/vhost/iommufd.c   | 178 +
>  drivers/vhost/vdpa.c  | 210 +-
>  drivers/vhost/vhost.h |  21 +++
>  include/linux/vdpa.h  |  38 +-
>  include/uapi/linux/vhost.h|  66 ++
>  10 files changed, 525 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/vhost/iommufd.c
>
> --
> 2.34.3
>

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [GIT PULL] vhost,virtio,vdpa: features, fixes, cleanups

2023-11-05 Thread pr-tracker-bot
The pull request you sent on Sun, 5 Nov 2023 10:58:06 -0500:

> https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git tags/for_linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/77fa2fbe87fc605c4bfa87dff87be9bfded0e9a3

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


CFP: WorldCIST'24 - 12nd World Conference on Information Systems and Technologies | Lodz, Poland | Deadline: November 24

2023-11-05 Thread WorldCIST-24
* CORE Conference
** Google Scholar H5-Index = 25

*** Indexed in Scopus, WoS, DBLP, etc.




--   --   
--   -
WorldCIST'24 - The 12th World Conference on Information Systems and Technologies

Lodz University of Technology, Lodz, Poland, March 26-28, 2024

http://worldcist.org/ 


 -   --   
--   -



Scope

The WorldCist'24 - 12nd World Conference on Information Systems and 
Technologies,  to be held in Lodz, at Lodz University of Technology, Poland, 26 
- 28 March 2024, is a global forum for researchers and practitioners to present 
and discuss the most recent innovations, trends, results, experiences and 
concerns in the several perspectives of Information Systems and Technologies.

We are pleased to invite you to submit your original papers to WorldCist'24. 
All submissions will be reviewed on the basis of relevance, originality, 
importance and clarity.



Themes

Submitted papers should be related with one or more of the main themes proposed 
for the Conference:

A) Information and Knowledge Management (IKM);

B) Organizational Models and Information Systems (OMIS);

C) Software and Systems Modeling (SSM);

D) Software Systems, Architectures, Applications and Tools (SSAAT);

E) Multimedia Systems and Applications (MSA);

F) Computer Networks, Mobility and Pervasive Systems (CNMPS);

G) Intelligent and Decision Support Systems (IDSS);

H) Big Data Analytics and Applications (BDAA);

I) Human-Computer Interaction (HCI);

J) Ethics, Computers and Security (ECS)

K) Health Informatics (HIS);

L) Information Technologies in Education (ITE);

M) Technologies for Biomedical Applications (TBA)

N) Information Technologies in Radiocommunications (ITR);



Types of Submissions and Decisions

Four types of original papers can be submitted:

Full paper: Finished or consolidated R works, to be included in one of the 
Conference themes. These papers are assigned a 10-page limit.

Short paper: Ongoing works with relevant preliminary results, open to 
discussion. These papers are assigned a 7-page limit.

Poster paper: Initial work with relevant ideas, open to discussion. These 
papers are assigned to a 4-page limit.

Company paper: Companies' papers that show practical experience, R & D, tools, 
etc., focused on some topics of the conference. These papers are assigned to a 
4-page limit.

Submitted papers must comply with the format of Lecture Notes in Networks and 
Systems series (see Instructions for Authors at Springer Website) 
,
 be written in English, must not have been published before, not be under 
review for any other conference or publication and not include any information 
leading to the authors’ identification. Therefore, the authors’ names, 
affiliations and bibliographic references should not be included in the version 
for evaluation by the Program Committee. This information should only be 
included in the camera-ready version, saved in Word or Latex format and also in 
PDF format. These files must be accompanied by the Consent to Publish form 
filled out, in a ZIP file, and uploaded at the conference management system.


All papers will be subjected to a “double-blind review” by at least two members 
of the Program Committee.

Based on Program Committee evaluation, a paper can be rejected or accepted by 
the Conference Chairs. In the later case, it can be accepted as the type 
originally submitted or as another type. Thus, full papers can be accepted as 
short papers or poster papers only. Similarly, short papers can be accepted as 
poster papers only.

Poster papers and Company papers are not published in the Conference 
Proceedings, being only presented and discussed. The authors of accepted poster 
papers should build and print a poster to be exhibited during the Conference. 
This poster must follow an A1 or A2 vertical format. The Conference includes 
Work Sessions where these posters are presented and orally discussed, with a 7 
minute limit per poster.

The authors of accepted Full papers will have 15 minutes to present their work 
in a Conference Work Session; approximately 5 minutes of discussion will follow 
each presentation. The authors of accepted Short papers and Company papers will 
have 11 minutes to present their work in a Conference Work Session; 
approximately 4 minutes of discussion will follow each presentation.



Publication and Indexing

To ensure that a full paper or short paper is published and presented, poster 
paper or company paper is presented, at least one of the authors must be fully 
registered by the 5th of January 2024, and the paper must comply 

[GIT PULL] vhost,virtio,vdpa: features, fixes, cleanups

2023-11-05 Thread Michael S. Tsirkin
The following changes since commit ffc253263a1375a65fa6c9f62a893e9767fbebfa:

  Linux 6.6 (2023-10-29 16:31:08 -1000)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git tags/for_linus

for you to fetch changes up to 86f6c224c97911b4392cb7b402e6a4ed323a449e:

  vdpa_sim: implement .reset_map support (2023-11-01 09:20:00 -0400)


vhost,virtio,vdpa: features, fixes, cleanups

vdpa/mlx5:
VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK
new maintainer
vdpa:
support for vq descriptor mappings
decouple reset of iotlb mapping from device reset

fixes, cleanups all over the place

Signed-off-by: Michael S. Tsirkin 


Dragos Tatulea (14):
  vdpa/mlx5: Expose descriptor group mkey hw capability
  vdpa/mlx5: Create helper function for dma mappings
  vdpa/mlx5: Decouple cvq iotlb handling from hw mapping code
  vdpa/mlx5: Take cvq iotlb lock during refresh
  vdpa/mlx5: Collapse "dvq" mr add/delete functions
  vdpa/mlx5: Rename mr destroy functions
  vdpa/mlx5: Allow creation/deletion of any given mr struct
  vdpa/mlx5: Move mr mutex out of mr struct
  vdpa/mlx5: Improve mr update flow
  vdpa/mlx5: Introduce mr for vq descriptor
  vdpa/mlx5: Enable hw support for vq descriptor mapping
  vdpa/mlx5: Make iotlb helper functions more generic
  vdpa/mlx5: Update cvq iotlb mapping on ASID change
  MAINTAINERS: Add myself as mlx5_vdpa driver

Eugenio Pérez (1):
  mlx5_vdpa: offer VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK

Geert Uytterhoeven (1):
  vhost-scsi: Spelling s/preceeding/preceding/g

Greg Kroah-Hartman (1):
  vduse: make vduse_class constant

Michael S. Tsirkin (1):
  Merge branch 'mlx5-vhost' of 
https://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux.git

Shannon Nelson (1):
  virtio: kdoc for struct virtio_pci_modern_device

Shawn.Shao (1):
  vdpa: Update sysfs ABI documentation

Si-Wei Liu (10):
  vdpa: introduce dedicated descriptor group for virtqueue
  vhost-vdpa: introduce descriptor group backend feature
  vhost-vdpa: uAPI to get dedicated descriptor group id
  vdpa: introduce .reset_map operation callback
  vhost-vdpa: reset vendor specific mapping to initial state in .release
  vhost-vdpa: introduce IOTLB_PERSIST backend feature bit
  vdpa: introduce .compat_reset operation callback
  vhost-vdpa: clean iotlb map during reset for older userspace
  vdpa/mlx5: implement .reset_map driver op
  vdpa_sim: implement .reset_map support

Xuan Zhuo (3):
  virtio: add definition of VIRTIO_F_NOTIF_CONFIG_DATA feature bit
  virtio_pci: add build offset check for the new common cfg items
  virtio_pci: add check for common cfg size

Xueshi Hu (1):
  virtio-balloon: correct the comment of virtballoon_migratepage()

zhenwei pi (1):
  virtio-blk: fix implicit overflow on virtio_max_dma_size

 Documentation/ABI/testing/sysfs-bus-vdpa |   4 +-
 MAINTAINERS  |   6 +
 drivers/block/virtio_blk.c   |   4 +-
 drivers/vdpa/mlx5/core/mlx5_vdpa.h   |  32 +++--
 drivers/vdpa/mlx5/core/mr.c  | 213 +++
 drivers/vdpa/mlx5/core/resources.c   |   6 +-
 drivers/vdpa/mlx5/net/mlx5_vnet.c| 137 +++-
 drivers/vdpa/vdpa_sim/vdpa_sim.c |  52 ++--
 drivers/vdpa/vdpa_user/vduse_dev.c   |  40 +++---
 drivers/vhost/scsi.c |   2 +-
 drivers/vhost/vdpa.c |  79 +++-
 drivers/virtio/virtio_balloon.c  |   2 +-
 drivers/virtio/virtio_pci_modern.c   |  36 ++
 drivers/virtio/virtio_pci_modern_dev.c   |   6 +-
 drivers/virtio/virtio_vdpa.c |   2 +-
 include/linux/mlx5/mlx5_ifc.h|   8 +-
 include/linux/mlx5/mlx5_ifc_vdpa.h   |   7 +-
 include/linux/vdpa.h |  41 +-
 include/linux/virtio_pci_modern.h|  35 +++--
 include/uapi/linux/vhost.h   |   8 ++
 include/uapi/linux/vhost_types.h |   7 +
 include/uapi/linux/virtio_config.h   |   5 +
 22 files changed, 546 insertions(+), 186 deletions(-)

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization