]> git.baikalelectronics.ru Git - uboot.git/commit
efi_loader: make efi_delete_handle() follow the EFI spec
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Mon, 24 Jul 2023 10:17:36 +0000 (13:17 +0300)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 28 Jul 2023 09:36:37 +0000 (11:36 +0200)
commit3bb932dd28ccdec3a081a5cf2bb72b3702e00ba6
tree968752653e7efd57ef5f58b6546cf94a21028782
parentbbe38931cb0ca3b3c3fbf2323fbd81e2cf1e67bb
efi_loader: make efi_delete_handle() follow the EFI spec

The EFI doesn't allow removal of handles, unless all hosted protocols
are cleanly removed.  Our efi_delete_handle() is a bit intrusive.
Although it does try to delete protocols before removing a handle,
it doesn't care if that fails.  Instead it only returns an error if the
handle is invalid. On top of that none of the callers of that function
check the return code.

So let's rewrite this in a way that fits the EFI spec better.  Instead
of forcing the handle removal, gracefully uninstall all the handle
protocols.  According to the EFI spec when the last protocol is removed
the handle will be deleted.  Also switch all the callers and check the
return code. Some callers can't do anything useful apart from reporting
an error.  The disk related functions on the other hand, can prevent a
medium that is being used by EFI from removal.

The only function that doesn't check the result is efi_delete_image().
But that function needs a bigger rework anyway, so we can clean it up in
the future

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
cmd/bootefi.c
include/efi_loader.h
lib/efi_driver/efi_uclass.c
lib/efi_loader/efi_boottime.c
lib/efi_loader/efi_disk.c