From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4003:c06::22f; helo=mail-oi0-x22f.google.com; envelope-from=rafaelrodrigues.machado@gmail.com; receiver=edk2-devel@lists.01.org Received: from mail-oi0-x22f.google.com (mail-oi0-x22f.google.com [IPv6:2607:f8b0:4003:c06::22f]) (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 77721210C642E for ; Mon, 30 Jul 2018 17:43:19 -0700 (PDT) Received: by mail-oi0-x22f.google.com with SMTP id y207-v6so24767943oie.13 for ; Mon, 30 Jul 2018 17:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w41g62f7kmkwPx21/7fh83bOyVsss6Z/8GrAQyq/7p0=; b=g3N2whkr6Hk+Vb174RUKdwSHRoZuavS1QXbjdSrH40IJIqcx4dCFfcc9KRCUG+Jkbg +HaoF+e9pIKh96KNnkVd6Welh870R7vsFf3Tr3K0+dBvdtxXQcw3DZnBF1fh5geeYdML VUn2gYEdZwzbqu2Et/OCQFWnFihpZ4TUCHMMTTQzm4ydYEG/v91RFfIlOPtphiGN22l5 4nVHP0vIDB8UVa7lrlQIkPMLo348V2q38NPMZwPraqYn6ru40bnQLYU7xc26LmB2/8Oh IBHhb+b1wJaKu4oYp+ZfzuMpSneu/gj4GVhFMGDvGtFnEaxQyaATeM/jF3RunKRztJaz o1Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w41g62f7kmkwPx21/7fh83bOyVsss6Z/8GrAQyq/7p0=; b=RDv2Ky2ZUl2ODpHntmd3FIzOdU1xEho9cO8iWHOZr5FLFnwjvCX/ObT/rTbEx5fGdA ffWOnmhgytnLfEVBHOcDSGqypFwn2+PkpMCm13kvn3LidMj7Rhuj/q8B4sXwRonz8bZ+ aegIK5O0tQy7aocfQXspk3loSLpbAoO+xz5i/7C3KAHAYH16RkR1aaFQo4IhkdjBuiMY 1J1PIZWbj36tdEYQwJsJD6rWOeiQqa/aZ/meyUDppv/fCQKKdrSKsqnSlgdOSpLZj02U 1ES3Bjts0lQCXjR4Q+CQ97Ed18NvbLJ7YGfwOTuoMFbBslpgxiHoPXCG8tyc8M0d6w++ GqQw== X-Gm-Message-State: AOUpUlEHlEEfL4LJhHRv+FriQdhyiooROtv4dOBnZs1WZKm+gF4LxEkY qvnngG2i/e6qqx2ZQnDseAv8jafBj1jtVW4IHHY= X-Google-Smtp-Source: AAOMgpdRVDISyd3yS3Ues0cDqoF/uHEkzbdFn4r6B2wx/PG4htqkqPNoeKjxoKINyYPmc0elnc+/yH/fmjJpREXmWbs= X-Received: by 2002:aca:3ad4:: with SMTP id h203-v6mr19513531oia.294.1532997798187; Mon, 30 Jul 2018 17:43:18 -0700 (PDT) MIME-Version: 1.0 References: <1B0B175F-9347-4D45-A7B3-799BC9FDFD49@apple.com> <8DB23AC9-C753-4697-BD99-0E31BFAB2CFC@apple.com> In-Reply-To: <8DB23AC9-C753-4697-BD99-0E31BFAB2CFC@apple.com> From: Rafael Machado Date: Mon, 30 Jul 2018 21:43:22 -0300 Message-ID: To: Andrew Fish Cc: "edk2-devel@lists.01.org" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 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: Tue, 31 Jul 2018 00:43:19 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Andrew, Thanks for clarifying this! Rafael Em seg, 30 de jul de 2018 12:28, Andrew Fish escreveu: > 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. > > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/DxeIplPei= m/DxeLoad.c#L254 > > Thanks, > > Andrew Fish > > > On Jul 30, 2018, at 4:46 AM, Rafael Machado < > rafaelrodrigues.machado@gmail.com> wrote: > > > > Hi Andrew > > > > Thanks a lot for the perfectly detailed explanation! > > Amazing! > > > > Thanks and Regards > > Rafael R. Machado > > > > Em sex, 27 de jul de 2018 =C3=A0s 19:14, Andrew Fish > escreveu: > > > >> Rafael, > >> > >> Since it is useful to also understand this when you are bringing up a > >> platform.... > >> > >> 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 Cor= e. > >> Worst case you can walk the BFV (Boot Firmware Volume) and find it. > >> > >> 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 > >> > >> > https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Pi/PiPeiCis.= h#L967 > >> > >> The PEI Core has a PPI Notify Callback for > >> gEfiPeiFirmwareVolumeInfoPpiGuid, and > gEfiPeiFirmwareVolumeInfo2PpiGuid to > >> discover new FVs. > >> > >> > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Pei/FwVol= /FwVol.c#L547 > >> > >> PEI Code writes hobs, EFI_HOB_TYPE_FV and EFI_HOB_TYPE_FV3, to help DX= E > >> discover FVs. > >> > >> 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. > >> > >> > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/FwVol= Block/FwVolBlock.c#L625 > >> > >> via calling ProduceFVBProtocolOnBuffer(). ProduceFVBProtocolOnBuffer() > can > >> also be called gBS->ProcessFirmwareVolume(). > >> > >> > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/FwVol= Block/FwVolBlock.c#L452 > >> > >> > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/FwVol= Block/FwVolBlock.c#L687 > >> > >> Loading drivers from the FV is the job of the DXE Dispatcher. The DXE > >> Dispatcher has protocol notify event on gEfiFirmwareVolume2ProtocolGui= d > >> that will get the executables in the Dispatch list, mDiscoveredList. > >> > >> > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Dispa= tcher/Dispatcher.c#L1193 > >> > >> 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. > >> > >> 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. > >> > >> > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Image= /Image.c#L1041 > >> > >> When the Dispatcher runs of things to Dispatch it returns and the DXE > Core > >> calls the BDS to process platform Boot Device Selection. > >> > >> > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/DxeMa= in/DxeMain.c#L550 > >> > >> 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. > >> > >> Thanks, > >> > >> Andrew Fish > >> > >> 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 a= t > the > >> reset vector location. > >> > >> > >>> On Jul 27, 2018, at 11:12 AM, Rafael Machado < > >> rafaelrodrigues.machado@gmail.com> wrote: > >>> > >>> Hi everyone > >>> > >>> I have a question. > >>> Let's suppose I have a BIOS with several FV regions. Between these FV > >> there > >>> is one that is empty. > >>> > >>> 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? > >>> > >>> In case the answer comes with some code examples from edk2 tree it > would > >> be > >>> amazing :) > >>> > >>> Thanks and Regards > >>> Rafael > >>> _______________________________________________ > >>> edk2-devel mailing list > >>> edk2-devel@lists.01.org > >>> https://lists.01.org/mailman/listinfo/edk2-devel > >> > >> > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > >