Bareflank / hypervisor

lightweight hypervisor SDK written in C++ with support for Windows, Linux and UEFI
Other
1.36k stars 207 forks source link

UEFI: use EFI_LOADED_IMAGE_PROTOCOL to locate boot volume #950

Closed tkchia closed 3 years ago

tkchia commented 3 years ago

Some UEFI environments lack EFI_SHELL_PROTOCOL, but still implement EFI_LOADED_IMAGE_PROTOCOL.

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

codecov[bot] commented 3 years ago

Codecov Report

Merging #950 (fec39b5) into master (8591a61) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #950   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          139       139           
  Lines        15570     15570           
  Branches       411       411           
=========================================
  Hits         15570     15570           
rianquinn commented 3 years ago

@tkchia WOW, you did a great job matching the same patterns that we use. Well done. Clang Format is failing. That is really easy to fix. Just ensure that Clang Format is enabled and then run "make format" before submitting and that should fix that specific issue.

The only actual question I have is, how does this work with respect to which FS it get the files from. Ideally, it would always just load the images sitting next to ./start_bareflank. I have tested on a number of systems, and where it wants to find the kernel and extensions seems to change depending on the system. The code that we put in was a hack to basically just say, always use FS0. Again, would rather that the it just grabbed the images from the same location as to where ever the hypervisor is being started from, but at the very least, if that is not possible, the FS0 hack at least ensures consistency. The mods to this seem to remove the FS0 part of this so my fear is that it will start randomly picking which FS it wants to get the images from like it did before (some would prefer FS0 while others would prefer FS1.

Or am I just missing something?

tkchia commented 3 years ago

Hello @rianquinn,

Just ensure that Clang Format is enabled and then run "make format" before submitting and that should fix that specific issue.

Thanks! I have run ninja format to reformat the code, and re-pushed the patch.

The only actual question I have is, how does this work with respect to which FS it get the files from.

My proposed method is to obtain an EFI_LOADED_IMAGE_PROTOCOL from the image handle passed to the UEFI entry point, and to use that to get an EFI_SIMPLE_FILE_SYSTEM_PROTOCOL — rather than just to search for any EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.

My understanding is that the resulting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL should correspond to just the filesystem which the UEFI program was loaded from. (I guess it might be good to test this, though.)

Thank you!

rianquinn commented 3 years ago

@tkchia I will give this some tests and let you know if I have any issues. Thanks a ton for the contributions. Hope to see more of them 👍

tkchia commented 3 years ago

Thank you @rianquinn !