From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org 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 14A5F2034BBDA for ; Thu, 9 Nov 2017 05:05:51 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2017 05:09:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,370,1505804400"; d="scan'208";a="1242000357" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 09 Nov 2017 05:09:52 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 9 Nov 2017 05:09:52 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Thu, 9 Nov 2017 21:09:50 +0800 From: "Zeng, Star" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" Thread-Topic: [Patch] MdeModulePkg/Core/Dxe: Remove extra connects for UEFI Applications Thread-Index: AQHTWLqusweo8hJId0+SEh/kT7I0IKMMBgXA Date: Thu, 9 Nov 2017 13:09:50 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B3AB7@shsmsx102.ccr.corp.intel.com> References: <20171108175447.21220-1-michael.d.kinney@intel.com> In-Reply-To: <20171108175447.21220-1-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/Core/Dxe: Remove extra connects for UEFI Applications X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Nov 2017 13:05:52 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng BTW: I see the code is using Image->ImageContext.ImageType at some places a= nd Image->Type at other place, it seems a little inconsistent. Thanks, Star -----Original Message----- From: Kinney, Michael D=20 Sent: Thursday, November 9, 2017 1:55 AM To: edk2-devel@lists.01.org Cc: Zeng, Star ; Dong, Eric Subject: [Patch] MdeModulePkg/Core/Dxe: Remove extra connects for UEFI Appl= ications https://bugzilla.tianocore.org/show_bug.cgi?id=3D765 The UEFI Specification Boot Services chapter, StartImage() service, EFF 1.10 Extension requires extra calls to ConnectController() if a UEFI Driver produces handles. The DXE Core is performing these extra calls to ConnectController() without evaluating the ImageType. A filter is added to not make extra calls to ConnectController() if the ImageType is EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION. Without this filter, extra calls to ConnectController() may be performed by UEFI Applications or a UEFI Shell Applications that also call ConnectController(). Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- MdeModulePkg/Core/Dxe/Image/Image.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index 4e22aa6dc7..c6b8ff44b9 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -1703,9 +1703,17 @@ CoreStartImage ( mCurrentImage =3D LastImage; =20 // - // Go connect any handles that were created or modified while the image = executed. + // UEFI Specification - StartImage() - EFI 1.10 Extension + // To maintain compatibility with UEFI drivers that are written to the E= FI + // 1.02 Specification, StartImage() must monitor the handle database bef= ore + // and after each image is started. If any handles are created or modifi= ed + // when an image is started, then EFI_BOOT_SERVICES.ConnectController() = must + // be called with the Recursive parameter set to TRUE for each of the ne= wly + // created or modified handles before StartImage() returns. // - CoreConnectHandlesByKey (HandleDatabaseKey); + if (Image->ImageContext.ImageType !=3D EFI_IMAGE_SUBSYSTEM_EFI_APPLICATI= ON) { + CoreConnectHandlesByKey (HandleDatabaseKey); + } =20 // // Handle the image's returned ExitData --=20 2.14.2.windows.3