From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: ANB0VdYYiA7BImmS+65IDFE224ccLNihoH0tVbx+G9jP6zagQNZQAb18uuAWw/gxoTBnH5Z5gufy2g== 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 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: 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: [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: , X-List-Received-Date: Sat, 15 Sep 2018 13:29:07 -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: - 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