All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] efi_loader: create handles from normal memory
@ 2018-05-27 14:47 Heinrich Schuchardt
  2018-06-03 13:23 ` Alexander Graf
  0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2018-05-27 14:47 UTC (permalink / raw)
  To: u-boot

Handles are not used at runtime. They are freed by the firmware when the
last protocol interface is uninstalled. So there is no reason to use EFI
memory when creating handles.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/efi_loader/efi_boottime.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index b7ab2e8208e..50d311548e2 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -431,16 +431,15 @@ void efi_add_handle(struct efi_object *obj)
 efi_status_t efi_create_handle(efi_handle_t *handle)
 {
 	struct efi_object *obj;
-	efi_status_t r;
 
-	r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
-			      sizeof(struct efi_object),
-			      (void **)&obj);
-	if (r != EFI_SUCCESS)
-		return r;
+	obj = calloc(1, sizeof(struct efi_object));
+	if (!obj)
+		return EFI_OUT_OF_RESOURCES;
+
 	efi_add_handle(obj);
 	*handle = obj->handle;
-	return r;
+
+	return EFI_SUCCESS;
 }
 
 /**
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: create handles from normal memory
  2018-05-27 14:47 [U-Boot] [PATCH 1/1] efi_loader: create handles from normal memory Heinrich Schuchardt
@ 2018-06-03 13:23 ` Alexander Graf
  2018-06-03 14:02   ` Heinrich Schuchardt
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Graf @ 2018-06-03 13:23 UTC (permalink / raw)
  To: u-boot



On 27.05.18 16:47, Heinrich Schuchardt wrote:
> Handles are not used at runtime. They are freed by the firmware when the
> last protocol interface is uninstalled. So there is no reason to use EFI
> memory when creating handles.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

I agree that efi object structs are supposed to be opaque and thus we
can use any allocation mechanism we like.

What I also see is that efi_delete_handle() even calls free() on
objects, so spawning them from efi memory rather than malloc memory is
also just wrong.

In short, I think your patch is completely correct :).


Alex

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: create handles from normal memory
  2018-06-03 13:23 ` Alexander Graf
@ 2018-06-03 14:02   ` Heinrich Schuchardt
  0 siblings, 0 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2018-06-03 14:02 UTC (permalink / raw)
  To: u-boot

On 06/03/2018 03:23 PM, Alexander Graf wrote:
> 
> 
> On 27.05.18 16:47, Heinrich Schuchardt wrote:
>> Handles are not used at runtime. They are freed by the firmware when the
>> last protocol interface is uninstalled. So there is no reason to use EFI
>> memory when creating handles.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> 
> I agree that efi object structs are supposed to be opaque and thus we
> can use any allocation mechanism we like.
> 
> What I also see is that efi_delete_handle() even calls free() on
> objects, so spawning them from efi memory rather than malloc memory is
> also just wrong.

The bit that is missing is to call efi_delete_handle() when the last
protocol interface is uninstalled. Before doing so we must ensure that
no static memory is used and the first element of the handles is an
efi_obj. I did not yet check if we reached that point.

Best regards

Heinrich

> 
> In short, I think your patch is completely correct :).
> 
> 
> Alex
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-03 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-27 14:47 [U-Boot] [PATCH 1/1] efi_loader: create handles from normal memory Heinrich Schuchardt
2018-06-03 13:23 ` Alexander Graf
2018-06-03 14:02   ` Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.