From patchwork Sat Sep 15 13:28:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146768 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1804980ljw; Sat, 15 Sep 2018 06:29:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdasyENnC94Ds7xbQbXCm+Cg216c15hCtfhU7VcSc3h2lFIymDZuqgwPrH8Mj+IxSH46sxyD X-Received: by 2002:a17:902:9a82:: with SMTP id w2-v6mr16993007plp.109.1537018148199; Sat, 15 Sep 2018 06:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537018148; cv=none; d=google.com; s=arc-20160816; b=Up+EMytikYRX+4f6fIeAUdpiGj0iWxfUCeF1Vq6Hnlp2dzIkj99SZuGlZgSDo++LRe Qi9SVcyOMCBSI6SAv8qFQ6OWjUsbemSdp1izlXeMr9P+2d9Bhl02jYk9rlY4s9gXGdE9 ztpyBEehLcob+tVhK5sZYiLIAxnklNEKVJ4cdb1kO7dlT3rkq+woFgVlsDSlGmn9qzCD QMz+gaeiGqeS/2PUfO9n1X2Vq+pGv/IsCVnypa1jTzBWXcs1sMpQRV9ptxdA1nlVpkUS rUjBxOfzEBkNaHU0UI3TW5f29EkbHOU8dHpyeInzGy5BtPShYLAdcgbzz9L6WKoLc77C a/NQ== 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:message-id:date:to:from:dkim-signature :delivered-to; bh=FPXPCeNqlRWsm86Vmb/X8M9pYB5r3ujfGee824Jk7wc=; b=yRXWaTQdqfAjlgoMSDcUDD9DfaDJp9YWrafDASFtpdo/fdyRy0OyVBrOVrUbwvJNyc QIHFd5qHxs1P/7uDL1xFTgR9f1PQXCotZyWssD/QZn8cLpqOk2P77ZoBjrLn7EPX/pKK dbLxZY9Bk8eLhcxsHmbkDEXFXE3IHrEez9LnSexFZIuCtsuVGEaLW1Dj2wsJispdkdV8 gGRI2e8dPZf6t0ABsWP2HqBrK5aeaz/Uiti9fgbHrQbRFDFeGJzPGnVlK5bv04nIYL/u BYFAmg1/bJgZQUdByjGsOxInTBzwBkPtr0Tf5RXtWboTPueNp/Frg5rBIaY5e75awWql XbRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ODpIuswS; 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 34-v6si10514345pgo.399.2018.09.15.06.29.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Sep 2018 06:29:08 -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=ODpIuswS; 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 CB0CF211350E1; Sat, 15 Sep 2018 06:29:07 -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=2a00:1450:4864:20::544; helo=mail-ed1-x544.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450: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 C5108211350D8 for ; Sat, 15 Sep 2018 06:29:06 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id y20-v6so9522630edq.2 for ; Sat, 15 Sep 2018 06:29:06 -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; bh=yVgvOm53aT++GDxzX8vnduyn6DDe5egEtXVKQrlyZ30=; b=ODpIuswSq2N47wDlZb1VYFCi/X+kq8jmnZZA6iIh4/w8N6MW3rAdMZhQAcJEiAwLfS GC4hiRbLn/nBrq70AtQWOIbybV0pZZn0nmf4cbBLzcNrzR7bFLVAJ6/nd3YsYko0kMVp cjrQe3JsAKY2KgNCe37px6kScTLDXdsFnY9w0= 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; bh=yVgvOm53aT++GDxzX8vnduyn6DDe5egEtXVKQrlyZ30=; b=rwPl/GdQd7BkNqiFOlYJOSmudixfN7YqOB+tz7zI2VQ0qfdkmBwi7RSoUNrUqTAtwk V7WvGFhHRHtA4aeMvvGdop9b7ltjXUHGClBx0qn6cs47WBWEG9jfGRhtKEluRO9OVj5d w8z9TDiB3V9HXiY3i80+DNwkNX144/i452re/sJu5RvcXG7/4F0yQCOBryQBypXvp37K dp9LvwK2M1LmjW4nbZzkB+PNcJvXVPrT0i6h4vbnHRZxi25HR2C4BcbyQYRirta7ZXyH SScdDhoAevMQ8C/U1ya0xxNhhT2dCLBZQv3Sck7KrEmAOXLpzpsFtzmb6S/f/aL7I5LE qaFA== X-Gm-Message-State: APzg51Ao0FK3IzeoV5rYpJM0E5AgZ8uqLaVzvPI6tI4+HZAJ0mUiVSx5 U1XynSDXpPiMU4cLZNSq2fG+4rkTi+b+pA== X-Received: by 2002:a50:d512:: with SMTP id u18-v6mr29530299edi.291.1537018144938; Sat, 15 Sep 2018 06:29:04 -0700 (PDT) Received: from mba13.kuq.prv ([194.138.39.100]) by smtp.gmail.com with ESMTPSA id j23-v6sm4449262edh.29.2018.09.15.06.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Sep 2018 06:29:04 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Sat, 15 Sep 2018 15:28:52 +0200 Message-Id: <20180915132859.25727-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Subject: [edk2] [PATCH v2 0/7] MdeModulePkg: add support for dispatching foreign arch PE/COFF 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 , Andrew Fish , 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" Add the basic plumbing to DXE core, the PCI bus driver and the boot manager 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. One implementation of such an emulator can be found here: https://github.com/ardbiesheuvel/X86EmulatorPkg 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 so that internal knowledge of how EBC is implemented (I-cache flushing, thunks) is removed from the DXE core. Changes since v2: - 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 Cc: Vincent Zimmer Cc: Brian Richardson 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 Ard Biesheuvel (7): MdeModulePkg: introduce PE/COFF image emulator protocol MdeModulePkg/DxeCore: invoke the emulator protocol for foreign images MdeModulePkg/PciBusDxe: invoke PE/COFF emulator for foreign option ROMs 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 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 1 + MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + .../Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 51 ++++++- MdeModulePkg/Core/Dxe/DxeMain.h | 6 +- MdeModulePkg/Core/Dxe/DxeMain.inf | 2 +- MdeModulePkg/Core/Dxe/Image/Image.c | 141 +++++++++++------- .../Include/Protocol/PeCoffImageEmulator.h | 99 ++++++++++++ .../Library/UefiBootManagerLib/BmLoadOption.c | 51 ++++++- .../Library/UefiBootManagerLib/InternalBm.h | 1 + .../UefiBootManagerLib/UefiBootManagerLib.inf | 1 + MdeModulePkg/MdeModulePkg.dec | 4 + MdeModulePkg/Universal/EbcDxe/EbcDxe.inf | 3 + MdeModulePkg/Universal/EbcDxe/EbcInt.c | 124 +++++++++++++++ MdeModulePkg/Universal/EbcDxe/EbcInt.h | 3 + MdePkg/Include/Uefi/UefiBaseType.h | 8 +- 15 files changed, 432 insertions(+), 64 deletions(-) create mode 100644 MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel