]> git.proxmox.com Git - mirror_edk2.git/commitdiff
DynamicTablesPkg: IORT set reference to Id array only if present
authorSami Mujawar <sami.mujawar@arm.com>
Thu, 14 Jul 2022 16:50:26 +0000 (17:50 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 29 Jul 2022 19:22:15 +0000 (19:22 +0000)
The IORT table generator is setting up a reference to ID array for
nodes even when the ID Mapping count is zero. This is not an issue as an
OS would only access the ID Reference if the ID mapping count is not zero.

However, it would be good to set the reference to ID array to zero when
the ID Mapping count is zero rather than populating it with an incorrect
value.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c

index daf9ff00c3deab4005814bbfcf1650469d1e7d92..a4dd3d4a895e0a1ae305c937d9a413665fb8e171 100644 (file)
@@ -876,9 +876,9 @@ AddNamedComponentNodes (
     NcNode->Node.NumIdMappings = NodeList->IdMappingCount;\r
 \r
     ObjectNameLength         = AsciiStrLen (NodeList->ObjectName) + 1;\r
-    NcNode->Node.IdReference =\r
-      (UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE) +\r
-               (ALIGN_VALUE (ObjectNameLength, 4)));\r
+    NcNode->Node.IdReference = (NodeList->IdMappingCount == 0) ?\r
+                               0 : ((UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE) +\r
+                                             (ALIGN_VALUE (ObjectNameLength, 4))));\r
 \r
     // Named Component specific data\r
     NcNode->Flags             = NodeList->Flags;\r
@@ -1007,7 +1007,8 @@ AddRootComplexNodes (
     RcNode->Node.Revision      = 1;\r
     RcNode->Node.Reserved      = EFI_ACPI_RESERVED_DWORD;\r
     RcNode->Node.NumIdMappings = NodeList->IdMappingCount;\r
-    RcNode->Node.IdReference   = sizeof (EFI_ACPI_6_0_IO_REMAPPING_RC_NODE);\r
+    RcNode->Node.IdReference   = (NodeList->IdMappingCount == 0) ?\r
+                                 0 : sizeof (EFI_ACPI_6_0_IO_REMAPPING_RC_NODE);\r
 \r
     // Root Complex specific data\r
     RcNode->CacheCoherent     = NodeList->CacheCoherent;\r
@@ -1188,11 +1189,12 @@ AddSmmuV1V2Nodes (
     SmmuNode->Node.Revision      = 0;\r
     SmmuNode->Node.Reserved      = EFI_ACPI_RESERVED_DWORD;\r
     SmmuNode->Node.NumIdMappings = NodeList->IdMappingCount;\r
-    SmmuNode->Node.IdReference   = sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE) +\r
-                                   (NodeList->ContextInterruptCount *\r
-                                    sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)) +\r
-                                   (NodeList->PmuInterruptCount *\r
-                                    sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT));\r
+    SmmuNode->Node.IdReference   = (NodeList->IdMappingCount == 0) ?\r
+                                   0 : (sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE) +\r
+                                        (NodeList->ContextInterruptCount *\r
+                                         sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)) +\r
+                                        (NodeList->PmuInterruptCount *\r
+                                         sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)));\r
 \r
     // SMMU v1/v2 specific data\r
     SmmuNode->Base  = NodeList->BaseAddress;\r
@@ -1360,8 +1362,8 @@ AddSmmuV3Nodes (
     SmmuV3Node->Node.Revision      = 2;\r
     SmmuV3Node->Node.Reserved      = EFI_ACPI_RESERVED_DWORD;\r
     SmmuV3Node->Node.NumIdMappings = NodeList->IdMappingCount;\r
-    SmmuV3Node->Node.IdReference   =\r
-      sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE);\r
+    SmmuV3Node->Node.IdReference   = (NodeList->IdMappingCount == 0) ?\r
+                                     0 : sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE);\r
 \r
     // SMMUv3 specific data\r
     SmmuV3Node->Base         = NodeList->BaseAddress;\r
@@ -1491,7 +1493,8 @@ AddPmcgNodes (
     PmcgNode->Node.Revision      = 1;\r
     PmcgNode->Node.Reserved      = EFI_ACPI_RESERVED_DWORD;\r
     PmcgNode->Node.NumIdMappings = NodeList->IdMappingCount;\r
-    PmcgNode->Node.IdReference   = sizeof (EFI_ACPI_6_0_IO_REMAPPING_PMCG_NODE);\r
+    PmcgNode->Node.IdReference   = (NodeList->IdMappingCount == 0) ?\r
+                                   0 : sizeof (EFI_ACPI_6_0_IO_REMAPPING_PMCG_NODE);\r
 \r
     // PMCG specific data\r
     PmcgNode->Base                  = NodeList->BaseAddress;\r