From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 CD14981924 for ; Sun, 8 Jan 2017 21:07:04 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 08 Jan 2017 21:07:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="806610838" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 08 Jan 2017 21:07:04 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 8 Jan 2017 21:07:04 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0248.002; Mon, 9 Jan 2017 13:07:02 +0800 From: "Tian, Feng" To: "Zeng, Star" , "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Tian, Feng" Thread-Topic: [Patch] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messages Thread-Index: AQHSajVYOybxtcBruESMP9pOYpD8YKEvEaoAgACGSEA= Date: Mon, 9 Jan 2017 05:07:01 +0000 Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE5699A68D5@SHSMSX101.ccr.corp.intel.com> References: <1483938017-28240-1-git-send-email-michael.d.kinney@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B7F6B8C@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B7F6B8C@shsmsx102.ccr.corp.intel.com> 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] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messages 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, 09 Jan 2017 05:07:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Feng Tian Thanks Feng -----Original Message----- From: Zeng, Star=20 Sent: Monday, January 9, 2017 1:06 PM To: Kinney, Michael D ; edk2-devel@lists.01.org Cc: Tian, Feng Subject: RE: [Patch] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() me= ssages Reviewed-by: Star Zeng -----Original Message----- From: Kinney, Michael D=20 Sent: Monday, January 9, 2017 1:00 PM To: edk2-devel@lists.01.org Cc: Tian, Feng ; Zeng, Star Subject: [Patch] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messag= es If a BaseAddress of NULL is passed into DXE Core services CoreAllocateIoSpace() or CoreAllocateMemorySpace(), and DEBUG() messages are enabled, then a NULL pointer reference is made. The p= arameter check for BaseAddress is performed in the function CoreAllocateSpa= ce() after the DEBUG() messages. A check is added in the DEBUG() messages = to prevent the NULL pointer reference. This issue was found with PI SCTs with DEBUG messages enabled in the DXE Co= re. Cc: Feng Tian Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index bd7c6c6..e008ce8 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -3,7 +3,7 @@ The GCD services are used to manage the memory and I/O regions that are accessible to the CPU that is executing the DXE core. =20 -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -1337,7 +1= 337,11 @@ CoreAllocateMemorySpace ( IN EFI_HANDLE DeviceHandle OPTIONAL ) { - DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=3D%016lx,Length=3D%016l= x)\n", *BaseAddress, Length)); + if (BaseAddress !=3D NULL) { + DEBUG ((DEBUG_GCD,=20 + "GCD:AllocateMemorySpace(Base=3D%016lx,Length=3D%016lx)\n", *BaseAddress,= Length)); } else { + DEBUG ((DEBUG_GCD,=20 + "GCD:AllocateMemorySpace(Base=3D,Length=3D%016lx)\n", Length)); } DEBUG ((DEBUG_GCD, " GcdAllocateType =3D %a\n", mGcdAllocationTypeNames= [MIN (GcdAllocateType, EfiGcdMaxAllocateType)])); DEBUG ((DEBUG_GCD, " GcdMemoryType =3D %a\n", mGcdMemoryTypeNames[MIN= (GcdMemoryType, EfiGcdMemoryTypeMaximum)])); DEBUG ((DEBUG_GCD, " Alignment =3D %016lx\n", LShiftU64 (1, Align= ment))); @@ -1761,7 +1765,11 @@ CoreAllocateIoSpace ( IN EFI_HANDLE DeviceHandle OPTIONAL ) { - DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=3D%016lx,Length=3D%016lx)\n= ", *BaseAddress, Length)); + if (BaseAddress !=3D NULL) { + DEBUG ((DEBUG_GCD,=20 + "GCD:AllocateIoSpace(Base=3D%016lx,Length=3D%016lx)\n", *BaseAddress, Len= gth)); } else { + DEBUG ((DEBUG_GCD,=20 + "GCD:AllocateIoSpace(Base=3D,Length=3D%016lx)\n", Length)); } DEBUG ((DEBUG_GCD, " GcdAllocateType =3D %a\n", mGcdAllocationTypeNames= [MIN (GcdAllocateType, EfiGcdMaxAllocateType)])); DEBUG ((DEBUG_GCD, " GcdIoType =3D %a\n", mGcdIoTypeNames[MIN (Gc= dIoType, EfiGcdIoTypeMaximum)])); DEBUG ((DEBUG_GCD, " Alignment =3D %016lx\n", LShiftU64 (1, Align= ment))); -- 2.6.3.windows.1