-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve user data during firmware updates #809
Comments
@krystian-hebel, some things to discuss here. How to know that a new version is compatible with the old one? Will flashing driver have a table of versions eventually or should this information be embedded with a capsule in that vendor code? By the way, from # This tool is intended to be used to generate UEFI Capsules to update the
# system firmware or device firmware for integrated devices. In order to
# keep the tool as simple as possible, it has the following limitations:
# * Do not support vendor code bytes in a capsule. The update code should be changed to:
SMMSTORE - holds UEFI variables, e.g. user settings
If copying the region, any EDK caches to flash initially? Otherwise need to make EDK use new SMMSTORE region before it's written by somehow swapping firmware volume protocol (old variables need to be read before doing that). Needs FMAP code. ROMHOLE (MSI only) - required for FlashBIOS recoveryNeed a set of MSI GUIDs to check against? Parse FMAP in both old and new images and copy the data over if sizes/offsets match? Could hard-code, but it doesn't seem reliable. SMBIOS - unique data like serial number or system UUIDNeeds both FMAP and CBFS code. The latter is mostly GPL2-only. boot logo - customizable by usersAlso needs FMAP code, but can do without CBFS code if region size didn't change. I think we don't need to upstream ROMHOLE/SMBIOS/logo, so GPL code shouldn't be a problem, but would this be the first time we add it to our fork? Any problems with that and need to work around it? |
in the best case, if the update driver determines FMAP to be the same in current and new versions, it can attempt to only flash code partitions (RW_SECTION_A, RW_SECTION_B, WP_RO in the Vboot case, COREBOOT in the non-vboot case, and SI_ALL if present). That way we preserve everything we need, and the update is faster and more reliable than attempting to transplant this data. We also get to keep the MRC cache, and we already have users complaining that the boot time after updating is long, caused by retraining. But then we'd have to somehow ensure that the FMAP never changes :) |
Not sure we can assume the best case.
Don't know if it's more reliable or not. It's patching old image vs the new one, either way incompatibilities are possible.
I guess it can be copied as well. Since we'll need at least FMAP, I did implementation using just it here. Also includes CBFS code, which can be compiled, but it's not used yet. @JanPrusinowski, building from that branch should already make some tests pass. |
In its current state the branch copies everything in the OP, but Replacing EFI protocols seems to not be feasible because |
There can be incompatibilities at different levels, some of them can be harder to deal with than others. We have
Wouldn't it be enough to add new variables driver to capsule and let it repeat what Now that I think of it, it is coreboot's SMI handler that ultimately knows where SMMSTORE is (for writing, at least), and we won't be able to move it without rebooting into new coreboot, in case it is moved between versions. I think we can leave it at copying whole region for now, and maybe leave accessing single variables as potential future improvements. We can access variables just fine before new image is flashed, so this should be just the question of running the capsule drivers in the correct order. |
There is an event handler that needs to be triggered, global data and it also initializes libraries. Maybe it can be made to work, but that will take more effort and doesn't really look reliable.
I made implementation from |
Send PR: Dasharo/edk2#166 Regarding MRC cache. As far as I can tell, something like this should work:
I don't know much about it and how safe it is to have these regions potentially containing incompatible garbage, but if somebody thinks it should work, it's an easy thing to add this to the PR. |
I have created tests for: SMMSTORE, SMBIOS and boot logo Also I used the latest release suggested by @SergiiDmytruk - however I must have done something wrong as I didnt notice any changes from previous builds except for that the logo tests now work. I still dont know how to create ROMHOLE data and put it into the fw. I have aed about ROMHOLETOOL in: Dasharo/open-source-firmware-validation#501 |
Please attach logs. |
@JanPrusinowski Note that there is an issue in coreboot preventing it from working on MSI without extra changes (works fine in QEMU): Dasharo/edk2#166 (comment). The capsule update should just fail during an update and the fact that it didn't, shows that you probably built firmware with old revision of EDK2 (go to Log from Jira: capsule-preserve-data-log.zip |
Dasharo/edk2#166 has been merged, but MSI requires fixes to coreboot to be able to read whole flash when it is bigger than 16 MiB. |
Pushed Dasharo/coreboot@8c87fbd to Dasharo/coreboot#509, can be reviewed there. |
Logs requested by Krystian: log(9)1.zip |
New log from current PR (6a640f33c1f829692e99e8706af372064e3ef1ca): It was tested on Z690-A DDR4 with image built from Dasharo/coreboot#509 (68e501abc20c9dc1d74c6b96b863b12f094bae67) with edk2 pointed at Dasharo/edk2#172 (15ff38aa8a9ed5efea9619380978ce8f04286d2b). |
Brief summary
Some of the data should be preserved between firmware versions. This includes:
The text was updated successfully, but these errors were encountered: