From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D86A481E28 for ; Sun, 6 Nov 2016 17:09:09 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 06 Nov 2016 17:09:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,604,1473145200"; d="scan'208";a="1056119354" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga001.jf.intel.com with ESMTP; 06 Nov 2016 17:09:12 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 6 Nov 2016 17:09:12 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 6 Nov 2016 17:09:11 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.104]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Mon, 7 Nov 2016 09:08:57 +0800 From: "Tian, Feng" To: =?iso-8859-1?Q?Marvin_H=E4user?= , "edk2-devel@lists.01.org" , "Fu, Siyuan" , "Wu, Jiaxin" CC: "Zeng, Star" , "Ye, Ting" , "Tian, Feng" Thread-Topic: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices (). Thread-Index: AQHSNidtNdv9Y2VlQE+ywGajW/iMv6DMulvg Date: Mon, 7 Nov 2016 01:08:57 +0000 Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE566E3D8E1@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices (). X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2016 01:09:10 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Marvin, The commit log is a little confusing. Please update the commit title to cla= rify it's only for Iscsi. And I will leave this RB to network owner. Thanks Feng -----Original Message----- From: Marvin H=E4user [mailto:Marvin.Haeuser@outlook.com]=20 Sent: Friday, November 4, 2016 7:10 AM To: edk2-devel@lists.01.org Cc: Tian, Feng ; Zeng, Star Subject: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootSer= vices (). During exiting Boot Services, there should be no changes made to the Memory= Map. This patch eliminates explicit and implicit calls to the Memory Alloc= ation Services and, where applicable, zeros the memory instead. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marvin Haeuser --- MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 11 +++++++++-- MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModul= ePkg/Universal/Network/IScsiDxe/IScsiMisc.c index ae202c3fe24a..b5e36b8bec06 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -872,9 +872,16 @@ IScsiOnExitBootService ( ISCSI_DRIVER_DATA *Private; =20 Private =3D (ISCSI_DRIVER_DATA *) Context; - gBS->CloseEvent (Private->ExitBootServiceEvent); =20 - IScsiSessionAbort (&Private->Session); + if (Private->Session.Signature !=3D 0) { + IScsiSessionAbort (&Private->Session); + + // + // Empty Session as it will not be freed. + // This will also prevent this code from being re-run. + // + ZeroMem (&Private->Session, sizeof (Private->Session)); } } =20 /** diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Uni= versal/Network/SnpDxe/Snp.c index 9f61aee05773..e15e79c7065f 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c @@ -32,6 +32,18 @@ SnpNotifyExitBootServices ( =20 Snp =3D (SNP_DRIVER *)Context; =20 + if (Snp->TxRxBuffer !=3D NULL) { + // + // Empty TxRxBuffer as it will not be freed. + // + ZeroMem (Snp->TxRxBuffer, Snp->TxRxBufferSize); + + // + // Set TxRxBuffer to NULL so FreeBuffer () will not be called. + // + Snp->TxRxBuffer =3D NULL; + } + // // Shutdown and stop UNDI driver // --=20 2.10.1.windows.1