From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 99BD581843 for ; Sun, 8 Jan 2017 21:06:16 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP; 08 Jan 2017 21:06:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="50759914" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 08 Jan 2017 21:06:16 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 8 Jan 2017 21:06:15 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 8 Jan 2017 21:06:15 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.177]) with mapi id 14.03.0248.002; Mon, 9 Jan 2017 13:06:13 +0800 From: "Zeng, Star" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Tian, Feng" Thread-Topic: [Patch] MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messages Thread-Index: AQHSajVYioOyF+nMmEiaZJP3VdLUrqEvl7Zw Date: Mon, 9 Jan 2017 05:06:12 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B7F6B8C@shsmsx102.ccr.corp.intel.com> References: <1483938017-28240-1-git-send-email-michael.d.kinney@intel.com> In-Reply-To: <1483938017-28240-1-git-send-email-michael.d.kinney@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:06:16 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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