From patchwork Mon Apr 1 03:27:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 161511 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4874472jan; Sun, 31 Mar 2019 20:27:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqIh7vTT601dW9smhhgSJjlNjSLcDod5dVLNSePhbQj8S4hUT6+Lzum61+u2eCEIFupTWN X-Received: by 2002:a63:da4e:: with SMTP id l14mr17738750pgj.96.1554089244254; Sun, 31 Mar 2019 20:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554089244; cv=none; d=google.com; s=arc-20160816; b=OBR/BfD3OoMSZDAt80EwqwG5O0TT78/OR+H9BKfTVaa4IyEZ97PtCcgAE0eQjQ9C3t MPmriTGhbvQf/VfmivYu3klnhlzG1t6BRNINMUZ9crZzyM3su2TJq2faUeEhp6j5FR6/ Di8dWJ5h9Y7TCk5LQ+1bW8hpCl1k+rIqOuFIBV/Zrt5Tx/7mCB2smeEJPV46/PlXMOM9 t93VZVLXzTmtfiYPz69khMGYOkAufkYS4Vlc+qNTuoyyBd0H/2HffCAmQwr2zFMWBo4C 1ZGgGWR8+jhWKaBPsorq7ktHhuMzLHMjXv6Pwni/ELERlOcnuNrmKd8e2WwyhrN6OVPq FhqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Xi6NfNHALgl22Xpwf7nCiC+k0O7Y0ftdXGu0lQ0ZQJI=; b=PYjY2lebKJY2lYU2R29bdFhV5lf/A5Xn6GDdAP4MLL1Av71TVuNRUUefJEgeGaSUpc TMZhAwJVYYNdx3MJ4hmR/9M+S1ssx9Aj5wLswLsQP78UIMS8NacaQHvlnidzHw3r/rqE yEeJr3QR6M1bDPSKB3RlSuRaZw1/a226RWf9ol1ijJF/u0tfDWQudHquzEftM6BKrZdC gYTXHMDUTiUv1Mq3i5RqrGNofM70CoAs99kEQatZqUrQ+PnrrwEjvNGKiU65XCqHMB8d QmR/HHZtsusQf8PHNGzt3218ZAcvu0BAtfKuHGf5tTXdgEI75guo6N/MuWtTuZbWrIlZ T3lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="LTHEa/Ff"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 33si7916149ply.361.2019.03.31.20.27.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="LTHEa/Ff"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DB43C211EC678; Sun, 31 Mar 2019 20:27:23 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::643; helo=mail-pl1-x643.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 8FB59211E011B for ; Sun, 31 Mar 2019 20:27:22 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id w23so807075ply.4 for ; Sun, 31 Mar 2019 20:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lj4odYtvxsw9UYzZLUqw/gPOstQuquFC6SfqcgweAQQ=; b=LTHEa/Ff4KOVW7EkoKpOR2LnQ+oGqpxbI2g+IwM4FWvQGsEGKkKWQIE6D8LUK1fquy SYYM4ktF9ogTwLQdazq2J6uVOGDlaiDMP3pZc+esKVUawFFV8C1KwTyLozjAwyI0MElV 3M0f1fA8eYXINn2yU/vJmv5wIlieRZU6z2P/quDm4vg3BqBqh4OeFjS84m6zgi+raZ0q PsLAWmzTdHkxjlo1OMaECcFc24LhImP3ytDJAYgvriycdlUhWUNDCzTqgweKxBr2IVwn yVO+JCirtHuOe6EsjALLJQTpC4A52aPZOdu+F2AzQ8Scx/NjbuU/UCsBXGELJfUNAJBM Vj8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lj4odYtvxsw9UYzZLUqw/gPOstQuquFC6SfqcgweAQQ=; b=pVl+Nl7QoaZLZ0344PUnE2QQPaAyrr20Cr3uGo0X6PHLLXSrtMokYO+m8dvXjIuyqF R0RcqkJjR/FzNn23XSapP2FBvQ3GDTihhTqUTbxCeX6PBwuuCFEeeI6g/ZDt54uy6cn3 BmkY/X8pAjyhAyOBlBPN2vuDsoGWwRWp17wo5evq7/gbU5I55aZNpx5HT/fGrNN6xbel bJ02ZpiRvV7Hc0neKa7qYaPq8HmfyhqIXJuzeJqMIFf/HwYOzI+C4V2FFtVqcl+rEQBy Vy0/lc6I9vZ38CwUqFYQLJlK4WIfI7OujlwmHPmZngvFTBsxObjUmXQ3cpPkn1eiwuPL A/Aw== X-Gm-Message-State: APjAAAWpduRa3X8AY2fzoFSBCzRkbftphagn3asifXJTpAssevC6BX7q eCkiv7MVPkpmkNkTq/Gb3DgBR8YLVwnSZQ== X-Received: by 2002:a17:902:ba98:: with SMTP id k24mr53359491pls.335.1554089242027; Sun, 31 Mar 2019 20:27:22 -0700 (PDT) Received: from mba13.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id 16sm12758092pfz.106.2019.03.31.20.27.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:21 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 1 Apr 2019 10:27:03 +0700 Message-Id: <20190401032709.14787-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401032709.14787-1-ard.biesheuvel@linaro.org> References: <20190401032709.14787-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 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: , Cc: Ruiyu Ni , Vincent Zimmer , Eric Dong , Jaben Carsey , Brian Richardson , Liming Gao , Michael D Kinney , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 | 107 ++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 4 + 2 files changed, 111 insertions(+) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h b/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h new file mode 100644 index 000000000000..1ca302440e4a --- /dev/null +++ b/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h @@ -0,0 +1,107 @@ +/** @file + Copyright (c) 2019, 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 IMPLIED. + +**/ + +#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_PROTOCOL + structure + @param[in] ImageType Whether the image is an application, a boot time + 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 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 structure + @param[in] ImageBase The base address in memory of the PE/COFF 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. Passed by + reference so that the emulator may modify it. + + @retval EFI_SUCCESS The image was registered with the emulator 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_PROTOCOL + structure + @param[in] ImageBase The base address in memory of the PE/COFF image + + @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 + ); + +#define EDKII_PECOFF_IMAGE_EMULATOR_VERSION 0x1 + +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; + + // Protocol version implemented by the emulator + UINT32 Version; + // The machine type implemented by the emulator + UINT16 MachineType; +} EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL; + +extern EFI_GUID gEdkiiPeCoffImageEmulatorProtocolGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index a2130bc43991..c2b4e7f69367 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -629,6 +629,10 @@ ## Include/Protocol/AtaAtapiPolicy.h gEdkiiAtaAtapiPolicyProtocolGuid = { 0xe59cd769, 0x5083, 0x4f26,{ 0x90, 0x94, 0x6c, 0x91, 0x9f, 0x91, 0x6c, 0x4e } } + + ## Include/Protocol/PeCoffImageEmulator.h + gEdkiiPeCoffImageEmulatorProtocolGuid = { 0x96f46153, 0x97a7, 0x4793, { 0xac, 0xc1, 0xfa, 0x19, 0xbf, 0x78, 0xea, 0x97 } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. From patchwork Mon Apr 1 03:27:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 161512 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4874505jan; Sun, 31 Mar 2019 20:27:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEynslL863nb6ETHGdcDepBkF2pso4qcHKNyAhE2ygI1oorD/RGQeITYX+nQaZ/LUYYAyH X-Received: by 2002:a63:25c4:: with SMTP id l187mr2540626pgl.202.1554089247568; Sun, 31 Mar 2019 20:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554089247; cv=none; d=google.com; s=arc-20160816; b=mJwtyd+ihlP51oSAMUqe45uLnIgDqJl0F2dD7o97XAZwobnZgwX0kvCV2wXPkvTWVu eatFmM8dozdk5jC9s049v48J8DaicXsscJuqGDxJD85fdMxoRAXlJd9LFOQTTdDdkHGn FPwGJqt7NG06pXFLLC/6v3UueDHe7hcaVX1s2/1R3LTX7QTd/2Z2e6lmRdTjmGJ53CfH q+EtDDI+eenh5pla9s+JWF311xceNsGpGZcz69UB6MoJY37XtL0/O1kxJ5WtL7w0DgLn MORgXnj0+5FZKXEZU4WRTPzmWEXp8yENyV0lTMtgCa7SDO1BTQoucUsTWcFzpOefuJAh lgYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Iw4g2kSjYWkc9pz3UnINou9a8knPWyEc/yEU326xNO4=; b=WZsdu6GGlXFVV46I1UntNSfMMt++V+ZX2pJAJnm6FZDaI7Sid8FPOtFosV7Yajjf/D iKsjsLzKKmIbwx40/4g43+qZcBPnfEZsqIcrLmjlaSiz03OeFffOTGYyPmx6zd5BOqR3 Z223vwIpvgL7AzSpHE/nfL1+2as0px0L8Pa5oVwiqiSA/2rACkW4M4aI/m3sx8r2mOPY Pb4ff9tmLEfCrPAa1DnYvi0/lx45UpzTRA3HcTeim/3xtyd418K6ytAniPeky/PqiUhT SyfBOJOo5MRfOZJWI/AZSzIh5BNxwIL2zAuRlWljBGy838phi7Ll1s34aP8ht1OBenhX X8OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=n6JDv5vv; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id r1si7534949pgv.428.2019.03.31.20.27.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=n6JDv5vv; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1BB96211EC0F4; Sun, 31 Mar 2019 20:27:27 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 B78C7211E011B for ; Sun, 31 Mar 2019 20:27:26 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id y13so3803982pfm.11 for ; Sun, 31 Mar 2019 20:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1kM/d0DCxSrkBgIGWttlTHAIeRJJEiXPzmAwpx+rgwA=; b=n6JDv5vvzEiTy5OVSlvAl19IkI0ySGfU3Lg72QlFo1bPV7Q42JOz7M6Ylghes3k3M8 TsNbj28GGJ91OBj4kV9RgC8sXwumg0tfaHeki5hpM/NZJ+ejK2eyopVyLzig/y3nHuHN aJcQSMj0z5huO/LIJZltuTJGi2WY6l937yKGtlaDBdH3wNFF5tcvuPkxBAQYTI5tOHxW NL5N2Y5iJ8zMkDjJjB7tc7ZDC65Je1A0o/N5yrmyJMpsUkWIKV+97QlUsQhtffkBuji4 313ma9oHUNU8SgfZk2ZLkLjt+PLeGZysA4bv4xzMu/GWvoqk2B6zK3FU9Oym+bUQWnSE mcoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1kM/d0DCxSrkBgIGWttlTHAIeRJJEiXPzmAwpx+rgwA=; b=i2ETJ8N9WlZGki8dr2vC4+IwTPebBhsBkTerbkjTMBDq2OHRaNdugW+WJrS1cgWkrA x+At0549vvvaFLFwonDxw7BrCHr7hxGQnSbvJhBRMoBYRNlB6b9j03VVhUPKONk3GXDL 3M3cpiJvxwdroYkod3h7Hk2PquzqOBrMwJtHa3gxSvOq9Ggd+U8BsGKFj1FrMV2+jwxg M6SXSRDFzmhjMQWSlAuOaF/p94GcLY2wt38uaqWBXkwq5eNRrH2qY/pxg+kHMxppQQvj lMgjvO6lbKXaB7/S0xMz/dbzfXoGt/goY7RMWRNvJ/luJlzYbwhQjkRHpdflVgpUMHuN wjqg== X-Gm-Message-State: APjAAAVRjJe2/Em9HCmHXI8INdVxTcRxx8RdLOjQ6e1sc+NEoGOn/5Dp 18TvWm6gtNEBjP4LLfl8MTkzFDvFK2tRlQ== X-Received: by 2002:a63:1a1b:: with SMTP id a27mr50939665pga.59.1554089245905; Sun, 31 Mar 2019 20:27:25 -0700 (PDT) Received: from mba13.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id 16sm12758092pfz.106.2019.03.31.20.27.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:25 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 1 Apr 2019 10:27:04 +0700 Message-Id: <20190401032709.14787-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401032709.14787-1-ard.biesheuvel@linaro.org> References: <20190401032709.14787-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 2/7] MdeModulePkg/DxeCore: invoke the emulator protocol for foreign images 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: , Cc: Ruiyu Ni , Vincent Zimmer , Eric Dong , Jaben Carsey , Brian Richardson , Liming Gao , Michael D Kinney , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" When encountering PE/COFF images that cannot be supported natively, attempt to locate an instance of the PE/COFF image emulator protocol, and if it supports the image, proceed with loading it and register it with the emulator. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/DxeMain.h | 3 + MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/Dxe/Image/Image.c | 144 ++++++++++++++++++-- 3 files changed, 137 insertions(+), 11 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 2dec9da5e35b..48ec30a48aa2 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -53,6 +53,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -228,6 +229,8 @@ typedef struct { UINT16 Machine; /// EBC Protocol pointer EFI_EBC_PROTOCOL *Ebc; + /// PE/COFF Image Emulator Protocol pointer + EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *PeCoffEmu; /// Runtime image list EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; /// Pointer to Loaded Image Device Path Protocol diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index 10375443c0f4..ce6fc19be5e4 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -162,6 +162,7 @@ gEfiHiiPackageListProtocolGuid ## SOMETIMES_PRODUCES gEfiEbcProtocolGuid ## SOMETIMES_CONSUMES gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES # Arch Protocols gEfiBdsArchProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index eddca140ee1a..cda447d23ec5 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -29,6 +29,15 @@ LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = { } }; +typedef struct { + LIST_ENTRY Link; + EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *Emulator; + UINT16 MachineType; +} EMULATOR_ENTRY; + +STATIC LIST_ENTRY mAvailableEmulators; +STATIC EFI_EVENT mPeCoffEmuProtocolRegistrationEvent; +STATIC VOID *mPeCoffEmuProtocolNotifyRegistration; // // This code is needed to build the Image handle for the DXE Core @@ -67,6 +76,7 @@ LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage = { NULL, // JumpContext 0, // Machine NULL, // Ebc + NULL, // PeCoffEmu NULL, // RuntimeData NULL // LoadedImageDevicePath }; @@ -118,6 +128,39 @@ GetMachineTypeName ( return L""; } +/** + Notification event handler registered by CoreInitializeImageServices () to + keep track of which PE/COFF image emulators are available. + + @param Event The Event that is being processed, not used. + @param Context Event Context, not used. + +**/ +STATIC +VOID +EFIAPI +PeCoffEmuProtocolNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EMULATOR_ENTRY *Entry; + + Entry = AllocateZeroPool (sizeof *Entry); + ASSERT (Entry != NULL); + + Status = CoreLocateProtocol (&gEdkiiPeCoffImageEmulatorProtocolGuid, + mPeCoffEmuProtocolNotifyRegistration, + (VOID **)&Entry->Emulator + ); + ASSERT_EFI_ERROR (Status); + + Entry->MachineType = Entry->Emulator->MachineType; + + InsertTailList (&mAvailableEmulators, &Entry->Link); +} + /** Add the Image Services to EFI Boot Services Table and install the protocol interfaces for this image. @@ -192,6 +235,30 @@ CoreInitializeImageServices ( gDxeCoreImageHandle = Image->Handle; gDxeCoreLoadedImage = &Image->Info; + // + // Create the PE/COFF emulator protocol registration event + // + Status = CoreCreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + PeCoffEmuProtocolNotify, + NULL, + &mPeCoffEmuProtocolRegistrationEvent + ); + ASSERT_EFI_ERROR(Status); + + // + // Register for protocol notifications on this event + // + Status = CoreRegisterProtocolNotify ( + &gEdkiiPeCoffImageEmulatorProtocolGuid, + mPeCoffEmuProtocolRegistrationEvent, + &mPeCoffEmuProtocolNotifyRegistration + ); + ASSERT_EFI_ERROR(Status); + + InitializeListHead (&mAvailableEmulators); + if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) { // // Export DXE Core PE Loader functionality for backward compatibility. @@ -425,6 +492,45 @@ GetPeCoffImageFixLoadingAssignedAddress( DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status = %r \n", (VOID *)(UINTN)(ImageContext->ImageAddress), Status)); return Status; } + +/** + Decides whether a PE/COFF image can execute on this system, either natively + or via emulation/interpretation. In that latter case, the PeCoffEmu member + of the LOADED_IMAGE_PRIVATE_DATA struct pointer is populated with a pointer + to the emulator protocol that supports this image. + + @param[in] Image LOADED_IMAGE_PRIVATE_DATA struct pointer +**/ +STATIC +BOOLEAN +CoreIsImageTypeSupported ( + IN OUT LOADED_IMAGE_PRIVATE_DATA *Image + ) +{ + LIST_ENTRY *Link; + EMULATOR_ENTRY *Entry; + + for (Link = GetFirstNode (&mAvailableEmulators); + !IsNull (&mAvailableEmulators, Link); + Link = GetNextNode (&mAvailableEmulators, Link)) { + + Entry = BASE_CR (Link, EMULATOR_ENTRY, Link); + if (Entry->MachineType != Image->ImageContext.Machine) { + continue; + } + + if (Entry->Emulator->IsImageSupported (Entry->Emulator, + Image->ImageContext.ImageType, + Image->Info.FilePath)) { + Image->PeCoffEmu = Entry->Emulator; + return TRUE; + } + } + + return EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->ImageContext.Machine) || + EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED (Image->ImageContext.Machine); +} + /** Loads, relocates, and invokes a PE/COFF image @@ -473,16 +579,14 @@ CoreLoadPeImage ( return Status; } - if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->ImageContext.Machine)) { - if (!EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED (Image->ImageContext.Machine)) { - // - // The PE/COFF loader can support loading image types that can be executed. - // If we loaded an image type that we can not execute return EFI_UNSUPORTED. - // - DEBUG ((EFI_D_ERROR, "Image type %s can't be loaded ", GetMachineTypeName(Image->ImageContext.Machine))); - DEBUG ((EFI_D_ERROR, "on %s UEFI system.\n", GetMachineTypeName(mDxeCoreImageMachineType))); - return EFI_UNSUPPORTED; - } + if (!CoreIsImageTypeSupported (Image)) { + // + // The PE/COFF loader can support loading image types that can be executed. + // If we loaded an image type that we can not execute return EFI_UNSUPORTED. + // + DEBUG ((EFI_D_ERROR, "Image type %s can't be loaded ", GetMachineTypeName(Image->ImageContext.Machine))); + DEBUG ((EFI_D_ERROR, "on %s UEFI system.\n", GetMachineTypeName(mDxeCoreImageMachineType))); + return EFI_UNSUPPORTED; } // @@ -687,6 +791,16 @@ CoreLoadPeImage ( if (EFI_ERROR(Status)) { goto Done; } + } else if (Image->PeCoffEmu != NULL) { + Status = Image->PeCoffEmu->RegisterImage (Image->PeCoffEmu, + Image->ImageBasePage, + EFI_PAGES_TO_SIZE (Image->NumberOfPages), + &Image->EntryPoint); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_LOAD | DEBUG_ERROR, + "CoreLoadPeImage: Failed to register foreign image with emulator.\n")); + goto Done; + } } // @@ -874,6 +988,13 @@ CoreUnloadAndCloseImage ( Image->Ebc->UnloadImage (Image->Ebc, Image->Handle); } + if (Image->PeCoffEmu != NULL) { + // + // If the PE/COFF Emulator protocol exists we must unregister the image. + // + Image->PeCoffEmu->UnregisterImage (Image->PeCoffEmu, Image->ImageBasePage); + } + // // Unload image, free Image->ImageContext->ModHandle // @@ -1599,7 +1720,8 @@ CoreStartImage ( // // The image to be started must have the machine type supported by DxeCore. // - if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->Machine)) { + if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->Machine) && + Image->PeCoffEmu == NULL) { // // Do not ASSERT here, because image might be loaded via EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED // But it can not be started. From patchwork Mon Apr 1 03:27:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 161513 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4874551jan; Sun, 31 Mar 2019 20:27:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM5T620A6nlv/GyOVbZtiaE0hnaet7OEqnH25NwnQuomk7bpdRS6qG0Z7Ougx9bfu/v9JQ X-Received: by 2002:a65:5cc8:: with SMTP id b8mr4549753pgt.36.1554089251680; Sun, 31 Mar 2019 20:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554089251; cv=none; d=google.com; s=arc-20160816; b=iA4616A8eYheD2ILInJ6bBnj1cwxkYAYniCqB57WQiCsARXjabxhia1OWg33K9TsOo cfJu73M/I26sQdBJ9eaOVqfEIU2iHC7BYcU/zdN1U5q+KDgqQVvD76PaZWlFdwV/Thqi IkFPVJkljoTY6bTa5MRxasUXUPxckl7nr5zINK7aRLcJDCiHIVoi7gQkFG4fsBkPqGCE KItGoQXzzTopqZEe9HwfY7I7L1K9p1lnfeRjabGbxlR7p2ptRk4ZrBRkHr428/HYwj6k hKqpqU/GzARh4p3ABJJqIbMzrmCck1WK7sc76pYgdI/2aaLM7yo6TQOmY+Oj1V8js3yb LYyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=QkkmkS898c+WFxD2eFQzLBVzWt7gVN4kZQ+VXB9rPRI=; b=OpV1h+uB1YKLaqKDnaAb1N5A+1ayYW76XKYY8to1LqeAFX+AFJyecSAnkb+JWR0itW 0yRCikkhG4L3gqfRYY2xsTIfjEoTTLWpTjzlEXKGK9F8Vx8Gq+XuKSsIGTfg16C86LJK oTEUAXvuYIEk+B4X4VoOAkQhQEmgRU0GzjIz41C2IWjpSDUUEtKiBOIv74eTVmq/EtUK EkclrgCuq1S+eMQYWOm/VZwAHDstqtfDdvsQ2we9JwxNA/42zcBJzGB3UdxF5aFyga5k /NBExEhxKq+OXFWppfpdBFmT3PB/pc0R/SYc6/T1I83Yb5/xQLcXKgeHyzc19viRX6Yr rTfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LgFn0eh1; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id t15si8071424pgq.235.2019.03.31.20.27.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LgFn0eh1; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5034E211EDB3A; Sun, 31 Mar 2019 20:27:31 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::544; helo=mail-pg1-x544.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 89351211E011B for ; Sun, 31 Mar 2019 20:27:30 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id z9so3996765pgu.10 for ; Sun, 31 Mar 2019 20:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xM4ttDr0FC3tm4+Ki+HNyFrnkjWXEw61mH+nCchvQJs=; b=LgFn0eh1F6hvzDav5jcJfg6zpAaW5cxAATWzWCrV88TCodOMxCjbB1ecP5lLeZAGu/ d1Lsiy6GB0+TUt8PTVKVhJmZxjTqIconrjOrFnEbyZN4DwsAEtWUs7MH+cGdc/cfc2kb dBr4uCqumx9yXbgxxlmbXUeLrRVPjgolg96Ud89P4nz+WdW86Yn/LtpOpjwM+hwcJ+w4 gyv4Kf1sERIEy8zfXlTfKzkbh8FQs1Z//zKtB4Kx5dwYgggCczbY9YVyItm7Gm4p/aA/ 3va0oLxB0XPFktvCttTJMjbJV1EQMtajXmFm6xIl6wKqoPa5ob4ZQKLxJ8KrRqZ1D4uV Eicw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xM4ttDr0FC3tm4+Ki+HNyFrnkjWXEw61mH+nCchvQJs=; b=OlnOKc8vQAhNZnN81cBx62mOtau7/l6zHeaA6YeTLF1miatvORcV3fn7s5YtTAcJWL rgPiEAYl1z/6mutF1OCsY007HPFwJNh0sHN+qxtbgf2jYg/P4GGkInsiEwKbTJAuAFqt ah9Feb9fsA1WEtJImcpV29O7eRas87x+Wn1snXtLXrL7T9LBhZzRfWKYbizDS7cIRLjS sYfesDYuDBzTNDDL/FzcDWNR7qphuf9LBy9AUNMSE+S6lrPooxc+W2NbnlM4CibkMB1r bvIcbaphd7cWB4amSotDgMwggQxL/l+623khF7K1NfoNz9WuPKuVRR4taZL/EgnrxzjI 5WdQ== X-Gm-Message-State: APjAAAUgdOSC5p5OlcQioleiHQcJeriVWBUlpCBQD4nt3ONsSP5mu155 bmGnXnAyGFTknMsYL/rW+gklDQU2p4Frpw== X-Received: by 2002:a62:4481:: with SMTP id m1mr61366691pfi.253.1554089249722; Sun, 31 Mar 2019 20:27:29 -0700 (PDT) Received: from mba13.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id 16sm12758092pfz.106.2019.03.31.20.27.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:29 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 1 Apr 2019 10:27:05 +0700 Message-Id: <20190401032709.14787-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401032709.14787-1-ard.biesheuvel@linaro.org> References: <20190401032709.14787-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 3/7] MdeModulePkg/PciBusDxe: dispatch option ROMs for foreign architectures 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: , Cc: Ruiyu Ni , Vincent Zimmer , Eric Dong , Jaben Carsey , Brian Richardson , Liming Gao , Michael D Kinney , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Delete the explicit machine type check for option ROM images, and instead, rely on the LoadImage() boot service to decide whether an option ROM can be dispatched or not. This permits platforms to ship with emulators to execute option ROMs that are not native to the processor architecture. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 7 ------- 1 file changed, 7 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c index c75ef1a82505..54cf4251cc86 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c @@ -699,13 +699,6 @@ ProcessOpRomImage ( goto NextImage; } - // - // Skip the EFI PCI Option ROM image if its machine type is not supported - // - if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (EfiRomHeader->EfiMachineType)) { - goto NextImage; - } - // // Ignore the EFI PCI Option ROM image if it is an EFI application // From patchwork Mon Apr 1 03:27:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 161514 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4874610jan; Sun, 31 Mar 2019 20:27:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqysP2zNko2WDfFskkFXd99zSr0Bs4N7QuGGUEtEsgHwBiDSwS1Ii534mzLYJOn5l+tqfXhA X-Received: by 2002:a17:902:7785:: with SMTP id o5mr42546458pll.33.1554089255868; Sun, 31 Mar 2019 20:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554089255; cv=none; d=google.com; s=arc-20160816; b=A2bZ2OJl8GxbpKqUxECVON/I+wnfhrw291s+KnpW8Jo85cI2JHIkjgMMhKwEF8uBoc jpMZ5YK+VPCAePRqvLN9XzgtR9w3AbePVXBo22oXfP1n/XSFvQBlRWeeV0FKPed11bKL 7Ja/MlLj8C41l7cUOp1X3UPBgKoXGSIQ8sT4ZJLGAHsKAW6KcwGqmsMs2I20grwf0fMH A0ZM9VQouZvCBVkCIlFEyCYp9rWfQWVA1YQzY2AwcNQk0L/mrKk7VoXvBIvxTz+Sf2Nb xG3+sXgI7JK0G+P/FA0BTpclpg+GiWKiZFXhjMbH4x3F0EVzRCLmbgntosC1Sw8HwKPI 7HFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=3gTIJ6DCkxrpeNSvae6S5fmjuAgb/GLUHJ4wbjJnRdI=; b=NKtEpVA1HWZTkdwtqI6M13D+tkva3hbmcZCQrUfd1Cdv/UvbFMpBR37UnbhCjFzN3x A91xzHvKlnDTiavUV5vgwc2SXPMcK9QbxY6L4riavSA8uBnBpQ8yGizLeSay2bzoUl8V 1+EnnZ2NTvGZcELrZsbTAH9vhXByRqcFBSQPvZwHfs1adopTZqTMdbKli0gdFUHMMOL0 x5rIhvimUtkkJxfcgc11Kr5qwm42r6Poqf58EnLR5imf5BSuaXC33HAydAoeOYAoxFkc z4TEzpzN0pRS2uDOTx4uFMc3bR7CvJcATVn7JHHfd+rN6/nkJRvzUiZ1LIfNoGFq/dB6 akUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=U1xNR+uO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id f40si8226267plb.339.2019.03.31.20.27.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=U1xNR+uO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7EE2F211EDB3D; Sun, 31 Mar 2019 20:27:35 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (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 4DA40211E011B for ; Sun, 31 Mar 2019 20:27:34 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id i17so3816924pfo.6 for ; Sun, 31 Mar 2019 20:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kJwAjnz7dW3QayejO1nSzFv7Z+xOomqoKI6R/KOcWkw=; b=U1xNR+uOfmVvW1F8PROm71pYR79pKSG/+GgvQek2XknOYxuAgQriCXXdpLhb7taV1O /ADGACv6FQVFtzcEdS543kBzay575sdQtuVHnBgc2Mr3DfuiyXt5xapoh3N1coaGL/Nj 2mly2fTR0fUkbvw7dea/Sv5QIchfuHd6RwAiJsFhor4QJzz41QDlm/cOPepGl4xpWIs3 ZKZ0wj72oJEDmvj7hSmdV9osMOQxF2ox7ZxdD5E7cgCN0RzQTzICV+7Nd1snabKL1DPL q4wiQhJHRl7VGx5HeY+CKeJ2Vi1I4wVIRcuLHgva9rIcOPeyrj3bsxJcKCEYyrr3JMwf ihYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kJwAjnz7dW3QayejO1nSzFv7Z+xOomqoKI6R/KOcWkw=; b=KqnUFMiZpvZ71eYPflxR1JuHNmx9lIS69RyXQiBJmQDYOHjBXfr5UroKZmM4XNMdML dROU9DNu1PKcpKMZMskJf0XEL4qx6wNUQcukpGHT5NvDG6FruQ0F4wcBDTIkc2K7i0vx Wo1ny8YmCW2L1Wtj8QhGsPhNKEGZGrkoM73DX0LbJ+Z3cncHZKjwDFFC9Z5lr/F1AT2O fIxBxgLdOGuJASAQBZL2xXj905DtVDQ67kOKNHJEMlBHWIfVXNwf5DJNNTGXQL/LxtqC rCcAS7lWFdKYkbbErmPneGPvY1y/1/a4A1Ai0wAUBxBRe70d5oBAMlTb5FKgaj9jA9Y4 y0+A== X-Gm-Message-State: APjAAAUwsYKgfyzhuwyb3jzHf3oBLDCtUHKKelATgXZtoADHx1BI7PpH lSByoR71iUohRB6MMseEYzBsQ88U5onmFQ== X-Received: by 2002:aa7:91d7:: with SMTP id z23mr21194335pfa.137.1554089253475; Sun, 31 Mar 2019 20:27:33 -0700 (PDT) Received: from mba13.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id 16sm12758092pfz.106.2019.03.31.20.27.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:32 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 1 Apr 2019 10:27:06 +0700 Message-Id: <20190401032709.14787-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401032709.14787-1-ard.biesheuvel@linaro.org> References: <20190401032709.14787-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 4/7] MdeModulePkg/UefiBootManagerLib: allow foreign Driver#### images 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: , Cc: Ruiyu Ni , Vincent Zimmer , Eric Dong , Jaben Carsey , Brian Richardson , Liming Gao , Michael D Kinney , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Allow PE/COFF images that must execute under emulation for Driver#### options, by removing the redundant machine type check from the BDS code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c index 7bf96646c690..8e6caaa63548 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c @@ -1233,10 +1233,8 @@ BmIsLoadOptionPeHeaderValid ( // Check PE32 or PE32+ magic, and machine type // OptionalHeader = (EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHeader->Pe32.OptionalHeader; - if ((OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC || - OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) && - EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeHeader->Pe32.FileHeader.Machine) - ) { + if (OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC || + OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { // // Check the Subsystem: // Driver#### must be of type BootServiceDriver or RuntimeDriver From patchwork Mon Apr 1 03:27:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 161515 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4874665jan; Sun, 31 Mar 2019 20:27:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcJmZ+8aBm5O+fphiHTM9c2+e237w9sm5Y4Vwl+sCtkVEphy2qILqV+nOdjK6CuO37NNbe X-Received: by 2002:a17:902:728e:: with SMTP id d14mr59542137pll.327.1554089260107; Sun, 31 Mar 2019 20:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554089260; cv=none; d=google.com; s=arc-20160816; b=DtKTF8Kr4/pv7yWG+ftnZuIYIU2yquudmkcvY/gC/xlZqeZv/NzUgDVxzFO1DuDBRS Cs8AGk1XWyQeoX+grWr1aQnWj0xjCZmS41LspVg17fFS8Lzu9uJOQuBtvUiiho2y6Voy ej6ex9e2RPzHN1/KW93s3h6nJc6svo9y2vhLKHnFw8ogDzty/YtP2GpBFS/PSqUNLZZO Nj3RVnlFzPZO1q4F21oZJfjDVqUIFIPf/XDcDX+L1Unyd/+tshSARV3yg4qxBK8YGkQB QLzPZC2M2FTPZAPFllIU2bDmAUjl8M94eBU6l1fhyocg2g/XjVgT3DS8yU8lnUjV3YZy QG+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=LRm6gByYJG2gobAWbSyqo4T/lFOEYkTMwhoYRqhFwwQ=; b=t6GBB/+xErnp26J79RLJ9ERHmJohKM131+QC8nvv+mmc0RyuXrL5NYE4Xd86FMTdG5 luQTz/P0+paThSg3egro/fWWV/w1lrBHe3+wo9YsmT820/kKgIIEyh/Dx+xqqeMc92tx Abchnb5oWa1MwATXOGFTSHWgyNaWqE3U9DE40qjCgUKGi6g64FXCsUOPRS8zCb94epXr kxa1klMnfl19/Dxtb13L9rI5obTvkoHh3+zwLrN1uEhfFj82e/f1xU3G3eepOYasezq6 8XOwOX2zVIwfyPfM9wCSfX/n8uDh0rJOllCxOH9PFmJWcnpuSRQrkgWGlMqRsXuB5ORp 791g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="l8/7/ciX"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id f131si7948116pfc.92.2019.03.31.20.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="l8/7/ciX"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B1CBA211EABD2; Sun, 31 Mar 2019 20:27:39 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::441; helo=mail-pf1-x441.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (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 98F41211E011B for ; Sun, 31 Mar 2019 20:27:38 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id b3so3824693pfd.1 for ; Sun, 31 Mar 2019 20:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6PFcI+JfAhwfsNi3wGhsqZzZwydtIb10w5ieK+xmkjQ=; b=l8/7/ciXjjh2+GeXXqwhv2K0pFRLehg2MKLw7BJ3Xj3vtT6k89sLHG1yo6shXyIt7D nAXLU6Bd+vsqav3Q1jNOw8xN9pIbiXwJFT3XbmTrCwLRszLNEttBOuriIRaxggWzIAJG 0MKDZ8jcMYUbWHR3Yacbr7uc5YduSGcAv2hdsPL87oO2WAoo/ZdebuUlUaEB8vbDeV6s t8ou2UipGG18ErFJPDQJSgUCaHZ8cjhVFhLqqz+NF9qIp7w5Po76kemAdzU2MM3c14W0 rEI7Fk1v+Z6StLfPPQBVGDe6AOEkWrmmaiXQNULfGlT+qEMj0Ai/bH4E65/avWJcPLVA +HJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6PFcI+JfAhwfsNi3wGhsqZzZwydtIb10w5ieK+xmkjQ=; b=hPQrmTLnc1O1RUzFeI7BUQFAgZ74dqx+QnzSHAK8nEIpuwK9vcjkthmGuBbAU5MPfh smfd7HQ1XRptDApso8bukLqLWkQHXFYghr6CTcbiQBF+G4mmvC15ULfOU6q51X92D8XK VHYoTiHRNtThs7dyb/cDgTQTXG8x9a6mcWOIRADT3/Eq6+VExl31Nhsi7lcDsaZVUsRQ fxdXV6AkPtuj5URaO7AAyHMckK2RosnBsJtldpvJsIEo+D8toZkIX5FGVFB6G74a47CW BzQQyBrwCb48AsHBM/8VllfgAoW8J1nmcee5MuieE31P4dgndXxySOFhtdBiGt/txcI4 rUbw== X-Gm-Message-State: APjAAAU6gfeB3HrnINOP1EH07xd5XVFWgsvSn8gTwiO4eBMXOEV+T96H bc26rcJY1MHakfTWLdne2uXa5HPrYaxuUA== X-Received: by 2002:aa7:8190:: with SMTP id g16mr33119268pfi.92.1554089257571; Sun, 31 Mar 2019 20:27:37 -0700 (PDT) Received: from mba13.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id 16sm12758092pfz.106.2019.03.31.20.27.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:36 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 1 Apr 2019 10:27:07 +0700 Message-Id: <20190401032709.14787-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401032709.14787-1-ard.biesheuvel@linaro.org> References: <20190401032709.14787-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 5/7] MdeModulePkg/EbcDxe: implement the PE/COFF 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: , Cc: Ruiyu Ni , Vincent Zimmer , Eric Dong , Jaben Carsey , Brian Richardson , Liming Gao , Michael D Kinney , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Implement the new EDK2 PE/COFF image emulator protocol so that we can remove the EBC specific handling in the DXE core and other places in the core code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf | 3 + MdeModulePkg/Universal/EbcDxe/EbcDxe.inf | 3 + MdeModulePkg/Universal/EbcDxe/EbcInt.c | 123 ++++++++++++++++++++ MdeModulePkg/Universal/EbcDxe/EbcInt.h | 3 + 4 files changed, 132 insertions(+) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf b/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf index 8f293f5c7c29..c7a9d519b080 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf @@ -89,6 +89,8 @@ BaseMemoryLib DebugLib BaseLib + CacheMaintenanceLib + PeCoffLib [Protocols] gEfiDebugSupportProtocolGuid ## PRODUCES @@ -98,6 +100,7 @@ gEfiEbcSimpleDebuggerProtocolGuid ## SOMETIMES_CONSUMES gEfiPciRootBridgeIoProtocolGuid ## SOMETIMES_CONSUMES gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiPeCoffImageEmulatorProtocolGuid ## PRODUCES [Guids] gEfiFileInfoGuid ## SOMETIMES_CONSUMES ## GUID diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf b/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf index d6ee6194a0c8..ecccf2c57ffe 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf +++ b/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf @@ -57,7 +57,9 @@ MdeModulePkg/MdeModulePkg.dec [LibraryClasses] + CacheMaintenanceLib MemoryAllocationLib + PeCoffLib UefiBootServicesTableLib BaseMemoryLib UefiDriverEntryPoint @@ -68,6 +70,7 @@ [Protocols] gEfiDebugSupportProtocolGuid ## PRODUCES gEfiEbcProtocolGuid ## PRODUCES + gEdkiiPeCoffImageEmulatorProtocolGuid ## PRODUCES gEfiEbcVmTestProtocolGuid ## SOMETIMES_PRODUCES gEfiEbcSimpleDebuggerProtocolGuid ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.c b/MdeModulePkg/Universal/EbcDxe/EbcInt.c index 727ba8bcae44..051eb0aaa07b 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.c @@ -349,6 +349,119 @@ UINTN mStackNum = 0; EFI_EVENT mEbcPeriodicEvent; VM_CONTEXT *mVmPtr = NULL; +/** + Check whether the emulator supports executing a certain PE/COFF image + + @param[in] This This pointer for EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL + structure + @param[in] ImageType Whether the image is an application, a boot time + 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. +**/ +BOOLEAN +EFIAPI +EbcIsImageSupported ( + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, + IN UINT16 ImageType, + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL + ) +{ + if (ImageType != EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION && + ImageType != EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) { + return FALSE; + } + return TRUE; +} + +/** + 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 structure + @param[in] ImageBase The base address in memory of the PE/COFF 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. Passed by + reference so that the emulator may modify it. + + @retval EFI_SUCCESS The image was registered with the emulator 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(). +**/ +EFI_STATUS +EFIAPI +EbcRegisterImage ( + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS ImageBase, + IN UINT64 ImageSize, + IN OUT EFI_IMAGE_ENTRY_POINT *EntryPoint + ) +{ + DEBUG_CODE_BEGIN (); + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + EFI_STATUS Status; + + ZeroMem (&ImageContext, sizeof (ImageContext)); + + ImageContext.Handle = (VOID *)(UINTN)ImageBase; + ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory; + + Status = PeCoffLoaderGetImageInfo (&ImageContext); + if (EFI_ERROR (Status)) { + return Status; + } + + ASSERT (ImageContext.Machine == EFI_IMAGE_MACHINE_EBC); + ASSERT (ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION || + ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER); + DEBUG_CODE_END (); + + EbcRegisterICacheFlush (NULL, + (EBC_ICACHE_FLUSH)InvalidateInstructionCacheRange); + + return EbcCreateThunk (NULL, (VOID *)(UINTN)ImageBase, *EntryPoint, + (VOID **)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_PROTOCOL + structure + @param[in] ImageBase The base address in memory of the PE/COFF image + + @retval EFI_SUCCESS The image was unregistered with the emulator. + @retval other Image could not be unloaded. +**/ +EFI_STATUS +EFIAPI +EbcUnregisterImage ( + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS ImageBase + ) +{ + return EbcUnloadImage (NULL, (VOID *)(UINTN)ImageBase); +} + +EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL mPeCoffEmuProtocol = { + EbcIsImageSupported, + EbcRegisterImage, + EbcUnregisterImage, + EDKII_PECOFF_IMAGE_EMULATOR_VERSION, + EFI_IMAGE_MACHINE_EBC +}; /** Initializes the VM EFI interface. Allocates memory for the VM interface @@ -449,6 +562,16 @@ InitializeEbcDriver ( } } + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gEdkiiPeCoffImageEmulatorProtocolGuid, + EFI_NATIVE_INTERFACE, + &mPeCoffEmuProtocol + ); + if (EFI_ERROR(Status)) { + goto ErrorExit; + } + Status = InitEBCStack(); if (EFI_ERROR(Status)) { goto ErrorExit; diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.h b/MdeModulePkg/Universal/EbcDxe/EbcInt.h index 8aa7a4abbd63..9b25e91f951c 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.h @@ -23,9 +23,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include +#include #include +#include #include #include #include From patchwork Mon Apr 1 03:27:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 161516 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4874724jan; Sun, 31 Mar 2019 20:27:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyebdXZrYuBiOGl1aswsLzPAU0C9j2xTFpQg0ghTQjmWRTb46EiA29pnGMDiGp3vm/CKDzh X-Received: by 2002:a17:902:29ca:: with SMTP id h68mr37468349plb.297.1554089264290; Sun, 31 Mar 2019 20:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554089264; cv=none; d=google.com; s=arc-20160816; b=a5I1yaGfabbcc5FFdJLfIriLgATS7K1Z6BwXfbHKKvfkDimha6+lvjoMK5ZulZ2hxv qxXvXgJ8nkGnlGkWnJs+/2Ru22AijrV0GL7JzkYOBc1nHRuP14kmtbhtrBePabls7ere L6nGn8AQSz59aWFZR47SdRswhMW1fFZYjjZ3k5ATDBxW0JNYIAs3oXI2T8EzA95iOICJ g4zaxVBShkVR0tmuyF5vIpVL71ZyIr3zt+exmS6HC+0U2/+knaY7YZ3MFOSb+dMYPv44 QCtk5F1VIJDMMJpiVZyKUSGT6i3Gg0DER2Cbi4CMzS2tP/sATkZJ1mXW+UrJVR+s/61w 0E1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=kiN/YD3YQreQ/OmHpnjtC0bakpYGVun5XjxuAwjlQio=; b=LGhJyUprF5TjvuowTdwzjDCh0BRNKgo3aaHbqPK/tEDwaqcabGYYedZFIt6Ax86i6q ySgYjn5AC6q+SKjuBYE3af0+ROj/ZydMhB0T8ois9voPFUPnMSoMQINNKzS+gW741krp hKonfk1YFVmtco44PIcmqcKlMODzidccro/3wWQ0bUcqky2HZCqmm0cR3UUCpX5+1c0K 75YbBuacorsmDf5Y66BlBZgJCQNwSPD0QarWbnvzzWtwqu5OLeYBNQdURYYPQNSfk4nS V9kOD4IKjP4zi2Cng8q85K/Db/3b5hxJl3rCQwpGw8J7ZWN/dGmcITWSsVgC5FVCw/lP JwiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=j9REY+Ef; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id w126si8247890pfb.196.2019.03.31.20.27.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=j9REY+Ef; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E1D17211EDB42; Sun, 31 Mar 2019 20:27:43 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (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 46982211E011B for ; Sun, 31 Mar 2019 20:27:42 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id b3so769490plr.7 for ; Sun, 31 Mar 2019 20:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hKgow8tW34pETiYCoOIXaLyUO/aUyZupfBLVnz4OeR0=; b=j9REY+EfsXh7Q1+XV/HCwKWyHy2ezj0LvFGpScdCRxAgSEbl+KBGyejtILP9FZZ5/x z0YrC22Q4Ux31vpbiZoIOCHBXr/JHijk3yA2YDosVyb8vCLVa9UAZwh5oFD8MY8bsJiI bEWiTcpvMOfjfV9UnUQlj62/s50rVzOFRpNRls13lMwb7gbh5VdWTnkRZ27l9Yy9RP5l Q35MI29Ouom7moG3UXBvW/ZBVCuC+RUfverU5acpa7Y/WHeWgLK7Ae3o6o+1XgJD9ThQ +ycsMqu/TAZoiT0O2TtfILR13flHTpnJI1BmEUnPa8VQNriwUGIDiLjN/CtWx80aa5/j s5OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hKgow8tW34pETiYCoOIXaLyUO/aUyZupfBLVnz4OeR0=; b=Ly6q0J9d8hUgWooz2H05ZPMAJBkBl6sG1Nbtm0NKLeHMkflnS5Jk5YbqbBM3s5bK0Y l6vPIMuI6UQEn/njZyQMJULeKc1oM3LE0oEqlaQ8oN430VLBSer/RalPO3+LO7lIMbAe nFoI/spMHPjr6Gi5HFanuVC1DRjHgWdFEiiStHfvrW/pmsNBNVdznt/ywDSj6bYMvpMh XbDTAjFlVJ2sHdChD/3BDpDW2RDowWWD2vYP5EqLpGZ8PaewzanTqkiSgGNWmhSe7Mib 0mM/pHfoCx/3XmzmzTc0WtVsccramOfZ81GH57fp1fnssQJVYjyiVvl0TZopyZafszzb mptg== X-Gm-Message-State: APjAAAX+60Ld6Qww6230cDmBlz5gcrUgwRA/jLrBNCDpbBMdMWUbVANy 8sv/y8njvKzusphustE5prs4iH4QdYg4bQ== X-Received: by 2002:a17:902:9a0b:: with SMTP id v11mr61901911plp.194.1554089261626; Sun, 31 Mar 2019 20:27:41 -0700 (PDT) Received: from mba13.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id 16sm12758092pfz.106.2019.03.31.20.27.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:40 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 1 Apr 2019 10:27:08 +0700 Message-Id: <20190401032709.14787-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401032709.14787-1-ard.biesheuvel@linaro.org> References: <20190401032709.14787-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 6/7] MdePkg/UefiBaseType.h: treat EBC as a non-native machine type 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: , Cc: Ruiyu Ni , Vincent Zimmer , Eric Dong , Jaben Carsey , Brian Richardson , Liming Gao , Michael D Kinney , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Instead of classifying EBC as a supported machine type and have special handling in DXE core for loading EBC images, make it a foreign type and rely on the EDK2 PE/COFF image emulator protocol to claim the image when the DXE core finds that it cannot be supported natively. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdePkg/Include/Uefi/UefiBaseType.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdePkg/Include/Uefi/UefiBaseType.h b/MdePkg/Include/Uefi/UefiBaseType.h index 8c9d571eb1ce..33b872af91a9 100644 --- a/MdePkg/Include/Uefi/UefiBaseType.h +++ b/MdePkg/Include/Uefi/UefiBaseType.h @@ -250,14 +250,14 @@ typedef union { #if defined (MDE_CPU_IA32) #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ - (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC)) + ((Machine) == EFI_IMAGE_MACHINE_IA32) #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64) #elif defined (MDE_CPU_X64) #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ - (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC)) + ((Machine) == EFI_IMAGE_MACHINE_X64) #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32) @@ -270,7 +270,7 @@ typedef union { #elif defined (MDE_CPU_AARCH64) #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ - (((Machine) == EFI_IMAGE_MACHINE_AARCH64) || ((Machine) == EFI_IMAGE_MACHINE_EBC)) + ((Machine) == EFI_IMAGE_MACHINE_AARCH64) #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) From patchwork Mon Apr 1 03:27:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 161517 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4874767jan; Sun, 31 Mar 2019 20:27:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyK7xJ83mStU8J3DkDKFZZCT9EkyjS9UWwDMG5hyzke1tcKjA4HGNlEv60TI7L2wzRm1+B9 X-Received: by 2002:a62:448d:: with SMTP id m13mr61806958pfi.182.1554089268499; Sun, 31 Mar 2019 20:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554089268; cv=none; d=google.com; s=arc-20160816; b=PW1oV1reuXlWc0jCUyy0uF3cmwJ3BiLcZQFB4uKOQtMk21XtkepZiTzCj++4KAOH7v rIfuztQVyl+Trrycl/Sq5N0fXpWcEiqxecYP2MZsSWPiKyXk4mLH78p7BHQQ9SdxfInh hQIywmsVgYs4/qdJemo2Tw/0XD1E2WxTOk9q/nR+MFIbR+ExAUb2qil98ERpDActMfRA Xf91yQBAI3gf24TLTudtFO/uigjLGWvvZPblx5AOnPbkBm6eN9IGkIXXrDn2a4Ow23zY TTslhZJMBcnJEZ7CvZyfFFb2Tr8IUwtvIYPwNT4Si4xq/n/uKtACx+lHgX1q0o2+Cf+k XSTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=PPBh2Meahy3B4Uqb5YgocRcNYWXp/J6+uyVei2GFK7o=; b=Q3XKb7j2eqwRmd1NFesoBHNL2VKoiRx6xnGC1JgkhJg9OUtwlkOJgBPEZaBEwTRzez fkAi8BnYY+qsON3XLKkTU1Q2bB2pwbBE7jcCu5jYHz7FEYU9QWIELiH72xcWRYWwNH3W nB+ZKkmfAu0vTWwINi8UhvPxy4AWs2lasGki97wvsTT6bzoEBuwGIqQ5qT3DXKehkfA5 dMca0ImmMHs+cxtL8pd34IV+eUZmYN9o/djrYasEFc/PcMfa9nuwsfcZe3GnX8W/Xf+G ZJWDrXaD1IhybQYRsXky48JTYAHhd3zs/6y5yz/+jkkUR4wTmjT+JvF8vb3vdD0qHpqR JZTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I4hog5Dy; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id s205si7553760pgs.467.2019.03.31.20.27.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I4hog5Dy; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1C5CE211EA9EE; Sun, 31 Mar 2019 20:27:48 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (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 069B5211E011B for ; Sun, 31 Mar 2019 20:27:46 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id i19so3823983pfd.0 for ; Sun, 31 Mar 2019 20:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OwXUHeDB4L60hLaVSJs2r8SdEEcXZ6K4jyQbqQxLzxc=; b=I4hog5DyKlg8hpTlWI6jABStxhTcKoUGVi5ISAfabwdFx03bANHkwlcJ9XZ6BmqXI2 q0hSk1+Iv1wD/u29DD/VQTlYOJjuHU1L7OC5Qh6x5Li8HmwgfhwB271hBu0WKbN7ji71 J0NaM8ICLcjoL4NR+ohV9+k26e9SBQLHBIACS9EjbiTqUHZ8rjxrRgoD8SgUjon3HsoI CDapHC5RiMtPlzu7eTZBrlb/mPzJrhTwzWbuwwSiGV+hBeOH/cp22XZl8WbBh6ChDBL4 rWb16T+DURdqJAfAMvtR/eWIRDGfCQiCClGE6Q9MEXJZDQkCXXLw2v2EMmMIulZ9LNbG vBuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OwXUHeDB4L60hLaVSJs2r8SdEEcXZ6K4jyQbqQxLzxc=; b=ER2bBhKIszQv2r/wpnd30H90PJLm0hm64wnigQtl/XeYVBqvvvMqamAfDf5y/y5rAw AQK2/TYPEvun+LRWlQGacO5zHGv+1QQOXu8MSed12a19vsCM9LPC1QAAbBOcOkWjbd71 Qy8TGUMDDGMWQXZ/zCSVMYGo+zXqYo5JetVB9pYKC5N2cSCE28HXM1AMrJNsjdkhPBdI P5irWetYXqhrOwEUeO1PrflHBvOG/4M/8n573ChxjzhgVaEXK6AIcOWQt5JkKSVM7hAo cUDw7JYHehOOkrjZ6mT3nSjTYGoo1ktAuRQKlEy419JoAW+JAus+CpEtl0R9wlxpxANu u+Bw== X-Gm-Message-State: APjAAAVf3y0efFZM2NbQ65MTZtDQYceqmRsQtSDQebgH6c+iz//ZgCGN wr4mFWzd2dAbO1HRH3XVcph4yjbhjyR0JA== X-Received: by 2002:a63:4542:: with SMTP id u2mr57812156pgk.291.1554089265456; Sun, 31 Mar 2019 20:27:45 -0700 (PDT) Received: from mba13.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id 16sm12758092pfz.106.2019.03.31.20.27.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 20:27:44 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 1 Apr 2019 10:27:09 +0700 Message-Id: <20190401032709.14787-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401032709.14787-1-ard.biesheuvel@linaro.org> References: <20190401032709.14787-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 7/7] MdeModulePkg/DxeCore: remove explicit EBC handling 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: , Cc: Ruiyu Ni , Vincent Zimmer , Eric Dong , Jaben Carsey , Brian Richardson , Liming Gao , Michael D Kinney , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Now that the EBC machine type is no longer classified as a natively supported machine type on the architectures that can support it via the EBC interpreter, the EBC specific handling in DXE core is no longer used and can be removed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/DxeMain.h | 3 -- MdeModulePkg/Core/Dxe/DxeMain.inf | 1 - MdeModulePkg/Core/Dxe/Image/Image.c | 53 ++------------------ 3 files changed, 3 insertions(+), 54 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 48ec30a48aa2..6e83f15a4541 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -42,7 +42,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include #include @@ -227,8 +226,6 @@ typedef struct { BASE_LIBRARY_JUMP_BUFFER *JumpContext; /// Machine type from PE image UINT16 Machine; - /// EBC Protocol pointer - EFI_EBC_PROTOCOL *Ebc; /// PE/COFF Image Emulator Protocol pointer EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *PeCoffEmu; /// Runtime image list diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index ce6fc19be5e4..68413517f2a7 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -160,7 +160,6 @@ gEfiLoadedImageProtocolGuid ## PRODUCES gEfiLoadedImageDevicePathProtocolGuid ## PRODUCES gEfiHiiPackageListProtocolGuid ## SOMETIMES_PRODUCES - gEfiEbcProtocolGuid ## SOMETIMES_CONSUMES gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index cda447d23ec5..0b8b2ba15ccf 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -75,7 +75,6 @@ LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage = { NULL, // JumpBuffer NULL, // JumpContext 0, // Machine - NULL, // Ebc NULL, // PeCoffEmu NULL, // RuntimeData NULL // LoadedImageDevicePath @@ -92,9 +91,6 @@ typedef struct { CHAR16 *MachineTypeName; } MACHINE_TYPE_INFO; -// -// EBC machine is not listed in this table, because EBC is in the default supported scopes of other machine type. -// GLOBAL_REMOVE_IF_UNREFERENCED MACHINE_TYPE_INFO mMachineTypeInfo[] = { {EFI_IMAGE_MACHINE_IA32, L"IA32"}, {EFI_IMAGE_MACHINE_IA64, L"IA64"}, @@ -747,51 +743,15 @@ CoreLoadPeImage ( InvalidateInstructionCacheRange ((VOID *)(UINTN)Image->ImageContext.ImageAddress, (UINTN)Image->ImageContext.ImageSize); // - // Copy the machine type from the context to the image private data. This - // is needed during image unload to know if we should call an EBC protocol - // to unload the image. + // Copy the machine type from the context to the image private data. // Image->Machine = Image->ImageContext.Machine; // - // Get the image entry point. If it's an EBC image, then call into the - // interpreter to create a thunk for the entry point and use the returned - // value for the entry point. + // Get the image entry point. // Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT)(UINTN)Image->ImageContext.EntryPoint; - if (Image->ImageContext.Machine == EFI_IMAGE_MACHINE_EBC) { - // - // Locate the EBC interpreter protocol - // - Status = CoreLocateProtocol (&gEfiEbcProtocolGuid, NULL, (VOID **)&Image->Ebc); - if (EFI_ERROR(Status) || Image->Ebc == NULL) { - DEBUG ((DEBUG_LOAD | DEBUG_ERROR, "CoreLoadPeImage: There is no EBC interpreter for an EBC image.\n")); - goto Done; - } - - // - // Register a callback for flushing the instruction cache so that created - // thunks can be flushed. - // - Status = Image->Ebc->RegisterICacheFlush (Image->Ebc, (EBC_ICACHE_FLUSH)InvalidateInstructionCacheRange); - if (EFI_ERROR(Status)) { - goto Done; - } - - // - // Create a thunk for the image's entry point. This will be the new - // entry point for the image. - // - Status = Image->Ebc->CreateThunk ( - Image->Ebc, - Image->Handle, - (VOID *)(UINTN) Image->ImageContext.EntryPoint, - (VOID **) &Image->EntryPoint - ); - if (EFI_ERROR(Status)) { - goto Done; - } - } else if (Image->PeCoffEmu != NULL) { + if (Image->PeCoffEmu != NULL) { Status = Image->PeCoffEmu->RegisterImage (Image->PeCoffEmu, Image->ImageBasePage, EFI_PAGES_TO_SIZE (Image->NumberOfPages), @@ -981,13 +941,6 @@ CoreUnloadAndCloseImage ( UnprotectUefiImage (&Image->Info, Image->LoadedImageDevicePath); - if (Image->Ebc != NULL) { - // - // If EBC protocol exists we must perform cleanups for this image. - // - Image->Ebc->UnloadImage (Image->Ebc, Image->Handle); - } - if (Image->PeCoffEmu != NULL) { // // If the PE/COFF Emulator protocol exists we must unregister the image.