Skip to contentSkip to conversation

iommu/vt-d: Allocate reserved region for ISA with correct permission

PATCH In review Jerry Snitselaar 3 participants 5 messages Dec 13, 2019 – Dec 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/vt-d: Allocate reserved region for ISA with correct permission

Currently the reserved region for ISA is allocated with no permissions. If a dma domain is being used, mapping this region will fail. Set the permissions to DMA_PTE_READ|DMA_PTE_WRITE.

Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>
Fixes d850c2ee5fe2 ("iommu/vt-d: Expose ISA direct mapping region via iommu_get_resv_regions")
---
 drivers/iommu/intel-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
index 0c8d81f56a30..998529cebcf2 100644
@@ -5736,7 +5736,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
 		struct pci_dev *pdev = to_pci_dev(device);
 
 		if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
-			reg = iommu_alloc_resv_region(0, 1UL << 24, 0,
+			reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
 						      IOMMU_RESV_DIRECT);
 			if (reg)
 				list_add_tail(&reg->list, head);
Signature · 1 line
2.24.0
#1 lore raw

Hi Jerry,

Quoted 19 lines · Jerry Snitselaar

Currently the reserved region for ISA is allocated with no permissions. If a dma domain is being used, mapping this region will fail. Set the permissions to DMA_PTE_READ|DMA_PTE_WRITE.

Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>
Fixes d850c2ee5fe2 ("iommu/vt-d: Expose ISA direct mapping region via iommu_get_resv_regions")
---
  drivers/iommu/intel-iommu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +0 -0
index 0c8d81f56a30..998529cebcf2 100644

drivers/iommu/intel-iommu.c static void intel_iommu_get_resv_regions(struct device *device, · line 5740

Quoted 6 lines
drivers/iommu/intel-iommu.c +1 -1
@@ -5736,7 +5736,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
  		struct pci_dev *pdev = to_pci_dev(device);
 
  		if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
-			reg = iommu_alloc_resv_region(0, 1UL << 24, 0,
+			reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
  						      IOMMU_RESV_DIRECT);

This also applies to the IOAPIC range. Can you please change them together?

drivers/iommu/intel-iommu.c +1 -1
index 0c8d81f56a30..256e48434f68 100644
@@ -5736,7 +5736,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
                struct pci_dev *pdev = to_pci_dev(device);
 
                if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
-                       reg = iommu_alloc_resv_region(0, 1UL << 24, 0,
+                       reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
                                                      IOMMU_RESV_DIRECT);
                        if (reg)
                                list_add_tail(&reg->list, head);
@@ -5746,7 +5746,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
 
        reg = iommu_alloc_resv_region(IOAPIC_RANGE_START,
                                      IOAPIC_RANGE_END - 

IOAPIC_RANGE_START + 1,
- 0, IOMMU_RESV_MSI);

+                                     prot, IOMMU_RESV_MSI);
        if (!reg)
                return;
        list_add_tail(&reg->list, head);

Best regards,
baolu

Quoted 3 lines
drivers/iommu/intel-iommu.c +0 -0
  			if (reg)
  				list_add_tail(&reg->list, head);
#2 lore raw

Hi Jerry,

Quoted 17 lines · Lu Baolu

Hi Jerry,

Quoted 14 lines · Jerry Snitselaar

Currently the reserved region for ISA is allocated with no permissions. If a dma domain is being used, mapping this region will fail. Set the permissions to DMA_PTE_READ|DMA_PTE_WRITE.

Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>
Fixes d850c2ee5fe2 ("iommu/vt-d: Expose ISA direct mapping region via iommu_get_resv_regions")

---
  drivers/iommu/intel-iommu.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

drivers/iommu/intel-iommu.c static void intel_iommu_get_resv_regions(struct · line 5740

Quoted 11 lines
drivers/iommu/intel-iommu.c +1 -1
index 0c8d81f56a30..998529cebcf2 100644
@@ -5736,7 +5736,7 @@ static void intel_iommu_get_resv_regions(struct 
 device *device,
           struct pci_dev *pdev = to_pci_dev(device);
           if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
-            reg = iommu_alloc_resv_region(0, 1UL << 24, 0,
+            reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
                                 IOMMU_RESV_DIRECT);

This also applies to the IOAPIC range. Can you please change them together?

Please ignore this comment. These two ranges are of different type. Your fix is enough. Sorry for the confusion.

Best regards,
baolu

Acked-by on v1 1/1
#3 lore raw
In reply to Jerry Snitselaar

Hi,

Quoted 10 lines · Jerry Snitselaar

Currently the reserved region for ISA is allocated with no permissions. If a dma domain is being used, mapping this region will fail. Set the permissions to DMA_PTE_READ|DMA_PTE_WRITE.

Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>
Fixes d850c2ee5fe2 ("iommu/vt-d: Expose ISA direct mapping region via iommu_get_resv_regions")

This fix looks reasonable to me.

Best regards,
baolu

Quoted 18 lines
---
  drivers/iommu/intel-iommu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
index 0c8d81f56a30..998529cebcf2 100644
@@ -5736,7 +5736,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
  		struct pci_dev *pdev = to_pci_dev(device);
 
  		if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
-			reg = iommu_alloc_resv_region(0, 1UL << 24, 0,
+			reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
  						      IOMMU_RESV_DIRECT);
  			if (reg)
  				list_add_tail(&reg->list, head);
#4 lore raw
Quoted 14 lines · Lu Baolu

Hi,

Quoted 10 lines · Jerry Snitselaar

Currently the reserved region for ISA is allocated with no permissions. If a dma domain is being used, mapping this region will fail. Set the permissions to DMA_PTE_READ|DMA_PTE_WRITE.

Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>
Fixes d850c2ee5fe2 ("iommu/vt-d: Expose ISA direct mapping region via iommu_get_resv_regions")
Quoted 3 lines

This fix looks reasonable to me.

Applied for v5.5, thanks.