From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 AE421802E6 for ; Thu, 16 Mar 2017 07:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1489674833; 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=S3t28koVTCfIKg2VbH9wrZwgB3sk5PI7WKrcmX+AKvE=; b=M8wk9USmFzFpf4DoYqQL6YY/Ey6c9tY4DTVDrsqc/BXemeGhTLx47k+gBRBL5yst RRVvdCf9eP7kkhQOTIbTuEueZjM2KTA4K2p5FCmUQMFlb2vygEPQNxHTEIBWiS69 zQ4+Z4iotdeKs6I7AzQs7gitARl285qvgzlw5/vVnxmvDywVLIxkQ3XKjuZD8ttW T+FhPNIb0DoSgv4uFGaCb/ld0AKOSI+LJ7IkZWhZxASyfuSZwMgtQVwrqbBW3eHm g6YYZOL8UjL1oJIIrbZaYQ9mSqzXeDYpF7aK279a4D2aOFrlzjB6RcS8YCrlf8kL asBvF9U0SaA4n0R8Sptllg==; Received: from relay3.apple.com (relay3.apple.com [17.128.113.83]) by mail-in25.apple.com (Apple Secure Mail Relay) with SMTP id 21.98.01140.052AAC85; Thu, 16 Mar 2017 07:33:53 -0700 (PDT) X-AuditID: 11ab0219-8c5fb70000000474-2d-58caa250df55 Received: from nwk-mmpp-sz11.apple.com (nwk-mmpp-sz11.apple.com [17.128.115.155]) by relay3.apple.com (Apple SCV relay) with SMTP id 15.99.01494.F42AAC85; Thu, 16 Mar 2017 07:33:51 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.47.209] (unknown [17.153.47.209]) by nwk-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0OMW00JROWGDFO20@nwk-mmpp-sz11.apple.com>; Thu, 16 Mar 2017 07:33:51 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Thu, 16 Mar 2017 07:33:49 -0700 Cc: Laszlo Ersek , Feng Tian , Liming Gao , "edk2-devel@lists.01.org" , Star Zeng Message-id: References: <426920F0-4266-4BB2-BF19-40715A0F1C01@apple.com> <385c68bb-4a3f-e586-f62b-9dd9f9c6490b@redhat.com> <75A865F3-53E6-4C54-91A0-46A32E3CAB84@apple.com> <7953ce1f-fa7e-e881-ba85-136938fdbd03@redhat.com> To: Michael Zimmermann X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsUi2FAYrBu46FSEwdPTJhbr9nxjt5i0m91i 2bEdLBYr7m1gt5g79Smrxb5eawc2j52z7rJ7LN7zkslj0oXHzB7v911lC2CJ4rJJSc3JLEst 0rdL4Mpo+SBe8N+horlpI1MD4xGTLkYODgkBE4lZn5y7GLk4hAT2MUrc/HWOuYuREyy+qfcr I4gtJHCIUaKzxwDE5hUQlPgx+R4LSC+zgLzEwfOyIGFmAS2J749aWSDmTGSSOPxlITtIQlhA XOLdmU3MELatRPOxGWwgNpuAssSK+R/AajgFgiW+nL8BtotFQFXi+LsXjCCDmAUOM0rcuXqY HWKxjcTUviOsEBumsUisnnWeCSQhImAo8bT5MRPEN7ISs395gdRICFxmk1j1+DTTBEbhWUgO n4Vw+Cwkhy9gZF7FKJybmJmjm5lnZKqXWFCQk6qXnJ+7iREUEauZJHcwfn1teIhRgINRiYdX YP6pCCHWxLLiytxDjNIcLErivFGLT0QICaQnlqRmp6YWpBbFF5XmpBYfYmTi4JRqYFQN3PeB 0cc50m5zjldzvW+1nrDa8alBExltXv7YnxnSn3Qhh4VnwiTHGS9D5G8fuHzzohRXq8u0gmc8 W8Xmdr6vn/vNPjdBZXGUaJT2sb+chmqLo6R4hFqYJizdJraATd3rwrc1YRfDdVzVDqec0j99 7arfEok8aavAZxfDnm3SNVz3ScExTImlOCPRUIu5qDgRAFQSbXppAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsUi2FA8W9d/0akIg5cTrC3W7fnGbjFpN7vF smM7WCxW3NvAbjF36lNWi3291g5sHjtn3WX3WLznJZPHpAuPmT3e77vKFsASxWWTkpqTWZZa pG+XwJXR8kG84L9DRXPTRqYGxiMmXYycHBICJhKber8ygthCAocYJTp7DEBsXgFBiR+T77F0 MXJwMAvISxw8LwsSZhbQkvj+qBUozAVUPpFJ4vCXhewgCWEBcYl3ZzYxQ9i2Es3HZrCB2GwC yhIr5n8Aq+EUCJb4cv4G2C4WAVWJ4+9eMIIMYhY4zChx5+phdojFNhJT+46wQmyYxiKxetZ5 JpCEiIChxNPmx0wgF0kIyErM/uU1gVFgFpJbZyHcOgvJrQsYmVcxChSl5iRWGuslFhTkpOol 5+duYgQHcGHwDsY/y6wOMQpwMCrx8GYsPBUhxJpYVlyZCwwLDmYlEd642UAh3pTEyqrUovz4 otKc1OJDjFVAD0xklhJNzgdGV15JvKGJiYGJsbGZsbG5iTlVhJXEeX9pnYwQEkhPLEnNTk0t SC2CWc7EwSnVwKg09eqBxLpdMtVrJu7wF4yZLb5TkGubkf5k6+o9raGnr69ctO1rzKyYNZKd i8SNz/cmHd6qunmKePGnsJ5TNbvl9INbc7geazYzaHIEPxdrD9D2WXfnPoNgam+Qp6D9Uv1a loL0FVuPn5t6fk3oIUFdXrutQss4/X+J7HEP0Vf6eOVSqJzQHSWW4oxEQy3mouJEAIn9LKK7 AgAA Subject: Re: how to load drivers from additional FV's? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Mar 2017 14:33:54 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Mar 16, 2017, at 5:33 AM, Michael Zimmermann wrote: > > Laszlo, I don't know if I was clear enough but I've been able to load > drivers from a nested FV without any manual loading or decompressing > and without any changes to my code. > > All I needed to do was putting this into FVMAIN: > FILE FV_IMAGE = $(GUID) { > SECTION FV_IMAGE = FVMAINPLATFORM > } > Michael, Load FVs from FVs has been a feature for a very long time in DXE (pre dates edk2) and eventually got added to PEI as well. My comments on compression are just generic optimization advice, it should work regardless of the pattern you use. My basic compression advice is: 1) Compress as much code together as possible 2) Files with high entropy like compressed files, and sometime graphics images can make compression not work well. So compressing a compressed file does not usually work well. 3) Like performance, the only way to know for sure what gets you the best compression is to try things out. Thanks, Andrew Fish > Thanks > Michael > > On Thu, Mar 16, 2017 at 1:27 PM, Laszlo Ersek wrote: >> On 03/16/17 13:20, Michael Zimmermann wrote: >>> So if I understand this correctly there's no bug to fix because >>> nested, uncompressed FV's are already supported >> >> I'm not sure how to answer this; I guess the answer depends on what >> meaning you attribute to "supported". In OVMF it works, but it depends >> on two things: OVMF's SEC driver having access to writeable RAM, and >> OVMF manually messing with the firmware volumes (locating them, >> decompressing the outer file, moving stuff around, and so on). >> >> On a physical platform, I guess you can do the same, if you are willing >> to mess with the FVs manually, and you delay that code until at least >> the PEI phase sees the permanent RAM installed. >> >> Thanks >> Laszlo >> >>> and using compressed >>> ones is bad practice anyway? >>> >>> Thanks >>> Michael >>> >>> On Thu, Mar 16, 2017 at 12:20 PM, Laszlo Ersek wrote: >>>> On 03/15/17 16:54, Andrew Fish wrote: >>>>> >>>>>> On Mar 15, 2017, at 8:38 AM, Laszlo Ersek >>>>> > wrote: >>>>>> >>>>>> On 03/15/17 16:13, Andrew Fish wrote: >>>>>>> >>>>>>>> On Mar 15, 2017, at 8:07 AM, Laszlo Ersek >>>>>>> > wrote: >>>>>>>> >>>>>>>> On 03/15/17 13:23, Michael Zimmermann wrote: >>>>>>>>> I'm trying to add another FV section FVMAIN_COMPACT so I can keep >>>>>>>>> Platform specific drivers in a separate, included fdf. >>>>>>>>> >>>>>>>>> I did this: >>>>>>>>> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >>>>>>>>> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF >>>>>>>>> PROCESSING_REQUIRED = TRUE { >>>>>>>>> SECTION FV_IMAGE = FVMAIN >>>>>>>>> SECTION FV_IMAGE = FVMAINPLATFORM >>>>>>>>> } >>>>>>>>> } >>>>>>>>> >>>>>>>>> The image builds file and using uefitool I can verify that the new FV >>>>>>>>> is inside the compressed section. >>>>>>>>> But none of the drivers gets discovered/loaded and I get 'Protocol not >>>>>>>>> present!!' errors. >>>>>>>> >>>>>>>> The FVs need to be exposed to the DXE core via FV HOBs. See >>>>>>>> - 9.8.5 "Firmware Volume HOBs" in Volume 2 of the Platform Init 1.5 >>>>>>>> spec, >>>>>>>> - and more importantly, 5.7 "Firmware Volume HOB" in Volume 3 of the >>>>>>>> same. >>>>>>>> >>>>>>>> You can use the BuildFvHob() function for this. >>>>>>>> >>>>>>>> If the firmware volume contains PEIMs (... as well), then it has to be >>>>>>>> exposed to the PEI core too, I think. I think the >>>>>>>> PeiServicesInstallFvInfoPpi() function can be used for that. (See 3.3 >>>>>>>> "PEI" in Volume 3 of the PI spec.) >>>>>>>> >>>>>>>> ... I used the PeiFvInitialization() function in >>>>>>>> OvmfPkg/PlatformPei/Fv.c as a "cheat sheet" for the above. >>>>>>>> >>>>>>> >>>>>>> Laszlo, >>>>>>> >>>>>>> I think this case is an FV that is compressed and nested in another >>>>>>> FV that is discovered. I think the issues is multiple FV Sections in >>>>>>> an FV file are not currently supported. >>>>>> >>>>>> In OVMF we do the same: >>>>>> >>>>>> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >>>>>> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF >>>>>> PROCESSING_REQUIRED = TRUE { >>>>>> # >>>>>> # These firmware volumes will have files placed in them uncompressed, >>>>>> # and then both firmware volumes will be compressed in a single >>>>>> # compression operation in order to achieve better overall >>>>>> compression. >>>>>> # >>>>>> SECTION FV_IMAGE = PEIFV >>>>>> SECTION FV_IMAGE = DXEFV >>>>>> } >>>>>> } >>>>>> >>>>>> "OvmfPkg/Sec/SecMain.c" decompresses the compressed FFS file into >>>>>> memory -- which is special to OVMF, i.e. the fact that there is >>>>>> writeable memory in SEC --, then jumps to the PEI entry point. >>>>>> PlatformPei then exposes DXEFV to the PEI core (for loading the DXE >>>>>> core AIUI) and to the DXE core as well (for loading DXE modules). >>>>>> >>>>>> The multiple FV sections in the FFS file are not discovered >>>>>> automatically. First, the OVMF build process saves the final (= >>>>>> decompressed) in-memory locations of the nested FVs into PCDs. Second, >>>>>> in DecompressMemFvs(), the SEC module decompresses the outer, >>>>>> compressed, FFS file, then locates the embedded FVs manually with >>>>>> FindFfsSectionInstance(), then moves the decompressed FVs individually >>>>>> to their pre-recorded locations. >>>>>> >>>>>> In Michael's case, I think the same should be possible -- since FVMAIN >>>>>> is running for him, the outer, compressed file must already be >>>>>> decompressed (in full) to some temporary buffer in memory. If he can >>>>>> find, manually, the second section (with the embedded FVMAINPLATFORM >>>>>> firmware volume in it) in that area, then he can also expose it to the >>>>>> DXE core, I believe. >>>>>> >>>>> >>>>> Laszlo, >>>>> >>>>> The DXE Core will dispatch FVs with Depex "automagically" but only one >>>>> FV_IMAGE Section per FV_IMAGE file. >>>>> >>>>> So one workaround would be to add a 2nd FV_IMAGE file that contains the >>>>> 2nd FV in the 1st FV_IMAGE Section. >>>>> >>>>> Also I'm not sure if the outer FV is compressed, but compressing >>>>> compressed data usually does not end well as the algorithms leverage >>>>> entropy. >>>> >>>> I apologize if my previous emails were confusing; I didn't mean to imply >>>> nested compression. OVMF doesn't do that. >>>> >>>>> It is better to just compress the outer FV and have everything >>>>> else uncompressed and let it all get compressed together. >>>> >>>> Yes, that's what OVMF does. >>>> >>>> Did you perhaps misread the comment above that I quoted from the FDF? >>>> >>>> "These firmware volumes will have files placed in them *uncompressed*, >>>> and then both firmware volumes will be compressed in a single >>>> compression operation in order to achieve better overall compression." >>>> >>>> (Emphasis mine.) >>>> >>>> Thanks! >>>> Laszlo >>>> >>>>> This also >>>>> helps as there will be common dictionary entries so compressing as much >>>>> data as possible in one shot usually works better. So for example if the >>>>> outer FV is compressed it may have a dictionary entry that represents >>>>> CopyMem, and it can represent that pattern with a small number of bits. >>>>> Doing compression multiple times causes duplication as each compressed >>>>> image has one copy of CopyMem (massive over simplification). Also if you >>>>> compress a nested FV then the CopyMem pattern does not exist in the >>>>> compressed data, and since the compressed data is more random it is hard >>>>> to find patterns to compress, so it hurts the compression of the outer FV. >>>>> >>>>> Thanks, >>>>> >>>>> Andrew Fish >>>>> >>>>>> Thanks >>>>>> Laszlo >>>>>> _______________________________________________ >>>>>> edk2-devel mailing list >>>>>> edk2-devel@lists.01.org >>>>>> https://lists.01.org/mailman/listinfo/edk2-devel >>>>> >>>> >>