Add a vendor specific structure for domain nesting info for
arm smmu-v3, and necessary info fields required to populate
stage1 page tables.
Signed-off-by: Vivek Gautam <redacted>
---
include/uapi/linux/iommu.h | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
@@ -409,6 +410,21 @@ struct iommu_nesting_info_vtd {__u64ecap_reg;};+/*+*structiommu_nesting_info_arm_smmuv3-ArmSMMU-v3nestinginfo.+*/+structiommu_nesting_info_arm_smmuv3{+__u32flags;+__u16asid_bits;++/* Arm LPAE page table format as per kernel */+#define ARM_PGTBL_32_LPAE_S1 (0x0)+#define ARM_PGTBL_64_LPAE_S1 (0x2)+__u8pgtbl_fmt;++__u8padding[9];+};+/**structiommu_nesting_info-Informationfornesting-capableIOMMU.*userspaceshouldcheckitbeforeusing
@@ -2555,6 +2555,7 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,void*data){structiommu_nesting_info*info=(structiommu_nesting_info*)data;+structarm_smmu_device*smmu=smmu_domain->smmu;unsignedintsize;if(!info||smmu_domain->stage!=ARM_SMMU_DOMAIN_NESTED)
@@ -2571,9 +2572,20 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,return0;}-/* report an empty iommu_nesting_info for now */-memset(info,0x0,size);+/* Update the nesting info as required for stage1 page tables */+info->addr_width=smmu->ias;+info->format=IOMMU_PASID_FORMAT_ARM_SMMU_V3;+info->features=IOMMU_NESTING_FEAT_BIND_PGTBL|+IOMMU_NESTING_FEAT_PAGE_RESP|+IOMMU_NESTING_FEAT_CACHE_INVLD;+info->pasid_bits=smmu->ssid_bits;+info->vendor.smmuv3.asid_bits=smmu->asid_bits;+info->vendor.smmuv3.pgtbl_fmt=ARM_64_LPAE_S1;+memset(&info->padding,0x0,12);+memset(&info->vendor.smmuv3.padding,0x0,9);+info->argsz=size;+return0;}
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Auger Eric <eric.auger@redhat.com> Date: 2021-02-12 18:15:33
Hi Vivek,
On 2/12/21 11:58 AM, Vivek Gautam wrote:
quoted hunk
Add a vendor specific structure for domain nesting info for
arm smmu-v3, and necessary info fields required to populate
stage1 page tables.
Signed-off-by: Vivek Gautam <redacted>
---
include/uapi/linux/iommu.h | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
@@ -409,6 +410,21 @@ struct iommu_nesting_info_vtd {__u64ecap_reg;};+/*+*structiommu_nesting_info_arm_smmuv3-ArmSMMU-v3nestinginfo.+*/+structiommu_nesting_info_arm_smmuv3{+__u32flags;+__u16asid_bits;++/* Arm LPAE page table format as per kernel */+#define ARM_PGTBL_32_LPAE_S1 (0x0)+#define ARM_PGTBL_64_LPAE_S1 (0x2)
Shouldn't it be a bitfield instead as both can be supported (the actual
driver only supports 64b table format though). Does it match matches
IDR0.TTF?
+ __u8 pgtbl_fmt;
So I understand this API is supposed to allow VFIO to expose those info
early enough to the userspace to help configuring the viommu and avoid
errors later on. I wonder how far we want to go on this path. What about
those other caps that impact the STE/CD validity. There may be others...
SMMU_IDR0.CD2L (support of 2 stage CD)
SMMU_IDR0.TTENDIAN (endianness)
SMMU_IDR0.HTTU (if 0 forbids HA/HD setting in the CD)
SMMU_IDR3.STT (impacts T0SZ)
Thanks
Eric
quoted hunk
+
+ __u8 padding[9];
+};
+
/*
* struct iommu_nesting_info - Information for nesting-capable IOMMU.
* userspace should check it before using
@@ -2555,6 +2555,7 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,void*data){structiommu_nesting_info*info=(structiommu_nesting_info*)data;+structarm_smmu_device*smmu=smmu_domain->smmu;unsignedintsize;if(!info||smmu_domain->stage!=ARM_SMMU_DOMAIN_NESTED)
@@ -2571,9 +2572,20 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,return0;}-/* report an empty iommu_nesting_info for now */-memset(info,0x0,size);+/* Update the nesting info as required for stage1 page tables */+info->addr_width=smmu->ias;+info->format=IOMMU_PASID_FORMAT_ARM_SMMU_V3;+info->features=IOMMU_NESTING_FEAT_BIND_PGTBL|
I understood IOMMU_NESTING_FEAT_BIND_PGTBL advertises the requirement to
bind tables per PASID, ie. passing iommu_gpasid_bind_data.
In ARM case I guess you plan to use attach/detach_pasid_table API with
iommu_pasid_table_config struct. So I understood we should add a new
feature here.
@@ -2555,6 +2555,7 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,void*data){structiommu_nesting_info*info=(structiommu_nesting_info*)data;+structarm_smmu_device*smmu=smmu_domain->smmu;unsignedintsize;if(!info||smmu_domain->stage!=ARM_SMMU_DOMAIN_NESTED)
@@ -2571,9 +2572,20 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,return0;}-/* report an empty iommu_nesting_info for now */-memset(info,0x0,size);+/* Update the nesting info as required for stage1 page tables */+info->addr_width=smmu->ias;+info->format=IOMMU_PASID_FORMAT_ARM_SMMU_V3;+info->features=IOMMU_NESTING_FEAT_BIND_PGTBL|+IOMMU_NESTING_FEAT_PAGE_RESP|
IOMMU_NESTING_FEAT_PAGE_RESP definition is missing too
Eric
@@ -2555,6 +2555,7 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,void*data){structiommu_nesting_info*info=(structiommu_nesting_info*)data;+structarm_smmu_device*smmu=smmu_domain->smmu;unsignedintsize;if(!info||smmu_domain->stage!=ARM_SMMU_DOMAIN_NESTED)
@@ -2571,9 +2572,20 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,return0;}-/* report an empty iommu_nesting_info for now */-memset(info,0x0,size);+/* Update the nesting info as required for stage1 page tables */+info->addr_width=smmu->ias;+info->format=IOMMU_PASID_FORMAT_ARM_SMMU_V3;+info->features=IOMMU_NESTING_FEAT_BIND_PGTBL|
I understood IOMMU_NESTING_FEAT_BIND_PGTBL advertises the requirement to
bind tables per PASID, ie. passing iommu_gpasid_bind_data.
In ARM case I guess you plan to use attach/detach_pasid_table API with
iommu_pasid_table_config struct. So I understood we should add a new
feature here.
Right, the idea is to let vfio know that we support pasid table binding, and
I thought we could use the same flag. But clearly that's not the case.
Will add a new feature.
Hi Vivek,
On 2/12/21 11:58 AM, Vivek Gautam wrote:
quoted
Add a vendor specific structure for domain nesting info for
arm smmu-v3, and necessary info fields required to populate
stage1 page tables.
Signed-off-by: Vivek Gautam <redacted>
---
include/uapi/linux/iommu.h | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
@@ -409,6 +410,21 @@ struct iommu_nesting_info_vtd {__u64ecap_reg;};+/*+*structiommu_nesting_info_arm_smmuv3-ArmSMMU-v3nestinginfo.+*/+structiommu_nesting_info_arm_smmuv3{+__u32flags;+__u16asid_bits;++/* Arm LPAE page table format as per kernel */+#define ARM_PGTBL_32_LPAE_S1 (0x0)+#define ARM_PGTBL_64_LPAE_S1 (0x2)
Thanks for reviewing and I am terribly sorry for coming to it with delay.
Shouldn't it be a bitfield instead as both can be supported (the actual
driver only supports 64b table format though). Does it match matches
IDR0.TTF?
Yes, it should be a bitfield rather, and it doesn't match with IDR0.TTF.
This is
to hint the stage1 table allocations from viommu.
Please see viommu_setup_pgtable() in the patch at [1].
quoted
+ __u8 pgtbl_fmt;
So I understand this API is supposed to allow VFIO to expose those info
early enough to the userspace to help configuring the viommu and avoid
errors later on. I wonder how far we want to go on this path. What about
those other caps that impact the STE/CD validity. There may be others...
SMMU_IDR0.CD2L (support of 2 stage CD)
SMMU_IDR0.TTENDIAN (endianness)
SMMU_IDR0.HTTU (if 0 forbids HA/HD setting in the CD)
SMMU_IDR3.STT (impacts T0SZ)
Right. The idea was to start with a minimal set of configuration.
But as you rightly pointed out we need a scalable solution to this problem
for arm-smmu-v3. I am now thinking if we could even use the nesting_info
for arm. We don't want to end up adding flags for all the feature bits.
Let me know if you have any suggestions.
Best regards
Vivek
[1]
https://lore.kernel.org/linux-arm-kernel/20210115121342.15093-14-vivek.gautam@arm.com/
[snip]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
@@ -2555,6 +2555,7 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,void*data){structiommu_nesting_info*info=(structiommu_nesting_info*)data;+structarm_smmu_device*smmu=smmu_domain->smmu;unsignedintsize;if(!info||smmu_domain->stage!=ARM_SMMU_DOMAIN_NESTED)
@@ -2571,9 +2572,20 @@ static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain,return0;}-/* report an empty iommu_nesting_info for now */-memset(info,0x0,size);+/* Update the nesting info as required for stage1 page tables */+info->addr_width=smmu->ias;+info->format=IOMMU_PASID_FORMAT_ARM_SMMU_V3;+info->features=IOMMU_NESTING_FEAT_BIND_PGTBL|
I understood IOMMU_NESTING_FEAT_BIND_PGTBL advertises the requirement to
bind tables per PASID, ie. passing iommu_gpasid_bind_data.
In ARM case I guess you plan to use attach/detach_pasid_table API with
iommu_pasid_table_config struct. So I understood we should add a new
feature here.
Right, the idea is to let vfio know that we support pasid table binding, and
I thought we could use the same flag. But clearly that's not the case.
I will add a new feature.