rhboot / efibootmgr

efibootmgr development tree
GNU General Public License v2.0
519 stars 99 forks source link

Feature request: ability to set LOAD_OPTION_FORCE_RECONNECT for driver #108

Closed slytomcat closed 5 years ago

slytomcat commented 5 years ago

-r option of efibootmgr allows to create DriverXXXX efi variable, but for some cases it is also required to force UEFI to remap devices after driver is loaded. It can be done by setting LOAD_OPTION_FORCE_RECONNECT attribute in driver loading variable.

I think it wold be very good to have an ability to set LOAD_OPTION_FORCE_RECONNECT attribute while creation new Driver option by efibootmgr.

slytomcat commented 5 years ago

Possible example:

efibootmgr -crl "EFI\drivers\ext2_x64.efi" -L "EXT2-4 Driver"

efibootmgr -crfl "EFI\drivers\ext2_x64.efi" -L "EXT2-4 Driver"

Assuming option -f or --force-reconnect of efibootmgr can be used for activation of LOAD_OPTION_FORCE_RECONNECT attribute (applicable only for driver).

-f option should set bit 1 (mask 0x00000002) in load boot option attributes field.

Probably unsetting of LOAD_OPTION_FORCE_RECONNECT attribute is also required as setting of this attribute for many drivers is not recommended (each reconnect requires some amount of time during boot process). In this case option -F|--do-not-reconnect also required. So, the command:

efibootmgr -r -b0000 -F

slytomcat commented 5 years ago

Having such ability in efibootmgr looks excellent as alternative way to set and unset this driver load option requires rather boring routine: remove uefi vars protection by chattr -a, write byte 0x03 (bit active and bit force_reconnect are set in 1) with offset 5 from beginning, restore vars protection by chattr +a. It is not only boring but also dangerous.

slytomcat commented 5 years ago

I've done some changes in my fork to implement this feature. But I'm not sure that I've done everything right.

slytomcat commented 5 years ago

Can anyone review my solution and give me some feedback?

slytomcat commented 5 years ago

I've managed to build from master and checked it. It works as expected (at least with UEFI on my laptop).