From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=jMgJyi1B; spf=pass (domain: arm.com, ip: 40.107.15.53, mailfrom: krzysztof.koch@arm.com) 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x9v/MOLuXvaZKHpdlr55+UeQUHnQNDyeu+w7A4l+Zj0=; b=jMgJyi1Bq/FJ3ve3ZCgpKwDIsZa9YhzB4UStsXnZ7ham3i+ltwJss+DCka/EmhNe6CK1rT0xrHukLINAQInXtHfPJwEaLhrkV1pAcGE7xF15URlRYaaEMFn+JEffpOf5RxK63GjaG5dBlW50sW+vAemvPnDphZ16RXOsA6HOHCA= 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 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 Authentication-Results: spf=temperror (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) 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 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 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 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: [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> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190516101133.34912-1-krzysztof.koch@arm.com> References: <20190516101133.34912-1-krzysztof.koch@arm.com> Return-Path: Krzysztof.Koch@arm.com MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:40.67.248.234;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(396003)(136003)(39860400002)(2980300002)(199004)(189003)(81166006)(81156014)(68736007)(72206003)(53416004)(76176011)(86362001)(476003)(186003)(26005)(2616005)(4326008)(6916009)(486006)(53936002)(77096007)(126002)(8676002)(1076003)(8936002)(356004)(48376002)(2351001)(11346002)(316002)(47776003)(70206006)(70586007)(6666004)(50226002)(7696005)(305945005)(2906002)(16586007)(54906003)(5660300002)(478600001)(336012)(50466002)(51416003)(63370400001)(426003)(44832011)(14444005)(63350400001)(36756003)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0802MB2511;H:nebula.arm.com;FPR:;SPF:TempError;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 262959f9-27c7-4c4c-8b51-08d6d9e6e62b X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328);SRVR:VI1PR0802MB2511; X-MS-TrafficTypeDiagnostic: VI1PR0802MB2511: NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0039C6E5C5 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 Content-Type: text/plain Check for duplicate frame numbers when populating the GT Block Timer Frames inside the GTDT table generator. Signed-off-by: Krzysztof Koch --- 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..d1ac9110cc5c8df8506b6db09cc362fdb0df8d76 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c @@ -179,6 +179,55 @@ AddGenericWatchdogList ( } // for } +/** + Function to test if two Generic Timer Block Frame Info structures have the + 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 Frame + Information List. + @param [in] Index2 Index of Frame2 in the shared GT Block Frame + Information List. + + @retval TRUE Frame1 and Frame2 have the same frame number. + @return FALSE Frame1 and Frame2 have different frame numbers. + +**/ +BOOLEAN +EFIAPI +IsGtFrameNumberEqual ( + IN CONST VOID * Frame1, + IN CONST VOID * Frame2, + IN UINTN Index1, + IN UINTN Index2 + ) +{ + UINT8 FrameNumber1; + UINT8 FrameNumber2; + + ASSERT ((Frame1 != NULL) && (Frame2 != NULL)); + + FrameNumber1 = ((CM_ARM_GTBLOCK_TIMER_FRAME_INFO*)Frame1)->FrameNumber; + FrameNumber2 = ((CM_ARM_GTBLOCK_TIMER_FRAME_INFO*)Frame2)->FrameNumber; + + if (FrameNumber1 == 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. @param [in] GtBlockFrame Pointer to the GT Block Frames @@ -187,8 +236,8 @@ AddGenericWatchdogList ( Information List. @param [in] GTBlockFrameCount Number of GT Block Frames. - @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 GTBlockFrameCount ) { + BOOLEAN IsFrameNumberDuplicated; + ASSERT (GtBlockFrame != NULL); ASSERT (GTBlockTimerFrameList != NULL); @@ -211,6 +262,17 @@ AddGTBlockTimerFrames ( return EFI_INVALID_PARAMETER; } + IsFrameNumberDuplicated = 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-- != 0) { DEBUG (( DEBUG_INFO, -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'