From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (EUR03-AM5-obe.outbound.protection.outlook.com [40.107.3.44]) by mx.groups.io with SMTP id smtpd.web11.7712.1608210370448448364 for ; Thu, 17 Dec 2020 05:06:10 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=vO+W+Dwe; spf=pass (domain: arm.com, ip: 40.107.3.44, 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=YQyC96K+gaIzmEXh+ybFMoeVx7D1OPf0sH0xVy8PKbw=; b=vO+W+Dwe9wydOncGQyXzK8l0oE278mEJKUs+2KeOnQZ/cn5NdvOAMJ/IEu+PlAFVFfDoclVWyhNhQ6IxQkJqhlOlHqKrJODp7CRYwfMf3um7T+dRovbrxpOwdcfAmY1scJyhbmJ8rQVYZqGZVmhmn4F8xaIwzZH2iABkkhYIwzw= Received: from DB6PR07CA0069.eurprd07.prod.outlook.com (2603:10a6:6:2a::31) by AS8PR08MB6279.eurprd08.prod.outlook.com (2603:10a6:20b:294::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Thu, 17 Dec 2020 13:06:08 +0000 Received: from DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2a:cafe::70) by DB6PR07CA0069.outlook.office365.com (2603:10a6:6:2a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.9 via Frontend Transport; Thu, 17 Dec 2020 13:06:08 +0000 X-MS-Exchange-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=pass 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 DB5EUR03FT018.mail.protection.outlook.com (10.152.20.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.22 via Frontend Transport; Thu, 17 Dec 2020 13:06:08 +0000 Received: ("Tessian outbound eeda57fffe7b:v71"); Thu, 17 Dec 2020 13:06:08 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 346dbd4c4f766fdc X-CR-MTA-TID: 64aa7808 Received: from 96dd9c488543.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 950B79FB-555E-4810-9AB2-95D1401592E7.1; Thu, 17 Dec 2020 13:05:30 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 96dd9c488543.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 17 Dec 2020 13:05:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dl/2Nr9kgjCgy0/+A+QENo7cZ2Z94lkyJNc2wHxkgIW6Jh6CPiXRuKyK0iQHc/DCXKiLUVOljIZRUB44/N6lyS5QB6ZMaQfqUlIWOtUrs13KPAOD0JBqTxzFhBP/pfKB0GJSTFMnucjK1I679kbnq3TPQznk8QnOWO/q4c1J4Etbnow1rIFOr8dc0aZC1H7rK79aDqA96FzUi0y+2CFPRsPimJuiUq3yEo3h2bFGYda7hBqjjaCvo740B1TEpjO09I3np9bjx4nMLKMe7392TCoxayqnokjK88ZUKaxZ6wB0o7Mw7WmcgHEXfRBIK2PJCwxS0ovnauE8olo2oCEoIQ== 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=YQyC96K+gaIzmEXh+ybFMoeVx7D1OPf0sH0xVy8PKbw=; b=mb0c0cD9pIkT/xWxCrNejPhQUQ4QdO/2JyRJKV8Xo1MUDWj1OrYhhrj71pN3CenJVE7KHcdtCddXdMyke1CtUQEZ91olyzkxi+UDe5P3QZaioaQwp3HLXjT1+kvEaRBrsDMiQ9WBL7yeyaswVmfUYuXuPBHZN51KUX6cAehvv8/Q6DkmXY2Q0lh0JYOayv8DCWYb748Qrn7/dCLKxOpE/b8+dq1sTz8WjCqYpy96YT2Xvw1Zn0Ni6PuK0vbmuIrLGQGqEPKo0X7Ycew65saVNlrr0Ul/CH2aP6pbIz0cvkBuZl906o2ti2/+vKgbpW1Ma+CGRtUPtdrezcCac6Upiw== 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=pass (p=none sp=none pct=100) 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=YQyC96K+gaIzmEXh+ybFMoeVx7D1OPf0sH0xVy8PKbw=; b=vO+W+Dwe9wydOncGQyXzK8l0oE278mEJKUs+2KeOnQZ/cn5NdvOAMJ/IEu+PlAFVFfDoclVWyhNhQ6IxQkJqhlOlHqKrJODp7CRYwfMf3um7T+dRovbrxpOwdcfAmY1scJyhbmJ8rQVYZqGZVmhmn4F8xaIwzZH2iABkkhYIwzw= Received: from DB9PR01CA0026.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::31) by HE1PR0801MB1788.eurprd08.prod.outlook.com (2603:10a6:3:88::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Thu, 17 Dec 2020 13:05:29 +0000 Received: from DB5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d8:cafe::e1) by DB9PR01CA0026.outlook.office365.com (2603:10a6:10:1d8::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.15 via Frontend Transport; Thu, 17 Dec 2020 13:05:29 +0000 X-MS-Exchange-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=pass 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 DB5EUR03FT061.mail.protection.outlook.com (10.152.21.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3676.22 via Frontend Transport; Thu, 17 Dec 2020 13:05:29 +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.2044.4; Thu, 17 Dec 2020 13:05:14 +0000 Received: from E107187.Arm.com (10.57.33.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Thu, 17 Dec 2020 13:05:14 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [PATCH v2 06/26] StandaloneMmPkg: Fix ECC error 3002 in StandaloneMmCpu Date: Thu, 17 Dec 2020 13:04:49 +0000 Message-ID: <20201217130509.12568-7-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20201217130509.12568-1-sami.mujawar@arm.com> References: <20201217130509.12568-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65e2f2e5-1518-43bc-f12f-08d8a28c84fd X-MS-TrafficTypeDiagnostic: HE1PR0801MB1788:|AS8PR08MB6279: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Hdjbnp59KXFYAwLveryGi3WR+VtYNzWXuqmSwQzGPrdGmul/fEMwZ+acEX9/l0uhncF8Ubx62lXUzRMcmUb7wJzmNCKLc0Z/FI5vDVEjluT2P9/lcbmlUtu9VooBd+MDsOv04YbGcZAvuQhBsW5XqufCgaqVX7fIFByFBY42ddK5isq6m6lmPJGJrQqhlpEFLsIYybz/XSK4NiOIF0m+gm1iZ0QyAt4JEqdfXKW5jWojUwsGqNUN3bXsVxlkMs89yFRORMY/FWLPFGWsyvfYFMf6Z+u8nVytY62GqtId2gVPReFqsQ46IZor+W45i7vZkYS+KOSDXiV6hjG9oBMnfKhgdTfXA+q7LWiLJI2fTh3oES/51X4VRM9XOdTvC0ilc8V/Lb5Wm5Lk8gCttHKJFA== 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;SFS:(6029001)(4636009)(376002)(136003)(396003)(346002)(39860400002)(46966005)(70206006)(70586007)(5660300002)(82740400003)(7696005)(316002)(426003)(44832011)(54906003)(336012)(2616005)(8676002)(186003)(83380400001)(86362001)(6916009)(26005)(8936002)(47076004)(356005)(36756003)(478600001)(6666004)(1076003)(4326008)(2906002)(81166007)(82310400003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1788 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 47c38c60-de7e-4e22-2333-08d8a28c6de4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p2x92ASTAO8ZfFMH11Cb/uajRUF75XKdXpNZMluwfg+5mEcTgpPvBWsbxMdYvbDgjOTQcHiaihNsswZWATOwp+aCJTvU/35W8xS0vdzotzz92Nb1l1me1ziFe7xvkXksu+qxJoK5J7PU1zmVxnsxZBnrLLBPlMT6ezl95Jt1v/bLDentu9m42j/nu3UzVs/XrNj9WFAERY24Jfd3KhwM50n15jBgAI+SbYVrvgPuPf9SQf53lc6PnK6TeQok9ywP587q4xZiqD1DEk6sdikVQGtIlLu3P454oeLpjmT4+uwgsvaUKuvJZw1jSCQGXlFWLlFB7e9uaXXW/KS4DPKvLlEojRb6Hn1qWf9G8pQ7T8nmEHtRYus5QFwHfD6OOw8AGy6KM8PBnRBytCXQcZMYp7h0vkkKjXkauVXKmEiwowajSnGY1izq1aJiqPz4k4l7 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;SFS:(6029001)(4636009)(376002)(136003)(396003)(39860400002)(346002)(46966005)(4326008)(26005)(1076003)(426003)(81166007)(2616005)(5660300002)(44832011)(336012)(316002)(83380400001)(6916009)(36756003)(8676002)(47076004)(186003)(54906003)(82740400003)(6666004)(478600001)(2906002)(7696005)(70206006)(86362001)(70586007)(8936002)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2020 13:06:08.3201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65e2f2e5-1518-43bc-f12f-08d8a28c84fd 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-AuthSource: DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6279 Content-Type: text/plain Fix the ECC tool reported error "[3002] Non-Boolean comparisons should use a compare operator". Also fix the following: - add curly braces for 'if' condition statements to comply with the coding standard. - The value returned by GET_GUID_HOB_DATA() is stored in *HobData. Therefore, check *HobData against NULL. The original code was checking HobData which is incorrect. Signed-off-by: Sami Mujawar Acked-by: Jiewen Yao --- Notes: v2: - No code change. Resending patch with v2 series. [SAMI] StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c | 19 +++++++++++++------ StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c | 11 +++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c index 6a25c4c54843ccdc2d745e8e537942d49b1d1141..9738e8bd60149efb45ef1b66139e0cec38b6c1fe 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c @@ -1,7 +1,7 @@ /** @file Copyright (c) 2016 HP Development Company, L.P. - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2020, Arm Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -84,12 +84,18 @@ PiMmStandaloneArmTfCpuDriverEntry ( } // Perform parameter validation of NsCommBufferAddr - if (NsCommBufferAddr && (NsCommBufferAddr < mNsCommBuffer.PhysicalStart)) + if (NsCommBufferAddr == (UINTN)NULL) { + return EFI_INVALID_PARAMETER; + } + + if (NsCommBufferAddr < mNsCommBuffer.PhysicalStart) { return EFI_ACCESS_DENIED; + } if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >= - (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) + (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) { return EFI_INVALID_PARAMETER; + } // Find out the size of the buffer passed NsCommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *) NsCommBufferAddr)->MessageLength + @@ -97,9 +103,9 @@ PiMmStandaloneArmTfCpuDriverEntry ( // perform bounds check. if (NsCommBufferAddr + NsCommBufferSize >= - mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize) + mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize) { return EFI_ACCESS_DENIED; - + } // Now that the secure world can see the normal world buffer, allocate // memory to copy the communication buffer to the secure world. @@ -192,8 +198,9 @@ PiMmCpuTpFwRootMmiHandler ( ASSERT (CommBufferSize == NULL); CpuNumber = mMmst->CurrentlyExecutingCpu; - if (!PerCpuGuidedEventContext[CpuNumber]) + if (PerCpuGuidedEventContext[CpuNumber] == NULL) { return EFI_NOT_FOUND; + } DEBUG ((DEBUG_INFO, "CommBuffer - 0x%x, CommBufferSize - 0x%x\n", PerCpuGuidedEventContext[CpuNumber], diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c index 617babd5ab4bcb200ee10e19ec6f99c2ef163200..7c004c8013460bb7f1690351aa64eeaa9eab91dc 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c @@ -2,7 +2,7 @@ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
Copyright (c) 2016 HP Development Company, L.P. - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2020, Arm Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -53,16 +53,19 @@ GetGuidedHobData ( { EFI_HOB_GUID_TYPE *Hob; - if (!HobList || !HobGuid || !HobData) + if ((HobList == NULL) || (HobGuid == NULL) || (HobData == NULL)) { return EFI_INVALID_PARAMETER; + } Hob = GetNextGuidHob (HobGuid, HobList); - if (!Hob) + if (Hob == NULL) { return EFI_NOT_FOUND; + } *HobData = GET_GUID_HOB_DATA (Hob); - if (!HobData) + if (*HobData == NULL) { return EFI_NOT_FOUND; + } return EFI_SUCCESS; } -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'