From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: hao.a.wu@intel.com) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by groups.io with SMTP; Sun, 14 Apr 2019 18:25:19 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Apr 2019 18:25:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,351,1549958400"; d="scan'208";a="131370848" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga007.jf.intel.com with ESMTP; 14 Apr 2019 18:25:18 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 14 Apr 2019 18:25:18 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 14 Apr 2019 18:25:18 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.92]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.164]) with mapi id 14.03.0415.000; Mon, 15 Apr 2019 09:25:15 +0800 From: "Wu, Hao A" To: Ard Biesheuvel , "devel@edk2.groups.io" CC: "Kinney, Michael D" , Andrew Fish , Leif Lindholm , "Zeng, Star" , "Dong, Eric" , "Ni, Ray" , "Gao, Liming" , "Carsey, Jaben" , "Shi, Steven" , "Wang, Jian J" Subject: Re: [PATCH v6 0/7] MdeModulePkg: add support for dispatching foreign arch PE/COFF images Thread-Topic: [PATCH v6 0/7] MdeModulePkg: add support for dispatching foreign arch PE/COFF images Thread-Index: AQHU8vum/W1yhQLlOUiDCLmjPVskzKY8baQw Date: Mon, 15 Apr 2019 01:25:15 +0000 Message-ID: References: <20190414195233.30045-1-ard.biesheuvel@linaro.org> In-Reply-To: <20190414195233.30045-1-ard.biesheuvel@linaro.org> 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 Return-Path: hao.a.wu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Monday, April 15, 2019 3:52 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel; Kinney, Michael D; Andrew Fish; Leif Lindholm; Zeng, = Star; > Dong, Eric; Ni, Ray; Gao, Liming; Carsey, Jaben; Shi, Steven; Wang, Jian = J; Wu, > Hao A > Subject: [PATCH v6 0/7] MdeModulePkg: add support for dispatching foreign > arch PE/COFF images >=20 > Add the basic plumbing to DXE core, the PCI bus driver and the boot manag= er > to allow PE/COFF images to be dispatched that target an architecture that= is > not native for the platform, but which is supported by one of potentially > several available emulators. >=20 > One implementation of such an emulator can be found here: > https://github.com/ardbiesheuvel/X86EmulatorPkg/tree/upstream-v4 >=20 > This also allows us to get rid of the special treatment of EBC images in > core code. Instead, the EbcDxe driver is augmented with an implementation > of the EDK2 PE/COFF image emulator protocol so that internal knowledge of > how EBC is implemented (I-cache flushing, thunks) is removed from the DXE > core. >=20 > Changes since v5: > - Fix build issues reported by Mike Kinney (#2, #5) > - Fix CheckPatch.py issue regarding the use of EFI_D_ERROR (#2) [This is = code > that is only being moved around but I fixed it nonetheless] > - Use InstallMultipleProtocolInterfaces() to install the EBC protocol and= the > PE/COFF emu protocol at the same time (to simplify/fix the error path) = (#5) > - Add Mike's Reviewed-by The series looks good to be. Please help to address the format issues as I replied in 1/7 and 2/7 patches. With those addressed, for the series, Reviewed-by: Hao Wu Best Regards, Hao Wu >=20 > Changes since v4: > - Fix an issue in the protocol notify handler pointed out by Mike Kinney = (#2) >=20 > Changes since v3: > - Simplify the handling of option ROMs and Driver#### images, by simply > deferring to the LoadImage() boot service to decide whether an image > can be supported or not - this removes some redundant checks from the > BDS layer and the PCI bus driver. > - Move the machine type supported by the emulator into the protocol struc= t, > so we can optimize away calls into the emulator for each image loaded. > Instead, the LoadImage() code will only invoke the IsSupported() method= for > images that are known to have a matching machine type. >=20 > Note that I have considered, but ultimately dismissed the suggestion to > register and unregister emulators via a new protocol. The main issue is > that registering and unregistering structs containing sets of function > pointers is awfully similar to managing a protocol database, and we alrea= dy > have the code to do that in EDK2. >=20 > So instead, I have removed all the code that iterates over a handle buffe= r > of emu protocols and invokes each one to see if it will support the image= . > Instead, this is all done by CoreLoadImage(). >=20 > Changes since v2: > - incorporate feedback from Andrew Fish (delivered in person): > * pass a device path into the IsImageSupported() protocol method so tha= t an > implementation can blacklist or whitelist certain devices, or impleme= nt > other policies that depend on the device where the driver originated > * allow the emulator to supersede the native loading of the image - thi= s > permits things like X86 on X86 emulators for security sandboxing or d= ebug >=20 > Changes since v1: > - subsume the EBC handling into the EDK2 emulator protocol and abstract > away from EBC specifics in core code. > - allow multiple emulator implementations to co-exist > - incorporate Star's review feedback >=20 > Cc: Michael D Kinney > Cc: Andrew Fish > Cc: Leif Lindholm > Cc: Star Zeng > Cc: Eric Dong > Cc: Ruiyu Ni > Cc: Liming Gao > Cc: Jaben Carsey > Cc: Steven Shi > Cc: Jian J Wang > Cc: Hao Wu >=20 > Ard Biesheuvel (7): > MdeModulePkg: introduce PE/COFF image emulator protocol > MdeModulePkg/DxeCore: invoke the emulator protocol for foreign images > MdeModulePkg/PciBusDxe: dispatch option ROMs for foreign architectures > MdeModulePkg/UefiBootManagerLib: allow foreign Driver#### images > MdeModulePkg/EbcDxe: implement the PE/COFF emulator protocol > MdePkg/UefiBaseType.h: treat EBC as a non-native machine type > MdeModulePkg/DxeCore: remove explicit EBC handling >=20 > .../Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 7 - > MdeModulePkg/Core/Dxe/DxeMain.h | 6 +- > MdeModulePkg/Core/Dxe/DxeMain.inf | 2 +- > MdeModulePkg/Core/Dxe/Image/Image.c | 210 +++++++++++++----- > .../Include/Protocol/PeCoffImageEmulator.h | 107 +++++++++ > .../Library/UefiBootManagerLib/BmLoadOption.c | 6 +- > MdeModulePkg/MdeModulePkg.dec | 4 + > MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf | 3 + > MdeModulePkg/Universal/EbcDxe/EbcDxe.inf | 3 + > MdeModulePkg/Universal/EbcDxe/EbcInt.c | 121 +++++++++- > MdeModulePkg/Universal/EbcDxe/EbcInt.h | 3 + > MdePkg/Include/Uefi/UefiBaseType.h | 6 +- > 12 files changed, 402 insertions(+), 76 deletions(-) > create mode 100644 > MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h >=20 > -- > 2.17.1