Skip to content
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

Support FVs that have the Extended header. #27

Open
GanShun opened this issue Jun 21, 2018 · 7 comments
Open

Support FVs that have the Extended header. #27

GanShun opened this issue Jun 21, 2018 · 7 comments

Comments

@GanShun
Copy link
Member

GanShun commented Jun 21, 2018

I've seen firmware volumes with the extended header preset, and it turns out on the roms I'm looking at, the HeaderLength field doesn't include the size of the extended header. To get the correct start of data, the ExtHeaderOffset must be added to the ExtendedHeaderSize if it exists.

@hugelgupf
Copy link
Member

shouldn't this be an issue on fiano?

@GanShun
Copy link
Member Author

GanShun commented Jun 21, 2018

I'm fixing it on fiano. Linuxboot extract-fv doesn't support it yet either. I wanna make a note for it.

@osresearch
Copy link
Contributor

It might work with extract-firmware -- the s2600wf uses them: https://github.com/linuxboot/linuxboot/blob/master/bin/extract-firmware#L166:

		if ($len == 0xFFFFFF)
		{
			# Version 2 header with extended length
			$len = EFI::read64($fv, $offset + 0x18);

			# If we have an all-0xFF length, which indicates
			# the start of free space
			return 1 if ~$len == 0;

			## Looks good, adjust the starting offset
			$data_offset += 0x8;
		}

However, adding 0x8 is probably not the right general pupose way to use the extended header.

More important is probably adding support for creating FV larger than 16 MB, which would require doing it the right way.

@GanShun
Copy link
Member Author

GanShun commented Jun 28, 2018

Wait I think the code you're pointing to is about supporting FFSes with the extended length. I'm talking about the FirmwareVolume header that is itself extended and pointed to by the ExtHeaderOffset in the standard header.
For reference: UEFI PI Spec 3.2.1 Firmware Volume Header.

There is an "extended header" that is pointed to by the FV header. In those cases, in order to know where the files actually start in the FV, you need to parse the extended header to find its length and add to its offset.

@GanShun
Copy link
Member Author

GanShun commented Jun 28, 2018

Specifically this line needs to be fixed:

my $offset = EFI::read16($fv, 0x30);

since it's not a given that that's where the data of the FV starts.

@osresearch
Copy link
Contributor

You're right, that code was for dealing with FFS larger than 16 MB.

The FV parsing code handles volumes larger than 16 MB since it does a read64 of the length:

my $fv_length = EFI::read64($_, $offset + 0x20);

But it does not include anything ot process the extended headers (since none of the ones I had encountered yet used it). Do you have a ROM image that uses them that we can add as a test case?

@GanShun
Copy link
Member Author

GanShun commented Jun 29, 2018

Unfortunately I don't have one that I can share. We might be able to tweak winterfell's dxe to produce one that uses the extended header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants