All of lore.kernel.org
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 2/6] efi: add RuntimeServicesSupported variable
Date: Thu, 13 Jun 2019 16:06:14 +0900	[thread overview]
Message-ID: <20190613070613.GC15190@linaro.org> (raw)
In-Reply-To: <68c416d1-6bbf-83fe-979e-cb654e669ef6@gmx.de>

On Thu, Jun 13, 2019 at 07:56:19AM +0200, Heinrich Schuchardt wrote:
> 
> 
> On 6/5/19 6:21 AM, AKASHI Takahiro wrote:
> > This variable is defined in UEFI specification 2.8, section 8.1.
> > Its value should be updated whenever we add any usable runtime services
> > function.
> 
> It is also required by the EBBR specification.
> 
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  include/efi_api.h            | 15 +++++++++++++++
> >  include/efi_loader.h         |  3 +++
> >  lib/efi_loader/efi_runtime.c | 28 ++++++++++++++++++++++++++++
> >  lib/efi_loader/efi_setup.c   |  5 +++++
> >  4 files changed, 51 insertions(+)
> >
> > diff --git a/include/efi_api.h b/include/efi_api.h
> > index 65584dd2d82a..d7d95edd4dfc 100644
> > --- a/include/efi_api.h
> > +++ b/include/efi_api.h
> > @@ -213,6 +213,21 @@ struct efi_capsule_header {
> >  	u32 capsule_image_size;
> >  };
> >
> > +#define EFI_RT_SUPPORTED_GET_TIME			0x0001
> > +#define EFI_RT_SUPPORTED_SET_TIME			0x0002
> > +#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME		0x0004
> > +#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME		0x0008
> > +#define EFI_RT_SUPPORTED_GET_VARIABLE			0x0010
> > +#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME		0x0020
> > +#define EFI_RT_SUPPORTED_SET_VARIABLE			0x0040
> > +#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP	0x0080
> > +#define EFI_RT_SUPPORTED_CONVERT_POINTER		0x0100
> > +#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT	0x0200
> > +#define EFI_RT_SUPPORTED_RESET_SYSTEM			0x0400
> > +#define EFI_RT_SUPPORTED_UPDATE_CAPSULE			0x0800
> > +#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES	0x1000
> > +#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO		0x2000
> > +
> >  struct efi_runtime_services {
> >  	struct efi_table_hdr hdr;
> >  	efi_status_t (EFIAPI *get_time)(struct efi_time *time,
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index 23ce73226762..7bd8002e303e 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -573,6 +573,9 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2)
> >  #define __efi_runtime_data __attribute__ ((section (".data.efi_runtime")))
> >  #define __efi_runtime __attribute__ ((section (".text.efi_runtime")))
> >
> > +/* Indicate supported runtime services */
> > +efi_status_t efi_init_runtime_supported(void);
> > +
> >  /* Update CRC32 in table header */
> >  void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table);
> >
> > diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> > index 60442cb21d37..cf202bb9ec07 100644
> > --- a/lib/efi_loader/efi_runtime.c
> > +++ b/lib/efi_loader/efi_runtime.c
> > @@ -89,6 +89,34 @@ struct elf_rela {
> >   * handle a good number of runtime callbacks
> >   */
> >
> > +efi_status_t efi_init_runtime_supported(void)
> > +{
> > +	u16 efi_runtime_services_supported;
> > +
> > +	/*
> > +	 * This value must be synced with efi_runtime_detach_list
> > +	 * as well as efi_runtime_services.
> > +	 */
> > +	efi_runtime_services_supported = EFI_RT_SUPPORTED_RESET_SYSTEM;
> 
> This support is system dependent, e.g. on RK3288 systems it does not exist.

efi_reset_system() is defined as a weak function and so
there is no easy way to determine whether this API is supported or not.

> > +#ifdef CONFIG_EFI_GET_TIME
> > +	efi_runtime_services_supported |= EFI_RT_SUPPORTED_GET_TIME;
> 
> We do not support this at runtime.

Okay, I will drop it.

> > +#endif
> > +#ifdef CONFIG_EFI_SET_TIME
> > +	efi_runtime_services_supported |= EFI_RT_SUPPORTED_SET_TIME;
> 
> We do not support this at runtime.

ditto

> > +#endif
> > +#ifdef CONFIG_EFI_RUNTIME_SET_VIRTUAL_ADDRESS_MAP
> > +	efi_runtime_services_supported |=
> > +				EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP;
> 
> Our support is incomplete as we have not implemented ConvertPointer().

Incomplete?
My patch#3 adds ConvertPointer().

-Takahiro Akashi

> For unsupported services we will have to change the return value to
> EFI_UNSUPPORTED. But that will be a separate patch.
> 
> Best regards
> 
> Heinrich
> 
> > +#endif
> > +
> > +	return EFI_CALL(efi_set_variable(L"RuntimeServicesSupported",
> > +					 &efi_global_variable_guid,
> > +					 EFI_VARIABLE_BOOTSERVICE_ACCESS |
> > +					 EFI_VARIABLE_RUNTIME_ACCESS,
> > +					 sizeof(efi_runtime_services_supported),
> > +					 &efi_runtime_services_supported));
> > +}
> > +
> >  /**
> >   * efi_update_table_header_crc32() - Update crc32 in table header
> >   *
> > diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
> > index 45d6aca051f3..75fa344060d5 100644
> > --- a/lib/efi_loader/efi_setup.c
> > +++ b/lib/efi_loader/efi_setup.c
> > @@ -123,6 +123,11 @@ efi_status_t efi_init_obj_list(void)
> >  	if (ret != EFI_SUCCESS)
> >  		goto out;
> >
> > +	/* Indicate supported runtime services */
> > +	ret = efi_init_runtime_supported();
> > +	if (ret != EFI_SUCCESS)
> > +		goto out;
> > +
> >  	/* Initialize system table */
> >  	ret = efi_initialize_system_table();
> >  	if (ret != EFI_SUCCESS)
> >

  reply	other threads:[~2019-06-13  7:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05  4:21 [U-Boot] [RFC 0/6] efi_loader: support runtime variable access via cache AKASHI Takahiro
2019-06-05  4:21 ` [U-Boot] [RFC 1/6] efi_loader: runtime: make SetVirtualAddressMap configurable AKASHI Takahiro
2019-06-15 19:46   ` Heinrich Schuchardt
2019-06-15 21:14     ` Mark Kettenis
2019-06-16 21:52       ` Heinrich Schuchardt
2019-06-18 18:11         ` Mark Kettenis
2019-06-17  1:05     ` AKASHI Takahiro
2019-06-05  4:21 ` [U-Boot] [RFC 2/6] efi: add RuntimeServicesSupported variable AKASHI Takahiro
2019-06-13  5:56   ` Heinrich Schuchardt
2019-06-13  7:06     ` AKASHI Takahiro [this message]
2019-06-13  9:17       ` Heinrich Schuchardt
2019-06-13  9:21         ` Heinrich Schuchardt
2019-06-05  4:21 ` [U-Boot] [RFC 3/6] efi_loader: support convert_pointer at runtime AKASHI Takahiro
2019-06-15 19:41   ` Heinrich Schuchardt
2019-06-17  1:15     ` AKASHI Takahiro
2019-06-17  5:41       ` Heinrich Schuchardt
2019-07-13  6:16         ` Heinrich Schuchardt
2019-06-05  4:21 ` [U-Boot] [RFC 4/6] efi_loader: Patch non-runtime code out at ExitBootServices already AKASHI Takahiro
2019-06-05  4:21 ` [U-Boot] [RFC 5/6] cmd: efidebug: add "boot exit" sub-command AKASHI Takahiro
2019-06-05  4:21 ` [U-Boot] [RFC 6/6] efi_loader: variable: support runtime variable access via cache AKASHI Takahiro
2019-06-15 19:01   ` Heinrich Schuchardt
2019-06-17  1:51     ` AKASHI Takahiro
2019-06-17 19:52       ` Heinrich Schuchardt
2019-06-18  1:19         ` AKASHI Takahiro
2019-06-18  2:25           ` AKASHI Takahiro
2019-06-18 10:34           ` Ilias Apalodimas
2019-06-18 20:45             ` Heinrich Schuchardt
2019-06-19  1:25               ` AKASHI Takahiro
2019-06-19  5:13                 ` Ilias Apalodimas
2019-06-19  6:24                   ` Heinrich Schuchardt
2019-06-19  7:07                     ` AKASHI Takahiro
2019-06-05 10:34 ` [U-Boot] [RFC 0/6] efi_loader: " Heinrich Schuchardt

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=20190613070613.GC15190@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /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 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.