efi_selftest: keep devices in ExitBootServices()
PATCH 1/1 efi_selftest: keep devices in ExitBootServices()
When calling ExitBootServices during out unit tests we should not detach devices as we need console output for runtime tests.
Fixes 529441ca89b1 ("efi_loader: Disable devices before handing over control")
Signed-off-by Heinrich Schuchardt <[email protected]>
--- include/efi_loader.h | 3 +++ lib/efi_loader/efi_boottime.c | 13 +++++++++---- lib/efi_selftest/efi_selftest.c | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-)
include/efi_loader.h +3 -0
@@ -59,6 +59,9 @@ extern efi_handle_t efi_root;/* Set to EFI_SUCCESS when initialized */ extern efi_status_t efi_obj_list_initialized; +/* Flag used by the selftest to avoid detaching devices in ExitBootServices() */ +extern bool efi_st_keep_devices; +/* EFI system partition */ extern struct efi_system_partition { enum if_type if_type;
lib/efi_loader/efi_boottime.c +9 -4
@@ -38,6 +38,9 @@ LIST_HEAD(efi_event_queue);/* Flag to disable timer activity in ExitBootServices() */ static bool timers_enabled = true; +/* Flag used by the selftest to avoid detaching devices in ExitBootServices() */ +bool efi_st_keep_devices; +/* List of all events registered by RegisterProtocolNotify() */ LIST_HEAD (efi_register_notify_events);
@@ -1996,10 +1999,12 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,list_del (&evt->link); } - if IS_ENABLED(CONFIG_USB_DEVICE) -udc_disconnect (); -board_quiesce_devices (); -dm_remove_devices_flags (DM_REMOVE_ACTIVE_ALL ); +if (!efi_st_keep_devices) { + if IS_ENABLED(CONFIG_USB_DEVICE) +udc_disconnect (); +board_quiesce_devices (); +dm_remove_devices_flags (DM_REMOVE_ACTIVE_ALL ); + }/* Patch out unsupported runtime function */ efi_runtime_detach ();
lib/efi_selftest/efi_selftest.c +3 -0
@@ -38,6 +38,9 @@ void efi_st_exit_boot_services(void)efi_status_t ret;struct efi_mem_desc *memory_map; +/* Do not detach devices in ExitBootServices. We need the console. */ + efi_st_keep_devices = true; + ret = boottime->get_memory_map (&map_size,NULL , &map_key, &desc_size, &desc_version);if (ret !=EFI_BUFFER_TOO_SMALL ) {
--
2.28.0
PATCH 1/1 efi_selftest: keep devices in ExitBootServices()
Quoted 71 lines · Heinrich Schuchardt
When calling ExitBootServices during out unit tests we should not detach devices as we need console output for runtime tests.
Fixes 529441ca89b1 ("efi_loader: Disable devices before handing over control")Signed-off-by Heinrich Schuchardt <[email protected]>--- include/efi_loader.h | 3 +++ lib/efi_loader/efi_boottime.c | 13 +++++++++---- lib/efi_selftest/efi_selftest.c | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-)include/efi_loader.h +3
-0@@ -59,6 +59,9 @@ extern efi_handle_t efi_root;/* Set to EFI_SUCCESS when initialized */ extern efi_status_t efi_obj_list_initialized; +/* Flag used by the selftest to avoid detaching devices in ExitBootServices() */ +extern bool efi_st_keep_devices; +/* EFI system partition */ extern struct efi_system_partition { enum if_type if_type;lib/efi_loader/efi_boottime.c +9
-4@@ -38,6 +38,9 @@ LIST_HEAD(efi_event_queue);/* Flag to disable timer activity in ExitBootServices() */ static bool timers_enabled = true; +/* Flag used by the selftest to avoid detaching devices in ExitBootServices() */ +bool efi_st_keep_devices; +/* List of all events registered by RegisterProtocolNotify() */ LIST_HEAD (efi_register_notify_events);@@ -1996,10 +1999,12 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,list_del (&evt->link); } - if IS_ENABLED(CONFIG_USB_DEVICE) -udc_disconnect (); -board_quiesce_devices (); -dm_remove_devices_flags (DM_REMOVE_ACTIVE_ALL ); +if (!efi_st_keep_devices) { + if IS_ENABLED(CONFIG_USB_DEVICE) +udc_disconnect (); +board_quiesce_devices (); +dm_remove_devices_flags (DM_REMOVE_ACTIVE_ALL ); + }/* Patch out unsupported runtime function */ efi_runtime_detach ();lib/efi_selftest/efi_selftest.c +3
-1@@ -38,6 +38,9 @@ void efi_st_exit_boot_services(void)efi_status_t ret;struct efi_mem_desc *memory_map; +/* Do not detach devices in ExitBootServices. We need the console. */ + efi_st_keep_devices = true; + ret = boottime->get_memory_map (&map_size,NULL , &map_key, &desc_size, &desc_version);if (ret !=EFI_BUFFER_TOO_SMALL ) { --
Quoted 2 lines
2.28.0
Acked-by Ilias Apalodimas <[email protected]>