From: "Krzysztof Koch" <krzysztof.koch@arm.com>
To: <devel@edk2.groups.io>
Cc: <leif.lindholm@linaro.org>, <Sami.Mujawar@arm.com>,
<Alexei.Fedorov@arm.com>, <Matteo.Carlini@arm.com>,
<Stephanie.Hughes-Fitt@arm.com>, <nd@arm.com>
Subject: [PATCH v1 2/3] DynamicTablesPkg: Test for duplicate UIDs in MADT generator
Date: Thu, 16 May 2019 11:11:32 +0100 [thread overview]
Message-ID: <20190516101133.34912-3-krzysztof.koch@arm.com> (raw)
In-Reply-To: <20190516101133.34912-1-krzysztof.koch@arm.com>
Check for duplicate ACPI Processor UIDs when populating the GIC CPU
(GICC) Interface structures inside the MADT table generator.
Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---
Notes:
v1:
- Detect duplicate ACPI Processor UIDs in GICCs [Krzysztof]
DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c | 90 ++++++++++++++++++--
1 file changed, 83 insertions(+), 7 deletions(-)
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
index ab9734fb31480f1b653227d1d56abf60bb04f98a..613bf665d9cecc6495f5ac84c2515ea89f476194 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
@@ -140,28 +140,96 @@ AddGICC (
Gicc->Reserved2[2] = EFI_ACPI_RESERVED_BYTE;
}
+/**
+ Function to test if two GIC CPU Interface information structures have the
+ same ACPI Processor UID.
+
+ @param [in] GicCInfo1 Pointer to the first GICC info structure.
+ @param [in] GicCInfo2 Pointer to the second GICC info structure.
+ @param [in] Index1 Index of GicCInfo1 in the shared list of GIC
+ CPU Interface Info structures.
+ @param [in] Index2 Index of GicCInfo2 in the shared list of GIC
+ CPU Interface Info structures.
+
+ @retval TRUE GicCInfo1 and GicCInfo2 have the same UID.
+ @retval FALSE GicCInfo1 and GicCInfo2 have different UIDs.
+**/
+BOOLEAN
+EFIAPI
+IsAcpiUidEqual (
+ IN CONST VOID * GicCInfo1,
+ IN CONST VOID * GicCInfo2,
+ IN UINTN Index1,
+ IN UINTN Index2
+ )
+{
+ UINT32 Uid1;
+ UINT32 Uid2;
+
+ ASSERT ((GicCInfo1 != NULL) && (GicCInfo2 != NULL));
+
+ Uid1 = ((CM_ARM_GICC_INFO*)GicCInfo1)->AcpiProcessorUid;
+ Uid2 = ((CM_ARM_GICC_INFO*)GicCInfo2)->AcpiProcessorUid;
+
+ if (Uid1 == Uid2) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: MADT: GICC Info Structures %d and %d have the same ACPI " \
+ "Processor UID: 0x%x.\n",
+ Index1,
+ Index2,
+ Uid1
+ ));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/** Add the GIC CPU Interface Information to the MADT Table.
- @param [in] Gicc Pointer to GIC CPU Interface
- structure list.
- @param [in] GicCInfo Pointer to the GIC CPU
- Information list.
- @param [in] GicCCount Count of GIC CPU Interfaces.
+ This function also checks for duplicate ACPI Processor UIDs.
+
+ @param [in] Gicc Pointer to GIC CPU Interface structure list.
+ @param [in] GicCInfo Pointer to the GIC CPU Information list.
+ @param [in] GicCCount Count of GIC CPU Interfaces.
+
+ @retval EFI_SUCCESS GIC CPU Interface Information was added
+ successfully.
+ @retval EFI_INVALID_PARAMETER One or more invalid GIC CPU Info values were
+ provided and the generator failed to add the
+ information to the table.
**/
STATIC
-VOID
+EFI_STATUS
AddGICCList (
IN EFI_ACPI_6_2_GIC_STRUCTURE * Gicc,
IN CONST CM_ARM_GICC_INFO * GicCInfo,
IN UINT32 GicCCount
)
{
+ BOOLEAN IsAcpiProcUidDuplicated;
+
ASSERT (Gicc != NULL);
ASSERT (GicCInfo != NULL);
+ IsAcpiProcUidDuplicated = FindDuplicateValue (
+ GicCInfo,
+ GicCCount,
+ sizeof (CM_ARM_GICC_INFO),
+ IsAcpiUidEqual
+ );
+ // Duplicate ACPI Processor UID was found so the GICC info provided
+ // is invalid
+ if (IsAcpiProcUidDuplicated) {
+ return EFI_INVALID_PARAMETER;
+ }
+
while (GicCCount-- != 0) {
AddGICC (Gicc++, GicCInfo++);
}
+
+ return EFI_SUCCESS;
}
/** Update the GIC Distributor Information in the MADT Table.
@@ -577,11 +645,19 @@ BuildMadtTable (
goto error_handler;
}
- AddGICCList (
+ Status = AddGICCList (
(EFI_ACPI_6_2_GIC_STRUCTURE*)((UINT8*)Madt + GicCOffset),
GicCInfo,
GicCCount
);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: MADT: Failed to add GICC structures. Status = %r\n",
+ Status
+ ));
+ goto error_handler;
+ }
AddGICD (
(EFI_ACPI_6_2_GIC_DISTRIBUTOR_STRUCTURE*)((UINT8*)Madt + GicDOffset),
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
next prev parent reply other threads:[~2019-05-16 10:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 10:11 [PATCH v1 0/3] Detect duplicate field values in ACPI tables Krzysztof Koch
2019-05-16 10:11 ` [PATCH v1 1/3] DynamicTablesPkg: Add code for finding duplicate values in arrays Krzysztof Koch
2019-05-16 10:11 ` Krzysztof Koch [this message]
2019-05-16 10:11 ` [PATCH v1 3/3] DynamicTablesPkg: Test for duplicate GT Block frame numbers Krzysztof Koch
2019-06-03 10:56 ` [edk2-devel] [PATCH v1 0/3] Detect duplicate field values in ACPI tables Alexei.Fedorov
2019-06-10 19:46 ` Sami Mujawar
2019-06-10 19:53 ` Sami Mujawar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190516101133.34912-3-krzysztof.koch@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox