linuxboot / fiano

Go-based tools for modifying UEFI firmware
BSD 3-Clause "New" or "Revised" License
302 stars 49 forks source link

extract / save an image change all file state to valid #256

Closed JulienVdG closed 5 years ago

JulienVdG commented 5 years ago

In some case, the rom image contains an invalid file state (I've seen 0x00 or 0xf0 while erase is 0xff) so doing extract then save will regenerate the rom with the only exception that the file state is changed to valid. I've seen that in the context of nvram where the image contains 2 fv : one with a valid file containing the store and a second one with the file marked as invalid (containing an older version of the store presumably)

The file state is defined somewhere in UEFI spec but can be found there: https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Pi/PiFirmwareFile.h#L100

Currently the assemble visitor (used by save) always set it to valid: https://github.com/linuxboot/fiano/blob/master/pkg/visitors/assemble.go#L223

Also UTK does not store the current state https://github.com/linuxboot/fiano/blob/master/pkg/uefi/file.go#L156

GanShun commented 5 years ago

Thanks for filling this! I had never encountered a file with invalid state since we didn't parse nvram.

JulienVdG commented 5 years ago

263 fixed it, closing