From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B4A9B2112E016 for ; Thu, 13 Sep 2018 03:25:33 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Sep 2018 03:25:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,368,1531810800"; d="scan'208";a="72643921" Received: from shzintpr01.sh.intel.com (HELO [10.7.209.58]) ([10.239.4.80]) by orsmga007.jf.intel.com with ESMTP; 13 Sep 2018 03:25:30 -0700 To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: Ruiyu Ni , Zimmer Vincent , Eric Dong , Andrew Fish , agraf@suse.de, Brian Richardson , Michael D Kinney , Laszlo Ersek , star.zeng@intel.com References: <20180912132151.4258-1-ard.biesheuvel@linaro.org> <20180912132151.4258-4-ard.biesheuvel@linaro.org> From: "Zeng, Star" Message-ID: Date: Thu, 13 Sep 2018 18:24:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180912132151.4258-4-ard.biesheuvel@linaro.org> Subject: Re: [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: , X-List-Received-Date: Thu, 13 Sep 2018 10:25:33 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 2018/9/12 21:21, Ard Biesheuvel wrote: > 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(-) > > 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; > + } Hi Ard, Could these be abstracted to a separate function like the PATCH 4/4 did? Thanks, Star > } > > // >