On Thursday, March 14, 2024 5:31 PM Gerd Hoffmann wrote: > Load, measure and cache all fw_cfg entries we care about early in the PEI > phase > (or SEC phase for pei-less builds), so we can > (a) easily have a fixed order, and > (b) store them all in HOBs? > > Which implies SEC/PEI must read all relevant fw_cfg entries, even in case they > are used only later in the DXE phase. > > Advantage is we have a single cache which can be used in all firmware phases. > When using global variables in DXE we still can end up reading entries > multiple > times, either because entries are needed by both PEI and DXE, or because > multiple DXE modules need them (global variables are per module). > We have some concerns that in above solution the size of a single cache is large ( because all fw_cfg data need to be read from qemu). Further more this is not a lazy mode which means some fw_cfg data may be read but it is not to be consumed later.
We propose below solution : Add a new API in QemuFwCfgLib, RETURN_STATUS QemuFwCfgGetData(fw_cfg_name, *size, *value, FW_CFG_GET_DATA_FLAG flag). Input: @fw_cfg_name: The fw_cfg file name . @size: Number of bytes in the file. @value: Value of fw_cfg item read. @flag: Bitmap providing additional information(cache? measurement ?) #define FW_CFG_GET_DATA_CACHE 0x00000001 #define FW_CFG_GET_DATA_MEASUREMENT 0x00000002 Output: @return: RETURN_NOT_FOUND: The fw_cfg file is not found RETURN_UNSUPPORTED: The fw_cfg is unavailable. RETURN_BUFFER_TOO_SMALL: The required buffer size is in @size. RETURN_SUCCESS: The fw_cfg file is found and load the data successfully. Description: This function finds fw_cfg item and reads its data into value. And it also provides callers with options to cache and/or measurement. Pros: Caller can decide how to get the fw_cfg data from QEMU (cache? Measurement?) And it can reduce the code complexity because it pack 3 fw_cfg call (QemuFwCfgFindFile/QemuFwCfgSelectItem/QemuFwCfgReadBytes) into one call. What's your thought? Thanks Ceping -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116915): https://edk2.groups.io/g/devel/message/116915 Mute This Topic: https://groups.io/mt/104880546/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-