From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 34D0221157FF6 for ; Wed, 26 Sep 2018 11:26:14 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2018 11:26:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,307,1534834800"; d="scan'208";a="73914459" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by fmsmga008.fm.intel.com with ESMTP; 26 Sep 2018 11:26:14 -0700 Received: from orsmsx161.amr.corp.intel.com (10.22.240.84) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Sep 2018 11:26:13 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.89]) by ORSMSX161.amr.corp.intel.com ([169.254.4.49]) with mapi id 14.03.0319.002; Wed, 26 Sep 2018 11:26:13 -0700 From: "Kinney, Michael D" To: Ard Biesheuvel , "edk2-devel@lists.01.org" , "Kinney, Michael D" CC: "Zimmer, Vincent" , "Richardson, Brian" , Andrew Fish , Leif Lindholm , "Zeng, Star" , "Dong, Eric" , "Ni, Ruiyu" , "Gao, Liming" , "Carsey, Jaben" , "Shi, Steven" Thread-Topic: [PATCH v3 3/7] MdeModulePkg/PciBusDxe: invoke PE/COFF emulator for foreign option ROMs Thread-Index: AQHUUTX6KwDB1QVWLEa7SfIsOxefb6UC6NDA Date: Wed, 26 Sep 2018 18:26:12 +0000 Message-ID: References: <20180920230145.7565-1-ard.biesheuvel@linaro.org> <20180920230145.7565-4-ard.biesheuvel@linaro.org> In-Reply-To: <20180920230145.7565-4-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Subject: Re: [PATCH v3 3/7] 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: Wed, 26 Sep 2018 18:26:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ard, I am wondering if we can simplify the PciBusDxe driver and=20 remove the image type supported check and instead depend on LoadImage(). LoadImage() will return EFI_UNSUPPORTED if the image type is not supported. Thanks, Mike > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Thursday, September 20, 2018 4:02 PM > To: edk2-devel@lists.01.org > Cc: Ard Biesheuvel ; Zimmer, > Vincent ; Richardson, Brian > ; Kinney, Michael D > ; Andrew Fish > ; Leif Lindholm > ; Zeng, Star > ; Dong, Eric > ; Ni, Ruiyu ; > Gao, Liming ; Carsey, Jaben > ; Shi, Steven > > Subject: [PATCH v3 3/7] MdeModulePkg/PciBusDxe: invoke > PE/COFF emulator for foreign option ROMs >=20 > When enumerating option ROM images, take into account > whether an emulator > exists that would allow dispatch of PE/COFF images > built for foreign > architectures. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > 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 | > 53 +++++++++++++++++++- > 3 files changed, 54 insertions(+), 1 deletion(-) >=20 > 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 >=20 > #include > #include > diff --git > a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > index a21dd2b5edf4..c8b861093292 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > @@ -96,6 +96,7 @@ > gEfiIncompatiblePciDeviceSupportProtocolGuid ## > SOMETIMES_CONSUMES > gEfiLoadFile2ProtocolGuid ## > SOMETIMES_PRODUCES > gEdkiiIoMmuProtocolGuid ## > SOMETIMES_CONSUMES > + gEdkiiPeCoffImageEmulatorProtocolGuid ## > SOMETIMES_CONSUMES > gEfiLoadedImageDevicePathProtocolGuid ## > CONSUMES >=20 > [FeaturePcd] > diff --git > a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c > index c2be85a906af..085bd5d571bd 100644 > --- > a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c > +++ > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c > @@ -651,6 +651,55 @@ RomDecode ( > } > } >=20 > +STATIC > +BOOLEAN > +IsImageTypeSupported ( > + IN UINT16 MachineType, > + IN UINT16 SubSystem, > + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath > + ) > +{ > + EFI_STATUS Status; > + EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *Emu; > + UINTN HandleCount; > + EFI_HANDLE *HandleBuffer; > + BOOLEAN ReturnValue; > + UINTN Index; > + > + if (EFI_IMAGE_MACHINE_TYPE_SUPPORTED (MachineType)) > { > + return TRUE; > + } > + > + Status =3D gBS->LocateHandleBuffer ( > + ByProtocol, > + > &gEdkiiPeCoffImageEmulatorProtocolGuid, > + NULL, > + &HandleCount, > + &HandleBuffer > + ); > + if (EFI_ERROR (Status)) { > + return FALSE; > + } > + > + ReturnValue =3D FALSE; > + for (Index =3D 0; Index < HandleCount; Index++) { > + Status =3D gBS->HandleProtocol ( > + HandleBuffer[Index], > + > &gEdkiiPeCoffImageEmulatorProtocolGuid, > + (VOID **)&Emu > + ); > + ASSERT_EFI_ERROR (Status); > + > + if (Emu->IsImageSupported (Emu, MachineType, > SubSystem, DevicePath)) { > + ReturnValue =3D TRUE; > + break; > + } > + } > + > + FreePool (HandleBuffer); > + return ReturnValue; > +} > + > /** > Load and start the Option Rom image. >=20 > @@ -715,7 +764,9 @@ ProcessOpRomImage ( > // > // Skip the EFI PCI Option ROM image if its > machine type is not supported > // > - if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED > (EfiRomHeader->EfiMachineType)) { > + if (!IsImageTypeSupported(EfiRomHeader- > >EfiMachineType, > + EfiRomHeader- > >EfiSubsystem, > + PciDevice->DevicePath)) > { > goto NextImage; > } >=20 > -- > 2.17.1