From patchwork Thu Sep 20 23:01:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 147167 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp99873ljw; Thu, 20 Sep 2018 16:01:53 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdabb3Xkb1Qp0GIsFmIMmU8ZkOeuSq/sf4KkR1vf5VQWerjKLwSRRCeizOs9NZLu2z36tJaO X-Received: by 2002:a17:902:344:: with SMTP id 62-v6mr41698974pld.164.1537484512949; Thu, 20 Sep 2018 16:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537484512; cv=none; d=google.com; s=arc-20160816; b=Zy+8FtkBc8HxsGKOGfISCed4HqCAIiEaf9jrUWYJK4ZEeR0L2yA4IsAzviNr2Jdjtn kLMyWw7y0x9WRnT17h+lgZIClqFQRbhcTHX8dmbKj5c0thYVxXby2RJXIi5DoBl85UqS d5OhfbDjplP2aVIn+4Kv36/NK+PLhxlWgpjF+M6RlKo+UAWKiAWaddHwRydqWDt3IOmx wXhmL/qBelmqdWfSA2Qaqio+5T6+K9OFXDblORGIIJcOEv4iVdhi9HqAH4M6xRctOpm4 lchk7bPAxYAxCmPdJdHIR4QrB4oPPLT98XjcWKTJUhnDRmCyA1HOAgEoZZc0cSIgHHyU LL/w== 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=Ww1jg+69uBgQHPb+7U64Cg6P+T5oFnxhpAwYbgsHGMA=; b=CfZS7pTvLfQa8yZ+bdnnX5BuG7r0taDbPlxqVghZBJEUIkYE5xzjRKX7fCEbez44jl YtV27JHxq+o+iVccjUPS63U3iUMS5x079SfSITJqNpcZgM47mEjOdsLr4kpp8tjv5p1+ dfJSsNEd/ZTsKq/mnCZD4EjaPde2ifrU6rmW5KcORF/jFrEKYzB4fqrCAhNp42K0hDWQ elTNis6ngpXe1dIGsW8+LcfP+sQjy6Z5f2/e+eIav8f80AdUGlWpdrZIxOnj7FFZNwI6 MgQatgvsYRm29tDKJcruseSJpoVteteJ84CxSLAPN7OjnMZqO+Ke9kvbz56+M/oCxlTl P/4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ck860cck; 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 m32-v6si24502669pld.404.2018.09.20.16.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 16:01:52 -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=Ck860cck; 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 14A072114A6A2; Thu, 20 Sep 2018 16:01:52 -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::644; helo=mail-pl1-x644.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 F3CD121148ED9 for ; Thu, 20 Sep 2018 16:01:50 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id q5-v6so1552176pli.4 for ; Thu, 20 Sep 2018 16:01:50 -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=OTUvPjZIRcy2D1s1OfLGPNIv/29Bkca46G3gUAI5iiY=; b=Ck860cckeYiMV7p4LabGBdmavSXhlqM8xqilUyZH3OlUiPGIUGFQ5Rzzf3O+4Hg93o wdMsAfY0bb+Fv8vyMKhajtrAl2cuWM/u+dglpjtMVxbvPvBid/RVP1kcmRNUMaTYP2Mk j55c33mO3kBmafQRT9ZI0IfFnN/ZORW2qIAnE= 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=OTUvPjZIRcy2D1s1OfLGPNIv/29Bkca46G3gUAI5iiY=; b=UveT2mBHL7Bmj7UQEaSbxE8it5RU4FFoVrNsxS/jP3WEnk3VS+h5F1+01I9ExAoXWd J0sYXvDb6UDnLNizhQhIurKSgT/i3I2AVcAhfPm8PyuWiPVFqdEfhbd9lIMluZgYQsn6 uarUI0LxX0hFyBJtIHEwI0psbAEcfUGAljAJ0j0RCJXV9ZsJnzeMfspU3LY2c5UapaF3 JFWmAY0AO09NQV8zkwMM9KvserOQ8GehS6n4TWx3WNi8azc5TYJ24bEIORBgGiPG7dsR jFEmjqCN30rKilUUsU1LpdvKGfHtPxtROjppY6k4zkflt6UuttfW2Q3Ok0Ysx1XmtkDC RghA== X-Gm-Message-State: APzg51C9foyS5mGBRbogJIXv6ljW+zSh4Kgi7kOsuXsD0avqhfI9Dk6c +U+5QhO4xqf462efBYrfC3Gt12kc9oQ= X-Received: by 2002:a17:902:7e09:: with SMTP id b9-v6mr41051339plm.221.1537484510249; Thu, 20 Sep 2018 16:01:50 -0700 (PDT) Received: from localhost.localdomain ([209.121.128.187]) by smtp.gmail.com with ESMTPSA id p4-v6sm37507823pfd.65.2018.09.20.16.01.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 16:01:49 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 20 Sep 2018 16:01:38 -0700 Message-Id: <20180920230145.7565-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Subject: [edk2] [PATCH v3 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: - incorporate feedback from Andrew Fish (delivered in person): * pass a device path into the IsImageSupported() protocol method so that an implementation can blacklist or whitelist certain devices, or implement other policies that depend on the device where the driver originated * allow the emulator to supersede the native loading of the image - this permits things like X86 on X86 emulators for security sandboxing or debug 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 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 | 53 +++++- MdeModulePkg/Core/Dxe/DxeMain.h | 6 +- MdeModulePkg/Core/Dxe/DxeMain.inf | 2 +- MdeModulePkg/Core/Dxe/Image/Image.c | 178 ++++++++++++------ MdeModulePkg/Core/Dxe/Image/Image.h | 1 + .../Include/Protocol/PeCoffImageEmulator.h | 102 ++++++++++ .../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 | 127 +++++++++++++ MdeModulePkg/Universal/EbcDxe/EbcInt.h | 3 + MdePkg/Include/Uefi/UefiBaseType.h | 8 +- 16 files changed, 478 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