From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.41]) by mx.groups.io with SMTP id smtpd.web12.29107.1585494856146029385 for ; Sun, 29 Mar 2020 08:14:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Rg4/DmFj; spf=pass (domain: arm.com, ip: 40.107.15.41, 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=VEbVH+Bgw8gAhEdl4MumBrcv5nMPapQt/J1aDOOOze4=; b=Rg4/DmFj6F+WjnyABE4AlqAq8pureogkTPp2wORkgSC0So9YwtmiGwYsyJSipphSBYnJjVD9L8mu793Q5Cn1zv8NZ40Jpk36wXEScfibZtORue6IFiFea04Rlhf17zLE8dOrpu5d0y3zsYj77xvB81Jhy+40A5DCj0pxLMZH5u0= Received: from DB8PR09CA0007.eurprd09.prod.outlook.com (2603:10a6:10:a0::20) by AM6PR08MB4659.eurprd08.prod.outlook.com (2603:10a6:20b:ca::16) 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:14 +0000 Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:a0:cafe::62) by DB8PR09CA0007.outlook.office365.com (2603:10a6:10:a0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18 via Frontend Transport; Sun, 29 Mar 2020 15:14:14 +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 DB5EUR03FT027.mail.protection.outlook.com (10.152.20.121) 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:14 +0000 Received: ("Tessian outbound e13acb17570e:v48"); Sun, 29 Mar 2020 15:14:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0901abb6ec8963b9 X-CR-MTA-TID: 64aa7808 Received: from 687ddea41359.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 283C1816-FC9C-40EC-98EB-72A822901640.1; Sun, 29 Mar 2020 15:14:08 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 687ddea41359.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 29 Mar 2020 15:14:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iCKuYHwKo/CvAFFnnZgrD4ZBbfyE1u6h7UJrIsk1YTcZTddgLekvVy+P0u7KIv+nEI3z7Bg3Im+8i+VPPQXm+zNpyTc7EARGRgIV7ZQOshCyhXwQZS/W/GIUpFW1BgwhMjUNxXYMhEKZCanKmQN8AnSd2DlrJUh3EqMSLywPfh9DbzOtkLRfpoARQPUmCKC0xtsHzuV9TPUR3UHXitOw7WhnzuiBZQFfj0hrPJV8q3QUtP7r06lDKQZofICCUId9d5UucBJNC2wOnpfi0WjpaOjvfdOJRvsDU997b4C0WfwkD/dKOXAmAp8eu24QsfernPfj2yZNFlNiSFRU//v6hA== 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=VEbVH+Bgw8gAhEdl4MumBrcv5nMPapQt/J1aDOOOze4=; b=FEIO1VVOQrZJDv+BMf9sdQaU682JvGv31EIgmwT6V26U94H9Uz6zIg7CSbyjhJ0kcRuNQmEC/W+JFO8UaHxo+pXJxIXIpMTokbyk94irbQ2Qy/CsZNuha/Net77Zb6Nt9tRk8fYKO1s1byDvf6INq5Vi4Hc8FroXqoadbHzlnbo8j0YclfJ7vFsQAd95gWl8Z9LSpzICaOM9FnU/6z20iG17PaXlUWo5CIa8xX9Nf4Kocd9R9tSoUoXmoYTGtKQiRrgiwk8EXArF4Gxl/FGfeGJxrpkKxp8YkywuoaxCsXwbfD/MDbdYtb7+9zwKevAI/nZwwQ4dOm1TMcFDRiSF5g== 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=VEbVH+Bgw8gAhEdl4MumBrcv5nMPapQt/J1aDOOOze4=; b=Rg4/DmFj6F+WjnyABE4AlqAq8pureogkTPp2wORkgSC0So9YwtmiGwYsyJSipphSBYnJjVD9L8mu793Q5Cn1zv8NZ40Jpk36wXEScfibZtORue6IFiFea04Rlhf17zLE8dOrpu5d0y3zsYj77xvB81Jhy+40A5DCj0pxLMZH5u0= Received: from AM4PR0902CA0007.eurprd09.prod.outlook.com (2603:10a6:200:9b::17) by VI1PR08MB2640.eurprd08.prod.outlook.com (2603:10a6:802:1a::32) 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:06 +0000 Received: from AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:200:9b:cafe::8c) by AM4PR0902CA0007.outlook.office365.com (2603:10a6:200:9b::17) 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:06 +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:06 +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:14:01 +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:14:01 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , Subject: [PATCH v2 09/16] DynamicTablesPkg: Fix unaligned pointers usage Date: Sun, 29 Mar 2020 16:13:46 +0100 Message-ID: <20200329151353.14096-10-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)(39850400004)(346002)(376002)(396003)(136003)(46966005)(5660300002)(316002)(54906003)(478600001)(966005)(86362001)(82740400003)(6916009)(47076004)(2616005)(44832011)(186003)(70586007)(336012)(26005)(426003)(70206006)(1076003)(2906002)(8676002)(36756003)(356004)(6666004)(81166006)(81156014)(8936002)(4326008)(7696005);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5a57c80-c2cf-441e-2326-08d7d3f3d771 X-MS-TrafficTypeDiagnostic: VI1PR08MB2640:|AM6PR08MB4659: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4303;OLM:4303; X-Forefront-PRVS: 035748864E X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Cafc2CR74KJq9nzppHJjg5IlmwZ5p1JbTPuYNwHyC/Nww3ZuIs7jN3SlPBgi5C6J9z8IJ5qWLy+R29+/NSz07FI86ryNrSR2tLSitTE+WYJkIOrAYBMsxyUuk0KK0EZJH6Otk6PAa/wXxm2ZmuKd6UJSZCbJbP/h90ch1KyA0O3US44PCfQZgWltknteftAqOVOXk0jE7+Sgc5KNJLTkBxbOr9y/F+wpECQjBlcsL9vC35wAZyy5at9EKgDtINsvTiAcATadQ5NNr3sIwgaZVdcDYv/uFVVZoXNHeuMV1YtPOz08AO/ds6XlGUWFANMn26IJ4q9XCJ6NWnlo5pPz6VvqPKNOhIMPcFO6raGk319d7DH1rxsZPWU0lLfgTgVhoK5QSYAY+kpMrf10l3je43Zz15IOtBqfeYpnMWV2ZeJzxII+YQX5YvZuBMnQ5YvffOQR7aJO/UJOU2zMRzXPMd1ETzwxLmSauF4ExPXASb8lfAT76otYm47sykf/aNWVT4BR0XJ3D/kN5xBaR6x5mOASVXjj2t80mSXQ64rZfWRZMdL5WgOcGL2bGC2yjqdbtrjilAYe+1ZqNkxSOG6vlAOLA7AJfAZN2GMqLwSf2ac= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2640 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: DB5EUR03FT027.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)(376002)(396003)(346002)(39850400004)(136003)(46966005)(86362001)(70586007)(8676002)(70206006)(316002)(54906003)(6916009)(81156014)(81166006)(4326008)(8936002)(7696005)(966005)(478600001)(5660300002)(26826003)(186003)(2616005)(44832011)(336012)(47076004)(82740400003)(26005)(6666004)(426003)(2906002)(1076003)(36756003);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 3f3b600a-bbeb-42ce-41a7-08d7d3f3d30c X-Forefront-PRVS: 035748864E X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p4Yjd6EdyuuFk5zlzULiu6DIoQXichgUy5NuO7qxEtatc0JboqAhFW0AKvxJbpjVlX25vucMQO0rOag5viemaJF+4Vbe1fcnLjxsrwtDJ0Iz/zANG7krGeXYbIZH917/LeV1OCOh+2eWqxHC0OkWI7imAsmo5xuIQy8uPLPqUegHDEj4kdrvYYp+9ZppEq5T0bw4XsTYcMpezKYz/9iJnioJxjCeWyewVM+FX0EUOZoEwTVO+zM4il69rwgJzVzZ6vuojELcD0VDqAtGTvbgyT4AnSfr24CgIhxERb6TqvuvpsYmUM19jMi1Hs3yvmCGQ2zQXPJsSkRyA89m2PXY1hp56W2aoGRgHhnRoSc4FLQGZ91wgUFqX0fgcwYG9M5i0zGV2LZWuzXtdgALBbOaDVx7UjMG+BvOegtVwQusZ83Oq5DPphiPclTKjtYTlpoqUf/eCQXvwfYqCh/jj7DiV8M49waWyc8kyFbli5BtnLbQG9HXvbC+WXes76ebSxj8KYMTo3QAq0jI148vJngC+PX0hGSwzlfE8uDlwGvcUfNpYILfb2nA+XIsAivgcvQvMrqwHHY/aMJnYzYtC36cbveha6vZAmEQKor+7+1eeuc= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2020 15:14:14.1184 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5a57c80-c2cf-441e-2326-08d7d3f3d771 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: AM6PR08MB4659 Content-Type: text/plain The VS2017 compiler reports 'warning C4366: The result of the unary '&' operator may be unaligned' if an address of an unaligned structure member is passed as an argument to a function. Fix this warning by using local variables in place of unaligned structure members. 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 | 24 +++++++++++++++----- DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.h | 13 +++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c index 40699ce113caa8530c89ac20562cf5abda26b88e..82070403ac8757f54e839fd00eb4acb3292fc60c 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c @@ -1066,6 +1066,9 @@ BuildPpttTable ( EFI_STATUS Status; UINT32 TableSize; UINT32 ProcTopologyStructCount; + UINT32 ProcHierarchyNodeCount; + UINT32 CacheStructCount; + UINT32 IdStructCount; UINT32 ProcHierarchyNodeOffset; UINT32 CacheStructOffset; @@ -1113,7 +1116,7 @@ BuildPpttTable ( CfgMgrProtocol, CM_NULL_TOKEN, &ProcHierarchyNodeList, - &Generator->ProcHierarchyNodeCount + &ProcHierarchyNodeCount ); if (EFI_ERROR (Status)) { DEBUG (( @@ -1124,7 +1127,8 @@ BuildPpttTable ( goto error_handler; } - ProcTopologyStructCount = Generator->ProcHierarchyNodeCount; + ProcTopologyStructCount = ProcHierarchyNodeCount; + Generator->ProcHierarchyNodeCount = ProcHierarchyNodeCount; // Get the cache info and update the processor topology structure count with // Cache Type Structures (Type 1) @@ -1132,7 +1136,7 @@ BuildPpttTable ( CfgMgrProtocol, CM_NULL_TOKEN, &CacheStructList, - &Generator->CacheStructCount + &CacheStructCount ); if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { DEBUG (( @@ -1143,7 +1147,8 @@ BuildPpttTable ( goto error_handler; } - ProcTopologyStructCount += Generator->CacheStructCount; + ProcTopologyStructCount += CacheStructCount; + Generator->CacheStructCount = CacheStructCount; // Get the processor hierarchy node ID info and update the processor topology // structure count with ID Structures (Type 2) @@ -1151,7 +1156,7 @@ BuildPpttTable ( CfgMgrProtocol, CM_NULL_TOKEN, &IdStructList, - &Generator->IdStructCount + &IdStructCount ); if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { DEBUG (( @@ -1163,7 +1168,8 @@ BuildPpttTable ( goto error_handler; } - ProcTopologyStructCount += Generator->IdStructCount; + ProcTopologyStructCount += IdStructCount; + Generator->IdStructCount = IdStructCount; // Allocate Node Indexer array NodeIndexer = (PPTT_NODE_INDEXER*)AllocateZeroPool ( @@ -1475,6 +1481,12 @@ ACPI_PPTT_GENERATOR PpttGenerator = { // Processor topology node count 0, + // Count of Processor Hierarchy Nodes + 0, + // Count of Cache Structures + 0, + // Count of Id Structures + 0, // Pointer to PPTT Node Indexer NULL }; diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.h b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.h index 6a0fdd08e1533c57285f420555586314c70a5ed5..0a14da502d595e27d87262b1bac681318f1d9ced 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.h +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.h @@ -167,6 +167,12 @@ typedef struct AcpiPpttGenerator { ACPI_TABLE_GENERATOR Header; /// PPTT structure count UINT32 ProcTopologyStructCount; + /// Count of Processor Hierarchy Nodes + UINT32 ProcHierarchyNodeCount; + /// Count of Cache Structures + UINT32 CacheStructCount; + /// Count of Id Structures + UINT32 IdStructCount; /// List of indexed CM objects for PPTT generation PPTT_NODE_INDEXER * NodeIndexer; /// Pointer to the start of Processor Hierarchy nodes in @@ -176,13 +182,6 @@ typedef struct AcpiPpttGenerator { PPTT_NODE_INDEXER * CacheStructIndexedList; /// Pointer to the start of Id Structures in the Node Indexer array PPTT_NODE_INDEXER * IdStructIndexedList; - /// Count of Processor Hierarchy Nodes - UINT32 ProcHierarchyNodeCount; - /// Count of Cache Structures - UINT32 CacheStructCount; - /// Count of Id Structures - UINT32 IdStructCount; - } ACPI_PPTT_GENERATOR; #pragma pack() -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'