]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: Simplify efi_free_pages()
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Thu, 24 Oct 2024 11:01:55 +0000 (14:01 +0300)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Wed, 30 Oct 2024 20:44:38 +0000 (21:44 +0100)
We currently call efi_free_pages() with a notify flag and explicitly
update the efi memory map. That's not needed as lmb_free_flags() will do
that for us if the LMB_NONOTIFY flag is removed

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_memory.c

index 9f3f08769977f7e2a77428c74e080da9692e4e79..d2f5d563f2a0e63da38c25e99de2ce7c1fbc57d7 100644 (file)
@@ -521,7 +521,6 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type,
 efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
 {
        u64 len;
-       uint flags;
        long status;
        efi_status_t ret;
 
@@ -536,18 +535,17 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
                return EFI_INVALID_PARAMETER;
        }
 
-       flags = LMB_NOOVERWRITE | LMB_NONOTIFY;
        len = (u64)pages << EFI_PAGE_SHIFT;
+       /*
+        * The 'memory' variable for sandbox holds a pointer which has already
+        * been mapped with map_sysmem() from efi_allocate_pages(). Convert
+        * it back to an address LMB understands
+        */
        status = lmb_free_flags(map_to_sysmem((void *)(uintptr_t)memory), len,
-                               flags);
+                               LMB_NOOVERWRITE);
        if (status)
                return EFI_NOT_FOUND;
 
-       ret = efi_add_memory_map_pg(memory, pages, EFI_CONVENTIONAL_MEMORY,
-                                   false);
-       if (ret != EFI_SUCCESS)
-               return EFI_NOT_FOUND;
-
        return ret;
 }