Skip to content

Instantly share code, notes, and snippets.

@heatd
Last active August 22, 2021 17:01
Show Gist options
  • Save heatd/51c94aa01c1fa72532775522695e984e to your computer and use it in GitHub Desktop.
Save heatd/51c94aa01c1fa72532775522695e984e to your computer and use it in GitHub Desktop.

EXT4 driver for Tianocore (GSoC 2021)

As part of GSoC 2021, I took on the task of writing an EXT4 driver for Tianocore, the main open-source UEFI implementation. This resulted in the addition of the Ext4Pkg package, and Ext4Dxe (which is the driver itself) to edk2-platforms, in Features/. In the process, I learned the ropes at Tianocore and edk2/edk2-platforms, which got me working on an open-source project I had never worked on before. Naturally, I had to adjust to the coding style and the community, which were both quite different from any project I had collaborated on before.

Ext4Dxe

The driver, Ext4Dxe, is a read-only UEFI DXE driver that consumes the Disk IO and Block IO protocols and produces the Simple File System protocol, which is a protocol in the UEFI spec that lets other drivers/applications open a filesystem and get a file handle to the root, which in turn lets users do all the regular filesystem operations (open, close, read, write).

Links, commits, and other references to the work

edk2-platforms link to Ext4Pkg: https://github.com/tianocore/edk2-platforms/tree/master/Features/Ext4Pkg

Merged commits

These commits added the Ext4Pkg package and the Ext4Dxe driver.

https://github.com/tianocore/edk2-platforms/commit/724d9c89efd4b94134280fc9f7186618a5c181b9

https://github.com/tianocore/edk2-platforms/commit/d9ceedca6c8f4110c73489a99ee74b371fca63fd

https://github.com/tianocore/edk2-platforms/commit/a47606201fed3ef054b84934a2aa49fc223745a1

Pending patches

After some testing, these patches fix some bugs and add a missing feature to the driver. They should be merged in the following days.

https://edk2.groups.io/g/devel/message/79661

https://edk2.groups.io/g/devel/message/79662

https://edk2.groups.io/g/devel/message/79663

https://edk2.groups.io/g/devel/message/79664

https://edk2.groups.io/g/devel/message/79665

https://edk2.groups.io/g/devel/message/79666

Future work

As a filesystem driver, there are a lot of things that can be improved on:

  1. Write support: The driver is currently lacking write support, which makes it so you can't, well, create files, write to files, delete files. The lack of this capability makes it so we can't use an EXT4 partition as the EFI system partition itself, due to capsule updates. Other members of the community think it's not such a good idea to add write support, which may be hard to test. Apple's HFS+ and APFS file system drivers don't have write-support. Link to relevant mailing list thread: https://edk2.groups.io/g/devel/topic/84368561

  2. Performance: The driver is still slower than edk2's FAT32 driver, despite having a theoretically more performant filesystem to work with. This is likely due to a big lack of caching.

  3. Testing: While I've tried to test however I could, it's still not very easy to test a filesystem. It was difficult to find a way to unit test the filesystem driver, and fuzzing is not so useful without code coverage instrumentation and other similar compiler features. The UEFI SCT tool looks like a solid test suite, but unfortunately it doesn't work for our case just yet, since we have no write support and most tests require it in one way or another.

Conclusion

Tianocore is a fantastic project, with very welcoming members and very friendly and insightful mentors. Due to GSoC, I plan on continuing to contribute to Tianocore, to both my own Ext4Pkg and other code that may need some love. Participating in GSoC 2021 was a very fun, challenging and rewarding experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment