Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
v5 --> v6
- Addressed comments from Robin & Lorenzo.
: Moved iort_parse_rmr() to acpi_iort_init() from
iort_init_platform_devices().
: Removed use of struct iort_rmr_entry during the initial
parse. Using struct iommu_resv_region instead.
: Report RMR address alignment and overlap errors, but continue.
: Reworked arm_smmu_init_bypass_stes() (patch # 6).
- Updated SMMUv2 bypass SMR code. Thanks to Jon N (patch #8).
- Set IOMMU protection flags(IOMMU_CACHE, IOMMU_MMIO) based
on Type of RMR region. Suggested by Jon N.
Thanks,
Shameer
[0] https://developer.arm.com/documentation/den0049/latest/
[1] https://lore.kernel.org/linux-acpi/20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com/T/#m043c95b869973a834b2fd57f3e1ed0325c84f3b7
------
v4 --> v5
-Added a fw_data union to struct iommu_resv_region and removed
struct iommu_rmr (Based on comments from Joerg/Robin).
-Added iommu_put_rmrs() to release mem.
-Thanks to Steve for verifying on SMMUv2, but not added the Tested-by
yet because of the above changes.
v3 -->v4
-Included the SMMUv2 SMR bypass install changes suggested by
Steve(patch #7)
-As per Robin's comments, RMR reserve implementation is now
more generic (patch #8) and dropped v3 patches 8 and 10.
-Rebase to 5.13-rc1
RFC v2 --> v3
-Dropped RFC tag as the ACPICA header changes are now ready to be
part of 5.13[0]. But this series still has a dependency on that patch.
-Added IORT E.b related changes(node flags, _DSM function 5 checks for
PCIe).
-Changed RMR to stream id mapping from M:N to M:1 as per the spec and
discussion here[1].
-Last two patches add support for SMMUv2(Thanks to Jon Nettleton!)
------
Jon Nettleton (1):
iommu/arm-smmu: Get associated RMR info and install bypass SMR
Shameer Kolothum (8):
iommu: Introduce a union to struct iommu_resv_region
ACPI/IORT: Add support for RMR node parsing
iommu/dma: Introduce generic helper to retrieve RMR info
ACPI/IORT: Add a helper to retrieve RMR memory regions
iommu/arm-smmu-v3: Introduce strtab init helper
iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force
bypass
iommu/arm-smmu-v3: Get associated RMR info and install bypass STE
iommu/dma: Reserve any RMR regions associated with a dev
drivers/acpi/arm64/iort.c | 172 +++++++++++++++++++-
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 76 +++++++--
drivers/iommu/arm/arm-smmu/arm-smmu.c | 48 ++++++
drivers/iommu/dma-iommu.c | 89 +++++++++-
include/linux/acpi_iort.h | 7 +
include/linux/dma-iommu.h | 13 ++
include/linux/iommu.h | 11 ++
7 files changed, 393 insertions(+), 23 deletions(-)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
A union is introduced to struct iommu_resv_region to hold
any firmware specific data. This is in preparation to add
support for IORT RMR reserve regions and the union now holds
the RMR specific information.
Signed-off-by: Shameer Kolothum <redacted>
---
include/linux/iommu.h | 11 +++++++++++
1 file changed, 11 insertions(+)
Add support for parsing RMR node information from ACPI.
Find the associated streamid and smmu node info from the
RMR node and populate a linked list with RMR memory
descriptors.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/acpi/arm64/iort.c | 134 +++++++++++++++++++++++++++++++++++++-
1 file changed, 133 insertions(+), 1 deletion(-)
@@ -40,6 +40,8 @@ struct iort_fwnode {staticLIST_HEAD(iort_fwnode_list);staticDEFINE_SPINLOCK(iort_fwnode_lock);+staticLIST_HEAD(iort_rmr_list);/* list of RMR regions from ACPI */+/***iort_set_fwnode()-Createiort_fwnodeanduseittoregister*iommudataintheiort_fwnode_list
Reserved Memory Regions(RMR) associated with an IOMMU can be
described through ACPI IORT tables in systems with devices
that require a unity mapping or bypass for those
regions.
Introduce a generic interface so that IOMMU drivers can retrieve
and set up necessary mappings.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/iommu/dma-iommu.c | 29 +++++++++++++++++++++++++++++
include/linux/dma-iommu.h | 13 +++++++++++++
2 files changed, 42 insertions(+)
Add a helper function (iort_iommu_get_rmrs()) that retrieves RMR
memory descriptors associated with a given IOMMU. This will be used
by IOMMU drivers to setup necessary mappings.
Invoke it from the generic helper iommu_dma_get_rmrs().
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/acpi/arm64/iort.c | 38 ++++++++++++++++++++++++++++++++++++++
drivers/iommu/dma-iommu.c | 4 ++++
include/linux/acpi_iort.h | 7 +++++++
3 files changed, 49 insertions(+)
Introduce a helper to check the sid range and to init the l2 strtab
entries(bypass). This will be useful when we have to initialize the
l2 strtab with bypass for RMR SIDs.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 28 +++++++++++----------
1 file changed, 15 insertions(+), 13 deletions(-)
@@ -2518,6 +2518,19 @@ static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid)returnsid<limit;}+staticintarm_smmu_init_sid_strtab(structarm_smmu_device*smmu,u32sid)+{+/* Check the SIDs are in range of the SMMU and our stream table */+if(!arm_smmu_sid_in_range(smmu,sid))+return-ERANGE;++/* Ensure l2 strtab is initialised */+if(smmu->features&ARM_SMMU_FEAT_2_LVL_STRTAB)+returnarm_smmu_init_l2_strtab(smmu,sid);++return0;+}+staticintarm_smmu_insert_master(structarm_smmu_device*smmu,structarm_smmu_master*master){
@@ -2541,20 +2554,9 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,new_stream->id=sid;new_stream->master=master;-/*-*ChecktheSIDsareinrangeoftheSMMUandourstreamtable-*/-if(!arm_smmu_sid_in_range(smmu,sid)){-ret=-ERANGE;+ret=arm_smmu_init_sid_strtab(smmu,sid);+if(ret)break;-}--/* Ensure l2 strtab is initialised */-if(smmu->features&ARM_SMMU_FEAT_2_LVL_STRTAB){-ret=arm_smmu_init_l2_strtab(smmu,sid);-if(ret)-break;-}/* Insert into SID tree */new_node=&(smmu->streams.rb_node);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
By default, disable_bypass flag is set and any dev without
an iommu domain installs STE with CFG_ABORT during
arm_smmu_init_bypass_stes(). Introduce a "force" flag and
move the STE update logic to arm_smmu_init_bypass_stes()
so that we can force it to install CFG_BYPASS STE for specific
SIDs.
This will be useful in follow-up patch to install bypass
for IORT RMR SIDs.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
Check if there is any RMR info associated with the devices behind
the SMMUv3 and if any, install bypass STEs for them. This is to
keep any ongoing traffic associated with these devices alive
when we enable/reset SMMUv3 during probe().
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 31 +++++++++++++++++++++
1 file changed, 31 insertions(+)
@@ -3841,6 +3869,9 @@ static int arm_smmu_device_probe(struct platform_device *pdev)/* Record our private device structure */platform_set_drvdata(pdev,smmu);+/* Check for RMRs and install bypass STEs if any */+arm_smmu_rmr_install_bypass_ste(smmu);+/* Reset the device */ret=arm_smmu_device_reset(smmu,bypass);if(ret)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Jon Nettleton <redacted>
Check if there is any RMR info associated with the devices behind
the SMMU and if any, install bypass SMRs for them. This is to
keep any ongoing traffic associated with these devices alive
when we enable/reset SMMU during probe().
Signed-off-by: Jon Nettleton <redacted>
Signed-off-by: Steven Price <steven.price@arm.com>
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/iommu/arm/arm-smmu/arm-smmu.c | 48 +++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
@@ -2189,6 +2233,10 @@ static int arm_smmu_device_probe(struct platform_device *pdev)}platform_set_drvdata(pdev,smmu);++/* Check for RMRs and install bypass SMRs if any */+arm_smmu_rmr_install_bypass_smr(smmu);+arm_smmu_device_reset(smmu);arm_smmu_test_smr_masks(smmu);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Get ACPI IORT RMR regions associated with a dev reserved
so that there is a unity mapping for them in SMMU.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/iommu/dma-iommu.c | 56 +++++++++++++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 5 deletions(-)
@@ -207,22 +207,68 @@ void iommu_dma_put_rmrs(struct fwnode_handle *iommu_fwnode,}EXPORT_SYMBOL(iommu_dma_put_rmrs);+staticbooliommu_dma_dev_has_rmr(structiommu_fwspec*fwspec,+structiommu_resv_region*e)+{+inti;++for(i=0;i<fwspec->num_ids;i++){+if(e->fw_data.rmr.sid==fwspec->ids[i])+returntrue;+}++returnfalse;+}++staticvoidiommu_dma_get_rmr_resv_regions(structdevice*dev,+structlist_head*list)+{+structiommu_fwspec*fwspec=dev_iommu_fwspec_get(dev);+structlist_headrmr_list;+structiommu_resv_region*rmr,*tmp;++INIT_LIST_HEAD(&rmr_list);+if(iommu_dma_get_rmrs(fwspec->iommu_fwnode,&rmr_list))+return;++if(dev_is_pci(dev)){+structpci_dev*pdev=to_pci_dev(dev);+structpci_host_bridge*host=pci_find_host_bridge(pdev->bus);++if(!host->preserve_config)+return;+}++list_for_each_entry_safe(rmr,tmp,&rmr_list,list){+if(!iommu_dma_dev_has_rmr(fwspec,rmr))+continue;++/* Remove from iommu RMR list and add to dev resv_regions */+list_del_init(&rmr->list);+list_add_tail(&rmr->list,list);+}++iommu_dma_put_rmrs(fwspec->iommu_fwnode,&rmr_list);+}+/***iommu_dma_get_resv_regions-Reservedregiondriverhelper*@dev:Devicefromiommu_get_resv_regions()*@list:Reservedregionlistfromiommu_get_resv_regions()**IOMMUdriverscanusethistoimplementtheir.get_resv_regionscallback-*forgeneralnon-IOMMU-specificreservations.Currently,thiscoversGICv3-*ITSregionreservationonACPIbasedARMplatformsthatmayrequireHWMSI-*reservation.+*forgeneralnon-IOMMU-specificreservations.Currentlythiscovers,+*-GICv3ITSregionreservationonACPIbasedARMplatformsthatmay+*requireHWMSIreservation.+*-AnyACPIIORTRMRmemoryrangereservations(IORTspecrevE.b)*/voidiommu_dma_get_resv_regions(structdevice*dev,structlist_head*list){-if(!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode))+if(!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode)){iort_iommu_msi_get_resv_regions(dev,list);-+iommu_dma_get_rmr_resv_regions(dev,list);+}}EXPORT_SYMBOL(iommu_dma_get_resv_regions);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, 5 Aug 2021 at 10:10, Shameer Kolothum
[off-list ref] wrote:
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Does this mean we are ignoring the RMR memory ranges, and exposing the
entire physical address space to devices using the stream IDs in
question?
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
v5 --> v6
- Addressed comments from Robin & Lorenzo.
: Moved iort_parse_rmr() to acpi_iort_init() from
iort_init_platform_devices().
: Removed use of struct iort_rmr_entry during the initial
parse. Using struct iommu_resv_region instead.
: Report RMR address alignment and overlap errors, but continue.
: Reworked arm_smmu_init_bypass_stes() (patch # 6).
- Updated SMMUv2 bypass SMR code. Thanks to Jon N (patch #8).
- Set IOMMU protection flags(IOMMU_CACHE, IOMMU_MMIO) based
on Type of RMR region. Suggested by Jon N.
Thanks,
Shameer
[0] https://developer.arm.com/documentation/den0049/latest/
[1] https://lore.kernel.org/linux-acpi/20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com/T/#m043c95b869973a834b2fd57f3e1ed0325c84f3b7
------
v4 --> v5
-Added a fw_data union to struct iommu_resv_region and removed
struct iommu_rmr (Based on comments from Joerg/Robin).
-Added iommu_put_rmrs() to release mem.
-Thanks to Steve for verifying on SMMUv2, but not added the Tested-by
yet because of the above changes.
v3 -->v4
-Included the SMMUv2 SMR bypass install changes suggested by
Steve(patch #7)
-As per Robin's comments, RMR reserve implementation is now
more generic (patch #8) and dropped v3 patches 8 and 10.
-Rebase to 5.13-rc1
RFC v2 --> v3
-Dropped RFC tag as the ACPICA header changes are now ready to be
part of 5.13[0]. But this series still has a dependency on that patch.
-Added IORT E.b related changes(node flags, _DSM function 5 checks for
PCIe).
-Changed RMR to stream id mapping from M:N to M:1 as per the spec and
discussion here[1].
-Last two patches add support for SMMUv2(Thanks to Jon Nettleton!)
------
Jon Nettleton (1):
iommu/arm-smmu: Get associated RMR info and install bypass SMR
Shameer Kolothum (8):
iommu: Introduce a union to struct iommu_resv_region
ACPI/IORT: Add support for RMR node parsing
iommu/dma: Introduce generic helper to retrieve RMR info
ACPI/IORT: Add a helper to retrieve RMR memory regions
iommu/arm-smmu-v3: Introduce strtab init helper
iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force
bypass
iommu/arm-smmu-v3: Get associated RMR info and install bypass STE
iommu/dma: Reserve any RMR regions associated with a dev
drivers/acpi/arm64/iort.c | 172 +++++++++++++++++++-
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 76 +++++++--
drivers/iommu/arm/arm-smmu/arm-smmu.c | 48 ++++++
drivers/iommu/dma-iommu.c | 89 +++++++++-
include/linux/acpi_iort.h | 7 +
include/linux/dma-iommu.h | 13 ++
include/linux/iommu.h | 11 ++
7 files changed, 393 insertions(+), 23 deletions(-)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
-----Original Message-----
From: Ard Biesheuvel [mailto:ardb@kernel.org]
Sent: 05 August 2021 14:23
To: Shameerali Kolothum Thodi <redacted>
Cc: Linux ARM <redacted>; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Lorenzo Pieralisi [off-list ref]; Joerg Roedel
[off-list ref]; Robin Murphy [off-list ref]; Will Deacon
[off-list ref]; wanghuiqiang [off-list ref]; Guohanjun
(Hanjun Guo) [off-list ref]; Steven Price
[off-list ref]; Sami Mujawar [off-list ref]; Jon
Nettleton [off-list ref]; Eric Auger [off-list ref];
yangyicong [off-list ref]
Subject: Re: [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node
On Thu, 5 Aug 2021 at 10:10, Shameer Kolothum
[off-list ref] wrote:
quoted
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Does this mean we are ignoring the RMR memory ranges, and exposing the
entire physical address space to devices using the stream IDs in
question?
Nope. RMR node is used to describe the memory ranges used by end points
behind SMMU. And this information is used to create 1 : 1 mappings for those
ranges in SMMU. Anything outside those ranges will result in translation
fault(if there are no other dynamic DMA mappings).
Thanks,
Shameer
quoted
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
v5 --> v6
- Addressed comments from Robin & Lorenzo.
: Moved iort_parse_rmr() to acpi_iort_init() from
iort_init_platform_devices().
: Removed use of struct iort_rmr_entry during the initial
parse. Using struct iommu_resv_region instead.
: Report RMR address alignment and overlap errors, but continue.
: Reworked arm_smmu_init_bypass_stes() (patch # 6).
- Updated SMMUv2 bypass SMR code. Thanks to Jon N (patch #8).
- Set IOMMU protection flags(IOMMU_CACHE, IOMMU_MMIO) based
on Type of RMR region. Suggested by Jon N.
Thanks,
Shameer
[0] https://developer.arm.com/documentation/den0049/latest/
[1]
------
v4 --> v5
-Added a fw_data union to struct iommu_resv_region and removed
struct iommu_rmr (Based on comments from Joerg/Robin).
-Added iommu_put_rmrs() to release mem.
-Thanks to Steve for verifying on SMMUv2, but not added the Tested-by
yet because of the above changes.
v3 -->v4
-Included the SMMUv2 SMR bypass install changes suggested by
Steve(patch #7)
-As per Robin's comments, RMR reserve implementation is now
more generic (patch #8) and dropped v3 patches 8 and 10.
-Rebase to 5.13-rc1
RFC v2 --> v3
-Dropped RFC tag as the ACPICA header changes are now ready to be
part of 5.13[0]. But this series still has a dependency on that patch.
-Added IORT E.b related changes(node flags, _DSM function 5 checks for
PCIe).
-Changed RMR to stream id mapping from M:N to M:1 as per the spec and
discussion here[1].
-Last two patches add support for SMMUv2(Thanks to Jon Nettleton!)
------
Jon Nettleton (1):
iommu/arm-smmu: Get associated RMR info and install bypass SMR
Shameer Kolothum (8):
iommu: Introduce a union to struct iommu_resv_region
ACPI/IORT: Add support for RMR node parsing
iommu/dma: Introduce generic helper to retrieve RMR info
ACPI/IORT: Add a helper to retrieve RMR memory regions
iommu/arm-smmu-v3: Introduce strtab init helper
iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force
bypass
iommu/arm-smmu-v3: Get associated RMR info and install bypass STE
iommu/dma: Reserve any RMR regions associated with a dev
drivers/acpi/arm64/iort.c | 172
On Thu, 5 Aug 2021 at 15:35, Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
-----Original Message-----
From: Ard Biesheuvel [mailto:ardb@kernel.org]
Sent: 05 August 2021 14:23
To: Shameerali Kolothum Thodi <redacted>
Cc: Linux ARM <redacted>; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Lorenzo Pieralisi [off-list ref]; Joerg Roedel
[off-list ref]; Robin Murphy [off-list ref]; Will Deacon
[off-list ref]; wanghuiqiang [off-list ref]; Guohanjun
(Hanjun Guo) [off-list ref]; Steven Price
[off-list ref]; Sami Mujawar [off-list ref]; Jon
Nettleton [off-list ref]; Eric Auger [off-list ref];
yangyicong [off-list ref]
Subject: Re: [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node
On Thu, 5 Aug 2021 at 10:10, Shameer Kolothum
[off-list ref] wrote:
quoted
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Does this mean we are ignoring the RMR memory ranges, and exposing the
entire physical address space to devices using the stream IDs in
question?
Nope. RMR node is used to describe the memory ranges used by end points
behind SMMU. And this information is used to create 1 : 1 mappings for those
ranges in SMMU. Anything outside those ranges will result in translation
fault(if there are no other dynamic DMA mappings).
Excellent! It was not obvious to me from looking at the patches, so I
had to ask.
Thanks,
Ard.
quoted
quoted
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
v5 --> v6
- Addressed comments from Robin & Lorenzo.
: Moved iort_parse_rmr() to acpi_iort_init() from
iort_init_platform_devices().
: Removed use of struct iort_rmr_entry during the initial
parse. Using struct iommu_resv_region instead.
: Report RMR address alignment and overlap errors, but continue.
: Reworked arm_smmu_init_bypass_stes() (patch # 6).
- Updated SMMUv2 bypass SMR code. Thanks to Jon N (patch #8).
- Set IOMMU protection flags(IOMMU_CACHE, IOMMU_MMIO) based
on Type of RMR region. Suggested by Jon N.
Thanks,
Shameer
[0] https://developer.arm.com/documentation/den0049/latest/
[1]
------
v4 --> v5
-Added a fw_data union to struct iommu_resv_region and removed
struct iommu_rmr (Based on comments from Joerg/Robin).
-Added iommu_put_rmrs() to release mem.
-Thanks to Steve for verifying on SMMUv2, but not added the Tested-by
yet because of the above changes.
v3 -->v4
-Included the SMMUv2 SMR bypass install changes suggested by
Steve(patch #7)
-As per Robin's comments, RMR reserve implementation is now
more generic (patch #8) and dropped v3 patches 8 and 10.
-Rebase to 5.13-rc1
RFC v2 --> v3
-Dropped RFC tag as the ACPICA header changes are now ready to be
part of 5.13[0]. But this series still has a dependency on that patch.
-Added IORT E.b related changes(node flags, _DSM function 5 checks for
PCIe).
-Changed RMR to stream id mapping from M:N to M:1 as per the spec and
discussion here[1].
-Last two patches add support for SMMUv2(Thanks to Jon Nettleton!)
------
Jon Nettleton (1):
iommu/arm-smmu: Get associated RMR info and install bypass SMR
Shameer Kolothum (8):
iommu: Introduce a union to struct iommu_resv_region
ACPI/IORT: Add support for RMR node parsing
iommu/dma: Introduce generic helper to retrieve RMR info
ACPI/IORT: Add a helper to retrieve RMR memory regions
iommu/arm-smmu-v3: Introduce strtab init helper
iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force
bypass
iommu/arm-smmu-v3: Get associated RMR info and install bypass STE
iommu/dma: Reserve any RMR regions associated with a dev
drivers/acpi/arm64/iort.c | 172
From: Lorenzo Pieralisi <hidden> Date: 2021-08-05 15:45:39
On Thu, Aug 05, 2021 at 09:07:19AM +0100, Shameer Kolothum wrote:
Add a helper function (iort_iommu_get_rmrs()) that retrieves RMR
memory descriptors associated with a given IOMMU. This will be used
by IOMMU drivers to setup necessary mappings.
Invoke it from the generic helper iommu_dma_get_rmrs().
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/acpi/arm64/iort.c | 38 ++++++++++++++++++++++++++++++++++++++
drivers/iommu/dma-iommu.c | 4 ++++
include/linux/acpi_iort.h | 7 +++++++
3 files changed, 49 insertions(+)
From: Lorenzo Pieralisi <hidden> Date: 2021-08-05 16:05:06
On Thu, Aug 05, 2021 at 09:07:17AM +0100, Shameer Kolothum wrote:
[...]
+static void __init iort_node_get_rmr_info(struct acpi_iort_node *iort_node)
+{
+ struct acpi_iort_node *smmu;
+ struct acpi_iort_rmr *rmr;
+ struct acpi_iort_rmr_desc *rmr_desc;
+ u32 map_count = iort_node->mapping_count;
+ u32 sid;
+ int i;
+
+ if (!iort_node->mapping_offset || map_count != 1) {
+ pr_err(FW_BUG "Invalid ID mapping, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve associated smmu and stream id */
+ smmu = iort_node_get_id(iort_node, &sid, 0);
+ if (!smmu) {
+ pr_err(FW_BUG "Invalid SMMU reference, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve RMR data */
+ rmr = (struct acpi_iort_rmr *)iort_node->node_data;
+ if (!rmr->rmr_offset || !rmr->rmr_count) {
+ pr_err(FW_BUG "Invalid RMR descriptor array, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ rmr_desc = ACPI_ADD_PTR(struct acpi_iort_rmr_desc, iort_node,
+ rmr->rmr_offset);
+
+ iort_rmr_desc_check_overlap(rmr_desc, rmr->rmr_count);
+
+ for (i = 0; i < rmr->rmr_count; i++, rmr_desc++) {
+ struct iommu_resv_region *region;
+ enum iommu_resv_type type;
+ int prot = IOMMU_READ | IOMMU_WRITE;
+ u64 addr = rmr_desc->base_address, size = rmr_desc->length;
+
+ if (!IS_ALIGNED(addr, SZ_64K) || !IS_ALIGNED(size, SZ_64K)) {
+ /* PAGE align base addr and size */
+ addr &= PAGE_MASK;
+ size = PAGE_ALIGN(size + offset_in_page(rmr_desc->base_address));
+
+ pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]\n",
+ rmr_desc->base_address,
+ rmr_desc->base_address + rmr_desc->length - 1,
+ addr, addr + size - 1);
+ }
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
On the prot value assignment based on the remapping flag, I'd like to
hear Robin/Joerg's opinion, I'd avoid being in a situation where
"normally" this would work but then we have to quirk it.
Is this a valid assumption _always_ ?
Thanks,
Lorenzo
From: Jon Nettleton <hidden> Date: 2021-08-05 16:34:17
On Thu, Aug 5, 2021 at 6:03 PM Lorenzo Pieralisi
[off-list ref] wrote:
On Thu, Aug 05, 2021 at 09:07:17AM +0100, Shameer Kolothum wrote:
[...]
quoted
+static void __init iort_node_get_rmr_info(struct acpi_iort_node *iort_node)
+{
+ struct acpi_iort_node *smmu;
+ struct acpi_iort_rmr *rmr;
+ struct acpi_iort_rmr_desc *rmr_desc;
+ u32 map_count = iort_node->mapping_count;
+ u32 sid;
+ int i;
+
+ if (!iort_node->mapping_offset || map_count != 1) {
+ pr_err(FW_BUG "Invalid ID mapping, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve associated smmu and stream id */
+ smmu = iort_node_get_id(iort_node, &sid, 0);
+ if (!smmu) {
+ pr_err(FW_BUG "Invalid SMMU reference, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve RMR data */
+ rmr = (struct acpi_iort_rmr *)iort_node->node_data;
+ if (!rmr->rmr_offset || !rmr->rmr_count) {
+ pr_err(FW_BUG "Invalid RMR descriptor array, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ rmr_desc = ACPI_ADD_PTR(struct acpi_iort_rmr_desc, iort_node,
+ rmr->rmr_offset);
+
+ iort_rmr_desc_check_overlap(rmr_desc, rmr->rmr_count);
+
+ for (i = 0; i < rmr->rmr_count; i++, rmr_desc++) {
+ struct iommu_resv_region *region;
+ enum iommu_resv_type type;
+ int prot = IOMMU_READ | IOMMU_WRITE;
+ u64 addr = rmr_desc->base_address, size = rmr_desc->length;
+
+ if (!IS_ALIGNED(addr, SZ_64K) || !IS_ALIGNED(size, SZ_64K)) {
+ /* PAGE align base addr and size */
+ addr &= PAGE_MASK;
+ size = PAGE_ALIGN(size + offset_in_page(rmr_desc->base_address));
+
+ pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]\n",
+ rmr_desc->base_address,
+ rmr_desc->base_address + rmr_desc->length - 1,
+ addr, addr + size - 1);
+ }
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
On the prot value assignment based on the remapping flag, I'd like to
hear Robin/Joerg's opinion, I'd avoid being in a situation where
"normally" this would work but then we have to quirk it.
Is this a valid assumption _always_ ?
These assumptions were made based on the historic use cases I could
find reading the history. There aren't many known examples "in the wild"
because so far we haven't had a mechanism other than quirks based
around device-tree implementations.
Ultimately I believe the proper solution will need to be another flag
in the RMR table that specifies the type of memory an RMR Node
describes, not just the base and length.
-Jon
On Thu, Aug 05, 2021 at 09:07:17AM +0100, Shameer Kolothum wrote:
[...]
quoted
+static void __init iort_node_get_rmr_info(struct acpi_iort_node *iort_node)
+{
+ struct acpi_iort_node *smmu;
+ struct acpi_iort_rmr *rmr;
+ struct acpi_iort_rmr_desc *rmr_desc;
+ u32 map_count = iort_node->mapping_count;
+ u32 sid;
+ int i;
+
+ if (!iort_node->mapping_offset || map_count != 1) {
+ pr_err(FW_BUG "Invalid ID mapping, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve associated smmu and stream id */
+ smmu = iort_node_get_id(iort_node, &sid, 0);
+ if (!smmu) {
+ pr_err(FW_BUG "Invalid SMMU reference, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve RMR data */
+ rmr = (struct acpi_iort_rmr *)iort_node->node_data;
+ if (!rmr->rmr_offset || !rmr->rmr_count) {
+ pr_err(FW_BUG "Invalid RMR descriptor array, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ rmr_desc = ACPI_ADD_PTR(struct acpi_iort_rmr_desc, iort_node,
+ rmr->rmr_offset);
+
+ iort_rmr_desc_check_overlap(rmr_desc, rmr->rmr_count);
+
+ for (i = 0; i < rmr->rmr_count; i++, rmr_desc++) {
+ struct iommu_resv_region *region;
+ enum iommu_resv_type type;
+ int prot = IOMMU_READ | IOMMU_WRITE;
+ u64 addr = rmr_desc->base_address, size = rmr_desc->length;
+
+ if (!IS_ALIGNED(addr, SZ_64K) || !IS_ALIGNED(size, SZ_64K)) {
+ /* PAGE align base addr and size */
+ addr &= PAGE_MASK;
+ size = PAGE_ALIGN(size + offset_in_page(rmr_desc->base_address));
+
+ pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]\n",
+ rmr_desc->base_address,
+ rmr_desc->base_address + rmr_desc->length - 1,
+ addr, addr + size - 1);
+ }
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
On the prot value assignment based on the remapping flag, I'd like to
hear Robin/Joerg's opinion, I'd avoid being in a situation where
"normally" this would work but then we have to quirk it.
Is this a valid assumption _always_ ?
I think we enable quite a bit of platforms with this assumption, so IMHO
it's a fair compromise for now. As per Jon's comment and oob
discussions, in the long run the spec should probably be updated to
include a way of explicitly specifying memory attributes.
---
Thanks & Best Regards, Laurentiu
From: Steven Price <steven.price@arm.com> Date: 2021-08-20 10:24:49
On 05/08/2021 09:07, Shameer Kolothum wrote:
quoted hunk
A union is introduced to struct iommu_resv_region to hold
any firmware specific data. This is in preparation to add
support for IORT RMR reserve regions and the union now holds
the RMR specific information.
Signed-off-by: Shameer Kolothum <redacted>
---
include/linux/iommu.h | 11 +++++++++++
1 file changed, 11 insertions(+)
NIT: This will provoke a kernel-doc warning as the field name in the
structure is 'fw_data' not 'rmr' ('rmr being a field of the anonymous
union).
I've also retested this series on my Juno setup, so feel free to add:
Tested-by: Steven Price <steven.price@arm.com>
Thanks,
Steve
From: Jon Nettleton <hidden> Date: 2021-08-31 05:10:01
On Thu, Aug 5, 2021 at 4:09 PM Ard Biesheuvel [off-list ref] wrote:
On Thu, 5 Aug 2021 at 15:35, Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
quoted
-----Original Message-----
From: Ard Biesheuvel [mailto:ardb@kernel.org]
Sent: 05 August 2021 14:23
To: Shameerali Kolothum Thodi <redacted>
Cc: Linux ARM <redacted>; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Lorenzo Pieralisi [off-list ref]; Joerg Roedel
[off-list ref]; Robin Murphy [off-list ref]; Will Deacon
[off-list ref]; wanghuiqiang [off-list ref]; Guohanjun
(Hanjun Guo) [off-list ref]; Steven Price
[off-list ref]; Sami Mujawar [off-list ref]; Jon
Nettleton [off-list ref]; Eric Auger [off-list ref];
yangyicong [off-list ref]
Subject: Re: [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node
On Thu, 5 Aug 2021 at 10:10, Shameer Kolothum
[off-list ref] wrote:
quoted
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Does this mean we are ignoring the RMR memory ranges, and exposing the
entire physical address space to devices using the stream IDs in
question?
Nope. RMR node is used to describe the memory ranges used by end points
behind SMMU. And this information is used to create 1 : 1 mappings for those
ranges in SMMU. Anything outside those ranges will result in translation
fault(if there are no other dynamic DMA mappings).
Excellent! It was not obvious to me from looking at the patches, so I
had to ask.
Thanks,
Ard.
quoted
quoted
quoted
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
v5 --> v6
- Addressed comments from Robin & Lorenzo.
: Moved iort_parse_rmr() to acpi_iort_init() from
iort_init_platform_devices().
: Removed use of struct iort_rmr_entry during the initial
parse. Using struct iommu_resv_region instead.
: Report RMR address alignment and overlap errors, but continue.
: Reworked arm_smmu_init_bypass_stes() (patch # 6).
- Updated SMMUv2 bypass SMR code. Thanks to Jon N (patch #8).
- Set IOMMU protection flags(IOMMU_CACHE, IOMMU_MMIO) based
on Type of RMR region. Suggested by Jon N.
Thanks,
Shameer
[0] https://developer.arm.com/documentation/den0049/latest/
[1]
------
v4 --> v5
-Added a fw_data union to struct iommu_resv_region and removed
struct iommu_rmr (Based on comments from Joerg/Robin).
-Added iommu_put_rmrs() to release mem.
-Thanks to Steve for verifying on SMMUv2, but not added the Tested-by
yet because of the above changes.
v3 -->v4
-Included the SMMUv2 SMR bypass install changes suggested by
Steve(patch #7)
-As per Robin's comments, RMR reserve implementation is now
more generic (patch #8) and dropped v3 patches 8 and 10.
-Rebase to 5.13-rc1
RFC v2 --> v3
-Dropped RFC tag as the ACPICA header changes are now ready to be
part of 5.13[0]. But this series still has a dependency on that patch.
-Added IORT E.b related changes(node flags, _DSM function 5 checks for
PCIe).
-Changed RMR to stream id mapping from M:N to M:1 as per the spec and
discussion here[1].
-Last two patches add support for SMMUv2(Thanks to Jon Nettleton!)
------
Jon Nettleton (1):
iommu/arm-smmu: Get associated RMR info and install bypass SMR
Shameer Kolothum (8):
iommu: Introduce a union to struct iommu_resv_region
ACPI/IORT: Add support for RMR node parsing
iommu/dma: Introduce generic helper to retrieve RMR info
ACPI/IORT: Add a helper to retrieve RMR memory regions
iommu/arm-smmu-v3: Introduce strtab init helper
iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force
bypass
iommu/arm-smmu-v3: Get associated RMR info and install bypass STE
iommu/dma: Reserve any RMR regions associated with a dev
drivers/acpi/arm64/iort.c | 172
Ping, Can we get some movement on this patchset? The standard was
was ratified over a year ago, and there is real world hardware that is
using or needs this functionality.
Thanks,
-Jon
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-09-06 17:46:20
On 2021-08-05 17:03, Lorenzo Pieralisi wrote:
On Thu, Aug 05, 2021 at 09:07:17AM +0100, Shameer Kolothum wrote:
[...]
quoted
+static void __init iort_node_get_rmr_info(struct acpi_iort_node *iort_node)
+{
+ struct acpi_iort_node *smmu;
+ struct acpi_iort_rmr *rmr;
+ struct acpi_iort_rmr_desc *rmr_desc;
+ u32 map_count = iort_node->mapping_count;
+ u32 sid;
+ int i;
+
+ if (!iort_node->mapping_offset || map_count != 1) {
+ pr_err(FW_BUG "Invalid ID mapping, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve associated smmu and stream id */
+ smmu = iort_node_get_id(iort_node, &sid, 0);
+ if (!smmu) {
+ pr_err(FW_BUG "Invalid SMMU reference, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve RMR data */
+ rmr = (struct acpi_iort_rmr *)iort_node->node_data;
+ if (!rmr->rmr_offset || !rmr->rmr_count) {
+ pr_err(FW_BUG "Invalid RMR descriptor array, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ rmr_desc = ACPI_ADD_PTR(struct acpi_iort_rmr_desc, iort_node,
+ rmr->rmr_offset);
+
+ iort_rmr_desc_check_overlap(rmr_desc, rmr->rmr_count);
+
+ for (i = 0; i < rmr->rmr_count; i++, rmr_desc++) {
+ struct iommu_resv_region *region;
+ enum iommu_resv_type type;
+ int prot = IOMMU_READ | IOMMU_WRITE;
+ u64 addr = rmr_desc->base_address, size = rmr_desc->length;
+
+ if (!IS_ALIGNED(addr, SZ_64K) || !IS_ALIGNED(size, SZ_64K)) {
+ /* PAGE align base addr and size */
+ addr &= PAGE_MASK;
+ size = PAGE_ALIGN(size + offset_in_page(rmr_desc->base_address));
+
+ pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]\n",
+ rmr_desc->base_address,
+ rmr_desc->base_address + rmr_desc->length - 1,
+ addr, addr + size - 1);
+ }
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
On the prot value assignment based on the remapping flag, I'd like to
hear Robin/Joerg's opinion, I'd avoid being in a situation where
"normally" this would work but then we have to quirk it.
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the device's
_CCA attribute or how CPUs may be accessing a shared buffer could lead
to a loss of coherency. At worst, applying IOMMU_MMIO to a
device-private buffer *could* cause the device to lose coherency with
itself if the memory underlying the RMR may have allocated into system
caches. Note that the expected use for non-remappable RMRs is the device
holding some sort of long-lived private data in system RAM - the MSI
doorbell trick is far more of a niche hack really.
At the very least I think we need to refer to the device's memory access
properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map on your
firmware? I'm starting to think that as long as the underlying memory is
described appropriately there then we should be able to infer correct
attributes from the EFI memory type and flags.
Robin.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Jon Nettleton <hidden> Date: 2021-09-06 19:53:54
On Mon, Sep 6, 2021 at 7:44 PM Robin Murphy [off-list ref] wrote:
On 2021-08-05 17:03, Lorenzo Pieralisi wrote:
quoted
On Thu, Aug 05, 2021 at 09:07:17AM +0100, Shameer Kolothum wrote:
[...]
quoted
+static void __init iort_node_get_rmr_info(struct acpi_iort_node *iort_node)
+{
+ struct acpi_iort_node *smmu;
+ struct acpi_iort_rmr *rmr;
+ struct acpi_iort_rmr_desc *rmr_desc;
+ u32 map_count = iort_node->mapping_count;
+ u32 sid;
+ int i;
+
+ if (!iort_node->mapping_offset || map_count != 1) {
+ pr_err(FW_BUG "Invalid ID mapping, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve associated smmu and stream id */
+ smmu = iort_node_get_id(iort_node, &sid, 0);
+ if (!smmu) {
+ pr_err(FW_BUG "Invalid SMMU reference, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ /* Retrieve RMR data */
+ rmr = (struct acpi_iort_rmr *)iort_node->node_data;
+ if (!rmr->rmr_offset || !rmr->rmr_count) {
+ pr_err(FW_BUG "Invalid RMR descriptor array, skipping RMR node %p\n",
+ iort_node);
+ return;
+ }
+
+ rmr_desc = ACPI_ADD_PTR(struct acpi_iort_rmr_desc, iort_node,
+ rmr->rmr_offset);
+
+ iort_rmr_desc_check_overlap(rmr_desc, rmr->rmr_count);
+
+ for (i = 0; i < rmr->rmr_count; i++, rmr_desc++) {
+ struct iommu_resv_region *region;
+ enum iommu_resv_type type;
+ int prot = IOMMU_READ | IOMMU_WRITE;
+ u64 addr = rmr_desc->base_address, size = rmr_desc->length;
+
+ if (!IS_ALIGNED(addr, SZ_64K) || !IS_ALIGNED(size, SZ_64K)) {
+ /* PAGE align base addr and size */
+ addr &= PAGE_MASK;
+ size = PAGE_ALIGN(size + offset_in_page(rmr_desc->base_address));
+
+ pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]\n",
+ rmr_desc->base_address,
+ rmr_desc->base_address + rmr_desc->length - 1,
+ addr, addr + size - 1);
+ }
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
On the prot value assignment based on the remapping flag, I'd like to
hear Robin/Joerg's opinion, I'd avoid being in a situation where
"normally" this would work but then we have to quirk it.
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the device's
_CCA attribute or how CPUs may be accessing a shared buffer could lead
to a loss of coherency. At worst, applying IOMMU_MMIO to a
device-private buffer *could* cause the device to lose coherency with
itself if the memory underlying the RMR may have allocated into system
caches. Note that the expected use for non-remappable RMRs is the device
holding some sort of long-lived private data in system RAM - the MSI
doorbell trick is far more of a niche hack really.
At the very least I think we need to refer to the device's memory access
properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map on your
firmware? I'm starting to think that as long as the underlying memory is
described appropriately there then we should be able to infer correct
attributes from the EFI memory type and flags.
The devices are all cache coherent and marked as _CCA, 1. The Memory
regions are in the virt table as ARM_MEMORY_REGION_ATTRIBUTE_DEVICE.
The current chicken and egg problem we have is that during the fsl-mc-bus
initialization we call
error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT,
&mc_stream_id);
which gets deferred because the SMMU has not been initialized yet. Then we
initialize the RMR tables but there is no device reference there to be able to
query device properties, only the stream id. After the IORT tables are parsed
and the SMMU is setup, on the second device probe we associate everything
based on the stream id and the fsl-mc-bus device is able to claim its 1-1 DMA
mappings.
cat /sys/kernel/iommu_groups/0/reserved_regions
0x0000000001000000 0x0000000010ffffff direct-relaxable
0x0000000008000000 0x00000000080fffff msi
0x000000080c000000 0x000000081bffffff direct-relaxable
0x0000001c00000000 0x0000001c001fffff direct-relaxable
0x0000002080000000 0x000000209fffffff direct-relaxable
-Jon
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 06 September 2021 20:51
To: Robin Murphy <robin.murphy@arm.com>
Cc: Lorenzo Pieralisi <redacted>; Shameerali Kolothum Thodi
[off-list ref]; Laurentiu Tudor
[off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Joerg Roedel [off-list ref]; Will Deacon [off-list ref];
wanghuiqiang [off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref]; Sami
Mujawar [off-list ref]; Eric Auger [off-list ref];
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing
[...]
quoted
quoted
On the prot value assignment based on the remapping flag, I'd like
to hear Robin/Joerg's opinion, I'd avoid being in a situation where
"normally" this would work but then we have to quirk it.
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the device's
_CCA attribute or how CPUs may be accessing a shared buffer could lead
to a loss of coherency. At worst, applying IOMMU_MMIO to a
device-private buffer *could* cause the device to lose coherency with
itself if the memory underlying the RMR may have allocated into system
caches. Note that the expected use for non-remappable RMRs is the
device holding some sort of long-lived private data in system RAM -
the MSI doorbell trick is far more of a niche hack really.
At the very least I think we need to refer to the device's memory
access properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map on your
firmware? I'm starting to think that as long as the underlying memory
is described appropriately there then we should be able to infer
correct attributes from the EFI memory type and flags.
The devices are all cache coherent and marked as _CCA, 1. The Memory
regions are in the virt table as ARM_MEMORY_REGION_ATTRIBUTE_DEVICE.
The current chicken and egg problem we have is that during the fsl-mc-bus
initialization we call
error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT,
&mc_stream_id);
which gets deferred because the SMMU has not been initialized yet. Then we
initialize the RMR tables but there is no device reference there to be able to
query device properties, only the stream id. After the IORT tables are parsed
and the SMMU is setup, on the second device probe we associate everything
based on the stream id and the fsl-mc-bus device is able to claim its 1-1 DMA
mappings.
Can we solve this order problem by delaying the iommu_alloc_resv_region()
to the iommu_dma_get_rmr_resv_regions(dev, list) ? We could invoke
device_get_dma_attr() from there which I believe will return the _CCA attribute.
Or is that still early to invoke that?
Thanks,
Shameer
From: Jon Nettleton <hidden> Date: 2021-09-16 07:54:48
On Thu, Sep 16, 2021 at 9:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 06 September 2021 20:51
To: Robin Murphy <robin.murphy@arm.com>
Cc: Lorenzo Pieralisi <redacted>; Shameerali Kolothum Thodi
[off-list ref]; Laurentiu Tudor
[off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Joerg Roedel [off-list ref]; Will Deacon [off-list ref];
wanghuiqiang [off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref]; Sami
Mujawar [off-list ref]; Eric Auger [off-list ref];
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing
[...]
quoted
quoted
quoted
On the prot value assignment based on the remapping flag, I'd like
to hear Robin/Joerg's opinion, I'd avoid being in a situation where
"normally" this would work but then we have to quirk it.
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the device's
_CCA attribute or how CPUs may be accessing a shared buffer could lead
to a loss of coherency. At worst, applying IOMMU_MMIO to a
device-private buffer *could* cause the device to lose coherency with
itself if the memory underlying the RMR may have allocated into system
caches. Note that the expected use for non-remappable RMRs is the
device holding some sort of long-lived private data in system RAM -
the MSI doorbell trick is far more of a niche hack really.
At the very least I think we need to refer to the device's memory
access properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map on your
firmware? I'm starting to think that as long as the underlying memory
is described appropriately there then we should be able to infer
correct attributes from the EFI memory type and flags.
The devices are all cache coherent and marked as _CCA, 1. The Memory
regions are in the virt table as ARM_MEMORY_REGION_ATTRIBUTE_DEVICE.
The current chicken and egg problem we have is that during the fsl-mc-bus
initialization we call
error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT,
&mc_stream_id);
which gets deferred because the SMMU has not been initialized yet. Then we
initialize the RMR tables but there is no device reference there to be able to
query device properties, only the stream id. After the IORT tables are parsed
and the SMMU is setup, on the second device probe we associate everything
based on the stream id and the fsl-mc-bus device is able to claim its 1-1 DMA
mappings.
Can we solve this order problem by delaying the iommu_alloc_resv_region()
to the iommu_dma_get_rmr_resv_regions(dev, list) ? We could invoke
device_get_dma_attr() from there which I believe will return the _CCA attribute.
Or is that still early to invoke that?
That looks like it should work. Do we then also need to parse through the
VirtualMemoryTable matching the start and end addresses to determine the
other memory attributes like MMIO?
-Jon
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 16 September 2021 08:52
To: Shameerali Kolothum Thodi <redacted>
Cc: Robin Murphy <robin.murphy@arm.com>; Lorenzo Pieralisi
[off-list ref]; Laurentiu Tudor [off-list ref];
linux-arm-kernel [off-list ref]; ACPI Devel Maling
List [off-list ref]; Linux IOMMU
[off-list ref]; Joerg Roedel [off-list ref]; Will
Deacon [off-list ref]; wanghuiqiang [off-list ref];
Guohanjun (Hanjun Guo) [off-list ref]; Steven Price
[off-list ref]; Sami Mujawar [off-list ref]; Eric
Auger [off-list ref]; yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing
On Thu, Sep 16, 2021 at 9:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 06 September 2021 20:51
To: Robin Murphy <robin.murphy@arm.com>
Cc: Lorenzo Pieralisi <redacted>; Shameerali
Kolothum Thodi [off-list ref]; Laurentiu
Tudor [off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Joerg Roedel [off-list ref]; Will Deacon [off-list ref];
wanghuiqiang [off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref]; Sami
Mujawar [off-list ref]; Eric Auger
[off-list ref];
quoted
quoted
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node
parsing
[...]
quoted
quoted
quoted
On the prot value assignment based on the remapping flag, I'd
like to hear Robin/Joerg's opinion, I'd avoid being in a
situation where "normally" this would work but then we have to quirk
it.
quoted
quoted
quoted
quoted
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the
device's _CCA attribute or how CPUs may be accessing a shared
buffer could lead to a loss of coherency. At worst, applying
IOMMU_MMIO to a device-private buffer *could* cause the device to
lose coherency with itself if the memory underlying the RMR may
have allocated into system caches. Note that the expected use for
non-remappable RMRs is the device holding some sort of long-lived
private data in system RAM - the MSI doorbell trick is far more of a niche
hack really.
quoted
quoted
quoted
At the very least I think we need to refer to the device's memory
access properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map on
your firmware? I'm starting to think that as long as the
underlying memory is described appropriately there then we should
be able to infer correct attributes from the EFI memory type and flags.
The devices are all cache coherent and marked as _CCA, 1. The
Memory regions are in the virt table as
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE.
quoted
quoted
The current chicken and egg problem we have is that during the
fsl-mc-bus initialization we call
error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT,
&mc_stream_id);
which gets deferred because the SMMU has not been initialized yet.
Then we initialize the RMR tables but there is no device reference
there to be able to query device properties, only the stream id.
After the IORT tables are parsed and the SMMU is setup, on the
second device probe we associate everything based on the stream id
and the fsl-mc-bus device is able to claim its 1-1 DMA mappings.
Can we solve this order problem by delaying the
iommu_alloc_resv_region() to the iommu_dma_get_rmr_resv_regions(dev,
list) ? We could invoke
device_get_dma_attr() from there which I believe will return the _CCA
attribute.
quoted
Or is that still early to invoke that?
That looks like it should work. Do we then also need to parse through the
VirtualMemoryTable matching the start and end addresses to determine the
other memory attributes like MMIO?
Yes. But that looks tricky as I can't find that readily available on Arm, like the
efi_mem_attributes(). I will take a look.
Please let me know if there is one or any other easy way to retrieve it.
Thanks,
Shameer
From: Jon Nettleton <hidden> Date: 2021-09-16 11:19:35
On Thu, Sep 16, 2021 at 10:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 16 September 2021 08:52
To: Shameerali Kolothum Thodi <redacted>
Cc: Robin Murphy <robin.murphy@arm.com>; Lorenzo Pieralisi
[off-list ref]; Laurentiu Tudor [off-list ref];
linux-arm-kernel [off-list ref]; ACPI Devel Maling
List [off-list ref]; Linux IOMMU
[off-list ref]; Joerg Roedel [off-list ref]; Will
Deacon [off-list ref]; wanghuiqiang [off-list ref];
Guohanjun (Hanjun Guo) [off-list ref]; Steven Price
[off-list ref]; Sami Mujawar [off-list ref]; Eric
Auger [off-list ref]; yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing
On Thu, Sep 16, 2021 at 9:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 06 September 2021 20:51
To: Robin Murphy <robin.murphy@arm.com>
Cc: Lorenzo Pieralisi <redacted>; Shameerali
Kolothum Thodi [off-list ref]; Laurentiu
Tudor [off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Joerg Roedel [off-list ref]; Will Deacon [off-list ref];
wanghuiqiang [off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref]; Sami
Mujawar [off-list ref]; Eric Auger
[off-list ref];
quoted
quoted
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node
parsing
[...]
quoted
quoted
quoted
On the prot value assignment based on the remapping flag, I'd
like to hear Robin/Joerg's opinion, I'd avoid being in a
situation where "normally" this would work but then we have to quirk
it.
quoted
quoted
quoted
quoted
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the
device's _CCA attribute or how CPUs may be accessing a shared
buffer could lead to a loss of coherency. At worst, applying
IOMMU_MMIO to a device-private buffer *could* cause the device to
lose coherency with itself if the memory underlying the RMR may
have allocated into system caches. Note that the expected use for
non-remappable RMRs is the device holding some sort of long-lived
private data in system RAM - the MSI doorbell trick is far more of a niche
hack really.
quoted
quoted
quoted
At the very least I think we need to refer to the device's memory
access properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map on
your firmware? I'm starting to think that as long as the
underlying memory is described appropriately there then we should
be able to infer correct attributes from the EFI memory type and flags.
The devices are all cache coherent and marked as _CCA, 1. The
Memory regions are in the virt table as
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE.
quoted
quoted
The current chicken and egg problem we have is that during the
fsl-mc-bus initialization we call
error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT,
&mc_stream_id);
which gets deferred because the SMMU has not been initialized yet.
Then we initialize the RMR tables but there is no device reference
there to be able to query device properties, only the stream id.
After the IORT tables are parsed and the SMMU is setup, on the
second device probe we associate everything based on the stream id
and the fsl-mc-bus device is able to claim its 1-1 DMA mappings.
Can we solve this order problem by delaying the
iommu_alloc_resv_region() to the iommu_dma_get_rmr_resv_regions(dev,
list) ? We could invoke
device_get_dma_attr() from there which I believe will return the _CCA
attribute.
quoted
Or is that still early to invoke that?
That looks like it should work. Do we then also need to parse through the
VirtualMemoryTable matching the start and end addresses to determine the
other memory attributes like MMIO?
Yes. But that looks tricky as I can't find that readily available on Arm, like the
efi_mem_attributes(). I will take a look.
Please let me know if there is one or any other easy way to retrieve it.
maybe we don't need to. Maybe it is enough to just move
iommu_alloc_resv_regions and then set the IOMMU_CACHE flag
if type = IOMMU_RESV_DIRECT_RELAXABLE and _CCN=1?
-Jon
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 16 September 2021 12:17
To: Shameerali Kolothum Thodi <redacted>
Cc: Robin Murphy <robin.murphy@arm.com>; Lorenzo Pieralisi
[off-list ref]; Laurentiu Tudor [off-list ref];
linux-arm-kernel [off-list ref]; ACPI Devel Maling
List [off-list ref]; Linux IOMMU
[off-list ref]; Joerg Roedel [off-list ref]; Will
Deacon [off-list ref]; wanghuiqiang [off-list ref];
Guohanjun (Hanjun Guo) [off-list ref]; Steven Price
[off-list ref]; Sami Mujawar [off-list ref]; Eric
Auger [off-list ref]; yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing
On Thu, Sep 16, 2021 at 10:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 16 September 2021 08:52
To: Shameerali Kolothum Thodi
[off-list ref]
quoted
quoted
Cc: Robin Murphy <robin.murphy@arm.com>; Lorenzo Pieralisi
[off-list ref]; Laurentiu Tudor
[off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Joerg Roedel [off-list ref];
Will Deacon [off-list ref]; wanghuiqiang
[off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref]; Sami
Mujawar [off-list ref]; Eric Auger
[off-list ref];
quoted
quoted
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node
parsing
On Thu, Sep 16, 2021 at 9:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 06 September 2021 20:51
To: Robin Murphy <robin.murphy@arm.com>
Cc: Lorenzo Pieralisi <redacted>; Shameerali
Kolothum Thodi [off-list ref]; Laurentiu
Tudor [off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm
[off-list ref]; Joerg Roedel [off-list ref]; Will
Deacon [off-list ref]; wanghuiqiang
[off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref];
Sami Mujawar [off-list ref]; Eric Auger
[off-list ref];
quoted
quoted
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node
parsing
[...]
quoted
quoted
quoted
On the prot value assignment based on the remapping flag,
I'd like to hear Robin/Joerg's opinion, I'd avoid being in a
situation where "normally" this would work but then we have
to quirk
it.
quoted
quoted
quoted
quoted
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the
device's _CCA attribute or how CPUs may be accessing a shared
buffer could lead to a loss of coherency. At worst, applying
IOMMU_MMIO to a device-private buffer *could* cause the device
to lose coherency with itself if the memory underlying the RMR
may have allocated into system caches. Note that the expected
use for non-remappable RMRs is the device holding some sort of
long-lived private data in system RAM - the MSI doorbell trick
is far more of a niche
hack really.
quoted
quoted
quoted
At the very least I think we need to refer to the device's
memory access properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map
on your firmware? I'm starting to think that as long as the
underlying memory is described appropriately there then we
should be able to infer correct attributes from the EFI memory type
and flags.
quoted
quoted
quoted
quoted
The devices are all cache coherent and marked as _CCA, 1. The
Memory regions are in the virt table as
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE.
quoted
quoted
The current chicken and egg problem we have is that during the
fsl-mc-bus initialization we call
error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT,
&mc_stream_id);
which gets deferred because the SMMU has not been initialized yet.
Then we initialize the RMR tables but there is no device
reference there to be able to query device properties, only the stream
id.
quoted
quoted
quoted
quoted
After the IORT tables are parsed and the SMMU is setup, on the
second device probe we associate everything based on the stream
id and the fsl-mc-bus device is able to claim its 1-1 DMA mappings.
Can we solve this order problem by delaying the
iommu_alloc_resv_region() to the
iommu_dma_get_rmr_resv_regions(dev,
list) ? We could invoke
device_get_dma_attr() from there which I believe will return the
_CCA
attribute.
quoted
Or is that still early to invoke that?
That looks like it should work. Do we then also need to parse
through the VirtualMemoryTable matching the start and end addresses
to determine the other memory attributes like MMIO?
Yes. But that looks tricky as I can't find that readily available on
Arm, like the efi_mem_attributes(). I will take a look.
Please let me know if there is one or any other easy way to retrieve it.
maybe we don't need to. Maybe it is enough to just move
iommu_alloc_resv_regions and then set the IOMMU_CACHE flag if type =
IOMMU_RESV_DIRECT_RELAXABLE and _CCN=1?
It looks like we could simply call efi_mem_type() and check for
EFI_MEMORY_MAPPED_IO. I have updated the code to set the
RMR prot value based on _CCA and EFI md type. Please see the
last commit on this branch here(not tested),
https://github.com/hisilicon/kernel-dev/commits/private-v5.14-rc4-rmr-v7-ext
Please take a look and let me know if this is good enough to solve this problem.
Thanks,
Shameer
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Eric Auger <eric.auger@redhat.com> Date: 2021-09-30 09:49:36
Hi Shameer,
On 8/5/21 10:07 AM, Shameer Kolothum wrote:
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
I used your series and RMRs to force a guest iommu (vSMMUv3 nested stage
use case) to have a flat mapping for IOVAs within [0x8000000, 0x8100000]
(matching MSI_IOVA_BASE and MSI_IOVA_LENGTH) used by the host to map MSI
physical doorbells.
That way when an assigned device protected by a vSMMUv3 implemented upon
nested stage issues an MSI transaction, let's say using IOVA=0x8000000,
we would get:
S1 (guest) S2 (host)
0x8000000 0x8000000 Physical DB
This method was suggested by Jean-Philippe (added in CC) and it
simplifies the nested stage integration because we don't have to care
about nested stage MSI bindings.
However if I understand correctly we cannot define a range of SIDs using
the same RMR (due to the single mapping bit which must be set, Table 5
flags format). This is a spec restriction and not an issue with your series.
As VFIO devices can be hot-plugged we thus need to create as many RMR
nodes as potential BDFs, leading to 256 * 6 = 1536 RMR nodes if you have
5 pcie root ports as it is usual in VMs. Then this causes some trouble
at qemu level for instance, wrt migration. See [RFC]
hw/arm/virt-acpi-build: Add IORT RMR regions to handle MSI nested binding.
Do you know if there is a plan to remove the single mapping limitation
in the spec?
Thanks
Eric
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
v5 --> v6
- Addressed comments from Robin & Lorenzo.
: Moved iort_parse_rmr() to acpi_iort_init() from
iort_init_platform_devices().
: Removed use of struct iort_rmr_entry during the initial
parse. Using struct iommu_resv_region instead.
: Report RMR address alignment and overlap errors, but continue.
: Reworked arm_smmu_init_bypass_stes() (patch # 6).
- Updated SMMUv2 bypass SMR code. Thanks to Jon N (patch #8).
- Set IOMMU protection flags(IOMMU_CACHE, IOMMU_MMIO) based
on Type of RMR region. Suggested by Jon N.
Thanks,
Shameer
[0] https://developer.arm.com/documentation/den0049/latest/
[1] https://lore.kernel.org/linux-acpi/20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com/T/#m043c95b869973a834b2fd57f3e1ed0325c84f3b7
------
v4 --> v5
-Added a fw_data union to struct iommu_resv_region and removed
struct iommu_rmr (Based on comments from Joerg/Robin).
-Added iommu_put_rmrs() to release mem.
-Thanks to Steve for verifying on SMMUv2, but not added the Tested-by
yet because of the above changes.
v3 -->v4
-Included the SMMUv2 SMR bypass install changes suggested by
Steve(patch #7)
-As per Robin's comments, RMR reserve implementation is now
more generic (patch #8) and dropped v3 patches 8 and 10.
-Rebase to 5.13-rc1
RFC v2 --> v3
-Dropped RFC tag as the ACPICA header changes are now ready to be
part of 5.13[0]. But this series still has a dependency on that patch.
-Added IORT E.b related changes(node flags, _DSM function 5 checks for
PCIe).
-Changed RMR to stream id mapping from M:N to M:1 as per the spec and
discussion here[1].
-Last two patches add support for SMMUv2(Thanks to Jon Nettleton!)
------
Jon Nettleton (1):
iommu/arm-smmu: Get associated RMR info and install bypass SMR
Shameer Kolothum (8):
iommu: Introduce a union to struct iommu_resv_region
ACPI/IORT: Add support for RMR node parsing
iommu/dma: Introduce generic helper to retrieve RMR info
ACPI/IORT: Add a helper to retrieve RMR memory regions
iommu/arm-smmu-v3: Introduce strtab init helper
iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force
bypass
iommu/arm-smmu-v3: Get associated RMR info and install bypass STE
iommu/dma: Reserve any RMR regions associated with a dev
drivers/acpi/arm64/iort.c | 172 +++++++++++++++++++-
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 76 +++++++--
drivers/iommu/arm/arm-smmu/arm-smmu.c | 48 ++++++
drivers/iommu/dma-iommu.c | 89 +++++++++-
include/linux/acpi_iort.h | 7 +
include/linux/dma-iommu.h | 13 ++
include/linux/iommu.h | 11 ++
7 files changed, 393 insertions(+), 23 deletions(-)
-----Original Message-----
From: Eric Auger [mailto:eric.auger@redhat.com]
Sent: 30 September 2021 10:48
To: Shameerali Kolothum Thodi <redacted>;
linux-arm-kernel@lists.infradead.org; linux-acpi@vger.kernel.org;
iommu@lists.linux-foundation.org; Jean-Philippe Brucker
[off-list ref]
Cc: Linuxarm <redacted>; lorenzo.pieralisi@arm.com;
joro@8bytes.org; robin.murphy@arm.com; will@kernel.org; wanghuiqiang
[off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; steven.price@arm.com; Sami.Mujawar@arm.com;
jon@solid-run.com; yangyicong [off-list ref]
Subject: Re: [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node
Hi Shameer,
On 8/5/21 10:07 AM, Shameer Kolothum wrote:
quoted
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
I used your series and RMRs to force a guest iommu (vSMMUv3 nested stage
use case) to have a flat mapping for IOVAs within [0x8000000, 0x8100000]
(matching MSI_IOVA_BASE and MSI_IOVA_LENGTH) used by the host to map
MSI
physical doorbells.
That way when an assigned device protected by a vSMMUv3 implemented
upon
nested stage issues an MSI transaction, let's say using IOVA=0x8000000,
we would get:
S1 (guest) S2 (host)
0x8000000 0x8000000 Physical DB
This method was suggested by Jean-Philippe (added in CC) and it
simplifies the nested stage integration because we don't have to care
about nested stage MSI bindings.
However if I understand correctly we cannot define a range of SIDs using
the same RMR (due to the single mapping bit which must be set, Table 5
flags format). This is a spec restriction and not an issue with your series.
Yes. The spec currently mandates single mapping bit to be set.
As VFIO devices can be hot-plugged we thus need to create as many RMR
nodes as potential BDFs, leading to 256 * 6 = 1536 RMR nodes if you have
5 pcie root ports as it is usual in VMs. Then this causes some trouble
at qemu level for instance, wrt migration. See [RFC]
hw/arm/virt-acpi-build: Add IORT RMR regions to handle MSI nested binding.
Do you know if there is a plan to remove the single mapping limitation
in the spec?
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
v5 --> v6
- Addressed comments from Robin & Lorenzo.
: Moved iort_parse_rmr() to acpi_iort_init() from
iort_init_platform_devices().
: Removed use of struct iort_rmr_entry during the initial
parse. Using struct iommu_resv_region instead.
: Report RMR address alignment and overlap errors, but continue.
: Reworked arm_smmu_init_bypass_stes() (patch # 6).
- Updated SMMUv2 bypass SMR code. Thanks to Jon N (patch #8).
- Set IOMMU protection flags(IOMMU_CACHE, IOMMU_MMIO) based
on Type of RMR region. Suggested by Jon N.
Thanks,
Shameer
[0] https://developer.arm.com/documentation/den0049/latest/
[1]
------
v4 --> v5
-Added a fw_data union to struct iommu_resv_region and removed
struct iommu_rmr (Based on comments from Joerg/Robin).
-Added iommu_put_rmrs() to release mem.
-Thanks to Steve for verifying on SMMUv2, but not added the Tested-by
yet because of the above changes.
v3 -->v4
-Included the SMMUv2 SMR bypass install changes suggested by
Steve(patch #7)
-As per Robin's comments, RMR reserve implementation is now
more generic (patch #8) and dropped v3 patches 8 and 10.
-Rebase to 5.13-rc1
RFC v2 --> v3
-Dropped RFC tag as the ACPICA header changes are now ready to be
part of 5.13[0]. But this series still has a dependency on that patch.
-Added IORT E.b related changes(node flags, _DSM function 5 checks for
PCIe).
-Changed RMR to stream id mapping from M:N to M:1 as per the spec and
discussion here[1].
-Last two patches add support for SMMUv2(Thanks to Jon Nettleton!)
------
Jon Nettleton (1):
iommu/arm-smmu: Get associated RMR info and install bypass SMR
Shameer Kolothum (8):
iommu: Introduce a union to struct iommu_resv_region
ACPI/IORT: Add support for RMR node parsing
iommu/dma: Introduce generic helper to retrieve RMR info
ACPI/IORT: Add a helper to retrieve RMR memory regions
iommu/arm-smmu-v3: Introduce strtab init helper
iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force
bypass
iommu/arm-smmu-v3: Get associated RMR info and install bypass STE
iommu/dma: Reserve any RMR regions associated with a dev
drivers/acpi/arm64/iort.c | 172
On 9/17/2021 2:26 PM, Shameerali Kolothum Thodi wrote:
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 16 September 2021 12:17
To: Shameerali Kolothum Thodi <redacted>
Cc: Robin Murphy <robin.murphy@arm.com>; Lorenzo Pieralisi
[off-list ref]; Laurentiu Tudor [off-list ref];
linux-arm-kernel [off-list ref]; ACPI Devel Maling
List [off-list ref]; Linux IOMMU
[off-list ref]; Joerg Roedel [off-list ref]; Will
Deacon [off-list ref]; wanghuiqiang [off-list ref];
Guohanjun (Hanjun Guo) [off-list ref]; Steven Price
[off-list ref]; Sami Mujawar [off-list ref]; Eric
Auger [off-list ref]; yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing
On Thu, Sep 16, 2021 at 10:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 16 September 2021 08:52
To: Shameerali Kolothum Thodi
[off-list ref]
quoted
quoted
Cc: Robin Murphy <robin.murphy@arm.com>; Lorenzo Pieralisi
[off-list ref]; Laurentiu Tudor
[off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Joerg Roedel [off-list ref];
Will Deacon [off-list ref]; wanghuiqiang
[off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref]; Sami
Mujawar [off-list ref]; Eric Auger
[off-list ref];
quoted
quoted
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node
parsing
On Thu, Sep 16, 2021 at 9:26 AM Shameerali Kolothum Thodi
[off-list ref] wrote:
quoted
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 06 September 2021 20:51
To: Robin Murphy <robin.murphy@arm.com>
Cc: Lorenzo Pieralisi <redacted>; Shameerali
Kolothum Thodi [off-list ref]; Laurentiu
Tudor [off-list ref]; linux-arm-kernel
[off-list ref]; ACPI Devel Maling List
[off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm
[off-list ref]; Joerg Roedel [off-list ref]; Will
Deacon [off-list ref]; wanghuiqiang
[off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref];
Sami Mujawar [off-list ref]; Eric Auger
[off-list ref];
quoted
quoted
yangyicong [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node
parsing
[...]
quoted
quoted
quoted
On the prot value assignment based on the remapping flag,
I'd like to hear Robin/Joerg's opinion, I'd avoid being in a
situation where "normally" this would work but then we have
to quirk
it.
quoted
quoted
quoted
quoted
Is this a valid assumption _always_ ?
No. Certainly applying IOMMU_CACHE without reference to the
device's _CCA attribute or how CPUs may be accessing a shared
buffer could lead to a loss of coherency. At worst, applying
IOMMU_MMIO to a device-private buffer *could* cause the device
to lose coherency with itself if the memory underlying the RMR
may have allocated into system caches. Note that the expected
use for non-remappable RMRs is the device holding some sort of
long-lived private data in system RAM - the MSI doorbell trick
is far more of a niche
hack really.
quoted
quoted
quoted
At the very least I think we need to refer to the device's
memory access properties here.
Jon, Laurentiu - how do RMRs correspond to the EFI memory map
on your firmware? I'm starting to think that as long as the
underlying memory is described appropriately there then we
should be able to infer correct attributes from the EFI memory type
and flags.
quoted
quoted
quoted
quoted
The devices are all cache coherent and marked as _CCA, 1. The
Memory regions are in the virt table as
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE.
quoted
quoted
The current chicken and egg problem we have is that during the
fsl-mc-bus initialization we call
error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT,
&mc_stream_id);
which gets deferred because the SMMU has not been initialized yet.
Then we initialize the RMR tables but there is no device
reference there to be able to query device properties, only the stream
id.
quoted
quoted
quoted
quoted
After the IORT tables are parsed and the SMMU is setup, on the
second device probe we associate everything based on the stream
id and the fsl-mc-bus device is able to claim its 1-1 DMA mappings.
Can we solve this order problem by delaying the
iommu_alloc_resv_region() to the
iommu_dma_get_rmr_resv_regions(dev,
list) ? We could invoke
device_get_dma_attr() from there which I believe will return the
_CCA
attribute.
quoted
Or is that still early to invoke that?
That looks like it should work. Do we then also need to parse
through the VirtualMemoryTable matching the start and end addresses
to determine the other memory attributes like MMIO?
Yes. But that looks tricky as I can't find that readily available on
Arm, like the efi_mem_attributes(). I will take a look.
Please let me know if there is one or any other easy way to retrieve it.
maybe we don't need to. Maybe it is enough to just move
iommu_alloc_resv_regions and then set the IOMMU_CACHE flag if type =
IOMMU_RESV_DIRECT_RELAXABLE and _CCN=1?
It looks like we could simply call efi_mem_type() and check for
EFI_MEMORY_MAPPED_IO. I have updated the code to set the
RMR prot value based on _CCA and EFI md type. Please see the
last commit on this branch here(not tested),
https://github.com/hisilicon/kernel-dev/commits/private-v5.14-rc4-rmr-v7-ext
Please take a look and let me know if this is good enough to solve this problem.
Sorry for the delay, I managed to test on a NXP LX2160A and things look
fine, so:
Tested-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
---
Best Regards, Laurentiu
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-10-08 12:16:11
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted hunk
A union is introduced to struct iommu_resv_region to hold
any firmware specific data. This is in preparation to add
support for IORT RMR reserve regions and the union now holds
the RMR specific information.
Signed-off-by: Shameer Kolothum <redacted>
---
include/linux/iommu.h | 11 +++++++++++
1 file changed, 11 insertions(+)
Do we really need to duplicate all this data? AFAICS we could just save
the acpi_iort_rmr pointer in the iommu_resv_region (with a forward
declaration here if necessary) and defer parsing its actual mappings
until the point where we can directly consume the results.
Robin.
quoted hunk
+
/**
* struct iommu_resv_region - descriptor for a reserved memory region
* @list: Linked list pointers
@@ -121,6 +128,7 @@ enum iommu_resv_type { * @length: Length of the region in bytes * @prot: IOMMU Protection flags (READ/WRITE/...) * @type: Type of the reserved region+ * @rmr: ACPI IORT RMR specific data */ struct iommu_resv_region { struct list_head list;
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-10-08 12:50:54
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted hunk
Add support for parsing RMR node information from ACPI.
Find the associated streamid and smmu node info from the
RMR node and populate a linked list with RMR memory
descriptors.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/acpi/arm64/iort.c | 134 +++++++++++++++++++++++++++++++++++++-
1 file changed, 133 insertions(+), 1 deletion(-)
@@ -40,6 +40,8 @@ struct iort_fwnode {staticLIST_HEAD(iort_fwnode_list);staticDEFINE_SPINLOCK(iort_fwnode_lock);+staticLIST_HEAD(iort_rmr_list);/* list of RMR regions from ACPI */+/***iort_set_fwnode()-Createiort_fwnodeanduseittoregister*iommudataintheiort_fwnode_list
@@ -1566,6 +1569,134 @@ static void __init iort_enable_acs(struct acpi_iort_node *iort_node)#elsestaticinlinevoidiort_enable_acs(structacpi_iort_node*iort_node){}#endif+staticvoidiort_rmr_desc_check_overlap(structacpi_iort_rmr_desc*desc,u32count)+{+inti,j;++for(i=0;i<count;i++){+u64end,start=desc[i].base_address,length=desc[i].length;++end=start+length-1;++/* Check for address overlap */+for(j=i+1;j<count;j++){+u64e_start=desc[j].base_address;+u64e_end=e_start+desc[j].length-1;++if(start<=e_end&&end>=e_start)+pr_err(FW_BUG"RMR descriptor[0x%llx - 0x%llx] overlaps, continue anyway\n",+start,end);+}+}+}++staticvoid__initiort_node_get_rmr_info(structacpi_iort_node*iort_node)+{+structacpi_iort_node*smmu;+structacpi_iort_rmr*rmr;+structacpi_iort_rmr_desc*rmr_desc;+u32map_count=iort_node->mapping_count;+u32sid;+inti;++if(!iort_node->mapping_offset||map_count!=1){+pr_err(FW_BUG"Invalid ID mapping, skipping RMR node %p\n",+iort_node);+return;+}++/* Retrieve associated smmu and stream id */+smmu=iort_node_get_id(iort_node,&sid,0);+if(!smmu){+pr_err(FW_BUG"Invalid SMMU reference, skipping RMR node %p\n",+iort_node);+return;+}++/* Retrieve RMR data */+rmr=(structacpi_iort_rmr*)iort_node->node_data;+if(!rmr->rmr_offset||!rmr->rmr_count){+pr_err(FW_BUG"Invalid RMR descriptor array, skipping RMR node %p\n",+iort_node);+return;+}++rmr_desc=ACPI_ADD_PTR(structacpi_iort_rmr_desc,iort_node,+rmr->rmr_offset);++iort_rmr_desc_check_overlap(rmr_desc,rmr->rmr_count);++for(i=0;i<rmr->rmr_count;i++,rmr_desc++){+structiommu_resv_region*region;+enumiommu_resv_typetype;+intprot=IOMMU_READ|IOMMU_WRITE;+u64addr=rmr_desc->base_address,size=rmr_desc->length;++if(!IS_ALIGNED(addr,SZ_64K)||!IS_ALIGNED(size,SZ_64K)){+/* PAGE align base addr and size */+addr&=PAGE_MASK;+size=PAGE_ALIGN(size+offset_in_page(rmr_desc->base_address));++pr_err(FW_BUG"RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]\n",+rmr_desc->base_address,+rmr_desc->base_address+rmr_desc->length-1,+addr,addr+size-1);+}+if(rmr->flags&IOMMU_RMR_REMAP_PERMITTED){+type=IOMMU_RESV_DIRECT_RELAXABLE;+/*+*SetIOMMU_CACHEasIOMMU_RESV_DIRECT_RELAXABLEis+*normallyusedforallocatedsystemmemorythatis+*thenusedfordevicespecificreservedregions.+*/+prot|=IOMMU_CACHE;+}else{+type=IOMMU_RESV_DIRECT;+/*+*SetIOMMU_MMIOasIOMMU_RESV_DIRECTisnormallyused+*fordevicememorylikeMSIdoorbell.+*/+prot|=IOMMU_MMIO;+}
I'm not sure we ever got a definitive answer to this - does DPAA2
actually go wrong if we use IOMMU_MMIO here? I'd still much prefer to
make the fewest possible assumptions, since at this point it's basically
just a stop-gap until we can fix the spec. It's become clear that we
can't reliably rely on guessing attributes, so I'm not too fussed about
theoretical cases that currently don't work (due to complete lack of RMR
support) continuing to not work for the moment, as long as we can make
the real-world cases we actually have work at all. Anything which only
affects performance I'd rather leave until firmware can tell us what to do.
I guess initcall ordering vs. driver registration probably covers it up,
but for the sake of cleanliness I'd rather make sure the RMRs are fully
discovered *before* we create the SMMU devices that we expect to start
consuming them.
Robin.
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-10-08 13:06:03
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted hunk
Reserved Memory Regions(RMR) associated with an IOMMU can be
described through ACPI IORT tables in systems with devices
that require a unity mapping or bypass for those
regions.
Introduce a generic interface so that IOMMU drivers can retrieve
and set up necessary mappings.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/iommu/dma-iommu.c | 29 +++++++++++++++++++++++++++++
include/linux/dma-iommu.h | 13 +++++++++++++
2 files changed, 42 insertions(+)
Unless there's something special you expect to need to do here, can we
just uphold the prevailing expectation that resv_regions are kmalloc()ed
and can be freed directly by the generic function?
quoted hunk
+
/**
* iommu_dma_get_resv_regions - Reserved region driver helper
* @dev: Device from iommu_get_resv_regions()
Hmm, if this needs to be stubbed at all then returning an error seems
like probably the wrong thing to do. I guess it's for 32-bit builds of
arm-smmu? It is not an error if the firmware describes no RMRs because
there are no RMRs, so it hardly deserves to be an error if there are no
RMRs simply because the firmware isn't ACPI.
Robin.
@@ -207,22 +207,68 @@ void iommu_dma_put_rmrs(struct fwnode_handle *iommu_fwnode,}EXPORT_SYMBOL(iommu_dma_put_rmrs);+staticbooliommu_dma_dev_has_rmr(structiommu_fwspec*fwspec,+structiommu_resv_region*e)+{+inti;++for(i=0;i<fwspec->num_ids;i++){+if(e->fw_data.rmr.sid==fwspec->ids[i])+returntrue;+}++returnfalse;+}++staticvoidiommu_dma_get_rmr_resv_regions(structdevice*dev,+structlist_head*list)+{+structiommu_fwspec*fwspec=dev_iommu_fwspec_get(dev);+structlist_headrmr_list;+structiommu_resv_region*rmr,*tmp;++INIT_LIST_HEAD(&rmr_list);+if(iommu_dma_get_rmrs(fwspec->iommu_fwnode,&rmr_list))+return;++if(dev_is_pci(dev)){+structpci_dev*pdev=to_pci_dev(dev);+structpci_host_bridge*host=pci_find_host_bridge(pdev->bus);++if(!host->preserve_config)+return;+}++list_for_each_entry_safe(rmr,tmp,&rmr_list,list){+if(!iommu_dma_dev_has_rmr(fwspec,rmr))+continue;++/* Remove from iommu RMR list and add to dev resv_regions */+list_del_init(&rmr->list);+list_add_tail(&rmr->list,list);+}++iommu_dma_put_rmrs(fwspec->iommu_fwnode,&rmr_list);+}+/***iommu_dma_get_resv_regions-Reservedregiondriverhelper*@dev:Devicefromiommu_get_resv_regions()*@list:Reservedregionlistfromiommu_get_resv_regions()**IOMMUdriverscanusethistoimplementtheir.get_resv_regionscallback-*forgeneralnon-IOMMU-specificreservations.Currently,thiscoversGICv3-*ITSregionreservationonACPIbasedARMplatformsthatmayrequireHWMSI-*reservation.+*forgeneralnon-IOMMU-specificreservations.Currentlythiscovers,+*-GICv3ITSregionreservationonACPIbasedARMplatformsthatmay+*requireHWMSIreservation.+*-AnyACPIIORTRMRmemoryrangereservations(IORTspecrevE.b)*/voidiommu_dma_get_resv_regions(structdevice*dev,structlist_head*list){-if(!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode))+if(!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode)){iort_iommu_msi_get_resv_regions(dev,list);-+iommu_dma_get_rmr_resv_regions(dev,list);+}}EXPORT_SYMBOL(iommu_dma_get_resv_regions);
From: Jon Nettleton <hidden> Date: 2021-10-09 07:00:41
On Fri, Oct 8, 2021 at 2:14 PM Robin Murphy [off-list ref] wrote:
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
A union is introduced to struct iommu_resv_region to hold
any firmware specific data. This is in preparation to add
support for IORT RMR reserve regions and the union now holds
the RMR specific information.
Signed-off-by: Shameer Kolothum <redacted>
---
include/linux/iommu.h | 11 +++++++++++
1 file changed, 11 insertions(+)
Do we really need to duplicate all this data? AFAICS we could just save
the acpi_iort_rmr pointer in the iommu_resv_region (with a forward
declaration here if necessary) and defer parsing its actual mappings
until the point where we can directly consume the results.
From earlier discussions on this patchset, the original goal was also for
device-tree mechanisms to be able to hook into this code to support
similar RMR's and SMMU initialization, just not through the ACPI / IORT
path.
Robin.
quoted
+
/**
* struct iommu_resv_region - descriptor for a reserved memory region
* @list: Linked list pointers
@@ -121,6 +128,7 @@ enum iommu_resv_type { * @length: Length of the region in bytes * @prot: IOMMU Protection flags (READ/WRITE/...) * @type: Type of the reserved region+ * @rmr: ACPI IORT RMR specific data */ struct iommu_resv_region { struct list_head list;
From: Jon Nettleton <hidden> Date: 2021-10-09 07:08:38
On Fri, Oct 8, 2021 at 2:49 PM Robin Murphy [off-list ref] wrote:
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
Add support for parsing RMR node information from ACPI.
Find the associated streamid and smmu node info from the
RMR node and populate a linked list with RMR memory
descriptors.
Signed-off-by: Shameer Kolothum <redacted>
---
drivers/acpi/arm64/iort.c | 134 +++++++++++++++++++++++++++++++++++++-
1 file changed, 133 insertions(+), 1 deletion(-)
@@ -40,6 +40,8 @@ struct iort_fwnode {staticLIST_HEAD(iort_fwnode_list);staticDEFINE_SPINLOCK(iort_fwnode_lock);+staticLIST_HEAD(iort_rmr_list);/* list of RMR regions from ACPI */+/***iort_set_fwnode()-Createiort_fwnodeanduseittoregister*iommudataintheiort_fwnode_list
@@ -1566,6 +1569,134 @@ static void __init iort_enable_acs(struct acpi_iort_node *iort_node)#elsestaticinlinevoidiort_enable_acs(structacpi_iort_node*iort_node){}#endif+staticvoidiort_rmr_desc_check_overlap(structacpi_iort_rmr_desc*desc,u32count)+{+inti,j;++for(i=0;i<count;i++){+u64end,start=desc[i].base_address,length=desc[i].length;++end=start+length-1;++/* Check for address overlap */+for(j=i+1;j<count;j++){+u64e_start=desc[j].base_address;+u64e_end=e_start+desc[j].length-1;++if(start<=e_end&&end>=e_start)+pr_err(FW_BUG"RMR descriptor[0x%llx - 0x%llx] overlaps, continue anyway\n",+start,end);+}+}+}++staticvoid__initiort_node_get_rmr_info(structacpi_iort_node*iort_node)+{+structacpi_iort_node*smmu;+structacpi_iort_rmr*rmr;+structacpi_iort_rmr_desc*rmr_desc;+u32map_count=iort_node->mapping_count;+u32sid;+inti;++if(!iort_node->mapping_offset||map_count!=1){+pr_err(FW_BUG"Invalid ID mapping, skipping RMR node %p\n",+iort_node);+return;+}++/* Retrieve associated smmu and stream id */+smmu=iort_node_get_id(iort_node,&sid,0);+if(!smmu){+pr_err(FW_BUG"Invalid SMMU reference, skipping RMR node %p\n",+iort_node);+return;+}++/* Retrieve RMR data */+rmr=(structacpi_iort_rmr*)iort_node->node_data;+if(!rmr->rmr_offset||!rmr->rmr_count){+pr_err(FW_BUG"Invalid RMR descriptor array, skipping RMR node %p\n",+iort_node);+return;+}++rmr_desc=ACPI_ADD_PTR(structacpi_iort_rmr_desc,iort_node,+rmr->rmr_offset);++iort_rmr_desc_check_overlap(rmr_desc,rmr->rmr_count);++for(i=0;i<rmr->rmr_count;i++,rmr_desc++){+structiommu_resv_region*region;+enumiommu_resv_typetype;+intprot=IOMMU_READ|IOMMU_WRITE;+u64addr=rmr_desc->base_address,size=rmr_desc->length;++if(!IS_ALIGNED(addr,SZ_64K)||!IS_ALIGNED(size,SZ_64K)){+/* PAGE align base addr and size */+addr&=PAGE_MASK;+size=PAGE_ALIGN(size+offset_in_page(rmr_desc->base_address));++pr_err(FW_BUG"RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]\n",+rmr_desc->base_address,+rmr_desc->base_address+rmr_desc->length-1,+addr,addr+size-1);+}+if(rmr->flags&IOMMU_RMR_REMAP_PERMITTED){+type=IOMMU_RESV_DIRECT_RELAXABLE;+/*+*SetIOMMU_CACHEasIOMMU_RESV_DIRECT_RELAXABLEis+*normallyusedforallocatedsystemmemorythatis+*thenusedfordevicespecificreservedregions.+*/+prot|=IOMMU_CACHE;+}else{+type=IOMMU_RESV_DIRECT;+/*+*SetIOMMU_MMIOasIOMMU_RESV_DIRECTisnormallyused+*fordevicememorylikeMSIdoorbell.+*/+prot|=IOMMU_MMIO;+}
I'm not sure we ever got a definitive answer to this - does DPAA2
actually go wrong if we use IOMMU_MMIO here? I'd still much prefer to
make the fewest possible assumptions, since at this point it's basically
just a stop-gap until we can fix the spec. It's become clear that we
can't reliably rely on guessing attributes, so I'm not too fussed about
theoretical cases that currently don't work (due to complete lack of RMR
support) continuing to not work for the moment, as long as we can make
the real-world cases we actually have work at all. Anything which only
affects performance I'd rather leave until firmware can tell us what to do.
Well it isn't DPAA2, it is FSL_MC_BUS that fails with IOMMU_MMIO
mappings. DPAA2 is just one connected device.
-Jon
I guess initcall ordering vs. driver registration probably covers it up,
but for the sake of cleanliness I'd rather make sure the RMRs are fully
discovered *before* we create the SMMU devices that we expect to start
consuming them.
Robin.
From: Jon Nettleton <hidden> Date: 2021-10-09 07:10:27
On Fri, Oct 8, 2021 at 3:10 PM Robin Murphy [off-list ref] wrote:
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
Get ACPI IORT RMR regions associated with a dev reserved
so that there is a unity mapping for them in SMMU.
This feels like most of it belongs in the IORT code rather than
iommu-dma (which should save the temporary list copy as well).
See previous comment. The original intent was for device-tree to also
be able to use these mechanisms to create RMR's and support them
in the SMMU.
-Jon
@@ -207,22 +207,68 @@ void iommu_dma_put_rmrs(struct fwnode_handle *iommu_fwnode,}EXPORT_SYMBOL(iommu_dma_put_rmrs);+staticbooliommu_dma_dev_has_rmr(structiommu_fwspec*fwspec,+structiommu_resv_region*e)+{+inti;++for(i=0;i<fwspec->num_ids;i++){+if(e->fw_data.rmr.sid==fwspec->ids[i])+returntrue;+}++returnfalse;+}++staticvoidiommu_dma_get_rmr_resv_regions(structdevice*dev,+structlist_head*list)+{+structiommu_fwspec*fwspec=dev_iommu_fwspec_get(dev);+structlist_headrmr_list;+structiommu_resv_region*rmr,*tmp;++INIT_LIST_HEAD(&rmr_list);+if(iommu_dma_get_rmrs(fwspec->iommu_fwnode,&rmr_list))+return;++if(dev_is_pci(dev)){+structpci_dev*pdev=to_pci_dev(dev);+structpci_host_bridge*host=pci_find_host_bridge(pdev->bus);++if(!host->preserve_config)+return;+}++list_for_each_entry_safe(rmr,tmp,&rmr_list,list){+if(!iommu_dma_dev_has_rmr(fwspec,rmr))+continue;++/* Remove from iommu RMR list and add to dev resv_regions */+list_del_init(&rmr->list);+list_add_tail(&rmr->list,list);+}++iommu_dma_put_rmrs(fwspec->iommu_fwnode,&rmr_list);+}+/***iommu_dma_get_resv_regions-Reservedregiondriverhelper*@dev:Devicefromiommu_get_resv_regions()*@list:Reservedregionlistfromiommu_get_resv_regions()**IOMMUdriverscanusethistoimplementtheir.get_resv_regionscallback-*forgeneralnon-IOMMU-specificreservations.Currently,thiscoversGICv3-*ITSregionreservationonACPIbasedARMplatformsthatmayrequireHWMSI-*reservation.+*forgeneralnon-IOMMU-specificreservations.Currentlythiscovers,+*-GICv3ITSregionreservationonACPIbasedARMplatformsthatmay+*requireHWMSIreservation.+*-AnyACPIIORTRMRmemoryrangereservations(IORTspecrevE.b)*/voidiommu_dma_get_resv_regions(structdevice*dev,structlist_head*list){-if(!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode))+if(!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode)){iort_iommu_msi_get_resv_regions(dev,list);-+iommu_dma_get_rmr_resv_regions(dev,list);+}}EXPORT_SYMBOL(iommu_dma_get_resv_regions);
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 09 October 2021 07:58
To: Robin Murphy <robin.murphy@arm.com>
Cc: Shameerali Kolothum Thodi <redacted>;
linux-arm-kernel [off-list ref]; ACPI Devel Maling
List [off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Steven Price [off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; yangyicong [off-list ref]; Sami
Mujawar [off-list ref]; Will Deacon [off-list ref];
wanghuiqiang [off-list ref]
Subject: Re: [PATCH v7 1/9] iommu: Introduce a union to struct
iommu_resv_region
On Fri, Oct 8, 2021 at 2:14 PM Robin Murphy [off-list ref]
wrote:
quoted
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
A union is introduced to struct iommu_resv_region to hold any
firmware specific data. This is in preparation to add support for
IORT RMR reserve regions and the union now holds the RMR specific
information.
Signed-off-by: Shameer Kolothum
[off-list ref]
---
include/linux/iommu.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index
Do we really need to duplicate all this data? AFAICS we could just
save the acpi_iort_rmr pointer in the iommu_resv_region (with a
forward declaration here if necessary) and defer parsing its actual
mappings until the point where we can directly consume the results.
From earlier discussions on this patchset, the original goal was also for
device-tree mechanisms to be able to hook into this code to support similar
RMR's and SMMU initialization, just not through the ACPI / IORT path.
Yes. IIRC, there were some earlier attempts to have DT support for reserved regions
and there was a suggestion to provide generic interfaces so that when DT solution
comes up it is easier to add the support.
Thanks,
Shameer
quoted
Robin.
quoted
+
/**
* struct iommu_resv_region - descriptor for a reserved memory region
* @list: Linked list pointers
@@ -121,6 +128,7 @@ enum iommu_resv_type { * @length: Length of the region in bytes * @prot: IOMMU Protection flags (READ/WRITE/...) * @type: Type of the reserved region+ * @rmr: ACPI IORT RMR specific data */ struct iommu_resv_region { struct list_head list;
-----Original Message-----
From: Robin Murphy [mailto:robin.murphy@arm.com]
Sent: 08 October 2021 14:04
To: Shameerali Kolothum Thodi <redacted>;
linux-arm-kernel@lists.infradead.org; linux-acpi@vger.kernel.org;
iommu@lists.linux-foundation.org
Cc: Linuxarm <redacted>; lorenzo.pieralisi@arm.com;
joro@8bytes.org; will@kernel.org; wanghuiqiang
[off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; steven.price@arm.com; Sami.Mujawar@arm.com;
jon@solid-run.com; eric.auger@redhat.com; yangyicong
[off-list ref]
Subject: Re: [PATCH v7 3/9] iommu/dma: Introduce generic helper to retrieve
RMR info
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
Reserved Memory Regions(RMR) associated with an IOMMU can be
described through ACPI IORT tables in systems with devices
that require a unity mapping or bypass for those
regions.
Introduce a generic interface so that IOMMU drivers can retrieve
and set up necessary mappings.
Signed-off-by: Shameer Kolothum
+ * with a given IOMMU
+ * @iommu_fwnode: fwnode associated with IOMMU
+ * @list: RMR list to be populated
+ *
+ */
+int iommu_dma_get_rmrs(struct fwnode_handle *iommu_fwnode,
+ struct list_head *list)
+{
+ return -EINVAL;
+}
+EXPORT_SYMBOL(iommu_dma_get_rmrs);
+
+/**
+ *
+ * iommu_dma_put_rmrs - Release Reserved Memory Regions(RMRs)
associated
quoted
+ * with a given IOMMU
+ * @iommu_fwnode: fwnode associated with IOMMU
+ * @list: RMR list
+ *
+ */
+void iommu_dma_put_rmrs(struct fwnode_handle *iommu_fwnode,
+ struct list_head *list)
+{
+}
+EXPORT_SYMBOL(iommu_dma_put_rmrs);
Unless there's something special you expect to need to do here, can we
just uphold the prevailing expectation that resv_regions are kmalloc()ed
and can be freed directly by the generic function?
Right. I think we can do that.
quoted
+
/**
* iommu_dma_get_resv_regions - Reserved region driver helper
* @dev: Device from iommu_get_resv_regions()
{
}
+static int iommu_dma_get_rmrs(struct fwnode_handle *iommu, struct
list_head *list)
quoted
+{
+ return -ENODEV;
Hmm, if this needs to be stubbed at all then returning an error seems
like probably the wrong thing to do. I guess it's for 32-bit builds of
arm-smmu? It is not an error if the firmware describes no RMRs because
there are no RMRs, so it hardly deserves to be an error if there are no
RMRs simply because the firmware isn't ACPI.
Yes, definitely not an error return. I will change that.
Thanks,
Shameer
-----Original Message-----
From: Robin Murphy [mailto:robin.murphy@arm.com]
Sent: 08 October 2021 13:49
To: Shameerali Kolothum Thodi <redacted>;
linux-arm-kernel@lists.infradead.org; linux-acpi@vger.kernel.org;
iommu@lists.linux-foundation.org
Cc: jon@solid-run.com; Linuxarm <redacted>;
steven.price@arm.com; Guohanjun (Hanjun Guo) [off-list ref];
yangyicong [off-list ref]; Sami.Mujawar@arm.com;
will@kernel.org; wanghuiqiang [off-list ref]
Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
Add support for parsing RMR node information from ACPI.
Find the associated streamid and smmu node info from the
RMR node and populate a linked list with RMR memory
descriptors.
Signed-off-by: Shameer Kolothum
@@ -40,6 +40,8 @@ struct iort_fwnode {staticLIST_HEAD(iort_fwnode_list);staticDEFINE_SPINLOCK(iort_fwnode_lock);+staticLIST_HEAD(iort_rmr_list);/* list of RMR regions from ACPI */+/***iort_set_fwnode()-Createiort_fwnodeanduseittoregister*iommudataintheiort_fwnode_list
+
+ pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] not aligned to
64K, continue with [0x%llx - 0x%llx]\n",
quoted
+ rmr_desc->base_address,
+ rmr_desc->base_address + rmr_desc->length - 1,
+ addr, addr + size - 1);
+ }
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally
used
quoted
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
I'm not sure we ever got a definitive answer to this - does DPAA2
actually go wrong if we use IOMMU_MMIO here? I'd still much prefer to
make the fewest possible assumptions, since at this point it's basically
just a stop-gap until we can fix the spec. It's become clear that we
can't reliably rely on guessing attributes, so I'm not too fussed about
theoretical cases that currently don't work (due to complete lack of RMR
support) continuing to not work for the moment, as long as we can make
the real-world cases we actually have work at all. Anything which only
affects performance I'd rather leave until firmware can tell us what to do.
Just to report back, we have done some basic sanity tests with IOMMU_MMIO
set as default and it works for us. But I see that it doesn't for Jon's case.
So not sure what the stop-gap can be.. Can we use the _CCA + EFI approach
and override it later when the spec gets updated?
Thanks,
Shameer
I guess initcall ordering vs. driver registration probably covers it up,
but for the sake of cleanliness I'd rather make sure the RMRs are fully
discovered *before* we create the SMMU devices that we expect to start
consuming them.
Robin.
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-10-11 13:51:22
On 2021-10-11 06:47, Shameerali Kolothum Thodi wrote:
quoted
-----Original Message-----
From: Jon Nettleton [mailto:jon@solid-run.com]
Sent: 09 October 2021 07:58
To: Robin Murphy <robin.murphy@arm.com>
Cc: Shameerali Kolothum Thodi <redacted>;
linux-arm-kernel [off-list ref]; ACPI Devel Maling
List [off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Steven Price [off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; yangyicong [off-list ref]; Sami
Mujawar [off-list ref]; Will Deacon [off-list ref];
wanghuiqiang [off-list ref]
Subject: Re: [PATCH v7 1/9] iommu: Introduce a union to struct
iommu_resv_region
On Fri, Oct 8, 2021 at 2:14 PM Robin Murphy [off-list ref]
wrote:
quoted
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
A union is introduced to struct iommu_resv_region to hold any
firmware specific data. This is in preparation to add support for
IORT RMR reserve regions and the union now holds the RMR specific
information.
Signed-off-by: Shameer Kolothum
[off-list ref]
---
include/linux/iommu.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index
Do we really need to duplicate all this data? AFAICS we could just
save the acpi_iort_rmr pointer in the iommu_resv_region (with a
forward declaration here if necessary) and defer parsing its actual
mappings until the point where we can directly consume the results.
From earlier discussions on this patchset, the original goal was also for
device-tree mechanisms to be able to hook into this code to support similar
RMR's and SMMU initialization, just not through the ACPI / IORT path.
Yes. IIRC, there were some earlier attempts to have DT support for reserved regions
and there was a suggestion to provide generic interfaces so that when DT solution
comes up it is easier to add the support.
OK, but in that case why is every single part of it IORT-specific in
either name, description or function?
Regardless, s/acpi_iort_rmr/original firmware descriptor of whatever
variety/ and my comment still stands. If a firmware-specific structure
is still going to exist to begin with, then what do we gain from
interpreting details earlier than needed and wasting memory storing
copies of them? This isn't something we're looking up hundreds of times
per second and need to cache in some more efficient format.
Furthermore, it seems unlikely that the eventual DT solution would end
up being semantically identical to IORT RMRs, so there's every
possibility that the One True Abstract Structure would need changing to
work for another firmware implementation anyway. Heck, it might not even
fit future IORT if it becomes permissible for multiple StreamIDs to
share a single RMR descriptor.
Thanks,
Robin.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-10-11 14:05:34
On 2021-10-09 08:06, Jon Nettleton wrote:
[...]
quoted
quoted
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
I'm not sure we ever got a definitive answer to this - does DPAA2
actually go wrong if we use IOMMU_MMIO here? I'd still much prefer to
make the fewest possible assumptions, since at this point it's basically
just a stop-gap until we can fix the spec. It's become clear that we
can't reliably rely on guessing attributes, so I'm not too fussed about
theoretical cases that currently don't work (due to complete lack of RMR
support) continuing to not work for the moment, as long as we can make
the real-world cases we actually have work at all. Anything which only
affects performance I'd rather leave until firmware can tell us what to do.
Well it isn't DPAA2, it is FSL_MC_BUS that fails with IOMMU_MMIO
mappings. DPAA2 is just one connected device.
Apologies if I'm being overly loose with terminology there - my point of
reference for this hardware is documentation for the old LS2080A, where
the "DPAA2 Reference Manual" gives a strong impression that the MC is a
component belonging to the overall DPAA2 architecture. Either way it
technically stands to reason that the other DPAA2 components would only
be usable if the MC itself works (unless I've been holding a major
misconception about that for years as well).
In the context of this discussion, please consider any reference I may
make to bits of NXP's hardware to be shorthand for "the thing for which
NXP have a vested interest in IORT RMRs".
Thanks,
Robin.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-10-11 15:03:12
On 2021-10-09 08:07, Jon Nettleton wrote:
On Fri, Oct 8, 2021 at 3:10 PM Robin Murphy [off-list ref] wrote:
quoted
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
Get ACPI IORT RMR regions associated with a dev reserved
so that there is a unity mapping for them in SMMU.
This feels like most of it belongs in the IORT code rather than
iommu-dma (which should save the temporary list copy as well).
See previous comment. The original intent was for device-tree to also
be able to use these mechanisms to create RMR's and support them
in the SMMU.
Can you clarify how code behind an "if (!is_of_node(...))" check
alongside other IORT-specific code is expected to be useful for DT?
Yes, iommu_dma_get_resv_regions() itself wants to end up serving as an
abstraction layer, but that still doesn't mean it has to do much more
than dispatch into firmware-specific backends as appropriate.
Robin.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
-----Original Message-----
From: Robin Murphy [mailto:robin.murphy@arm.com]
Sent: 11 October 2021 16:01
To: Jon Nettleton <redacted>
Cc: Shameerali Kolothum Thodi <redacted>;
linux-arm-kernel [off-list ref]; ACPI Devel Maling
List [off-list ref]; Linux IOMMU
[off-list ref]; Linuxarm [off-list ref];
Lorenzo Pieralisi [off-list ref]; Joerg Roedel
[off-list ref]; Will Deacon [off-list ref]; wanghuiqiang
[off-list ref]; Guohanjun (Hanjun Guo)
[off-list ref]; Steven Price [off-list ref]; Sami
Mujawar [off-list ref]; Eric Auger [off-list ref];
yangyicong [off-list ref]
Subject: Re: [PATCH v7 9/9] iommu/dma: Reserve any RMR regions associated
with a dev
On 2021-10-09 08:07, Jon Nettleton wrote:
quoted
On Fri, Oct 8, 2021 at 3:10 PM Robin Murphy [off-list ref]
wrote:
quoted
quoted
On 2021-08-05 09:07, Shameer Kolothum wrote:
quoted
Get ACPI IORT RMR regions associated with a dev reserved
so that there is a unity mapping for them in SMMU.
This feels like most of it belongs in the IORT code rather than
iommu-dma (which should save the temporary list copy as well).
See previous comment. The original intent was for device-tree to also
be able to use these mechanisms to create RMR's and support them
in the SMMU.
Can you clarify how code behind an "if (!is_of_node(...))" check
alongside other IORT-specific code is expected to be useful for DT?
Yes, iommu_dma_get_resv_regions() itself wants to end up serving as an
abstraction layer, but that still doesn't mean it has to do much more
than dispatch into firmware-specific backends as appropriate.
(Resending as I accidently replied earlier from our internal ML id. Sorry)
The way I thought about is as below,
1. iommu_dma_get_resv_regions() will invoke the common iommu_dma_get_rmr_resv_regions().
Yes, the if (!is_of_node(...)) is not required here.
2. iommu_dma_get_rmr_resv_regions() calls iommu_dma_get_rmrs().
iommu_dma_get_rmrs() has the (!is_of_node(...)) check to call into IORT or DT specific functions
to retrieve the RMR reserve regions associated with a given iommu_fwnode.
3. The common iommu_dma_get_rmr_resv_regions() further checks for PCI host preserve_config
and whether the returned RMR list actually has any dev specific region to reserve or not.
So the only firmware specific backend is handled inside the iommu_dma_get_rmrs() and that is also called
from the SMMU driver probe to install bypass SIDs.
Anyway, if the eventual DT implementation or further IORT spec changes makes this abstraction
irrelevant I am Ok to move this into the IORT code.
Thanks,
Shameer
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Jon Nettleton <hidden> Date: 2021-10-12 08:03:24
On Mon, Oct 11, 2021 at 4:04 PM Robin Murphy [off-list ref] wrote:
On 2021-10-09 08:06, Jon Nettleton wrote:
[...]
quoted
quoted
quoted
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
I'm not sure we ever got a definitive answer to this - does DPAA2
actually go wrong if we use IOMMU_MMIO here? I'd still much prefer to
make the fewest possible assumptions, since at this point it's basically
just a stop-gap until we can fix the spec. It's become clear that we
can't reliably rely on guessing attributes, so I'm not too fussed about
theoretical cases that currently don't work (due to complete lack of RMR
support) continuing to not work for the moment, as long as we can make
the real-world cases we actually have work at all. Anything which only
affects performance I'd rather leave until firmware can tell us what to do.
Well it isn't DPAA2, it is FSL_MC_BUS that fails with IOMMU_MMIO
mappings. DPAA2 is just one connected device.
Apologies if I'm being overly loose with terminology there - my point of
reference for this hardware is documentation for the old LS2080A, where
the "DPAA2 Reference Manual" gives a strong impression that the MC is a
component belonging to the overall DPAA2 architecture. Either way it
technically stands to reason that the other DPAA2 components would only
be usable if the MC itself works (unless I've been holding a major
misconception about that for years as well).
In the context of this discussion, please consider any reference I may
make to bits of NXP's hardware to be shorthand for "the thing for which
NXP have a vested interest in IORT RMRs".
Ultimately the spec doesn't mention what IOMMU properties the regions
should have. Even marking them as IOMMU_READ/WRITE is as much
of an assumption as using IOMMU_MMIO or IOMMU_CACHE. It just seems
IOMMU_MMIO is the most popular since all the examples use it for MSI
doorbells in the documentation.
I am interested why this concern is only being brought up at this point
in a patchset that has been on the mailing list for 8+ months? This is
based on a spec that has existed from Arm since 2020 with the most recent
revisions published in Feb 2021. The lack of RMR support in the kernel
is affecting real world products, and the ability for SystemReady ES
certified systems from just fully working with recent distributions. Even
worse, is that without this patchset customers are forced to jump through
hoops to purposefully re-enable smmu bypass making their systems less
secure.
How is this a good experience for customers of SystemReady hardware
when for any mainline distribution to work the first thing they have to do is
make their system less secure?
-Jon
From: Lorenzo Pieralisi <hidden> Date: 2021-12-08 12:20:41
On Tue, Oct 12, 2021 at 10:00:24AM +0200, Jon Nettleton wrote:
On Mon, Oct 11, 2021 at 4:04 PM Robin Murphy [off-list ref] wrote:
quoted
On 2021-10-09 08:06, Jon Nettleton wrote:
[...]
quoted
quoted
quoted
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
I'm not sure we ever got a definitive answer to this - does DPAA2
actually go wrong if we use IOMMU_MMIO here? I'd still much prefer to
make the fewest possible assumptions, since at this point it's basically
just a stop-gap until we can fix the spec. It's become clear that we
can't reliably rely on guessing attributes, so I'm not too fussed about
theoretical cases that currently don't work (due to complete lack of RMR
support) continuing to not work for the moment, as long as we can make
the real-world cases we actually have work at all. Anything which only
affects performance I'd rather leave until firmware can tell us what to do.
Well it isn't DPAA2, it is FSL_MC_BUS that fails with IOMMU_MMIO
mappings. DPAA2 is just one connected device.
Apologies if I'm being overly loose with terminology there - my point of
reference for this hardware is documentation for the old LS2080A, where
the "DPAA2 Reference Manual" gives a strong impression that the MC is a
component belonging to the overall DPAA2 architecture. Either way it
technically stands to reason that the other DPAA2 components would only
be usable if the MC itself works (unless I've been holding a major
misconception about that for years as well).
In the context of this discussion, please consider any reference I may
make to bits of NXP's hardware to be shorthand for "the thing for which
NXP have a vested interest in IORT RMRs".
Ultimately the spec doesn't mention what IOMMU properties the regions
should have.
It will have to and that's what we are working on.
Even marking them as IOMMU_READ/WRITE is as much of an assumption as
using IOMMU_MMIO or IOMMU_CACHE. It just seems IOMMU_MMIO is the most
popular since all the examples use it for MSI doorbells in the
documentation.
We don't merge code based on assumptions that can easily break because
the specifications don't contemplate the details that are required.
I am interested why this concern is only being brought up at this point
on a patchset that has been on the mailing list for 8+ months?
See above. We don't merge code that we know can break and is based on
assumptions, we need to update the IORT specifications to make them
cover all the use cases - in a predictable way - and that's what we are
working on.
This is based on a spec that has existed from Arm since 2020 with the
most recent revisions published in Feb 2021. The lack of RMR support
in the kernel is affecting real world products, and the ability for
SystemReady ES certified systems from just fully working with recent
distributions.
I answered above - if you have any questions please ask them, here,
as far as Linux code is concerned.
I understand this is taking a long time, it is also helping us
understand all the possible use cases and how to cover them in
a way that is maintainable in the long run.
Thanks,
Lorenzo
Even worse, is that without this patchset customers are forced to jump
through hoops to purposefully re-enable smmu bypass making their
systems less secure.
How is this a good experience for customers of SystemReady hardware
when for any mainline distribution to work the first thing they have
to do is make their system less secure?
-Jon
From: Jon Nettleton <hidden> Date: 2021-12-08 13:28:34
On Wed, Dec 8, 2021 at 1:19 PM Lorenzo Pieralisi
[off-list ref] wrote:
On Tue, Oct 12, 2021 at 10:00:24AM +0200, Jon Nettleton wrote:
quoted
On Mon, Oct 11, 2021 at 4:04 PM Robin Murphy [off-list ref] wrote:
quoted
On 2021-10-09 08:06, Jon Nettleton wrote:
[...]
quoted
quoted
quoted
+ if (rmr->flags & IOMMU_RMR_REMAP_PERMITTED) {
+ type = IOMMU_RESV_DIRECT_RELAXABLE;
+ /*
+ * Set IOMMU_CACHE as IOMMU_RESV_DIRECT_RELAXABLE is
+ * normally used for allocated system memory that is
+ * then used for device specific reserved regions.
+ */
+ prot |= IOMMU_CACHE;
+ } else {
+ type = IOMMU_RESV_DIRECT;
+ /*
+ * Set IOMMU_MMIO as IOMMU_RESV_DIRECT is normally used
+ * for device memory like MSI doorbell.
+ */
+ prot |= IOMMU_MMIO;
+ }
I'm not sure we ever got a definitive answer to this - does DPAA2
actually go wrong if we use IOMMU_MMIO here? I'd still much prefer to
make the fewest possible assumptions, since at this point it's basically
just a stop-gap until we can fix the spec. It's become clear that we
can't reliably rely on guessing attributes, so I'm not too fussed about
theoretical cases that currently don't work (due to complete lack of RMR
support) continuing to not work for the moment, as long as we can make
the real-world cases we actually have work at all. Anything which only
affects performance I'd rather leave until firmware can tell us what to do.
Well it isn't DPAA2, it is FSL_MC_BUS that fails with IOMMU_MMIO
mappings. DPAA2 is just one connected device.
Apologies if I'm being overly loose with terminology there - my point of
reference for this hardware is documentation for the old LS2080A, where
the "DPAA2 Reference Manual" gives a strong impression that the MC is a
component belonging to the overall DPAA2 architecture. Either way it
technically stands to reason that the other DPAA2 components would only
be usable if the MC itself works (unless I've been holding a major
misconception about that for years as well).
In the context of this discussion, please consider any reference I may
make to bits of NXP's hardware to be shorthand for "the thing for which
NXP have a vested interest in IORT RMRs".
Ultimately the spec doesn't mention what IOMMU properties the regions
should have.
It will have to and that's what we are working on.
Where is this being worked on? I see no open tickets for this.
quoted
Even marking them as IOMMU_READ/WRITE is as much of an assumption as
using IOMMU_MMIO or IOMMU_CACHE. It just seems IOMMU_MMIO is the most
popular since all the examples use it for MSI doorbells in the
documentation.
We don't merge code based on assumptions that can easily break because
the specifications don't contemplate the details that are required.
quoted
I am interested why this concern is only being brought up at this point
on a patchset that has been on the mailing list for 8+ months?
See above. We don't merge code that we know can break and is based on
assumptions, we need to update the IORT specifications to make them
cover all the use cases - in a predictable way - and that's what we are
working on.
This is not really an answer to the question. The latest version of the
IORT RMR spec was published in Feb 2021. Why was this issue not
brought up with Rev 1 of this patchset? Instead you have wasted
10 months of developer and customer time. This could have easily been
turned into a code first spec change request, which is a valid option
for ACPI changes.
quoted
This is based on a spec that has existed from Arm since 2020 with the
most recent revisions published in Feb 2021. The lack of RMR support
in the kernel is affecting real world products, and the ability for
SystemReady ES certified systems from just fully working with recent
distributions.
I answered above - if you have any questions please ask them, here,
as far as Linux code is concerned.
I understand this is taking a long time, it is also helping us
understand all the possible use cases and how to cover them in
a way that is maintainable in the long run.
Every month that this patchset has sat being unattended by the
maintainers is another kernel dev cycle missed, it is another
another distribution release where users need to add hackish
kernel command-line options to disable security features that
were forced on by default. Not to mention Linux is just one
platform. What if other platforms have already adopted the
existing spec? These are Arm specs and Arm maintainers and
yet nobody seems to agree on anything and absolutely nothing
has been achieved except wasting the time of Shameer, myself,
our companies, and our customers.
-Jon
Thanks,
Lorenzo
quoted
Even worse, is that without this patchset customers are forced to jump
through hoops to purposefully re-enable smmu bypass making their
systems less secure.
How is this a good experience for customers of SystemReady hardware
when for any mainline distribution to work the first thing they have
to do is make their system less secure?
-Jon
From: Robin Murphy <robin.murphy@arm.com> Date: 2021-12-08 14:39:18
Jon,
On 2021-12-08 13:26, Jon Nettleton wrote:
[...]
quoted
quoted
Even marking them as IOMMU_READ/WRITE is as much of an assumption as
using IOMMU_MMIO or IOMMU_CACHE. It just seems IOMMU_MMIO is the most
popular since all the examples use it for MSI doorbells in the
documentation.
We don't merge code based on assumptions that can easily break because
the specifications don't contemplate the details that are required.
quoted
I am interested why this concern is only being brought up at this point
on a patchset that has been on the mailing list for 8+ months?
See above. We don't merge code that we know can break and is based on
assumptions, we need to update the IORT specifications to make them
cover all the use cases - in a predictable way - and that's what we are
working on.
This is not really an answer to the question. The latest version of the
IORT RMR spec was published in Feb 2021. Why was this issue not
brought up with Rev 1 of this patchset? Instead you have wasted
10 months of developer and customer time. This could have easily been
turned into a code first spec change request, which is a valid option
for ACPI changes.
It was only on v5 of the patchset - *six months* after the original RFC
posting - that anyone even first started to question the initial
assumptions made about attributes[1], and even then somebody familiar
countered that it didn't appear to matter[2]. Sorry, but you don't get
to U-turn and throw unjust shade at Arm for not being prescient.
Yes, when those of us within Arm set out the initial RMR spec, an
assumption was made that it seemed reasonable for an OS to simply pick
some default strong memory type (Device or Normal-NC) and full
permissions if it did need to map RMRs at stage 1. That spec was
reviewed and published externally and no interested parties came forth
asking "hey, what about attributes?". Linux patches were written around
that assumption and proceeded through many rounds of review until we
eventually received sufficient feedback to demonstrate that the
assumption did not in fact hold well enough in general and there seemed
to be a genuine need for RMR attributes, and at that point we started
work on revising the spec.
In the meantime, these patches have sat at v7 for four months - the
*other* outstanding review comments have not been addressed; I still
don't recall seeing an answer about whether LX2160 or anything else
currently deployed actually *needs* cacheable mappings or whether it
could muddle through with the IOMMU_MMIO assumption until proper "RMR
v2" support arrived later; even if so, an interim workaround specific to
LX2160 could have been proposed but hasn't. It is hardly reasonable to
pretend that Arm or the upstream maintainers are responsible for a lack
of development activity on the part of the submitters, no matter how
much blatant misinformation is repeated on Twitter.
Regards,
Robin.
[1]
https://lore.kernel.org/linux-iommu/13c2499e-cc0c-d395-0d60-6c3437f206ac@nxp.com/
[2]
https://lore.kernel.org/linux-iommu/CABdtJHv2QBHNoWTyp51H-J_apc75imPj0FbrV70Tm8xuNjpiTA@mail.gmail.com/
quoted
quoted
This is based on a spec that has existed from Arm since 2020 with the
most recent revisions published in Feb 2021. The lack of RMR support
in the kernel is affecting real world products, and the ability for
SystemReady ES certified systems from just fully working with recent
distributions.
I answered above - if you have any questions please ask them, here,
as far as Linux code is concerned.
I understand this is taking a long time, it is also helping us
understand all the possible use cases and how to cover them in
a way that is maintainable in the long run.
Every month that this patchset has sat being unattended by the
maintainers is another kernel dev cycle missed, it is another
another distribution release where users need to add hackish
kernel command-line options to disable security features that
were forced on by default. Not to mention Linux is just one
platform. What if other platforms have already adopted the
existing spec? These are Arm specs and Arm maintainers and
yet nobody seems to agree on anything and absolutely nothing
has been achieved except wasting the time of Shameer, myself,
our companies, and our customers.
-Jon
quoted
Thanks,
Lorenzo
quoted
Even worse, is that without this patchset customers are forced to jump
through hoops to purposefully re-enable smmu bypass making their
systems less secure.
How is this a good experience for customers of SystemReady hardware
when for any mainline distribution to work the first thing they have
to do is make their system less secure?
-Jon
From: Jon Nettleton <hidden> Date: 2021-12-08 15:13:30
On Wed, Dec 8, 2021 at 3:37 PM Robin Murphy [off-list ref] wrote:
Jon,
On 2021-12-08 13:26, Jon Nettleton wrote:
[...]
quoted
quoted
quoted
Even marking them as IOMMU_READ/WRITE is as much of an assumption as
using IOMMU_MMIO or IOMMU_CACHE. It just seems IOMMU_MMIO is the most
popular since all the examples use it for MSI doorbells in the
documentation.
We don't merge code based on assumptions that can easily break because
the specifications don't contemplate the details that are required.
quoted
I am interested why this concern is only being brought up at this point
on a patchset that has been on the mailing list for 8+ months?
See above. We don't merge code that we know can break and is based on
assumptions, we need to update the IORT specifications to make them
cover all the use cases - in a predictable way - and that's what we are
working on.
This is not really an answer to the question. The latest version of the
IORT RMR spec was published in Feb 2021. Why was this issue not
brought up with Rev 1 of this patchset? Instead you have wasted
10 months of developer and customer time. This could have easily been
turned into a code first spec change request, which is a valid option
for ACPI changes.
It was only on v5 of the patchset - *six months* after the original RFC
posting - that anyone even first started to question the initial
assumptions made about attributes[1], and even then somebody familiar
countered that it didn't appear to matter[2]. Sorry, but you don't get
to U-turn and throw unjust shade at Arm for not being prescient.
Yes, when those of us within Arm set out the initial RMR spec, an
assumption was made that it seemed reasonable for an OS to simply pick
some default strong memory type (Device or Normal-NC) and full
permissions if it did need to map RMRs at stage 1. That spec was
reviewed and published externally and no interested parties came forth
asking "hey, what about attributes?". Linux patches were written around
that assumption and proceeded through many rounds of review until we
eventually received sufficient feedback to demonstrate that the
assumption did not in fact hold well enough in general and there seemed
to be a genuine need for RMR attributes, and at that point we started
work on revising the spec.
Was it documented anywhere that the RMR spec mandated Device
or Normal-NC memory attributes? I have read through the spec
pretty thoroughly and not seen this requirement documented
anywhere. Also please feel free to point out where we can find information
regarding how the spec is being revised. I am on causeway and in
all the SC meetings and haven't seen this topic brought up at all.
In the meantime, these patches have sat at v7 for four months - the
*other* outstanding review comments have not been addressed; I still
don't recall seeing an answer about whether LX2160 or anything else
currently deployed actually *needs* cacheable mappings or whether it
could muddle through with the IOMMU_MMIO assumption until proper "RMR
v2" support arrived later; even if so, an interim workaround specific to
LX2160 could have been proposed but hasn't. It is hardly reasonable to
pretend that Arm or the upstream maintainers are responsible for a lack
of development activity on the part of the submitters, no matter how
much blatant misinformation is repeated on Twitter.
Oh the "other" comments where after 7 series of patches you decided
that the approach that was agreed upon on the mailing list was no longer
to your liking? Not to mention the month the patchset sat idle after initial
comments from Ard that were cleared up, when I pinged the thread
and it was ignored. If there was some sort of prompt response on the
threads by the maintainers with accurate information about why the
patches were being held up, or that they were working on a new
spec maybe developers would have bothered to push the patchset forward.
There is no misinformation on Twitter. After 7 series on a patchset after
initial discussion that it would be designed so device-tree could leverage
the backend work, you just changed your mind, and basically sent
everything back to the start. Meanwhile only now in this thread are we
finding out that the spec is getting re-worked again, which means that
we will need to update our firmware, and wait for someone to write patches
for the new spec, because guess what?... Arm didn't write the patches
for any of the initial specs.
Arm maintainers should be helping to find ways to get Arm "specifications",
integrated for SystemReady customers to use. Instead we get delayed
responses, about right turns on the path of the patches, or just outright
ignored for a month at a time. Maybe if Arm developers had actually
written the patches when the spec was released there wouldn't have been
almost a year of wasted time by the hardware manufacturers actually
trying to build and deploy products.
-Jon
This is based on a spec that has existed from Arm since 2020 with the
most recent revisions published in Feb 2021. The lack of RMR support
in the kernel is affecting real world products, and the ability for
SystemReady ES certified systems from just fully working with recent
distributions.
I answered above - if you have any questions please ask them, here,
as far as Linux code is concerned.
I understand this is taking a long time, it is also helping us
understand all the possible use cases and how to cover them in
a way that is maintainable in the long run.
Every month that this patchset has sat being unattended by the
maintainers is another kernel dev cycle missed, it is another
another distribution release where users need to add hackish
kernel command-line options to disable security features that
were forced on by default. Not to mention Linux is just one
platform. What if other platforms have already adopted the
existing spec? These are Arm specs and Arm maintainers and
yet nobody seems to agree on anything and absolutely nothing
has been achieved except wasting the time of Shameer, myself,
our companies, and our customers.
-Jon
quoted
Thanks,
Lorenzo
quoted
Even worse, is that without this patchset customers are forced to jump
through hoops to purposefully re-enable smmu bypass making their
systems less secure.
How is this a good experience for customers of SystemReady hardware
when for any mainline distribution to work the first thing they have
to do is make their system less secure?
-Jon
-----Original Message-----
From: iommu [mailto:iommu-bounces@lists.linux-foundation.org] On Behalf
Of Shameer Kolothum
Sent: 05 August 2021 09:07
To: linux-arm-kernel@lists.infradead.org; linux-acpi@vger.kernel.org;
iommu@lists.linux-foundation.org
Cc: robin.murphy@arm.com; jon@solid-run.com; Linuxarm
[off-list ref]; steven.price@arm.com; Guohanjun (Hanjun Guo)
[off-list ref]; yangyicong [off-list ref];
Sami.Mujawar@arm.com; will@kernel.org; wanghuiqiang
[off-list ref]
Subject: [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
Since we have an update to IORT spec(E.c) now[1] and includes additional
attributes/flags for the RMR node, I am planning to respin this series soon.
Going through the new spec, I have a few queries,
The memory range attributes can now be described as one of the following,
0x00: Device-nGnRnE memory
0x01: Device-nGnRE memory
0x02: Device-nGRE memory
0x03: Device-GRE memory
0x04: Normal Inner Non-cacheable Outer Non-cacheable
0x05: Normal Inner Write-back Outer Write-back Inner Shareable
I am not sure how this needs to be captured and used in the kernel. Is there
any intention of using these fine-grained attributes in the kernel now
or a generic mapping of the above to the struct iommu_rev_region prot field
is enough? i.e., something like,
{
....
prot = IOMMU_READ | IOMMU_WRITE;
if (rmr_attr == normal_mem) // 0x05
prot |= IOMMU_CACHE;
if (rmr_attr == device_mem) { //0x00 - 0x03
prot |= IOMMU_MMIO;
prot |= IOMMU_NOEXEC;
}
....
}
Similarly for the 'flags' field, the new 'Access Privilege' is intended to set the
IOMMU_PRIV ?
Please let me know.
Thanks,
Shameer
[1] https://developer.arm.com/documentation/den0049/ec/?lang=en
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Robin Murphy <robin.murphy@arm.com> Date: 2022-01-25 19:32:08
On 2022-01-25 13:00, Shameerali Kolothum Thodi wrote:
Hi Robin/Lorenzo,
quoted
-----Original Message-----
From: iommu [mailto:iommu-bounces@lists.linux-foundation.org] On Behalf
Of Shameer Kolothum
Sent: 05 August 2021 09:07
To: linux-arm-kernel@lists.infradead.org; linux-acpi@vger.kernel.org;
iommu@lists.linux-foundation.org
Cc: robin.murphy@arm.com; jon@solid-run.com; Linuxarm
[off-list ref]; steven.price@arm.com; Guohanjun (Hanjun Guo)
[off-list ref]; yangyicong [off-list ref];
Sami.Mujawar@arm.com; will@kernel.org; wanghuiqiang
[off-list ref]
Subject: [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node
Hi,
The series adds support to IORT RMR nodes specified in IORT
Revision E.b -ARM DEN 0049E[0]. RMR nodes are used to describe
memory ranges that are used by endpoints and require a unity
mapping in SMMU.
We have faced issues with 3408iMR RAID controller cards which
fail to boot when SMMU is enabled. This is because these
controllers make use of host memory for various caching related
purposes and when SMMU is enabled the iMR firmware fails to
access these memory regions as there is no mapping for them.
IORT RMR provides a way for UEFI to describe and report these
memory regions so that the kernel can make a unity mapping for
these in SMMU.
Change History:
v6 --> v7
The only change from v6 is the fix pointed out by Steve to
the SMMUv2 SMR bypass install in patch #8.
Thanks to the Tested-by tags by Laurentiu with SMMUv2 and
Hanjun/Huiqiang with SMMUv3 for v6. I haven't added the tags
yet as the series still needs more review[1].
Feedback and tests on this series is very much appreciated.
Since we have an update to IORT spec(E.c) now[1] and includes additional
attributes/flags for the RMR node, I am planning to respin this series soon.
Going through the new spec, I have a few queries,
The memory range attributes can now be described as one of the following,
0x00: Device-nGnRnE memory
0x01: Device-nGnRE memory
0x02: Device-nGRE memory
0x03: Device-GRE memory
0x04: Normal Inner Non-cacheable Outer Non-cacheable
0x05: Normal Inner Write-back Outer Write-back Inner Shareable
I am not sure how this needs to be captured and used in the kernel. Is there
any intention of using these fine-grained attributes in the kernel now
or a generic mapping of the above to the struct iommu_rev_region prot field
is enough? i.e., something like,
{
....
prot = IOMMU_READ | IOMMU_WRITE;
if (rmr_attr == normal_mem) // 0x05
prot |= IOMMU_CACHE;
if (rmr_attr == device_mem) { //0x00 - 0x03
prot |= IOMMU_MMIO;
prot |= IOMMU_NOEXEC;
}
....
}
Yup, pretty much that, except don't bother with IOMMU_NOEXEC. We can't
reliably infer it - e.g. on an AXI-based interconnect AxCACHE and AxPROT
are entirely orthogonal, so a Device-type read with the "Instruction
access" hint is perfectly legal - and in the common IORT code we're not
in a position to second-guess what any given RMR might represent for
whatever agent is accessing it.
All we can reasonably do here is map the Device types to IOMMU_MMIO and
Write-back to IOMMU_CACHE, and if anyone ever does want to insist that
that's not sufficient, then they're welcome to send patches to make the
IOMMU API more expressive :)
Similarly for the 'flags' field, the new 'Access Privilege' is intended to set the
IOMMU_PRIV ?