Add error handling when the IdMappingCount is not zero and the
IdMappingToken is NULL.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
Notes:
v3:
- New patch in this series. Moves error handling code for [SAMI]
IdMappingToken from patch v2 6/8 and v2 8/8 into this
patch.
Ref: https://edk2.groups.io/g/devel/topic/83600728#76662
https://edk2.groups.io/g/devel/topic/83600726#76661
DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 75 +++++++++++++++++---
1 file changed, 65 insertions(+), 10 deletions(-)
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
index 349caa8006bc34ca789cb3e321a0f87c0cd4ff0d..a1714dbedd3e34e2716e828092aac169461c43c9 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
@@ -899,8 +899,19 @@ AddNamedComponentNodes (
return Status;
}
- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if (NodeList->IdMappingCount > 0) {
+ if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Invalid Id Mapping token,"
+ " Token = 0x%x, Status =%r\n",
+ NodeList->IdMappingToken,
+ Status
+ ));
+ return Status;
+ }
+
// Ids for Named Component
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)NcNode +
NcNode->Node.IdReference);
@@ -1004,8 +1015,19 @@ AddRootComplexNodes (
RcNode->Reserved1[1] = EFI_ACPI_RESERVED_BYTE;
RcNode->Reserved1[2] = EFI_ACPI_RESERVED_BYTE;
- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if (NodeList->IdMappingCount > 0) {
+ if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Invalid Id Mapping token,"
+ " Token = 0x%x, Status =%r\n",
+ NodeList->IdMappingToken,
+ Status
+ ));
+ return Status;
+ }
+
// Ids for Root Complex
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)RcNode +
RcNode->Node.IdReference);
@@ -1233,8 +1255,19 @@ AddSmmuV1V2Nodes (
}
}
- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if (NodeList->IdMappingCount > 0) {
+ if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Invalid Id Mapping token,"
+ " Token = 0x%x, Status =%r\n",
+ NodeList->IdMappingToken,
+ Status
+ ));
+ return Status;
+ }
+
// Ids for SMMU v1/v2 Node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuNode +
SmmuNode->Node.IdReference);
@@ -1349,8 +1382,19 @@ AddSmmuV3Nodes (
SmmuV3Node->DeviceIdMappingIndex = NodeList->DeviceIdMappingIndex;
}
- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if (NodeList->IdMappingCount > 0) {
+ if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Invalid Id Mapping token,"
+ " Token = 0x%x, Status =%r\n",
+ NodeList->IdMappingToken,
+ Status
+ ));
+ return Status;
+ }
+
// Ids for SMMUv3 node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuV3Node +
SmmuV3Node->Node.IdReference);
@@ -1463,8 +1507,19 @@ AddPmcgNodes (
return Status;
}
- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if (NodeList->IdMappingCount > 0) {
+ if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Invalid Id Mapping token,"
+ " Token = 0x%x, Status =%r\n",
+ NodeList->IdMappingToken,
+ Status
+ ));
+ return Status;
+ }
+
// Ids for PMCG node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)PmcgNode +
PmcgNode->Node.IdReference);
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83549): https://edk2.groups.io/g/devel/message/83549
Mute This Topic: https://groups.io/mt/86954331/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-