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::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-Google-Smtp-Source: ANB0VdZoWxk6cZ/pqYSmKNZZwju0QrLlMyXauQid6BfQaVvJpol/qs8j1/V+BRGLCZ6M/exRhXYxQA== 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 Cc: Ard Biesheuvel , Vincent Zimmer , Brian Richardson , Michael D Kinney , Andrew Fish , Leif Lindholm , Star Zeng , Eric Dong , Ruiyu Ni , Liming Gao , Jaben Carsey , Steven Shi 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: [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: , X-List-Received-Date: Thu, 20 Sep 2018 23:01:51 -0000 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