]> xenbits.xensource.com Git - xen.git/commitdiff
AMD/IOMMU: introduce a "valid" flag for IVRS mappings
authorJan Beulich <jbeulich@suse.com>
Tue, 17 Sep 2019 14:05:01 +0000 (16:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 17 Sep 2019 14:05:01 +0000 (16:05 +0200)
For us to no longer blindly allocate interrupt remapping tables for
everything the ACPI tables name, we can't use struct ivrs_mappings'
intremap_table field anymore to also have the meaning of "this entry
is valid". Add a separate boolean field instead.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/drivers/passthrough/amd/iommu_acpi.c
xen/drivers/passthrough/amd/iommu_init.c
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/include/asm-x86/amd-iommu.h

index 668a9805eff225dc28328b1b538c962982abe98e..197f3e64039c9a7f7d00751d87ed3d9593aee107 100644 (file)
@@ -88,6 +88,8 @@ static void __init add_ivrs_mapping_entry(
          }
     }
 
+    ivrs_mappings[alias_id].valid = true;
+
     /* Assign IOMMU hardware. */
     ivrs_mappings[bdf].iommu = iommu;
 }
index df7dded939b2da66794e9529d925ab9624f16011..d6a5cf2e4ab8354a84c3ac0e1b43af65f98a462c 100644 (file)
@@ -1241,7 +1241,6 @@ static int __init amd_iommu_setup_device_table(
     u16 seg, struct ivrs_mappings *ivrs_mappings)
 {
     unsigned int bdf;
-    void *intr_tb, *dte;
 
     BUG_ON( (ivrs_bdf_entries == 0) );
 
@@ -1261,16 +1260,17 @@ static int __init amd_iommu_setup_device_table(
     /* Add device table entries */
     for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ )
     {
-        intr_tb = ivrs_mappings[bdf].intremap_table;
-
-        if ( intr_tb )
+        if ( ivrs_mappings[bdf].valid )
         {
+            void *dte;
+
             /* add device table entry */
             dte = device_table.buffer + (bdf * IOMMU_DEV_TABLE_ENTRY_SIZE);
             iommu_dte_add_device_entry(dte, &ivrs_mappings[bdf]);
 
             amd_iommu_set_intremap_table(
-                dte, (u64)virt_to_maddr(intr_tb), iommu_intremap);
+                dte, virt_to_maddr(ivrs_mappings[bdf].intremap_table),
+                iommu_intremap);
         }
     }
 
index 8d4a5fbc37f40aa378099e704f9c8cb588b61302..465a49798d631cde6f2971f3482cdb8e1e50d72e 100644 (file)
@@ -69,8 +69,8 @@ struct amd_iommu *find_iommu_for_device(int seg, int bdf)
  * table and I/O page table respectively. Such devices will have
  * both alias entry and select entry in IVRS structure.
  *
- * Return original device id, if device has valid interrupt remapping
- * table setup for both select entry and alias entry.
+ * Return original device id if both the specific entry and the alias entry
+ * have been marked valid.
  */
 int get_dma_requestor_id(uint16_t seg, uint16_t bdf)
 {
@@ -79,8 +79,7 @@ int get_dma_requestor_id(uint16_t seg, uint16_t bdf)
 
     BUG_ON ( bdf >= ivrs_bdf_entries );
     req_id = ivrs_mappings[bdf].dte_requestor_id;
-    if ( (ivrs_mappings[bdf].intremap_table != NULL) &&
-         (ivrs_mappings[req_id].intremap_table != NULL) )
+    if ( ivrs_mappings[bdf].valid && ivrs_mappings[req_id].valid )
         req_id = bdf;
 
     return req_id;
index 951a0125654db25a9fdf033d9c3e42acd48b11b5..1ca6735a256853d5fd53b68fd97fdc22033aeffb 100644 (file)
@@ -111,6 +111,7 @@ struct ivrs_mappings {
     u8 unity_map_enable;
     u8 write_permission;
     u8 read_permission;
+    bool valid;
     unsigned long addr_range_start;
     unsigned long addr_range_length;
     struct amd_iommu *iommu;