From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: Re: [PATCH 7/7] efi: write volatile EFI variables used by systemd
Date: Fri, 17 Jul 2015 09:19:49 +0200 [thread overview]
Message-ID: <20150717071949.GN18700@pengutronix.de> (raw)
In-Reply-To: <20150717070540.GB26620@pengutronix.de>
On Fri, Jul 17, 2015 at 09:05:40AM +0200, Michael Olbrich wrote:
> On Thu, Jul 16, 2015 at 10:08:48PM +0200, Sascha Hauer wrote:
> > On Thu, Jul 16, 2015 at 10:43:56AM +0200, Michael Olbrich wrote:
> > > LoaderTimeInitUSec and LoaderTimeExecUSec are used e.g. in systemd-analyze
> > > to calculate the time spent in the firmare and barebox.
> > >
> > > LoaderDevicePartUUID is used to mount the EFI partition to /boot.
> > >
> > > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> > > ---
> > > arch/efi/efi/efi-image.c | 5 +++++
> > > arch/efi/efi/efi.c | 14 ++++++++++++++
> > > common/efi-guid.c | 1 +
> > > include/efi.h | 5 +++++
> > > 4 files changed, 25 insertions(+)
> > >
> > > diff --git a/arch/efi/efi/efi-image.c b/arch/efi/efi/efi-image.c
> > > index f41322744bbc..89b712baab1f 100644
> > > --- a/arch/efi/efi/efi-image.c
> > > +++ b/arch/efi/efi/efi-image.c
> > > @@ -17,6 +17,7 @@
> > > *
> > > */
> > >
> > > +#include <clock.h>
> > > #include <common.h>
> > > #include <linux/sizes.h>
> > > #include <memory.h>
> > > @@ -242,6 +243,10 @@ static int do_bootm_efi(struct image_data *data)
> > > boot_header->ramdisk_image);
> > > printf("...\n");
> > > }
> > > +
> > > + efi_set_variable_usec("LoaderTimeExecUSec", &efi_systemd_vendor_guid,
> > > + get_time_ns()/1000);
> > > +
> > > linux_efi_handover(handle, boot_header);
> > >
> > > return 0;
> > > diff --git a/arch/efi/efi/efi.c b/arch/efi/efi/efi.c
> > > index b0e98f95b02b..a665a546be90 100644
> > > --- a/arch/efi/efi/efi.c
> > > +++ b/arch/efi/efi/efi.c
> > > @@ -340,6 +340,7 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table)
> > > efi_physical_addr_t mem;
> > > size_t memsize;
> > > efi_status_t efiret;
> > > + char *uuid;
> > >
> > > #ifdef DEBUG
> > > sys_table->con_out->output_string(sys_table->con_out, L"barebox\n");
> > > @@ -377,6 +378,19 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table)
> > > mem_malloc_init((void *)mem, (void *)mem + memsize);
> > >
> > > efi_clocksource_init();
> > > + efi_set_variable_usec("LoaderTimeInitUSec", &efi_systemd_vendor_guid,
> > > + get_time_ns()/1000);
> > > +
> > > + uuid = device_path_to_partuuid(device_path_from_handle(
> > > + efi_loaded_image->device_handle));
> > > + if (uuid) {
> > > + wchar_t *uuid16 = strdup_char_to_wchar(uuid);
> > > + efi_set_variable("LoaderDevicePartUUID",
> > > + &efi_systemd_vendor_guid,
> > > + EFI_VARIABLE_BOOTSERVICE_ACCESS |
> > > + EFI_VARIABLE_RUNTIME_ACCESS,
> > > + uuid16, (strlen(uuid)+1) * sizeof(wchar_t));
> > > + }
> >
> > Shouldn't you free uuid here?
>
> Yes, and uuid16.
>
> Hmmm, what's the policy for OOM checks for string functions? None of the
> existing calls of strdup_char_to_wchar() check for NULL. And I didn't find
> any checks for asprintf() either.
Introducing xasprintf and using it throughout the tree is on my mental
todo list for some time now. I think You can skip the error check, or,
even better, introduce xasprintf ;)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2015-07-17 7:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 8:43 [PATCH 0/7] EFI updates Michael Olbrich
2015-07-16 8:43 ` [PATCH 1/7] efi: improve malloc pool allocation Michael Olbrich
2015-07-16 8:43 ` [PATCH 2/7] efi: refactor & improve application loading code Michael Olbrich
2015-07-16 8:43 ` [PATCH 3/7] efi: add support for initrd loading Michael Olbrich
2015-07-16 8:43 ` [PATCH 4/7] efi: add helper to get the GPT partition UUID for a device Michael Olbrich
2015-07-16 9:34 ` Marc Kleine-Budde
2015-07-16 9:43 ` Michael Olbrich
2015-07-16 8:43 ` [PATCH 5/7] efi: export device_path_from_handle() Michael Olbrich
2015-07-16 8:43 ` [PATCH 6/7] efi: add helper functions to write EFI variables Michael Olbrich
2015-07-16 8:43 ` [PATCH 7/7] efi: write volatile EFI variables used by systemd Michael Olbrich
2015-07-16 20:08 ` Sascha Hauer
2015-07-17 7:05 ` Michael Olbrich
2015-07-17 7:19 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150717071949.GN18700@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox