From patchwork Wed Sep 12 13:21:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146565 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4825635ljw; Wed, 12 Sep 2018 06:22:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYK4y2aiQvDoinBLs8hNBxNhLw2FIn91FDr9VE5gGBAGLIdVWpGLzMq7X33Y31EVQCixujB X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr2224916plb.176.1536758571506; Wed, 12 Sep 2018 06:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536758571; cv=none; d=google.com; s=arc-20160816; b=HVdGt4Z9sBl65lJ6CGrsmmbpa6LNysnWJfKGfYbGiPfeWj0cGfIInSE29U1E7MomzZ L25f3woUvPmFk0ry71AP4fcJWa1sVCaHcGyEOK6Y0IigRmuGcJNb2ELGqvQPZPzrSQTC TwDseuxobV9hPb2UXe0cJVM4GNlZPPFBI4eyAp8YFChylQ7o8ybn5QCAm/HPuhjQ2y5H 6oIiMkLPsQD7jRGGOhe0uwFrTuGPyCYkmEoxk5KiKgTZtf4a7k2BrWAnZrfLNONA1R52 HMswf9YdwVOmCOXPihImNYXUXMrvQs0NPZWe7Z8TBslYQPueXe4+0/LPicN/6Hk0/6vs XIZw== 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=27Hs6IDH+gwfNqqOr8jB61woM8/DcBj4SHZ6ditBDa4=; b=p1PuCS3hMce1BfjGUi0P+1/IMVpgefDNxrXjU91h4D+GpfxdkpqAXvcLi2wx99pByT 4SRdfDlXtD6hJnK0oukbpI8BI7Ved7Aays30uZiUqqwPugdCtM1LQBIaJC3DTMQZUGf8 EkhtJg3+jtXH+aTehB+qPEhZVKDV1bCClT9+v5RZtLARB/lgAoGd5KfsrwJV1xFzxKAe v6vzg5iPW12Za56U57uqyC1eQEhlpin9yLgx3/7nRpmEGNtspm8LWxoaoemnnZNFd0g7 c7ryFAhbzhTEgPsxTWNqK559G3JtlsxIcbv5GxPfUub1Msxv1so12Pxg0WDqK3f280pK QvTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="WnP/BJkj"; 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 p67-v6si975668pfg.295.2018.09.12.06.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 06:22:51 -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="WnP/BJkj"; 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 6FB4F2112B1C6; Wed, 12 Sep 2018 06:22:47 -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::441; helo=mail-wr1-x441.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450: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 AA91921959CB2 for ; Wed, 12 Sep 2018 06:22:45 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id 20-v6so2009040wrb.12 for ; Wed, 12 Sep 2018 06:22:45 -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=1mPsRwICitXpw5IpjTEB5Cg9062CZQWh0lcwt+o5jhY=; b=WnP/BJkjTmlv6w0Yq2VGUzvF5LWN2562YtC+4B94FXroEFBmb+caIG0ah+BqKaN+M2 mIxLFpxv2q1MGGk0g5iQaD2wbeboKCek5R26czchKPsBBU6NuBqeYHImQWBTofcdhL1J d+bwWNXdIlKeEhygSER/B25KZ0lCdpnWcCwfE= 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=1mPsRwICitXpw5IpjTEB5Cg9062CZQWh0lcwt+o5jhY=; b=h7TKM3XN0lTFjFIdlR7i4+0Am5HxLqeSCVxFNMnbdCJehZs8zrShgUWlndqriKzTzT jIMvbe1kha6Usvnq03T4LPm+oQ9BvyifmddI6VmPGBhWhvwlYj+buWqFi6GcA6MsAHMj jeKhREqYzoDcEZ+JUwd5ScZbbWF2xWdXjrQW5m2YBcYlgumByNkN9Mq7xHMNnqkwbiok XxPvOUBn1jGbF4kd1w+pLVj508a4PJv59ORRaLi0fxco6NeM6icykOzeHUezWeW9hn0E 6HLXSGDVk1VR1RGBKAmg0CgHkuafaKdrU/TN35HXpf/trU3fk3s14fkD1EzLNXJFjavG y+DQ== X-Gm-Message-State: APzg51CqvMzoidbkgmjbZZvLi3u0Q6sHU4lUrSUzaS9cqivjwEliob8z fBYciK3z1CN62xmv3WJEZR17DB/VDakIPg== X-Received: by 2002:a5d:69d1:: with SMTP id s17-v6mr1593915wrw.77.1536758563792; Wed, 12 Sep 2018 06:22:43 -0700 (PDT) Received: from mba13.kuq.prv ([2001:a62:605:90f4:1f3:d690:1764:36ca]) by smtp.gmail.com with ESMTPSA id e133-v6sm1985129wma.33.2018.09.12.06.22.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 06:22:43 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 12 Sep 2018 15:21:50 +0200 Message-Id: <20180912132151.4258-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180912132151.4258-1-ard.biesheuvel@linaro.org> References: <20180912132151.4258-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 3/4] MdeModulePkg/PciBusDxe: invoke PE/COFF emulator for foreign option ROMs 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 , Zimmer Vincent , Eric Dong , Andrew Fish , agraf@suse.de, Brian Richardson , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" When enumerating option ROM images, take into account whether an emulator exists that would allow dispatch of PE/COFF images built for foreign architectures. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 1 + MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) -- 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/PciBus.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h index 55eb3a5a8070..dc57d4876c0f 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h @@ -33,6 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf index a21dd2b5edf4..3d99ea0c1047 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf @@ -97,6 +97,7 @@ gEfiLoadFile2ProtocolGuid ## SOMETIMES_PRODUCES gEdkiiIoMmuProtocolGuid ## SOMETIMES_CONSUMES gEfiLoadedImageDevicePathProtocolGuid ## CONSUMES + gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport ## CONSUMES diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c index c2be85a906af..07236afd327d 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c @@ -678,6 +678,7 @@ ProcessOpRomImage ( MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH EfiOpRomImageNode; VOID *Buffer; UINTN BufferSize; + EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *PeCoffEmulator; Indicator = 0; @@ -693,6 +694,7 @@ ProcessOpRomImage ( } ASSERT (((EFI_PCI_EXPANSION_ROM_HEADER *) RomBarOffset)->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE); + PeCoffEmulator = NULL; do { EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) RomBarOffset; if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) { @@ -716,7 +718,19 @@ ProcessOpRomImage ( // Skip the EFI PCI Option ROM image if its machine type is not supported // if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (EfiRomHeader->EfiMachineType)) { - goto NextImage; + // + // Check whether we have a PE/COFF emulator that supports this image + // + if (PeCoffEmulator == NULL) { + gBS->LocateProtocol (&gEdkiiPeCoffImageEmulatorProtocolGuid, NULL, + (VOID **)&PeCoffEmulator); + } + if (PeCoffEmulator == NULL || + !PeCoffEmulator->IsImageSupported (PeCoffEmulator, + EfiRomHeader->EfiMachineType, + EfiRomHeader->EfiSubsystem)) { + goto NextImage; + } } //