From nobody Wed May 15 19:16:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52946+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52946+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1578358404; cv=none; d=zohomail.com; s=zohoarc; b=jmos8uHoJYG1cVkhgEthYAn7EcjNT558msU8xWAEpvRPaKtada4H9PDy5sBQwiC5ddjNcb389yIID9tsSqluo4zKHdCYUXWvFiiYG3bOlqBD5lr0TPuphzMLq7e0TpO5g2SYtiru6777kRvLibM9G15mSzlA8NQXbPYgrfojBOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578358404; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=DZCctnLPu5QFHQNj4G9iB56Ne8nOssMinOM79kyRtv8=; b=E+6PKSeqrpYRTqSlRKAe1lz2I1eT/FfSYEsJ9KnslqPj/pbmunS/rsmZRIXeG/JhlyzUG7opg3mEpwkbf22xRcvw5XYwqYzIqjvZiQKVt987TAh3RgjkVpf9H+EOElBAuYLPIo85M9u6bBZ1bzFOpLQquM5RAdVWQYOPzVTlouY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52946+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1578358404139868.2505826046859; Mon, 6 Jan 2020 16:53:24 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id JNGGYY1788612xRKvUhl6bfo; Mon, 06 Jan 2020 16:53:23 -0800 X-Received: from mga17.intel.com (mga17.intel.com []) by mx.groups.io with SMTP id smtpd.web09.2899.1578358402523485664 for ; Mon, 06 Jan 2020 16:53:23 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jan 2020 16:53:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,404,1571727600"; d="scan'208";a="217568778" X-Received: from ydong10-desktop.ccr.corp.intel.com ([10.239.158.133]) by fmsmga008.fm.intel.com with ESMTP; 06 Jan 2020 16:53:22 -0800 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek Subject: [edk2-devel] [PATCH 1/2] Revert "UefiCpuPkg/PiSmmCpuDxeSmm: Fix buffer overflow issue." Date: Tue, 7 Jan 2020 08:53:18 +0800 Message-Id: <20200107005319.937-2-eric.dong@intel.com> In-Reply-To: <20200107005319.937-1-eric.dong@intel.com> References: <20200107005319.937-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com X-Gm-Message-State: hu14PGeMVWvhCO73e1pz5CHpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578358403; bh=d1Jg7mPdhnlNlO4V8vLwhW8MBU0z89eMw1kPmn6Z2qI=; h=Cc:Date:From:Reply-To:Subject:To; b=uoc9lRRrj3kyWm6cBpm1xqOb2pOrlgn0YinE752gTLKSjyZgcn+WZ3R3a3Yzf1a/Ccl trxJp2K32X697jQeoyiRYZtDZLyiDGA9JZ5Iux9bY4MS8VRURQY0JoC50gRU5oq+652Aq 7TPP4l/E/F4fw6Cvei3bt7YgVeExMpdm/T0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This reverts commit 123b720eeb371e0a31eb727bcf59255b584e355f. The commit message for commit 123b720eeb37 is not correct. Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Eric Dong Reviewed-by: Laszlo Ersek --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 870250b0c5..f445d7b030 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -137,7 +137,7 @@ ReleaseAllAPs ( { UINTN Index; =20 - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { if (IsPresentAp (Index)) { ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run); } @@ -170,7 +170,7 @@ AllCpusInSmmWithExceptions ( =20 CpuData =3D mSmmMpSyncData->CpuData; ProcessorInfo =3D gSmmCpuPrivate->ProcessorInfo; - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != =3D INVALID_APIC_ID) { if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) !=3D 0) && SmmCpuFeatu= resGetSmmRegister (Index, SmmRegSmmDelayed) !=3D 0) { continue; @@ -305,7 +305,7 @@ SmmWaitForApArrival ( // // Send SMI IPIs to bring outside processors in // - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->= ProcessorInfo[Index].ProcessorId !=3D INVALID_APIC_ID) { SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].Processor= Id); } @@ -361,7 +361,7 @@ WaitForAllAPsNotBusy ( { UINTN Index; =20 - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { // // Ignore BSP and APs which not call in SMM. // @@ -608,7 +608,7 @@ BSPHandler ( // while (TRUE) { PresentCount =3D 0; - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { if (*(mSmmMpSyncData->CpuData[Index].Present)) { PresentCount ++; } @@ -1343,7 +1343,7 @@ InternalSmmStartupAllAPs ( } =20 CpuCount =3D 0; - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { if (IsPresentAp (Index)) { CpuCount ++; =20 @@ -1375,13 +1375,13 @@ InternalSmmStartupAllAPs ( // Here code always use AcquireSpinLock instead of AcquireSpinLockOrFail= for not // block mode. // - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { if (IsPresentAp (Index)) { AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy); } } =20 - for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { if (IsPresentAp (Index)) { mSmmMpSyncData->CpuData[Index].Procedure =3D (EFI_AP_PROCEDURE2) Pro= cedure; mSmmMpSyncData->CpuData[Index].Parameter =3D ProcedureArguments; --=20 2.23.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52946): https://edk2.groups.io/g/devel/message/52946 Mute This Topic: https://groups.io/mt/69493490/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 19:16:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52947+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52947+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1578358405; cv=none; d=zohomail.com; s=zohoarc; b=KDGWLt+ZwpylEPZ9sdsN09X0iJCOH6N0uGdoDwPkf7n+USu08T+BJed/Aef0h/5YuizV/7kzyPML8YTEm8bJfflckKDsxww899fSwSnRXIssEWC5o0+x+nj+d6Khc9VIqGAjUK6HFE2sb6zB6u/kjnoasX2GC49t/j/JfjoETVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578358405; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jO24yh+BQXefMthY0lMCY1889gpoIZOhhDvqNGuB7wU=; b=Ppx4QmEQf4hEGaBRNperB+WQUVfCmnHM7XAbiOmfdXSrjR4dmiCNA8DMWEHW3e5az+H04DVowoI5+yXaidMEM3rNalCQ3uzSUouRibAmWxhXYIoVc0Xtf+12ZhE2n3wo5KUShT0ULZcvvtn6PML/Tz5gffnQkndkFAVSaL+RcNU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52947+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1578358405442857.0538445524835; Mon, 6 Jan 2020 16:53:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id uCezYY1788612xJL6KDvCn7y; Mon, 06 Jan 2020 16:53:25 -0800 X-Received: from mga17.intel.com (mga17.intel.com []) by mx.groups.io with SMTP id smtpd.web09.2899.1578358402523485664 for ; Mon, 06 Jan 2020 16:53:24 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jan 2020 16:53:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,404,1571727600"; d="scan'208";a="217568781" X-Received: from ydong10-desktop.ccr.corp.intel.com ([10.239.158.133]) by fmsmga008.fm.intel.com with ESMTP; 06 Jan 2020 16:53:23 -0800 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Laszlo Ersek , Ray Ni Subject: [edk2-devel] [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: improve the coding style Date: Tue, 7 Jan 2020 08:53:19 +0800 Message-Id: <20200107005319.937-3-eric.dong@intel.com> In-Reply-To: <20200107005319.937-1-eric.dong@intel.com> References: <20200107005319.937-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com X-Gm-Message-State: etxffQiMFqN7MBkjrpYlqPzyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578358405; bh=rvtVeIu76xfveBnKxbLqIfA+62HT9AQ6KeUkxUal3QQ=; h=Cc:Date:From:Reply-To:Subject:To; b=YerK1bcpj/Lk0u5vFMygCIEZmqUzuORUhgUmW4mWtWoa6WnLKAUarJHyrkTIisaUuGR FWIXMs6sgTbDyt27RtRQhF/CBl3XH9b2EMrICb58zfthx3qLg0gsDLx/RRARCV9RyLggY hW6bpYGBUtazFWZz870nrXSjINHbYKDHaRo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2434 Current code use below loops to enumerate the CPUs: for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { it has no issue but not easy for the developers to read the code. Update above code to below style, for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { It make the developers easy to read and consistent with other similar cases in this driver. Cc: Laszlo Ersek Cc: Ray Ni Signed-off-by: Eric Dong Reviewed-by: Laszlo Ersek --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index f445d7b030..35a6996ba3 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -1,7 +1,7 @@ /** @file SMM MP service implementation =20 -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -137,7 +137,7 @@ ReleaseAllAPs ( { UINTN Index; =20 - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { if (IsPresentAp (Index)) { ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run); } @@ -170,7 +170,7 @@ AllCpusInSmmWithExceptions ( =20 CpuData =3D mSmmMpSyncData->CpuData; ProcessorInfo =3D gSmmCpuPrivate->ProcessorInfo; - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != =3D INVALID_APIC_ID) { if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) !=3D 0) && SmmCpuFeatu= resGetSmmRegister (Index, SmmRegSmmDelayed) !=3D 0) { continue; @@ -305,7 +305,7 @@ SmmWaitForApArrival ( // // Send SMI IPIs to bring outside processors in // - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->= ProcessorInfo[Index].ProcessorId !=3D INVALID_APIC_ID) { SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].Processor= Id); } @@ -361,7 +361,7 @@ WaitForAllAPsNotBusy ( { UINTN Index; =20 - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { // // Ignore BSP and APs which not call in SMM. // @@ -608,7 +608,7 @@ BSPHandler ( // while (TRUE) { PresentCount =3D 0; - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { if (*(mSmmMpSyncData->CpuData[Index].Present)) { PresentCount ++; } @@ -1343,7 +1343,7 @@ InternalSmmStartupAllAPs ( } =20 CpuCount =3D 0; - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { if (IsPresentAp (Index)) { CpuCount ++; =20 @@ -1375,13 +1375,13 @@ InternalSmmStartupAllAPs ( // Here code always use AcquireSpinLock instead of AcquireSpinLockOrFail= for not // block mode. // - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { if (IsPresentAp (Index)) { AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy); } } =20 - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { if (IsPresentAp (Index)) { mSmmMpSyncData->CpuData[Index].Procedure =3D (EFI_AP_PROCEDURE2) Pro= cedure; mSmmMpSyncData->CpuData[Index].Parameter =3D ProcedureArguments; --=20 2.23.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52947): https://edk2.groups.io/g/devel/message/52947 Mute This Topic: https://groups.io/mt/69493491/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-