From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::d41; helo=mail-io1-xd41.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EB7892194D387 for ; Wed, 26 Sep 2018 03:14:07 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id w16-v6so4710078iom.7 for ; Wed, 26 Sep 2018 03:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=AeU5QQxS6YVp9FNtFyCIIckkEQzvwtLJueGpksWspUU=; b=QBiHzVK99bO5vUsBW9e/F97uOAWeJpKbep0a9/ilh6kj4BUIkW31CP3Ctlv2SvVdEp 2gH8Va4mfT/vNybn6XTVV/ORRL36s1f312Wb6xPGbwv7VFAK0xoTZGtuGOy2tmK10kEm MBx9n9YHLaW+5fQRsUzGKyIvmCmIBqvzp+rgI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=AeU5QQxS6YVp9FNtFyCIIckkEQzvwtLJueGpksWspUU=; b=jCG+n/DQXyjsDOusxeaKq7zoRKK6dDlIw696cFFC3ce4c99S/7Bg6hv4Z8GfoA7AJP kSUjfOKmB7yJYU1KxFUCZuHaHWQcl03kE3Q68N2p0/m6ciQ9jSaBJCb594FXmZahdgt7 dgtd7l+4ue10j4p4uAb8dwxyK5zvKhfKnV47iMUcnB5zrAEaXvuCiJPLfgLgVXRXmtPl gUQeqecgk7t2XSTW9rJJiP3jjbrw+78UXUB9wDvAhAjlDyAAQ70U7h2tNk+xt4TBtll4 9NsKqvBXWMp9nxnH8dxpydZxXDmt415pxjZxI10MCBM/o235rM60NuzPJ9yWWs+/bliw 5CEA== X-Gm-Message-State: ABuFfoiowvYOmC8raBse1R0VBbLp19G42JXfbvNlJqFrJTL7hm6mAXB8 K195F76jkWDPwRLBPY7Waf86UGFAk2qRMHbia+Ziow== X-Google-Smtp-Source: ACcGV627DG9TSsUUiVMhG05tb9bz95sDOtguFYkqS3kft1A30RgBOXIxjpVwRVv8harTdbcEz17abdeEdQzZYsNA+KI= X-Received: by 2002:a6b:be83:: with SMTP id o125-v6mr4271378iof.173.1537956846125; Wed, 26 Sep 2018 03:14:06 -0700 (PDT) MIME-Version: 1.0 References: <20180920230145.7565-1-ard.biesheuvel@linaro.org> <20180920230145.7565-2-ard.biesheuvel@linaro.org> <0C09AFA07DD0434D9E2A0C6AEB0483103BBF0A34@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103BBF0A34@shsmsx102.ccr.corp.intel.com> From: Ard Biesheuvel Date: Wed, 26 Sep 2018 12:13:53 +0200 Message-ID: To: "Zeng, Star" Cc: "edk2-devel@lists.01.org" , "Zimmer, Vincent" , "Richardson, Brian" , "Kinney, Michael D" , Andrew Fish , Leif Lindholm , Eric Dong , Ruiyu Ni , "Gao, Liming" , "Carsey, Jaben" , "Shi, Steven" Subject: Re: [PATCH v3 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2018 10:14:08 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 26 Sep 2018 at 12:07, Zeng, Star wrote: > > A little late feedback. Just an idea. > > Do you think whether it can make the consumer simpler like below or not? > > Add a new API RegisterInterfaces in the protocol and add a wrapper driver= PeCoffEmulatorDxe. > The emulators can call RegisterInterfaces, and consumer will call other A= PIs simply, PeCoffEmulatorDxe will be a wrapper as manager. > > typedef > EFI_STATUS > (EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_INTERFACES) ( > IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, > IN EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED IsImageSupported, > IN EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE RegisterImage, > IN EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE UnregisterImage > ); > > typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL { > EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_INTERFACES RegisterInterfaces; > EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED IsImageSupported; > EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE RegisterImage; > EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE UnregisterImage; > } EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL; > Hi Star, Thanks for taking a look. I tried to avoid introducing new drivers or library classes because it will break existing platforms that incorporate EbcDxe. Do you think this is not an issue? > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Friday, September 21, 2018 7:02 AM > To: edk2-devel@lists.01.org > Cc: Ard Biesheuvel ; Zimmer, Vincent ; Richardson, Brian ; Kinney, = Michael D ; Andrew Fish ; Leif= Lindholm ; Zeng, Star ; Don= g, Eric ; Ni, Ruiyu ; Gao, Liming = ; Carsey, Jaben ; Shi, Steven= > Subject: [PATCH v3 1/7] MdeModulePkg: introduce PE/COFF image emulator pr= otocol > > Introduce a protocol that can be invoked by the image loading services to= execute foreign architecture PE/COFF images via an emulator. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h | 102 ++++++++++++++= ++++++ > MdeModulePkg/MdeModulePkg.dec | 4 + > 2 files changed, 106 insertions(+) > > diff --git a/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h b/MdeMod= ulePkg/Include/Protocol/PeCoffImageEmulator.h > new file mode 100644 > index 000000000000..27bad556209c > --- /dev/null > +++ b/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h > @@ -0,0 +1,102 @@ > +/** @file > + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> + > + This program and the accompanying materials are licensed and made > + available under the terms and conditions of the BSD License which > + accompanies this distribution. The full text of the license may be > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. > + > +**/ > + > +#ifndef PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > +#define PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > + > +#define EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID \ > + { 0x96F46153, 0x97A7, 0x4793, { 0xAC, 0xC1, 0xFA, 0x19, 0xBF, 0x78, > +0xEA, 0x97 } } > + > +typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL > +EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL; > + > +/** > + Check whether the emulator supports executing a certain PE/COFF image > + > + @param[in] This This pointer for EDKII_PECOFF_IMAGE_EMULATOR_P= ROTOCOL > + structure > + @param[in] MachineType The machine type for which the image was built > + @param[in] ImageType Whether the image is an application, a boot ti= me > + driver or a runtime driver. > + @param[in] DevicePath Path to device where the image originated > + (e.g., a PCI option ROM) > + > + @retval TRUE The image is supported by the emulator > + @retval FALSE The image is not supported by the emulator. > +**/ > +typedef > +BOOLEAN > +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED) ( > + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, > + IN UINT16 MachineType, > + IN UINT16 ImageType, > + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL > + ); > + > +/** > + Register a supported PE/COFF image with the emulator. After this call > + completes successfully, the PE/COFF image may be started as usual, > +and > + it is the responsibility of the emulator implementation that any > +branch > + into the code section of the image (including returns from functions > +called > + from the foreign code) is executed as if it were running on the > +machine > + type it was built for. > + > + @param[in] This This pointer for > + EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL str= ucture > + @param[in] ImageBase The base address in memory of the PE/COF= F image > + @param[in] ImageSize The size in memory of the PE/COFF image > + @param[in,out] EntryPoint The entry point of the PE/COFF image. Pa= ssed by > + reference so that the emulator may modif= y it. > + > + @retval EFI_SUCCESS The image was registered with the emulat= or and > + can be started as usual. > + @retval other The image could not be registered. > + > + If the PE/COFF machine type or image type are not supported by the > +emulator, > + then ASSERT(). > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE) ( > + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, > + IN EFI_PHYSICAL_ADDRESS ImageBase, > + IN UINT64 ImageSize, > + IN OUT EFI_IMAGE_ENTRY_POINT *EntryPoint > + ); > + > +/** > + Unregister a PE/COFF image that has been registered with the emulator. > + This should be done before the image is unloaded from memory. > + > + @param[in] This This pointer for EDKII_PECOFF_IMAGE_EMULATOR_P= ROTOCOL > + structure > + @param[in] ImageBase The base address in memory of the PE/COFF imag= e > + > + @retval EFI_SUCCESS The image was unregistered with the emulator. > + @retval other Image could not be unloaded. > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE) ( > + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, > + IN EFI_PHYSICAL_ADDRESS ImageBase > + ); > + > +typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL { > + EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED IsImageSupported; > + EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE RegisterImage; > + EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE UnregisterImage; > +} EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL; > + > +extern EFI_GUID gEdkiiPeCoffImageEmulatorProtocolGuid; > + > +#endif > diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.de= c index 6a6d9660edc2..be307329f901 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -617,6 +617,10 @@ > > ## Include/Protocol/AtaAtapiPolicy.h > gEdkiiAtaAtapiPolicyProtocolGuid =3D { 0xe59cd769, 0x5083, 0x4f26,{ 0x= 90, 0x94, 0x6c, 0x91, 0x9f, 0x91, 0x6c, 0x4e } } > + > + ## Include/Protocol/PeCoffImageEmulator.h > + gEdkiiPeCoffImageEmulatorProtocolGuid =3D { 0x96f46153, 0x97a7, 0x4793= , > + { 0xac, 0xc1, 0xfa, 0x19, 0xbf, 0x78, 0xea, 0x97 } } > + > # > # [Error.gEfiMdeModulePkgTokenSpaceGuid] > # 0x80000001 | Invalid value provided. > -- > 2.17.1 >