From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.85]) by mx.groups.io with SMTP id smtpd.web12.29105.1585494852565137775 for ; Sun, 29 Mar 2020 08:14:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=kPzfA8GT; spf=pass (domain: arm.com, ip: 40.107.22.85, mailfrom: sami.mujawar@arm.com) 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=LzTTtZa1XlR9rsEyZv/H3rASrIUytthlz2H3Dc+LRdg=; b=kPzfA8GTxDqQNFf3eLljf7WU3NWE/AlxCZk2zRgjTRWJKkDsxCHuc/k29/GcPLJQt/CtzSaewrYiOgi6iFFZs/yEnBITxscMx8Scp6GWyypMsRXRv+SYA61vCWIyF0q/cxAzch0RBAewSJU5XufRF01hlIAhD8M3y3LEjFNjOi8= Received: from AM7PR02CA0010.eurprd02.prod.outlook.com (2603:10a6:20b:100::20) by DB7PR08MB3353.eurprd08.prod.outlook.com (2603:10a6:5:20::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20; Sun, 29 Mar 2020 15:14:09 +0000 Received: from AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::47) by AM7PR02CA0010.outlook.office365.com (2603:10a6:20b:100::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19 via Frontend Transport; Sun, 29 Mar 2020 15:14:09 +0000 Authentication-Results: spf=pass (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=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT064.mail.protection.outlook.com (10.152.17.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.17 via Frontend Transport; Sun, 29 Mar 2020 15:14:09 +0000 Received: ("Tessian outbound 19f8d550f75c:v48"); Sun, 29 Mar 2020 15:14:08 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7b59c68280bbcfbf X-CR-MTA-TID: 64aa7808 Received: from 5d2ee7a3c96e.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 95F71EE5-0B6F-487E-B423-FA49426F2EB8.1; Sun, 29 Mar 2020 15:14:03 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5d2ee7a3c96e.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 29 Mar 2020 15:14:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZdnYCg/xXhiXYO1/SRSh34W9UBc/XkjPOtHZVe5ji4srojVRRPNUuQEE6fDkUzQnx7/sWXSV3DvYdOxlx/8dNsiPJUeFjkdPAqBnOlEGKkXcZYtF+z4c+3+brGqUNDllw/97OZVjssByFynw8BwMU09PIN8e+Fw4a+MTgiYE3aUS1Cy8T11grTKb3woeSH4F3rv33glH07VuBf4rWyU8OpV3rkyc7lmEgizi3ymrfwgRBKQKP461avDx44Epvlt1kZVItE9KY2EaBtFRrpkqIQ0RSn1RHQi31KmS0VUhc3fS2sfY5V+ipp1xwKv8LFxm1P2rHU59l9hS28fRLRim9A== 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=LzTTtZa1XlR9rsEyZv/H3rASrIUytthlz2H3Dc+LRdg=; b=Pk76/zlzDvpqK6izFrlpRzVi88HwOmO3LZgQymWV43aLN3iCDpsupUgwS8IF0/5l7jlrxbvbwJkYaVly8t5HriqmilsrnvHLxRqWBTBbWwqN1KTy84Jke13dreE5jwLU0iK7dxqhjVSoIz+XyJKHowPGMWYbAs8+umJMg0S0Dl0xTytSyDL9b715awVLKVj7Iv+MVTXgsZD6DGyJoYaKjBBIi56WwHmPnH0QNIj29DBz6oU0B20aWxUtdICQVn41VMDFLfNz2cBdzM4i0uShMrxbuJJ/as8l2gMu+73jCzBAXLkZhcdvTJzIsdqdnCmNmKyjO8QQfKx/fhvK58e7RQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass 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=LzTTtZa1XlR9rsEyZv/H3rASrIUytthlz2H3Dc+LRdg=; b=kPzfA8GTxDqQNFf3eLljf7WU3NWE/AlxCZk2zRgjTRWJKkDsxCHuc/k29/GcPLJQt/CtzSaewrYiOgi6iFFZs/yEnBITxscMx8Scp6GWyypMsRXRv+SYA61vCWIyF0q/cxAzch0RBAewSJU5XufRF01hlIAhD8M3y3LEjFNjOi8= Received: from AM4PR0902CA0004.eurprd09.prod.outlook.com (2603:10a6:200:9b::14) by DB7PR08MB3082.eurprd08.prod.outlook.com (2603:10a6:5:1d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19; Sun, 29 Mar 2020 15:14:00 +0000 Received: from AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:200:9b:cafe::6) by AM4PR0902CA0004.outlook.office365.com (2603:10a6:200:9b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20 via Frontend Transport; Sun, 29 Mar 2020 15:14:00 +0000 Authentication-Results-Original: spf=pass (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=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT061.mail.protection.outlook.com (10.152.16.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2856.17 via Frontend Transport; Sun, 29 Mar 2020 15:14:00 +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; Sun, 29 Mar 2020 15:13:58 +0000 Received: from E107187.Arm.com (10.57.20.21) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 29 Mar 2020 15:13:58 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , Subject: [PATCH v2 05/16] DynamicTablesPkg: Fix Proc node length assignment Date: Sun, 29 Mar 2020 16:13:42 +0100 Message-ID: <20200329151353.14096-6-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20200329151353.14096-1-sami.mujawar@arm.com> References: <20200329151353.14096-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;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(136003)(39850400004)(376002)(396003)(346002)(46966005)(6666004)(44832011)(426003)(8676002)(82740400003)(36756003)(2906002)(316002)(336012)(5660300002)(81166006)(356004)(7696005)(54906003)(2616005)(1076003)(47076004)(86362001)(966005)(4326008)(186003)(478600001)(70206006)(70586007)(81156014)(26005)(8936002)(6916009);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9730dc0-11c1-4c49-70c4-08d7d3f3d470 X-MS-TrafficTypeDiagnostic: DB7PR08MB3082:|DB7PR08MB3353: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 035748864E X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 0bzUiglaFWURobdxVmwDaXWKmcwRqulQYMFZuUbLQfMYRhZoYjchxVufy0KUoYwBpicIYrnRblHztcbEGoXKGJRbyAXcGYHKgRkkEKVZyS6uttlnamem5smG9N2hsFpFws47bZSrbfE7Km0GJkdm0/fLnUKgSTdbAgn+SW0bzuMCBz0r+nu2W/zANR9cPAePPANdaTi+wROySgvxk5EPkj63W5/gIq2QMr19Uy3gHaeBf2HqxYynuZic3KPSrowl2ONelCjFuTDpfeNkP9QyhdMa7Mwp/KOOn7DSAsFUbdXKT/R3lsF8bKdn77tPnmhsaK7DVYXTqkq7xlU4GGwZ3G441aphPsgXeD9QsvuOpNA1Sk90S/lqeAZH4EVwxKFujsi46XAZpzEiLrpvgynxmFibOI179FGhLomerC9XIgw76s/21hdpZPoMbIKghZRkyf2J1y42FWlnvZoS0hgXEsUzOQvdzDqW2L0hOPA3LGxlCNF5aN77vBliRX4ECyyUmts3MMv6yrlAMLlRvrSmazcOTVJY+lKWfLVw0MBVOdTgFWd84NHj7qyk3ICdxiOAZ1L9nqgt/40Tf7HxNjEIRjElhoF1QMn4+CNcJF24JqI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3082 Original-Authentication-Results: spf=pass (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=bestguesspass action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(346002)(39850400004)(136003)(396003)(376002)(46966005)(36756003)(6666004)(1076003)(2906002)(8676002)(4326008)(7696005)(8936002)(81166006)(81156014)(966005)(86362001)(47076004)(6916009)(5660300002)(316002)(54906003)(36906005)(26826003)(478600001)(82740400003)(70206006)(44832011)(2616005)(336012)(426003)(26005)(186003)(70586007);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 13a31d51-2b78-4aa9-7db6-08d7d3f3cf70 X-Forefront-PRVS: 035748864E X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3a7PoBhSOEnGHGJt3yZnGmn+5Qrh3xH/4J262P5+UwxapJPgjS2fq2ktM4CPu1+kvFIgpt7ZikYLeszniK+uKoY3527nYi00YeaimsdNBo0qeKknraIq0XBWoMyxSVAL6ijS27+jGeMmHgJnynn0GJ3DlckNzA83MvRZNA+CoKyG6p9zu3BL85lr31nPd+BXEF6sTGllkFMFpD+8OCbG6xBg/0freKODzlWnN/flBmJbodTWIkX6RJqeXYITxiRwdv2VEdeqlHXm9FVaXgbnih6CLBr8sXSiHJCfEPrLaH78YgShl2kEpFGsLIYNBrg//xPk20OFBOSgt8P77AyoDg5YG5NP5VTXEcTM3j8XKeVLf3O9xgYMUi3BSFU7SzIR3nd9/zkdy9qlJ1doK48t09kN8QV72V6EJqBoZRfw2ErAiAxTokN+uAGGGse4H3jw/rP2r/VFQZyPDn2xlT5U04A42HojxWr76JLRM3qEy0uWb7lV4Q3In2rezcVycv+C8iuWvRZOphmTaKJyj98LeKcxDgmkf7sLfKZOzZyG2LE1IZQ/QVPpbqLYOZgPH2J39IYOhtHOO59RFdVn8SKxRycKLHa5VnyJubN76TnDCuw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2020 15:14:09.0166 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9730dc0-11c1-4c49-70c4-08d7d3f3d470 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: DB7PR08MB3353 Content-Type: text/plain The length field for the Processor Hierarchy node structure is 8-bit wide while the number of private resource field is 32-bit wide. Therefore, the GetProcHierarchyNodeSize() returns the size as a 32-bit value. The VS2017 compiler reports 'warning C4244: '=': conversion from 'UINT32' to 'UINT8', possible loss of data' while assigning the length field of the Processor Hierarchy node structure. To fix this, a type cast is added. In addition, there is a check to ensure that the Processor Hierarchy node size does not exceed MAX_UINT8. Signed-off-by: Sami Mujawar Reviewed-by: Alexei Fedorov --- Notes: v2: Splitting patch series and re-submitting DynamicTablesPkg [SAMI] patches from https://edk2.groups.io/g/devel/message/46261 DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c index 9e42eee9b75bb330833b0f56c98947563d9eb821..40699ce113caa8530c89ac20562cf5abda26b88e 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c @@ -504,6 +504,7 @@ AddProcHierarchyNodes ( PPTT_NODE_INDEXER * ProcNodeIterator; UINT32 NodeCount; + UINT32 Length; ASSERT ( (Generator != NULL) && @@ -539,8 +540,8 @@ AddProcHierarchyNodes ( // imposed on the Processor Hierarchy node by the specification. // Note: The length field is 8 bit wide while the number of private // resource field is 32 bit wide. - if ((sizeof (EFI_ACPI_6_3_PPTT_STRUCTURE_PROCESSOR) + - (ProcInfoNode->NoOfPrivateResources * sizeof (UINT32))) > MAX_UINT8) { + Length = GetProcHierarchyNodeSize (ProcInfoNode); + if (Length > MAX_UINT8) { Status = EFI_INVALID_PARAMETER; DEBUG (( DEBUG_ERROR, @@ -556,7 +557,7 @@ AddProcHierarchyNodes ( // Populate the node header ProcStruct->Type = EFI_ACPI_6_3_PPTT_TYPE_PROCESSOR; - ProcStruct->Length = GetProcHierarchyNodeSize (ProcInfoNode); + ProcStruct->Length = (UINT8)Length; ProcStruct->Reserved[0] = EFI_ACPI_RESERVED_BYTE; ProcStruct->Reserved[1] = EFI_ACPI_RESERVED_BYTE; -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'