xen/arm: domain_build: Don't expose IOMMU specific properties to hwdom
PATCH v2 1/1 xen/arm: domain_build: Don't expose IOMMU specific properties to hwdom
From: Oleksandr Tyshchenko <[email protected]>
We don't passthrough IOMMU device to hwdom even if it is not used by Xen. Therefore exposing the properties that describe relationship between master devices and IOMMUs does not make any sense.
According to the:
1. Documentation/devicetree/bindings/iommu/iommu.txt
2. Documentation/devicetree/bindings/pci/pci-iommu.txt
---
Changes V1 [1] -> V2:
- Only skip IOMMU specific properties of the master device if we skip the corresponding IOMMU device
- Use "hwdom" over "Dom0"
[1] https://lists.xenproject.org/archives/html/xen-devel/2019-10/msg00104.html
--- xen/arch/arm/domain_build.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
xen/arch/arm/domain_build.c +29 -0
@@ -480,10 +480,26 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,const struct dt_property *prop, *status =NULL ;int res =0 ;int had_dom0_bootargs =0 ; +struct dt_device_node *iommu_node;if ( kinfo->cmdline && kinfo->cmdline[0 ] ) bootargs = &kinfo->cmdline[0 ]; +/* +* If we skip the IOMMU device when creating DT for hwdom (even if +* the IOMMU device is not used by Xen), we should also skip the IOMMU +* specific properties of the master device behind it in order to avoid +* exposing an half complete IOMMU bindings to hwdom. +* Use "iommu_node" as an indicator of the master device which properties +* should be skipped. +*/ + iommu_node =dt_parse_phandle (node,"iommus" ,0 ); +if ( iommu_node ) + { +if (device_get_class (iommu_node) !=DEVICE_IOMMU ) + iommu_node =NULL ; + } + dt_for_each_property_node (node, prop) {const void *prop_data = prop->value;
@@ -540,6 +556,19 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,continue ; } +if ( iommu_node ) + { +/* Don't expose IOMMU specific properties to hwdom */ +if (dt_property_name_is_equal (prop,"iommus" ) ) +continue ; + +if (dt_property_name_is_equal (prop,"iommu-map" ) ) +continue ; + +if (dt_property_name_is_equal (prop,"iommu-map-mask" ) ) +continue ; + } + res =fdt_property (kinfo->fdt, prop->name, prop_data, prop_len);if ( res )
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 9 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
We don't passthrough IOMMU device to hwdom even if it is not used by Xen. Therefore exposing the properties that describe relationship between master devices and IOMMUs does not make any sense.
According to the:
1.Documentation/devicetree/bindings/iommu/iommu.txt
2.Documentation/devicetree/bindings/pci/pci-iommu.txt
It is not entirely clear that documentation is from Linux.
Quoted 26 lines
Signed-off-by Oleksandr Tyshchenko <[email protected]>---
Changes V1 [1] -> V2:
- Only skip IOMMU specific properties of the master device if we skip the corresponding IOMMU device
- Use "hwdom" over "Dom0"[1] https://lists.xenproject.org/archives/html/xen-devel/2019-10/msg00104.html
--- xen/arch/arm/domain_build.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)xen/arch/arm/domain_build.c +1
-0@@ -480,10 +480,26 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,const struct dt_property *prop, *status =NULL ;int res =0 ;int had_dom0_bootargs =0 ; +struct dt_device_node *iommu_node;if ( kinfo->cmdline && kinfo->cmdline[0 ] ) bootargs = &kinfo->cmdline[0 ];
xen/arch/arm/domain_build.c static int __init write_properties(struct domain *d, struct kernel_info *kinfo, · line 496
Quoted 10 lines
xen/arch/arm/domain_build.c +9
-0+/* +* If we skip the IOMMU device when creating DT for hwdom (even if +* the IOMMU device is not used by Xen), we should also skip the IOMMU +* specific properties of the master device behind it in order to avoid +* exposing an half complete IOMMU bindings to hwdom. +* Use "iommu_node" as an indicator of the master device which properties +* should be skipped. +*/ + iommu_node =dt_parse_phandle (node,"iommus" ,0 );
The code is slightly confusing to read. I don't think we should care of invalid DT here, so let's only consider valid one.
For valid DT, any non-NULL return should point to an IOMMU. The comment above suggests that all IOMMU will be skipped. However, the check below (device_get_class(iommu_node)) will not return DEVICE_IOMMU when there are not have a driver for the IOMMU.
So this needs to be clarified in the commit message.
xen/arch/arm/domain_build.c static int __init write_properties(struct domain *d, struct kernel_info *kinfo, · line 501
Quoted 5 lines
xen/arch/arm/domain_build.c +5
-0+if ( iommu_node ) + { +if (device_get_class (iommu_node) !=DEVICE_IOMMU ) + iommu_node =NULL ; + }
Could we gather the two conditions in one if?
Quoted 15 lines
xen/arch/arm/domain_build.c +7
-0+ dt_for_each_property_node (node, prop) {const void *prop_data = prop->value;@@ -540,6 +556,19 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,continue ; } +if ( iommu_node ) + { +/* Don't expose IOMMU specific properties to hwdom */ +if (dt_property_name_is_equal (prop,"iommus" ) ) +continue ; +
xen/arch/arm/domain_build.c static int __init write_properties(struct domain *d, struct kernel_info *kinfo, · line 574
Quoted 10 lines
xen/arch/arm/domain_build.c +7
-0+if (dt_property_name_is_equal (prop,"iommu-map" ) ) +continue ; + +if (dt_property_name_is_equal (prop,"iommu-map-mask" ) ) +continue ; + } + res =fdt_property (kinfo->fdt, prop->name, prop_data, prop_len);if ( res )
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 1 line · Julien Grall
Hi,
Hi Julien
Quoted 8 lines · Oleksandr Tyshchenko
Quoted 6 lines
From: Oleksandr Tyshchenko <[email protected]>
We don't passthrough IOMMU device to hwdom even if it is not used by Xen. Therefore exposing the properties that describe relationship between master devices and IOMMUs does not make any sense.
Quoted 5 lines
Quoted 3 lines
According to the:
1.Documentation/devicetree/bindings/iommu/iommu.txt
2.Documentation/devicetree/bindings/pci/pci-iommu.txtIt is not entirely clear that documentation is from Linux.
Will clarify.
Quoted 33 lines
Quoted 33 lines
Signed-off-by Oleksandr Tyshchenko <[email protected]>---
Changes V1 [1] -> V2:
- Only skip IOMMU specific properties of the master device if we skip the corresponding IOMMU device
- Use "hwdom" over "Dom0"[1] https://lists.xenproject.org/archives/html/xen-devel/2019-10/msg00104.html
---
xen/arch/arm/domain_build.c| 29 +++++++++++++++++++++++++++++1 file changed, 29 insertions(+)xen/arch/arm/domain_build.c +1
-0@@ -480,10 +480,26 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo, const struct dt_property *prop, *status = NULL; int res = 0; int had_dom0_bootargs = 0; + struct dt_device_node *iommu_node; if ( kinfo->cmdline && kinfo->cmdline[0] ) bootargs = &kinfo->cmdline[0];+ /*
+ * If we skip the IOMMU device when creating DT for hwdom (even if + * the IOMMU device is not used by Xen), we should also skip the IOMMU
+ * specific properties of the master device behind it in order to avoid
Quoted 8 lines
Quoted 6 lines
+ * exposing an half complete IOMMU bindings to hwdom. + * Use "
iommu_node" as an indicator of the master device which properties
+ * should be skipped.
+ */
+iommu_node=dt_parse_phandle(node, "iommus", 0);The code is slightly confusing to read. I don't think we should care of invalid DT here, so let's only consider valid one.
Do you mean "the comment" is confusing to read?
Quoted 4 lines
For valid DT, any non-NULL return should point to an IOMMU. The comment above suggests that all IOMMU will be skipped. However, the check below (
device_get_class(iommu_node)) will not returnDEVICE_IOMMUwhen there are not have a driver for the IOMMU.So this needs to be clarified in the commit message.
Will do.
Quoted 8 lines
Quoted 6 lines
+ if (
iommu_node)
+ {
+ if (device_get_class(iommu_node)!=DEVICE_IOMMU) +iommu_node= NULL;
+ }Could we gather the two conditions in one if?
Yes.
Signature · 9 lines
Regards, Oleksandr Tyshchenko _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 67 lines · Oleksandr
Quoted 1 line · Julien Grall
Hi,
Hi Julien
Quoted 8 lines · Oleksandr Tyshchenko
Quoted 6 lines
From: Oleksandr Tyshchenko <[email protected]>
We don't passthrough IOMMU device to hwdom even if it is not used by Xen. Therefore exposing the properties that describe relationship between master devices and IOMMUs does not make any sense.
Quoted 5 lines
Quoted 3 lines
According to the:
1.Documentation/devicetree/bindings/iommu/iommu.txt
2.Documentation/devicetree/bindings/pci/pci-iommu.txtIt is not entirely clear that documentation is from Linux.
Will clarify.
Quoted 34 lines
Quoted 34 lines
Signed-off-by Oleksandr Tyshchenko <[email protected]>---
Changes V1 [1] -> V2:
- Only skip IOMMU specific properties of the master device if we skip the corresponding IOMMU device
- Use "hwdom" over "Dom0"[1] https://lists.xenproject.org/archives/html/xen-devel/2019-10/msg00104.html
---
xen/arch/arm/domain_build.c| 29 +++++++++++++++++++++++++++++1 file changed, 29 insertions(+)xen/arch/arm/domain_build.c +1
-0@@ -480,10 +480,26 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo, const struct dt_property *prop, *status = NULL; int res = 0; int had_dom0_bootargs = 0; + struct dt_device_node *iommu_node; if ( kinfo->cmdline && kinfo->cmdline[0] ) bootargs = &kinfo->cmdline[0];+ /*
+ * If we skip the IOMMU device when creating DT for hwdom (even if + * the IOMMU device is not used by Xen), we should also skip the IOMMU
+ * specific properties of the master device behind it in order to avoidQuoted 8 lines
Quoted 6 lines
+ * exposing an half complete IOMMU bindings to hwdom. + * Use "
iommu_node" as an indicator of the master device which properties
+ * should be skipped.
+ */
+iommu_node=dt_parse_phandle(node, "iommus", 0);The code is slightly confusing to read. I don't think we should care of invalid DT here, so let's only consider valid one.
Quoted 1 line
Do you mean "the comment" is confusing to read?
The code is confusing because "iommus" should always point to a IOMMU node, but then you check whether this is an IOMMU. So it is not clear if this is done for sanity check (or for a different reason).
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 1 line · Julien Grall
Hi,
Hi
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines
Quoted 24 lines
[1] https://lists.xenproject.org/archives/html/xen-devel/2019-10/msg00104.html
---
xen/arch/arm/domain_build.c| 29 +++++++++++++++++++++++++++++1 file changed, 29 insertions(+)xen/arch/arm/domain_build.c +1
-0@@ -480,10 +480,26 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo, const struct dt_property *prop, *status = NULL; int res = 0; int had_dom0_bootargs = 0; + struct dt_device_node *iommu_node; if ( kinfo->cmdline && kinfo->cmdline[0] ) bootargs = &kinfo->cmdline[0];+ /*
+ * If we skip the IOMMU device when creating DT for hwdom (even if
+ * the IOMMU device is not used by Xen), we should also skip the IOMMUQuoted 8 lines
+ * specific properties of the master device behind it in order to avoid
+ * exposing an half complete IOMMU bindings to hwdom. + * Use "iommu_node" as an indicator of the master device which properties
+ * should be skipped.
+ */
+iommu_node=dt_parse_phandle(node, "iommus", 0);The code is slightly confusing to read. I don't think we should care of invalid DT here, so let's only consider valid one.
Quoted 3 lines
Quoted 1 line
Do you mean "the comment" is confusing to read?
The code is confusing because "iommus" should always point to a IOMMU node, but then you check whether this is an IOMMU. So it is not clear if this is done for sanity check (or for a different reason).
Got it. Will clarify a reason.
Signature · 9 lines
Regards, Oleksandr Tyshchenko _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel