From nobody Fri Apr 26 14:18:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40779+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1558001508; cv=none; d=zoho.com; s=zohoarc; b=EyVP/XeZBI6gjkxMfT1sdmZaTzkTFlvk+3QjXfy5ukjpM5w8NUUPS029z8lulCYftaKEqzUGbQ8LSJzrHX0r8HikldwG3LE/khe6DJ8QEtj/BGeF1vw8ndPSHDzKegk/Ke9OEFfJh0P1waRgjsJcAdTWNMo4k62eQCpIssXtWSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558001508; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=bdZ+CkLyxf3EKc1SkYu0qR/hM8ZQKanm9ssGcFVMYrE=; b=dCa4ntKhWkCvS0xh9ZJYPs3yUpsgpQsV5qbtAu10ARxQUn01q+OLOW1flUCM7rp/YIl3xwzDIqNocFChmyt/8fqK2EL9r1muV7TuwN3A7NsQ8zKKAGw8oNpDba4xhLley70GJvXQr1WecAbvzl2ohSiX23ki30mWsUh6aKC+MMo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40779+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558001508928296.7596002000847; Thu, 16 May 2019 03:11:48 -0700 (PDT) Return-Path: X-Received: from EUR03-DB5-obe.outbound.protection.outlook.com (EUR03-DB5-obe.outbound.protection.outlook.com [40.107.4.66]) by groups.io with SMTP; Thu, 16 May 2019 03:11:48 -0700 X-Received: from VI1PR0802CA0039.eurprd08.prod.outlook.com (2603:10a6:800:a9::25) by VI1PR08MB3982.eurprd08.prod.outlook.com (2603:10a6:803:e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1900.16; Thu, 16 May 2019 10:11:43 +0000 X-Received: from DB5EUR03FT048.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by VI1PR0802CA0039.outlook.office365.com (2603:10a6:800:a9::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1900.16 via Frontend Transport; Thu, 16 May 2019 10:11:43 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40779+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT048.mail.protection.outlook.com (10.152.21.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1856.11 via Frontend Transport; Thu, 16 May 2019 10:11:42 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Thu, 16 May 2019 10:11:41 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Thu, 16 May 2019 10:11:40 +0000 X-Received: from E119924.Arm.com (10.1.37.21) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 16 May 2019 10:11:39 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 1/3] DynamicTablesPkg: Add code for finding duplicate values in arrays Date: Thu, 16 May 2019 11:11:31 +0100 Message-ID: <20190516101133.34912-2-krzysztof.koch@arm.com> In-Reply-To: <20190516101133.34912-1-krzysztof.koch@arm.com> References: <20190516101133.34912-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 813c7e7a-68a0-476c-00ed-08d6d9e6e4a2 X-MS-TrafficTypeDiagnostic: VI1PR08MB3982: NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: RLhQWuQ3xdA59nTbHnZmm0EJjgnNpORAcaTx6Lws+WWiaUKCLBKMnAO/8kxZeSLVqVlVZJiWsqZUOsLG4ZE6TUJx+aXdTTVN2SO7sCYgoIEuO6fsy8kHmxmau+O/1HMNZxLSo/NJPW+A2FV9yLT2AaNiHmfxOT2e4dG7C3CQ59bp2UdrtO6IF030gPd/HiflyWXU7WrvXydgo26pQUjjKVtFNKqvfhSr6zVcOgklB6nnxf4wK9P7QdeYWeTb8yS8KwozlVWOI8VrKHS68P0F9J+S1TWnpgp2pJdckNZ7ZEHnUqc9pHpDIJdJXJkTCvxcEbaYVOwaxPC/qO30M/jpOhdMs50VKxONkPMCw8CFuQZXlbo+8pXie50ZPUZ6B6mp3m+HtY5a8HRVpvo3rPN7IQr0L+E8LtGrtwBbE6IcYSE= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2019 10:11:42.0911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 813c7e7a-68a0-476c-00ed-08d6d9e6e4a2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[40.67.248.234];Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3982 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558001508; bh=ybaQYisC0lldpyEJaJtgHgtvmD1Y0L9JX1KMAxCBagg=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=K2vnExYee4Xra6qr3qxHZn7eCJbY5LPJ1XofGvrz20c3Vdxjm2rQ7FPgrZfjdTNhAqO yqdtIysrt+rFAhjPXua24vcX3/+3q9TD4L0c7ebPijsSE1dvdCvnRsgTn0rzP5ChDi3lX l4BgNDh6ekjZq43ldKG/LZjtXHTPZLfQVUk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Added generic function for detecting duplicate values in an array. Also defined a function prototype to test if two objects are equal. The prototype is used as an argument to the 'FindDuplicateValues' function. Signed-off-by: Krzysztof Koch Reviewed-by: Alexei Fedorov Alexei.Fedorov@arm.com ( Alexei.Fedorov@arm.com= ) Reviewed-by: Sami Mujawar --- Notes: v1: - Add generic code for duplicate detection [Krzysztof] DynamicTablesPkg/Include/Library/TableHelperLib.h | 48 ++++++++= +++++++ DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c | 64 ++++++++= ++++++++++++ 2 files changed, 112 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTab= lesPkg/Include/Library/TableHelperLib.h index 9c5b3835413f8768ef81ababa932c9f9be7ced82..e4a8dfa046bd97d89f0297ccad5= 21f317bed5c36 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -4,6 +4,9 @@ =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 + @par Glossary: + - PFN - Pointer to a Function + **/ =20 #ifndef TABLE_HELPER_LIB_H_ @@ -59,4 +62,49 @@ AddAcpiHeader ( IN CONST UINT32 Length ); =20 +/** + Function prototype for testing if two arbitrary objects are equal. + + @param [in] Object1 Pointer to the first object to compare. + @param [in] Object2 Pointer to the second object to compare. + @param [in] Index1 Index of Object1. This value is optional a= nd + can be ignored by the specified implementa= tion. + @param [in] Index2 Index of Object2. This value is optional a= nd + can be ignored by the specified implementa= tion. + + @retval TRUE Object1 and Object2 are equal. + @retval FALSE Object1 and Object2 are NOT equal. +**/ +typedef +BOOLEAN +(EFIAPI *PFN_IS_EQUAL)( + IN CONST VOID * Object1, + IN CONST VOID * Object2, + IN UINTN Index1 OPTIONAL, + IN UINTN Index2 OPTIONAL + ); + +/** + Test and report if a duplicate entry exists in the given array of compar= able + elements. + + @param [in] Array Array of elements to test for duplicat= es. + @param [in] Count Number of elements in Array. + @param [in] ElementSize Size of an element in bytes + @param [in] EqualTestFunction The function to call to check if any t= wo + elements are equal. + + @retval TRUE A duplicate element was found or one of + the input arguments is invalid. + @retval FALSE Every element in Array is unique. +**/ +BOOLEAN +EFIAPI +FindDuplicateValue ( + IN CONST VOID * Array, + IN CONST UINTN Count, + IN CONST UINTN ElementSize, + IN PFN_IS_EQUAL EqualTestFunction + ); + #endif // TABLE_HELPER_LIB_H_ diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b= /DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c index 3938302b6d770c5bed2bc6c55a51c96ea8316dff..fc6cf3b088da1f7ad89dd4356b4= 14bede9e80575 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c @@ -13,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Module specific include files. #include #include +#include #include =20 /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO @@ -180,3 +181,66 @@ AddAcpiHeader ( error_handler: return Status; } + +/** + Test and report if a duplicate entry exists in the given array of compar= able + elements. + + @param [in] Array Array of elements to test for duplicat= es. + @param [in] Count Number of elements in Array. + @param [in] ElementSize Size of an element in bytes + @param [in] EqualTestFunction The function to call to check if any t= wo + elements are equal. + + @retval TRUE A duplicate element was found or one of + the input arguments is invalid. + @retval FALSE Every element in Array is unique. +**/ +BOOLEAN +EFIAPI +FindDuplicateValue ( + IN CONST VOID * Array, + IN CONST UINTN Count, + IN CONST UINTN ElementSize, + IN PFN_IS_EQUAL EqualTestFunction + ) +{ + UINTN Index1; + UINTN Index2; + UINT8 * Element1; + UINT8 * Element2; + + if (Array =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "ERROR: FindDuplicateValues: Array is NULL.\n")); + return TRUE; + } + + if (ElementSize =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "ERROR: FindDuplicateValues: ElementSize is 0.\n"= )); + return TRUE; + } + + if (EqualTestFunction =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "ERROR: FindDuplicateValues: EqualTestFunction is NULL.\n" + )); + return TRUE; + } + + if (Count < 2) { + return FALSE; + } + + for (Index1 =3D 0; Index1 < Count - 1; Index1++) { + for (Index2 =3D Index1 + 1; Index2 < Count; Index2++) { + Element1 =3D (UINT8*)Array + (Index1 * ElementSize); + Element2 =3D (UINT8*)Array + (Index2 * ElementSize); + + if (EqualTestFunction (Element1, Element2, Index1, Index2)) { + return TRUE; + } + } + } + return FALSE; +} -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#40779): https://edk2.groups.io/g/devel/message/40779 Mute This Topic: https://groups.io/mt/31639037/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 14:18:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40780+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1558001511; cv=none; d=zoho.com; s=zohoarc; b=RjZ546RfvRKePMUX3Tc/ds5p5RdnezbpvivDVvOmb9atxPxpm4UJnJ5jA8xVBYMZL9y+r6xwh5RDDAq0yot8ND5hIscNJUT6sqNiJab2xWI9Vel0Jda6fgjIVS31KOhseKyhRTFbMX4Pxtv3JJyzCf0X8Hm+d8ubaVOT/maiKoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558001511; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=cIX2IAe+F86K4j2h5YycJ9emQaYwEyyF7nWzqRwg/3M=; b=YDEAQ+sq1x1AWD60JDrXHx7NjwbDcli06DAN3TKKe+phsku1zx7qaIOXPGZbrUZ5opWbLONQK76xe6UjV328BW23L6ZRzE6+fypoHAsumAV1Dv5Cp5HNNT8cbStohbVSY4fTsWtrslAqDK8ymLQQM9vxJz0Ydc8ClRJ2LUI9NWo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40780+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558001510960274.1396360479446; Thu, 16 May 2019 03:11:50 -0700 (PDT) Return-Path: X-Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.48]) by groups.io with SMTP; Thu, 16 May 2019 03:11:49 -0700 X-Received: from VI1PR08CA0229.eurprd08.prod.outlook.com (2603:10a6:802:15::38) by DBBPR08MB4775.eurprd08.prod.outlook.com (2603:10a6:10:d5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Thu, 16 May 2019 10:11:44 +0000 X-Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by VI1PR08CA0229.outlook.office365.com (2603:10a6:802:15::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1900.16 via Frontend Transport; Thu, 16 May 2019 10:11:44 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40780+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1856.11 via Frontend Transport; Thu, 16 May 2019 10:11:43 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Thu, 16 May 2019 10:11:40 +0000 X-Received: from E119924.Arm.com (10.1.37.21) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 16 May 2019 10:11:40 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 2/3] DynamicTablesPkg: Test for duplicate UIDs in MADT generator Date: Thu, 16 May 2019 11:11:32 +0100 Message-ID: <20190516101133.34912-3-krzysztof.koch@arm.com> In-Reply-To: <20190516101133.34912-1-krzysztof.koch@arm.com> References: <20190516101133.34912-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c5d1161-4b8b-47c3-afaa-08d6d9e6e537 X-MS-TrafficTypeDiagnostic: DBBPR08MB4775: NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: WGnTyTgoTEqRX2AIiMZuOEWAa2FQzRzqDc53lnluuPe9/bbIzkmO1rRLzAcVYs3JqVX4Mz+PptNpIbtm4m9GRqpTNxBsgtN+W0DQqMYaKB0z4rtgAwOeNPWCUoxDC3A17fxVFqqOW5BbG6cXm94lP8XowVneAZ7KRC8hVgmL6v93+9tGciFT+Qx9/xBJ4mcYl2bi8rkdUVv8q2UmiGmE/X841z9ILmBy0XQrWDjpIQk9hglwFK8bhjU9grSKzR4lXeDOOZwJFMYVRBidj/ZU+HJeS+gkGRmw0AedBYEJz07x0GuLwWfIhsm0YFMGCaT0+mQbn4MZqqRMifWcVfFeqYaaQANn5sCG+Bhkr+5dho7R7vLI/I5XzHFNmKf+yhXdl7CRjesnLvRg9b7bbngVk1QiwO6UjU19GBWOhq9ayZ8= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2019 10:11:43.0070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c5d1161-4b8b-47c3-afaa-08d6d9e6e537 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[40.67.248.234];Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4775 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558001510; bh=3zyFbOsxVXWLQLUycGICroFsa6jOdKHJqDKhJrOOgwM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=kA5MtIiov/8LS1n5iFxNNQHL+pJOMs9i+fmZq4OQ+7R/QzV/eCZaVQInQcC/7W9FjlZ eS4BGM5QlTPMknKhnEDwybxxIV6+zEOnmIc6y6Nb15NAz1CX2yWnaZ3E/RMmUc6SK2Hle g7m2/551QbwmIstDeYhqXwTvRba6YjxyQSM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check for duplicate ACPI Processor UIDs when populating the GIC CPU (GICC) Interface structures inside the MADT table generator. Signed-off-by: Krzysztof Koch Reviewed-by: Alexei Fedorov Alexei.Fedorov@arm.com ( Alexei.Fedorov@arm.com= ) Reviewed-by: Sami Mujawar --- 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..613bf665d9cecc6495f5ac84c25= 15ea89f476194 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] =3D EFI_ACPI_RESERVED_BYTE; } =20 +/** + 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 structur= e. + @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 UI= D. + @retval FALSE GicCInfo1 and GicCInfo2 have different U= IDs. +**/ +BOOLEAN +EFIAPI +IsAcpiUidEqual ( + IN CONST VOID * GicCInfo1, + IN CONST VOID * GicCInfo2, + IN UINTN Index1, + IN UINTN Index2 + ) +{ + UINT32 Uid1; + UINT32 Uid2; + + ASSERT ((GicCInfo1 !=3D NULL) && (GicCInfo2 !=3D NULL)); + + Uid1 =3D ((CM_ARM_GICC_INFO*)GicCInfo1)->AcpiProcessorUid; + Uid2 =3D ((CM_ARM_GICC_INFO*)GicCInfo2)->AcpiProcessorUid; + + if (Uid1 =3D=3D 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. =20 - @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 lis= t. + @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 value= s were + provided and the generator failed to a= dd 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 !=3D NULL); ASSERT (GicCInfo !=3D NULL); =20 + IsAcpiProcUidDuplicated =3D 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-- !=3D 0) { AddGICC (Gicc++, GicCInfo++); } + + return EFI_SUCCESS; } =20 /** Update the GIC Distributor Information in the MADT Table. @@ -577,11 +645,19 @@ BuildMadtTable ( goto error_handler; } =20 - AddGICCList ( + Status =3D 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 =3D %r\n", + Status + )); + goto error_handler; + } =20 AddGICD ( (EFI_ACPI_6_2_GIC_DISTRIBUTOR_STRUCTURE*)((UINT8*)Madt + GicDOffset), -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#40780): https://edk2.groups.io/g/devel/message/40780 Mute This Topic: https://groups.io/mt/31639038/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 14:18:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40781+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1558001512; cv=none; d=zoho.com; s=zohoarc; b=JhrLTYEDtJtqI1V7R1jE1SPgKlL7MY5d17xDznYYX+9FYZwC5HxU5fEhMk3B4xclJQN9DEHTm3wq0SbifHbG38I65bInqrVcuf1gKGlfULiYbizxpc6fBWwr7Y2zOdslNAjD7SXOlkL6t6uAvegLhm3XJUX8BP2+RLtZeVt2i14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558001512; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ch4egDoZvp2QiIuNY2K+ekjZuVOv9xCgN5DzmOAZLIs=; b=cPMH6J1FRbGVib/X/mchJFELTRQTLrO2vC0l0f2UFYoa25woTNOULzvMBx9WqZURBNUGjzloimV4tPQkIDHurcIqzah9oosP9g/QxSwNkTJs1yb6VyIoBtCP47K2t1ZN8chCGcT0Qz/MrYbiW5mJhtzmm/eBXkKO8zis2GhCexs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40781+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558001512113170.01259493638702; Thu, 16 May 2019 03:11:52 -0700 (PDT) Return-Path: X-Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.53]) by groups.io with SMTP; Thu, 16 May 2019 03:11:50 -0700 X-Received: from DB6PR0802CA0040.eurprd08.prod.outlook.com (10.172.252.154) by VI1PR0802MB2511.eurprd08.prod.outlook.com (10.175.20.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1900.16; Thu, 16 May 2019 10:11:46 +0000 X-Received: from VE1EUR03FT061.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::205) by DB6PR0802CA0040.outlook.office365.com (2603:10a6:4:a3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1900.16 via Frontend Transport; Thu, 16 May 2019 10:11:46 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40781+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT061.mail.protection.outlook.com (10.152.19.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1856.11 via Frontend Transport; Thu, 16 May 2019 10:11:44 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Thu, 16 May 2019 10:11:41 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Thu, 16 May 2019 10:11:41 +0000 X-Received: from E119924.Arm.com (10.1.37.21) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 16 May 2019 10:11:40 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 3/3] DynamicTablesPkg: Test for duplicate GT Block frame numbers Date: Thu, 16 May 2019 11:11:33 +0100 Message-ID: <20190516101133.34912-4-krzysztof.koch@arm.com> In-Reply-To: <20190516101133.34912-1-krzysztof.koch@arm.com> References: <20190516101133.34912-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 262959f9-27c7-4c4c-8b51-08d6d9e6e62b X-MS-TrafficTypeDiagnostic: VI1PR0802MB2511: NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: JGSICj4klblyapOQ9RtdaPaDjAsWmhHlqE6wSKZAH77hUyYzD8pNXGuJdwOsPtPQBIFsc/SgYoKJF7uZCwJnNc7gb+OFinikQ/hti8vaMmBrnjuClxA+Y2KWog+xb3Uq2aD+OoNH3mX45guQifVj7PV0+EslA4ZH3ASpfnjCRN8p3gN7qchcAiY1wCkZZjwUsyRziIoFDsPtbe4NK0U9/jyUHgsbBvDvozB8n6E/mBbr2WCcya6zkbCdicgKURzhvYIo1r6s2NqlPa0koh9AbwM2bEuQ/wvVADzwMaT8BFzjnvZXp6MNmyGU/l5hQLOQm4/i0K5hpZd/uT1s59k/U5fvXcWPr2yDvRAFKY3rE+jPPuin39CVgE7i0KBcN/QqoAZ9ZARZKELBKICcYV6qpzSuGQ1xjNVx/Mqfwwmza/c= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2019 10:11:44.5631 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 262959f9-27c7-4c4c-8b51-08d6d9e6e62b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[40.67.248.234];Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2511 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558001511; bh=pjWpLF4EIjxZkkMHXbsEGj29UWrAFzFBW+Ug15YQHDo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=aE0Kwjwb5LI3hjYkU3dtUT6ZQSCdEw3aIkIU5BrkaZs7xgaEMvMsJVliUTvQ4PpGded UUdnj5qbsNuE4JfR4EqLRUe8pS9lB1Oh/drnJLyWcqsNOg0Gp3DLsvCujYkLQdCF82CUN QHMZWi6iSUJq9g9Zmt9Bny96clIk8EZnwZ8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check for duplicate frame numbers when populating the GT Block Timer Frames inside the GTDT table generator. Signed-off-by: Krzysztof Koch Reviewed-by: Alexei Fedorov Alexei.Fedorov@arm.com ( Alexei.Fedorov@arm.com= ) Reviewed-by: Sami Mujawar --- Notes: v1: - Detect duplicate GT Frame Numbers in GTDT [Krzysztof] DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c | 66 ++++= +++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c index 8d9ddcf9244b9f8b795edf7a53dd8a071bb121bc..d1ac9110cc5c8df8506b6db09cc= 362fdb0df8d76 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c @@ -179,6 +179,55 @@ AddGenericWatchdogList ( } // for } =20 +/** + Function to test if two Generic Timer Block Frame Info structures have t= he + same frame number. + + @param [in] Frame1 Pointer to the first GT Block Frame Info + structure. + @param [in] Frame2 Pointer to the second GT Block Frame Info + structure. + @param [in] Index1 Index of Frame1 in the shared GT Block Fra= me + Information List. + @param [in] Index2 Index of Frame2 in the shared GT Block Fra= me + Information List. + + @retval TRUE Frame1 and Frame2 have the same frame numb= er. + @return FALSE Frame1 and Frame2 have different frame num= bers. + +**/ +BOOLEAN +EFIAPI +IsGtFrameNumberEqual ( + IN CONST VOID * Frame1, + IN CONST VOID * Frame2, + IN UINTN Index1, + IN UINTN Index2 + ) +{ + UINT8 FrameNumber1; + UINT8 FrameNumber2; + + ASSERT ((Frame1 !=3D NULL) && (Frame2 !=3D NULL)); + + FrameNumber1 =3D ((CM_ARM_GTBLOCK_TIMER_FRAME_INFO*)Frame1)->FrameNumber; + FrameNumber2 =3D ((CM_ARM_GTBLOCK_TIMER_FRAME_INFO*)Frame2)->FrameNumber; + + if (FrameNumber1 =3D=3D FrameNumber2) { + DEBUG (( + DEBUG_ERROR, + "ERROR: GTDT: GT Block Frame Info Structures %d and %d have the same= " \ + "frame number: 0x%x.\n", + Index1, + Index2, + FrameNumber1 + )); + return TRUE; + } + + return FALSE; +} + /** Update the GT Block Timer Frame lists in the GTDT Table. =20 @param [in] GtBlockFrame Pointer to the GT Block Frames @@ -187,8 +236,8 @@ AddGenericWatchdogList ( Information List. @param [in] GTBlockFrameCount Number of GT Block Frames. =20 - @retval EFI_SUCCESS Table generated successfully. - @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. **/ STATIC EFI_STATUS @@ -198,6 +247,8 @@ AddGTBlockTimerFrames ( IN UINT32 GTBlockFrame= Count ) { + BOOLEAN IsFrameNumberDuplicated; + ASSERT (GtBlockFrame !=3D NULL); ASSERT (GTBlockTimerFrameList !=3D NULL); =20 @@ -211,6 +262,17 @@ AddGTBlockTimerFrames ( return EFI_INVALID_PARAMETER; } =20 + IsFrameNumberDuplicated =3D FindDuplicateValue ( + GTBlockTimerFrameList, + GTBlockFrameCount, + sizeof (CM_ARM_GTBLOCK_TIMER_FRAME_INFO), + IsGtFrameNumberEqual + ); + // Duplicate entry was found so timer frame numbers provided are invalid + if (IsFrameNumberDuplicated) { + return EFI_INVALID_PARAMETER; + } + while (GTBlockFrameCount-- !=3D 0) { DEBUG (( DEBUG_INFO, -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#40781): https://edk2.groups.io/g/devel/message/40781 Mute This Topic: https://groups.io/mt/31639039/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-