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=Qg+uCKfU; spf=pass (domain: arm.com, ip: 40.107.2.85, mailfrom: sami.mujawar@arm.com) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com [40.107.2.85]) by groups.io with SMTP; Fri, 23 Aug 2019 03:57:03 -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=STN+0P7tz3g7WTSgrl8YvAHv9WC0XGzBZkd/rmpRdd8=; b=Qg+uCKfU+RY9CYLRl7qqNBTXSSwmgapdZO+pggqg3Yih+cigLa7BZZYyHytB/dsRAx56+juGs7FEyZmDFxH6+HQF7D+Vn2K/dzYy71Y4FinBE0Vzrp8iMyMihMrrvgIyBv4INj6ksLNz/GYibZ5IOKE6Ru+4pWB+KTr/+T7rNX8= Received: from VI1PR08CA0180.eurprd08.prod.outlook.com (2603:10a6:800:d1::34) by DB6PR0802MB2598.eurprd08.prod.outlook.com (2603:10a6:4:97::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18; Fri, 23 Aug 2019 10:56:59 +0000 Received: from VE1EUR03FT064.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by VI1PR08CA0180.outlook.office365.com (2603:10a6:800:d1::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.18 via Frontend Transport; Fri, 23 Aug 2019 10:56:58 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;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 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT064.mail.protection.outlook.com (10.152.19.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.13 via Frontend Transport; Fri, 23 Aug 2019 10:56:57 +0000 Received: ("Tessian outbound 0c23f37acac0:v27"); Fri, 23 Aug 2019 10:56:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0892f88288b5b917 X-CR-MTA-TID: 64aa7808 Received: from 64dae712afa0.1 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.0.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 77D25131-24EA-4332-8F15-DA873394C4A4.1; Fri, 23 Aug 2019 10:56:42 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2051.outbound.protection.outlook.com [104.47.0.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 64dae712afa0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Fri, 23 Aug 2019 10:56:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mFcg51/voHtQHWauxzNgB6+2tMLrMslGSqpEPumkQzb0LmH2Q97eHWMKjgr+Q/0AzEYY1FLdpk5d4TEHZy0GmlIG8WV7lNbhNBCUXDg5Ca8z5Ec1hUhHtdc44n1Fq9Xw7iklDheJdAYWaGE6G2ukfeTmbvcmenaES8Yw3brZdI+m1xnjF+E7ayynCdbuPdEgtZxe97/5k+9r0EnqpL8uahR6WgnlvcTsz9BK6fXJ0Q4TcWWTqSQ4ASoF2aatHLmHrzEGkONvEMhXHcJ/mjtGuC3OGiD9xLhH/UpyYX2jUAp/PVNt1JvPe+a+kYySENn9vKbYatcoRXMK3joWLz2HXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=STN+0P7tz3g7WTSgrl8YvAHv9WC0XGzBZkd/rmpRdd8=; b=Om5sCnx2Ztqt+MLGuaKzwUtbuRY+m1YwyGwgKYEEZcqOVFiswU8FlVhYyXsBtlGnrJxWd8UpBduLlIwwqybwSlRHoMKhzqFT/HwGpKkPfBShd7hZFCkwNvLsb27RQqxdILBMHhQAt1y+Ic2yw/qZvkdzOuW6Aiyb6wKmgt4ncOf4k/emG37m8/crCuW6YSwoY0CWEVO59JzF242eW9tWxbOK+rib+FilnmIRGraLZMUwAd0BHS1FDlj5oMCf8hZfxa47iE691sqO7SNsWypCeInFjqLA0FnR1mjMU8hG0WVO3SbGpjaOfIf6okvkZRUFPHyHEn7UrsiM3EHRxMA8rA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=temperror action=none header.from=arm.com; dkim=none (message not signed); arc=none 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=STN+0P7tz3g7WTSgrl8YvAHv9WC0XGzBZkd/rmpRdd8=; b=Qg+uCKfU+RY9CYLRl7qqNBTXSSwmgapdZO+pggqg3Yih+cigLa7BZZYyHytB/dsRAx56+juGs7FEyZmDFxH6+HQF7D+Vn2K/dzYy71Y4FinBE0Vzrp8iMyMihMrrvgIyBv4INj6ksLNz/GYibZ5IOKE6Ru+4pWB+KTr/+T7rNX8= Received: from DB6PR0801CA0050.eurprd08.prod.outlook.com (2603:10a6:4:2b::18) by AM0PR08MB4948.eurprd08.prod.outlook.com (2603:10a6:208:163::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.19; Fri, 23 Aug 2019 10:56:40 +0000 Received: from AM5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::208) by DB6PR0801CA0050.outlook.office365.com (2603:10a6:4:2b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.14 via Frontend Transport; Fri, 23 Aug 2019 10:56:39 +0000 Authentication-Results-Original: 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 AM5EUR03FT003.mail.protection.outlook.com (10.152.16.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2199.13 via Frontend Transport; Fri, 23 Aug 2019 10:56:38 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Fri, 23 Aug 2019 10:56:21 +0000 Received: from E107187.Arm.com (10.1.195.55) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Fri, 23 Aug 2019 10:56:21 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , Subject: [PATCH v1 06/19] DynamicTablesPkg: Fix GT Block length assignment Date: Fri, 23 Aug 2019 11:55:26 +0100 Message-ID: <20190823105539.13260-7-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20190823105539.13260-1-sami.mujawar@arm.com> References: <20190823105539.13260-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;IPV:NLI;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(136003)(39860400002)(376002)(346002)(2980300002)(199004)(189003)(446003)(336012)(426003)(63350400001)(63370400001)(186003)(1076003)(44832011)(53416004)(486006)(70586007)(11346002)(2616005)(36756003)(126002)(356004)(476003)(70206006)(2351001)(2906002)(16586007)(51416003)(26005)(76176011)(54906003)(316002)(8676002)(7696005)(6916009)(86362001)(5660300002)(50466002)(48376002)(47776003)(305945005)(53936002)(8936002)(4326008)(50226002)(478600001)(81166006)(81156014)(14444005);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB4948;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: dde24ff1-ddcf-4533-7650-08d727b89dfe X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328);SRVR:AM0PR08MB4948; X-MS-TrafficTypeDiagnostic: AM0PR08MB4948:|DB6PR0802MB2598: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:608;OLM:608; X-Forefront-PRVS: 0138CD935C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: 0WlQsZFx+1OUARM8VHUjswYb2DfBcSczg9PDeh+yhbO4H1MjQuMbRLTgbnQsu4xEn7PYrd0yzweENcQRaNeg4Mu78giCKf7CR2YK26j0+2/jyDU5XjavsaFHnzJq3DUhVGsxKZt7LlULODg9bzKZBZX27G89OyGyV6nQ4MsngviYrNAPJycJnb/QERUMFYxVL4wyUdg/3KGHU9fjeorw0cYUmDslz1O6CTW6RF6ZK69CWASxWZntbi017iCrXwYsT9WV11l0fIjyr0mjRvcChDZWkByzQdA4nYYakWALfbd+vc2P/ales8cSNp5oQ6pwgj5y1Sn/L7sujGx2mVgheFmbDwIfb47oPmBtbAhxBc2xbmCsNQEUW1aRFtsCrfiHgJihJOUDrtXdNydv1pnUiQIc3viddTK6z438LBflGnk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4948 Original-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; Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT064.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(376002)(346002)(39860400002)(396003)(136003)(2980300002)(189003)(199004)(305945005)(26005)(478600001)(6916009)(76176011)(16586007)(336012)(186003)(50226002)(26826003)(51416003)(54906003)(7696005)(48376002)(8936002)(4326008)(47776003)(1076003)(2351001)(14444005)(36756003)(2906002)(36906005)(50466002)(316002)(8676002)(81156014)(81166006)(2616005)(70206006)(70586007)(63370400001)(446003)(22756006)(126002)(5660300002)(486006)(76130400001)(476003)(63350400001)(53416004)(11346002)(426003)(44832011)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0802MB2598;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:TempError;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;MX:1;A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 61acf15f-073f-447e-bc01-08d727b89297 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600166)(710020)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:DB6PR0802MB2598; NoDisclaimer: True X-Forefront-PRVS: 0138CD935C X-Microsoft-Antispam-Message-Info: JGka9Fp/QASSwuSSKefe1Ynyd4GxpziDdaZsJPeIKA8Dlzvnn+xVJuLCYiS8qt5kNS4UjMkwyI/Q2bLYBxqrltCbgfUivexDknK008F4wLk80s9clbgzC1U0CsT4ip4CT0es1pI5VQcEFqV1mnsJ8HqQ5p35nkz09pkF3e+4tep0gsy/yz8Qoou/8onx3SC79iHBROPAEs/FKjC5tprV39wG+zng7kvLXhZdVhfL0e6qLoCR42O6OBJteiiwVGnCRvZP/5ZbqgHf1Y7MAABuhJ9pOt60SxzNWy2GNb3D2lMNqFGpdLi/UTChEOfIpJfZvGhDeqoITI+iISdL/VnF2dVJ4zNf0fWounO7Cczd9LLzr50n5vfJqwWnoE9HuUVB0sHzLLr0pMCEGneakQtj+tubKSXvNh7wepwaqLO7wFY= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2019 10:56:57.2778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dde24ff1-ddcf-4533-7650-08d727b89dfe X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2598 Content-Type: text/plain The VS2017 compiler reports 'warning C4267: '=': conversion from 'size_t' to 'UINT16', possible loss of data'. The sizeof() operator is used to calculate the size of the GT Block structure. The length field in the GT Block structure is 16-bit wide. Since the return type of sizeof() operator is size_t the VS2017 compiler reports the above warning. To fix the warning, an explicit type cast is added. An additional check is also performed to ensure that the calculated GT Block length does not exceed MAX_UINT16. Signed-off-by: Sami Mujawar --- DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c | 25 ++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c index 7e86c30649bd36ecebac75c7e3a86a0c25cd590b..0e996698887aefca8a7240fc27fe3cb9324fd3e2 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c @@ -350,6 +350,7 @@ AddGTBlockList ( EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE * GtBlockFrame; CM_ARM_GTBLOCK_TIMER_FRAME_INFO * GTBlockTimerFrameList; UINT32 GTBlockTimerFrameCount; + UINTN Length; ASSERT (Gtdt != NULL); ASSERT (GTBlockInfo != NULL); @@ -376,11 +377,27 @@ AddGTBlockList ( return Status; } + Length = sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE) + + (sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE) * + GTBlockInfo->GTBlockTimerFrameCount); + + // Check that the length of the GT block does not + // exceed MAX_UINT16 + if (Length > MAX_UINT16) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: GTDT: Too many GT Frames. Count = %d. " \ + "Maximum supported GT Block size exceeded. " \ + "Status = %r\n", + GTBlockInfo->GTBlockTimerFrameCount, + Status + )); + return Status; + } + GTBlock->Type = EFI_ACPI_6_3_GTDT_GT_BLOCK; - GTBlock->Length = sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE) + - (sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE) * - GTBlockInfo->GTBlockTimerFrameCount); - + GTBlock->Length = (UINT16)Length; GTBlock->Reserved = EFI_ACPI_RESERVED_BYTE; GTBlock->CntCtlBase = GTBlockInfo->GTBlockPhysicalAddress; GTBlock->GTBlockTimerCount = GTBlockInfo->GTBlockTimerFrameCount; -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'