From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.171.2.35; helo=mail-in25.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from mail-in25.apple.com (mail-out25.apple.com [17.171.2.35]) (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 64FB121BADAB2 for ; Mon, 30 Jul 2018 08:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1532964510; x=2396878110; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qcqShJLEes/m78Hz3PUuBekIy1DZZHINcJ6bEa7g+F0=; b=n5HvUIoWLn9kSZ+hUgZN9cXrzZvTFVdZ79o/1CWPWEFKNrKevCruXdv7DersCRQp XEelKckIMSi61LEg5yc8yBJdY8AKTmkG2XegU29qE5izExWNZVGWZDasVfTvnVGO Dm9GjkBogH7kl8c9HR0vVkvYOkhsxjNL24Nb5PYoUmWZ7Ovgz0W+J3rxBxAhoVq+ q6Oqao4rtCwMFEhdc2dN5PtLck0iHIj9BW6rc8WDO8udTUGhPKSMt1+x6fq2YZNH w6nKSFwEwCmjWlqyx6SiD0y390M+nrnirQ7nViC1nl+XHn9PHl9udV2kPFpsNAzB PKbOvPjtHga2VsJ3PfgnBg==; X-AuditID: 11ab0219-a862c9e000004c1b-c8-5b5f2e9d4884 Received: from mr2-mtap-s02.rno.apple.com (mr2-mtap-s02.rno.apple.com [17.179.226.134]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail-in25.apple.com (Apple Secure Mail Relay) with SMTP id B9.BD.19483.D9E2F5B5; Mon, 30 Jul 2018 08:28:30 -0700 (PDT) MIME-version: 1.0 Received: from ma1-mmpp-sz10.apple.com (ma1-mmpp-sz10.apple.com [17.171.128.150]) by mr2-mtap-s02.rno.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPS id <0PCO00A08QYWX1E0@mr2-mtap-s02.rno.apple.com>; Mon, 30 Jul 2018 08:28:12 -0700 (PDT) Received: from process_viserion-daemon.ma1-mmpp-sz10.apple.com by ma1-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PCO00D00QSGEH00@ma1-mmpp-sz10.apple.com>; Mon, 30 Jul 2018 08:28:11 -0700 (PDT) X-Va-A: X-Va-T-CD: 7b94995cc9f7b636481b394f88e9b0f7 X-Va-E-CD: 8a618f7f4dc287a493048b03b21974e9 X-Va-R-CD: 504f23f21a6554c441c6e9be3ddf7c12 X-Va-CD: 0 X-Va-ID: 27976f4b-1050-4c7f-9557-befde2772872 X-V-A: X-V-T-CD: 7b94995cc9f7b636481b394f88e9b0f7 X-V-E-CD: 8a618f7f4dc287a493048b03b21974e9 X-V-R-CD: 504f23f21a6554c441c6e9be3ddf7c12 X-V-CD: 0 X-V-ID: b0986c46-eb9f-4c0e-9dad-abadc1b01758 Received: from process_milters-daemon.ma1-mmpp-sz10.apple.com by ma1-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PCO00D00QSGEG00@ma1-mmpp-sz10.apple.com>; Mon, 30 Jul 2018 08:28:11 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-30_07:,, signatures=0 X-Proofpoint-Scanner-Instance: ma-grpmailp-qapp25.corp.apple.com-10000_instance1 Received: from [17.234.239.180] (unknown [17.234.239.180]) by ma1-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPSA id <0PCO00I08QYWNS20@ma1-mmpp-sz10.apple.com>; Mon, 30 Jul 2018 08:28:11 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Mon, 30 Jul 2018 08:28:06 -0700 Cc: "edk2-devel@lists.01.org" Message-id: <8DB23AC9-C753-4697-BD99-0E31BFAB2CFC@apple.com> References: <1B0B175F-9347-4D45-A7B3-799BC9FDFD49@apple.com> To: Rafael Machado X-Mailer: Apple Mail (2.3445.6.18) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFIsWRmVeSWpSXmKPExsUiuPlRm+48vfhog/2vuS32HDrKbLHz5Qx2 ByaPnbPusnt0z/7HEsAUxWWTkpqTWZZapG+XwJWx5fshxoIO7YrJvQvYGxiPKHcxcnJICJhI rPn9lbGLkYtDSOAgk0T3ncXMIAleAUGJH5PvsXQxcnAwC6hLTJmSC1Gznkni2c5NrBBOF5PE pw3PWCAmsUv8+bUDytaW6No+nxHG/v6ghRnG3tlwlAnC5pJYsPU0K4StK/H+ewdUnE1i/Ykl ULaWxIoNR+Dsw7MfMMPYH9fOZIewOSXOf5kIZetIPD/wnAniuE4miXvbTkItyJY4vwmmKEBi zeUFUEWTmSS2H1oFlhAWEJd4d2YTM4RtKXH20l8wm01AWWLF/A9gNZwCwRIb1r5lA7FZBFQl njw5D3Yds4C5xIwLX6BsbYkn7y6wQoLRRuJ/dxc7xLIzjBILTr4CGyQiYCaxd9YE9gmMirOQ gnsWIrhnIRm1gJF5FaNwbmJmjm5mnpGpXmJBQU6qXnJ+7iZGUGJYzSS5g/Hra8NDjAIcjEo8 vB/U46OFWBPLiitzDzFKc7AoifN+3CUWLSSQnliSmp2aWpBaFF9UmpNafIiRiYNTqoHRdkPl zVav/cwqfQsXuq5dFieXM2mDSFWvcmUkv8Xmsz7vfftTWT72tx52Mn68beM3J901PCt47KuK dkVIrDi+9NxFYf3/RuW6zyZkapo3OrNmL50762NsZ2rLlkfnCx/sjHFxMo3fd/CZ7ymOL82P zNaxx0z8X6q7dl2v7hynl5xLXnj6OCYrsRRnJBpqMRcVJwIA+R/u0e0CAAA= Subject: Re: Question About DxeDriver load process X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 15:28:31 -0000 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable Rafael, I forgot to mention that the DXE Core is loaded by the DXE IPL PEIM. = This can sometime require the discovery of a new FV to find the DXE = Core.=20 = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/DxeIplPeim= /DxeLoad.c#L254 Thanks, Andrew Fish > On Jul 30, 2018, at 4:46 AM, Rafael Machado = wrote: >=20 > Hi Andrew >=20 > Thanks a lot for the perfectly detailed explanation! > Amazing! >=20 > Thanks and Regards > Rafael R. Machado >=20 > Em sex, 27 de jul de 2018 =C3=A0s 19:14, Andrew Fish = escreveu: >=20 >> Rafael, >>=20 >> Since it is useful to also understand this when you are bringing up a >> platform.... >>=20 >> SEC generally contains the hardware reset vector. SEC hands off to = the PEI >> Core. Generally there is some build magic to help SEC find the PEI = Core. >> Worst case you can walk the BFV (Boot Firmware Volume) and find it. >>=20 >> SEC hands the PEI Core the EFI_SEC_PEI_HAND_OFF structure. This is = how the >> PEI Core knows about stack, heap, and the location of the BFV to find = PEIMs >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Pi/PiPeiCis.h= #L967 >>=20 >> The PEI Core has a PPI Notify Callback for >> gEfiPeiFirmwareVolumeInfoPpiGuid, and = gEfiPeiFirmwareVolumeInfo2PpiGuid to >> discover new FVs. >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Pei/FwVol/= FwVol.c#L547 >>=20 >> PEI Code writes hobs, EFI_HOB_TYPE_FV and EFI_HOB_TYPE_FV3, to help = DXE >> discover FVs. >>=20 >> When the DXE Core is started it will call FwVolBlockDriverInit() and = all >> the EFI_HOB_TYPE_FV, and optionally pick up the authentication status = from >> EFI_HOB_TYPE_FV3, will get processed. >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/FwVolB= lock/FwVolBlock.c#L625 >>=20 >> via calling ProduceFVBProtocolOnBuffer(). = ProduceFVBProtocolOnBuffer() can >> also be called gBS->ProcessFirmwareVolume(). >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/FwVolB= lock/FwVolBlock.c#L452 >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/FwVolB= lock/FwVolBlock.c#L687 >>=20 >> Loading drivers from the FV is the job of the DXE Dispatcher. The DXE >> Dispatcher has protocol notify event on = gEfiFirmwareVolume2ProtocolGuid >> that will get the executables in the Dispatch list, mDiscoveredList. >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Dispat= cher/Dispatcher.c#L1193 >>=20 >> So adding a gEfiFirmwareVolume2ProtocolGuid driver, or calling >> gBS->ProcessFirmwareVolume() is how you would make an FV show up that = was >> not listed in the HOBs. >>=20 >> In the DXE Phase security is handle by gBS->LoadImage() and it uses >> gEfiSecurity2ArchProtocolGuid and gEfiSecurityArchProtocolGuid to = validate >> the image. This makes sense as a signed EFI PE/COFF image has the = signature >> in the PE/COFF image, so you have to start the PE/COFF loading = process to >> verify that signature. gEfiSecurity2ArchProtocolGuid lets you build >> security policy based on the location of the driver. >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Image/= Image.c#L1041 >>=20 >> When the Dispatcher runs of things to Dispatch it returns and the DXE = Core >> calls the BDS to process platform Boot Device Selection. >>=20 >> = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/DxeMai= n/DxeMain.c#L550 >>=20 >> After BDS starts the only way to run code from an FV would be to call >> gDS->Dispatcher(). Likely you would call gDS->ProcessFirmwareVolume() = and >> then gDS->Dispatcher(). To speed boot it is not uncommon to have = multiple >> FVs. For example you could have an FV that contained all the setup >> resources and only call gDS->ProcessFirmwareVolume() on that FV if = the user >> hit the Setup hot key. >>=20 >> Thanks, >>=20 >> Andrew Fish >>=20 >> PS For x86 (0xFFFFFFF0 reset vector) and any other architectures that = have >> the reset vector at the end there is a special file name in the FV = called >> gEfiFirmwareVolumeTopFileGuid that tells the FV creation tools to put = that >> file at the very end of the FV, so the end of that file would end up = at the >> reset vector location. >>=20 >>=20 >>> On Jul 27, 2018, at 11:12 AM, Rafael Machado < >> rafaelrodrigues.machado@gmail.com> wrote: >>>=20 >>> Hi everyone >>>=20 >>> I have a question. >>> Let's suppose I have a BIOS with several FV regions. Between these = FV >> there >>> is one that is empty. >>>=20 >>> My question is: >>> In case I get this BIOS and inject a dxe driver at this FV. Would it = be >>> executed, or there are specific FVs that are considered as = containers to >>> executable code avoiding other FVs content to be executed? >>>=20 >>> In case the answer comes with some code examples from edk2 tree it = would >> be >>> amazing :) >>>=20 >>> Thanks and Regards >>> Rafael >>> _______________________________________________ >>> edk2-devel mailing list >>> edk2-devel@lists.01.org >>> https://lists.01.org/mailman/listinfo/edk2-devel >>=20 >>=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel