iommu/virtio: Use page size bitmap supported by endpoint
Subsystems (3)
RFC PATCH v2 1/1 iommu/virtio: Use page size bitmap supported by endpoint
Different endpoint can support different page size, probe endpoint if it supports specific page size otherwise use global page sizes.
--- drivers/iommu/virtio-iommu.c | 33 +++++++++++++++++++++++++++---- include/uapi/linux/virtio_iommu.h | 7 +++++++ 2 files changed, 36 insertions(+), 4 deletions(-)
drivers/iommu/virtio-iommu.c +29 -4
@@ -78,6 +78,7 @@ struct viommu_endpoint {struct viommu_dev *viommu;struct viommu_domain *vdomain;struct list_head resv_regions; +u64 pgsize_bitmap; };struct viommu_request {
@@ -415,6 +416,20 @@ static int viommu_replay_mappings(struct viommu_domain *vdomain)return ret; } +static int viommu_set_pgsize_bitmap (struct viommu_endpoint *vdev, +struct virtio_iommu_probe_pgsize_mask *mask, +size_t len) + +{ +u64 pgsize_bitmap =le64_to_cpu (mask->pgsize_bitmap); + +if (len <sizeof (*mask)) +return -EINVAL ; + + vdev->pgsize_bitmap = pgsize_bitmap; +return 0 ; +} +static int viommu_add_resv_mem (struct viommu_endpoint *vdev,struct virtio_iommu_probe_resv_mem *mem,size_t len)
@@ -494,11 +509,13 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev)while (type !=VIRTIO_IOMMU_PROBE_T_NONE && cur < viommu->probe_size) { len =le16_to_cpu (prop->length) +sizeof (*prop); -switch (type) {case VIRTIO_IOMMU_PROBE_T_RESV_MEM : ret =viommu_add_resv_mem (vdev, (void *)prop, len);break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + ret =viommu_set_pgsize_bitmap (vdev, (void *)prop, len); +break ;default :dev_err (dev,"unknown viommu prop 0x%x\n" , type); }
@@ -607,16 +624,23 @@ static struct iommu_domain *viommu_domain_alloc(unsigned type)return &vdomain->domain; } -static int viommu_domain_finalise (struct viommu_dev *viommu, +static int viommu_domain_finalise (struct viommu_endpoint *vdev,struct iommu_domain *domain) {int ret;struct viommu_domain *vdomain =to_viommu_domain (domain); +struct viommu_dev *viommu = vdev->viommu; vdomain->viommu = viommu; vdomain->map_flags = viommu->map_flags; - domain->pgsize_bitmap = viommu->pgsize_bitmap; +/* Devices in same domain must support same size pages */ +if ((domain->pgsize_bitmap != viommu->pgsize_bitmap) && + (domain->pgsize_bitmap != vdev->pgsize_bitmap)) +return -EINVAL ; + + domain->pgsize_bitmap = vdev->pgsize_bitmap; + domain->geometry = viommu->geometry; ret = ida_alloc_range(&viommu->domain_ids, viommu->first_domain,
@@ -657,7 +681,7 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev)* Properly initialize the domain now that we know which viommu * owns it. */ - ret =viommu_domain_finalise (vdev->viommu, domain); + ret =viommu_domain_finalise (vdev, domain); }else if (vdomain->viommu != vdev->viommu) {dev_err (dev,"cannot attach to foreign vIOMMU\n" ); ret = -EXDEV ;
@@ -875,6 +899,7 @@ static int viommu_add_device(struct device *dev) vdev->dev = dev; vdev->viommu = viommu; + vdev->pgsize_bitmap = viommu->pgsize_bitmap;INIT_LIST_HEAD (&vdev->resv_regions); fwspec->iommu_priv = vdev;
include/uapi/linux/virtio_iommu.h +7 -0
@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff
@@ -119,6 +120,12 @@ struct virtio_iommu_probe_property {__le16 length; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +__u8 reserved[4 ]; +__u64 pgsize_bitmap; +}; +#define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0#define VIRTIO_IOMMU_RESV_MEM_T_MSI 1
Signature · 1 line
2.17.1
Robin Murphy
reviewerQuoted 65 lines · Bharat Bhushan
Different endpoint can support different page size, probe endpoint if it supports specific page size otherwise use global page sizes.
Signed-off-by Bharat Bhushan <[email protected]>--- drivers/iommu/virtio-iommu.c | 33 +++++++++++++++++++++++++++---- include/uapi/linux/virtio_iommu.h | 7 +++++++ 2 files changed, 36 insertions(+), 4 deletions(-)drivers/iommu/virtio-iommu.c +19
-2@@ -78,6 +78,7 @@ struct viommu_endpoint {struct viommu_dev *viommu;struct viommu_domain *vdomain;struct list_head resv_regions; +u64 pgsize_bitmap; };struct viommu_request {@@ -415,6 +416,20 @@ static int viommu_replay_mappings(struct viommu_domain *vdomain)return ret; } +static int viommu_set_pgsize_bitmap (struct viommu_endpoint *vdev, +struct virtio_iommu_probe_pgsize_mask *mask, +size_t len) + +{ +u64 pgsize_bitmap =le64_to_cpu (mask->pgsize_bitmap); + +if (len <sizeof (*mask)) +return -EINVAL ; + + vdev->pgsize_bitmap = pgsize_bitmap; +return 0 ; +} +static int viommu_add_resv_mem (struct viommu_endpoint *vdev,struct virtio_iommu_probe_resv_mem *mem,size_t len)@@ -494,11 +509,13 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev)while (type !=VIRTIO_IOMMU_PROBE_T_NONE && cur < viommu->probe_size) { len =le16_to_cpu (prop->length) +sizeof (*prop); -switch (type) {case VIRTIO_IOMMU_PROBE_T_RESV_MEM : ret =viommu_add_resv_mem (vdev, (void *)prop, len);break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + ret =viommu_set_pgsize_bitmap (vdev, (void *)prop, len); +break ;default :dev_err (dev,"unknown viommu prop 0x%x\n" , type); }@@ -607,16 +624,23 @@ static struct iommu_domain *viommu_domain_alloc(unsigned type)return &vdomain->domain; } -static int viommu_domain_finalise (struct viommu_dev *viommu, +static int viommu_domain_finalise (struct viommu_endpoint *vdev,struct iommu_domain *domain)
drivers/iommu/virtio-iommu.c static struct iommu_domain *viommu_domain_alloc(unsigned type) · line 637
Quoted 10 lines
drivers/iommu/virtio-iommu.c +2
-1{int ret;struct viommu_domain *vdomain =to_viommu_domain (domain); +struct viommu_dev *viommu = vdev->viommu; vdomain->viommu = viommu; vdomain->map_flags = viommu->map_flags; - domain->pgsize_bitmap = viommu->pgsize_bitmap; +/* Devices in same domain must support same size pages */
AFAICS what the code appears to do is enforce that the first endpoint attached to any domain has the same pgsize_bitmap as the most recently probed viommu_dev instance, then ignore any subsequent endpoints attached to the same domain. Thus I'm not sure that comment is accurate.
Robin.
Quoted 52 lines
drivers/iommu/virtio-iommu.c +8
-1+if ((domain->pgsize_bitmap != viommu->pgsize_bitmap) && + (domain->pgsize_bitmap != vdev->pgsize_bitmap)) +return -EINVAL ; + + domain->pgsize_bitmap = vdev->pgsize_bitmap; + domain->geometry = viommu->geometry; ret = ida_alloc_range(&viommu->domain_ids, viommu->first_domain,@@ -657,7 +681,7 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev)* Properly initialize the domain now that we know which viommu * owns it. */ - ret =viommu_domain_finalise (vdev->viommu, domain); + ret =viommu_domain_finalise (vdev, domain); }else if (vdomain->viommu != vdev->viommu) {dev_err (dev,"cannot attach to foreign vIOMMU\n" ); ret = -EXDEV ;@@ -875,6 +899,7 @@ static int viommu_add_device(struct device *dev) vdev->dev = dev; vdev->viommu = viommu; + vdev->pgsize_bitmap = viommu->pgsize_bitmap;INIT_LIST_HEAD (&vdev->resv_regions); fwspec->iommu_priv = vdev;include/uapi/linux/virtio_iommu.h +7
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -119,6 +120,12 @@ struct virtio_iommu_probe_property {__le16 length; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +__u8 reserved[4 ]; +__u64 pgsize_bitmap; +}; +#define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0#define VIRTIO_IOMMU_RESV_MEM_T_MSI 1
Quoted 39 lines · Robin Murphy
Quoted 38 lines · Bharat Bhushan
Different endpoint can support different page size, probe endpoint if it supports specific page size otherwise use global page sizes.
Signed-off-by Bharat Bhushan <[email protected]>--- drivers/iommu/virtio-iommu.c | 33 +++++++++++++++++++++++++++---- include/uapi/linux/virtio_iommu.h | 7 +++++++ 2 files changed, 36 insertions(+), 4 deletions(-)drivers/iommu/virtio-iommu.c +15
-0@@ -78,6 +78,7 @@ struct viommu_endpoint {struct viommu_dev *viommu;struct viommu_domain *vdomain;struct list_head resv_regions; +u64 pgsize_bitmap; };struct viommu_request {@@ -415,6 +416,20 @@ static int viommu_replay_mappings(struct viommu_domain *vdomain)return ret; } +static int viommu_set_pgsize_bitmap (struct viommu_endpoint *vdev, +struct virtio_iommu_probe_pgsize_mask *mask, +size_t len) + +{ +u64 pgsize_bitmap =le64_to_cpu (mask->pgsize_bitmap); + +if (len <sizeof (*mask)) +return -EINVAL ; + + vdev->pgsize_bitmap = pgsize_bitmap; +return 0 ; +} +
Quoted 8 lines
drivers/iommu/virtio-iommu.c static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) · line 497
Quoted 8 lines
drivers/iommu/virtio-iommu.c +0
-1static int viommu_add_resv_mem (struct viommu_endpoint *vdev,struct virtio_iommu_probe_resv_mem *mem,size_t len)@@ -494,11 +509,13 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev)while (type !=VIRTIO_IOMMU_PROBE_T_NONE && cur < viommu->probe_size) { len =le16_to_cpu (prop->length) +sizeof (*prop); -
Whitespace change
Quoted 21 lines
Quoted 21 lines
drivers/iommu/virtio-iommu.c +5
-1switch (type) {case VIRTIO_IOMMU_PROBE_T_RESV_MEM : ret =viommu_add_resv_mem (vdev, (void *)prop, len);break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + ret =viommu_set_pgsize_bitmap (vdev, (void *)prop, len); +break ;default :dev_err (dev,"unknown viommu prop 0x%x\n" , type); }@@ -607,16 +624,23 @@ static struct iommu_domain *viommu_domain_alloc(unsigned type)return &vdomain->domain; } -static int viommu_domain_finalise (struct viommu_dev *viommu, +static int viommu_domain_finalise (struct viommu_endpoint *vdev,struct iommu_domain *domain) {int ret;struct viommu_domain *vdomain =to_viommu_domain (domain); +struct viommu_dev *viommu = vdev->viommu; vdomain->viommu = viommu;
Quoted 9 lines
drivers/iommu/virtio-iommu.c static struct iommu_domain *viommu_domain_alloc(unsigned type) · line 634
Quoted 3 lines
drivers/iommu/virtio-iommu.c +1
-1vdomain->map_flags = viommu->map_flags; - domain->pgsize_bitmap = viommu->pgsize_bitmap; +/* Devices in same domain must support same size pages */ AFAICS what the code appears to do is enforce that the first endpoint attached to any domain has the same
pgsize_bitmapas the most recently probedviommu_devinstance, then ignore any subsequent endpoints attached to the same domain. Thus I'm not sure that comment is accurate.
Yes viommu_domain_finalise() is only called once. What I had in mind is something like:
---- 8< ----
drivers/iommu/virtio-iommu.c +25 -4
@@ -639,6 +639,29 @@ static int viommu_domain_finalise(struct viommu_endpoint *vdev,return 0 ; } +/* +* Check whether the endpoint's capabilities are compatible with other endpoints +* in the domain. Report any inconsistency. +*/ +static bool viommu_endpoint_is_compatible (struct viommu_endpoint *vdev, +struct viommu_domain *vdomain) +{ +struct device *dev = vdev->dev; + +if (vdomain->viommu != vdev->viommu) { +dev_err (dev,"cannot attach to foreign vIOMMU\n" ); +return false; + } + +if (vdomain->domain.pgsize_bitmap != vdev->pgsize_bitmap) { +dev_err (dev,"incompatible domain bitmap 0x%lx != 0x%lx\n" , + vdomain->domain.pgsize_bitmap, vdev->pgsize_bitmap); +return false; + } + +return true; +} +static void viommu_domain_free (struct iommu_domain *domain) {struct viommu_domain *vdomain =to_viommu_domain (domain);
@@ -670,9 +693,8 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev)* owns it. */ ret =viommu_domain_finalise (vdev, domain); - }else if (vdomain->viommu != vdev->viommu) { -dev_err (dev,"cannot attach to foreign vIOMMU\n" ); - ret = -EXDEV ; + }else if (!viommu_endpoint_is_compatible (vdev, vdomain)) { + ret = -EINVAL ; }mutex_unlock (&vdomain->mutex); ---- >8 ----
Quoted 32 lines
Quoted 32 lines
drivers/iommu/virtio-iommu.c +8
-1+if ((domain->pgsize_bitmap != viommu->pgsize_bitmap) && + (domain->pgsize_bitmap != vdev->pgsize_bitmap)) +return -EINVAL ; + + domain->pgsize_bitmap = vdev->pgsize_bitmap; + domain->geometry = viommu->geometry; ret = ida_alloc_range(&viommu->domain_ids, viommu->first_domain,@@ -657,7 +681,7 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev)* Properly initialize the domain now that we know which viommu * owns it. */ - ret =viommu_domain_finalise (vdev->viommu, domain); + ret =viommu_domain_finalise (vdev, domain); }else if (vdomain->viommu != vdev->viommu) {dev_err (dev,"cannot attach to foreign vIOMMU\n" ); ret = -EXDEV ;@@ -875,6 +899,7 @@ static int viommu_add_device(struct device *dev) vdev->dev = dev; vdev->viommu = viommu; + vdev->pgsize_bitmap = viommu->pgsize_bitmap;INIT_LIST_HEAD (&vdev->resv_regions); fwspec->iommu_priv = vdev;include/uapi/linux/virtio_iommu.h +1
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2
Quoted 8 lines
include/uapi/linux/virtio_iommu.h struct virtio_iommu_probe_property { · line 125
Quoted 8 lines
include/uapi/linux/virtio_iommu.h +4
-0#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -119,6 +120,12 @@ struct virtio_iommu_probe_property {__le16 length; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +__u8 reserved[4 ]; +__u64 pgsize_bitmap;
Should be __le64
Thanks,
Jean
Quoted 5 lines
Quoted 5 lines
include/uapi/linux/virtio_iommu.h +2
-0+}; +#define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0#define VIRTIO_IOMMU_RESV_MEM_T_MSI 1
Quoted 101 lines
-----Original Message-----
From: Jean-Philippe Brucker <[email protected]>
Sent: Wednesday, April 1, 2020 9:20 PM
To: Robin Murphy <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; virtualization-cunTk1MwBs/[email protected] foundation.org; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [RFC PATCH v2] iommu/virtio: Use page size bitmap supported by
endpointExternal Email
----------------------------------------------------------------------
Quoted 10 lines · Robin Murphy
Quoted 9 lines · Bharat Bhushan
Different endpoint can support different page size, probe endpoint if it supports specific page size otherwise use global page sizes.
Signed-off-by Bharat Bhushan <[email protected]>--- drivers/iommu/virtio-iommu.c | 33 +++++++++++++++++++++++++++---- include/uapi/linux/virtio_iommu.h | 7 +++++++ 2 files changed, 36 insertions(+), 4 deletions(-)Quoted 13 lines
drivers/iommu/virtio-iommu.c static int viommu_replay_mappings(struct
Quoted 13 lines
(quoted diff) +0
-0
b/drivers/iommu/virtio-iommu.cindexcce329d71fba..c794cb5b7b3e100644drivers/iommu/virtio-iommu.c +1
-0@@ -78,6 +78,7 @@ struct viommu_endpoint {struct viommu_dev *viommu;struct viommu_domain *vdomain;struct list_head resv_regions; +u64 pgsize_bitmap; };struct viommu_request {@@ -415,6 +416,20 @@ static int viommu_replay_mappings(struct
viommu_domain*vdomain)Quoted 12 lines
Quoted 12 lines
drivers/iommu/virtio-iommu.c +10
-0return ret; } +static int viommu_set_pgsize_bitmap (struct viommu_endpoint *vdev, +struct virtio_iommu_probe_pgsize_mask *mask, +size_t len) + +{ +u64 pgsize_bitmap =le64_to_cpu (mask->pgsize_bitmap); + +if (len <sizeof (*mask)) +return -EINVAL ; +Quoted 8 lines
drivers/iommu/virtio-iommu.c static int viommu_probe_endpoint(struct
Quoted 8 lines
drivers/iommu/virtio-iommu.c +4
-0+ vdev->pgsize_bitmap = pgsize_bitmap; +return 0 ; +} +static int viommu_add_resv_mem (struct viommu_endpoint *vdev,struct virtio_iommu_probe_resv_mem *mem,size_t len)@@ -494,11 +509,13 @@ static int viommu_probe_endpoint(struct
viommu_dev*viommu, struct device *dev)Quoted 4 lines
drivers/iommu/virtio-iommu.c static int viommu_probe_endpoint(struct · line 497
Quoted 4 lines
drivers/iommu/virtio-iommu.c +0
-1while (type !=VIRTIO_IOMMU_PROBE_T_NONE && cur < viommu->probe_size) { len =le16_to_cpu (prop->length) +sizeof (*prop); -Whitespace change
Quoted 11 lines
drivers/iommu/virtio-iommu.c static struct iommu_domain
Quoted 11 lines
drivers/iommu/virtio-iommu.c +3
-0switch (type) {case VIRTIO_IOMMU_PROBE_T_RESV_MEM : ret =viommu_add_resv_mem (vdev, (void *)prop, len);break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + ret =viommu_set_pgsize_bitmap (vdev, (void *)prop, len); +break ;default :dev_err (dev,"unknown viommu prop 0x%x\n" , type); }@@ -607,16 +624,23 @@ static struct iommu_domain*viommu_domain_alloc(unsigned type)
Quoted 10 lines
Quoted 10 lines
drivers/iommu/virtio-iommu.c +2
-1return &vdomain->domain; } -static int viommu_domain_finalise (struct viommu_dev *viommu, +static int viommu_domain_finalise (struct viommu_endpoint *vdev,struct iommu_domain *domain) {int ret;struct viommu_domain *vdomain =to_viommu_domain (domain); +struct viommu_dev *viommu = vdev->viommu; vdomain->viommu = viommu;Quoted 9 lines
drivers/iommu/virtio-iommu.c static struct iommu_domain · line 634
Quoted 3 lines
drivers/iommu/virtio-iommu.c +1
-1vdomain->map_flags = viommu->map_flags; - domain->pgsize_bitmap = viommu->pgsize_bitmap; +/* Devices in same domain must support same size pages */ AFAICS what the code appears to do is enforce that the first endpoint attached to any domain has the same
pgsize_bitmapas the most recently probedviommu_devinstance, then ignore any subsequent endpoints attached to the same domain. Thus I'm not sure that comment is accurate.
Quoted 2 lines
Yes
viommu_domain_finalise()is only called once. What I had in mind is something like:
Ohh, I did not realized that viommu_domain_finalise(). I have included below suggested changes
Quoted 87 lines
---- 8< ----
drivers/iommu/virtio-iommu.c index renamed from drivers/iommu/virtio-iommu.c +0
-0
750f69c49b95..8303b7b513ff100644drivers/iommu/virtio-iommu.c +24
-0@@ -639,6 +639,29 @@ static int viommu_domain_finalise(structviommu_endpoint *vdev, return 0; } +/* +* Check whether the endpoint's capabilities are compatible with other +endpoints +* in the domain. Report any inconsistency. +*/ +static bool viommu_endpoint_is_compatible (struct viommu_endpoint *vdev, +struct viommu_domain *vdomain) +{ +struct device *dev = vdev->dev; + +if (vdomain->viommu != vdev->viommu) { +dev_err (dev,"cannot attach to foreign vIOMMU\n" ); +return false; + } + +if (vdomain->domain.pgsize_bitmap != vdev->pgsize_bitmap) { +dev_err (dev,"incompatible domain bitmap 0x%lx != 0x%lx\n" , + vdomain->domain.pgsize_bitmap, vdev->pgsize_bitmap); +return false; + } + +return true; +} +static void viommu_domain_free (struct iommu_domain *domain) { struct viommu_domain *vdomain = to_viommu_domain(domain); @@ -670,9 +693,8 @@ static int
viommu_attach_dev(struct iommu_domain *domain, struct device *dev)drivers/iommu/virtio-iommu.c +2
-4* owns it. */ ret =viommu_domain_finalise (vdev, domain); - }else if (vdomain->viommu != vdev->viommu) { -dev_err (dev,"cannot attach to foreign vIOMMU\n" ); - ret = -EXDEV ; + }else if (!viommu_endpoint_is_compatible (vdev, vdomain)) { + ret = -EINVAL ; }mutex_unlock (&vdomain->mutex); ---- >8 ----Quoted 11 lines
drivers/iommu/virtio-iommu.c static int viommu_attach_dev(struct iommu_domain
Quoted 11 lines
drivers/iommu/virtio-iommu.c +6
-0+if ((domain->pgsize_bitmap != viommu->pgsize_bitmap) && + (domain->pgsize_bitmap != vdev->pgsize_bitmap)) +return -EINVAL ; + + domain->pgsize_bitmap = vdev->pgsize_bitmap; + domain->geometry = viommu->geometry; ret = ida_alloc_range(&viommu->domain_ids, viommu->first_domain,@@ -657,7 +681,7 @@ static int viommu_attach_dev(struct iommu_domain*domain, struct device *dev)
Quoted 25 lines
Quoted 25 lines
drivers/iommu/virtio-iommu.c +2
-1* Properly initialize the domain now that we know which viommu * owns it. */ - ret =viommu_domain_finalise (vdev->viommu, domain); + ret =viommu_domain_finalise (vdev, domain); }else if (vdomain->viommu != vdev->viommu) {dev_err (dev,"cannot attach to foreign vIOMMU\n" ); ret = -EXDEV ;@@ -875,6 +899,7 @@ static int viommu_add_device(struct device *dev) vdev->dev = dev; vdev->viommu = viommu; + vdev->pgsize_bitmap = viommu->pgsize_bitmap;INIT_LIST_HEAD (&vdev->resv_regions); fwspec->iommu_priv = vdev;include/uapi/linux/virtio_iommu.h +1
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -119,6 +120,12 @@ struct virtio_iommu_probe_property {
Quoted 8 lines
Quoted 6 lines
include/uapi/linux/virtio_iommu.h struct virtio_iommu_probe_property { · line 125
Quoted 6 lines
include/uapi/linux/virtio_iommu.h +4
-0__le16 length; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +__u8 reserved[4 ]; +__u64 pgsize_bitmap;Should be
__le64
Based on" iommu/virtio: Fix sparse warning" patch https://www.spinics.net/lists/linux-virtualization/msg41944.html changed to __u64 (not __le64)
Will keep __le64.
Thanks
-Bharat
Quoted 9 lines
Thanks,
JeanQuoted 5 lines
Quoted 5 lines
include/uapi/linux/virtio_iommu.h +2
-0+}; +#define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0#define VIRTIO_IOMMU_RESV_MEM_T_MSI 1
Quoted 8 lines · Bharat Bhushan
Quoted 6 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+struct virtio_iommu_probe_pgsize_mask { + struct virtio_iommu_probe_property head; + __u8 reserved[4]; + __u64 pgsize_bitmap;Should be
__le64Based on" iommu/virtio: Fix sparse warning" patch https://www.spinics.net/lists/linux-virtualization/msg41944.html changed to
__u64(not__le64)
Yes that one was only for the virtio config struct, to play nice with other devices. We should still use __le for the other structures, including probe properties.
Thanks,
Jean
Quoted 15 lines
Will keep
__le64.Thanks
-BharatQuoted 9 lines
Thanks,
JeanQuoted 5 lines
Quoted 5 lines
(quoted diff) +2
-0+}; + #define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0 #define VIRTIO_IOMMU_RESV_MEM_T_MSI 1