All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Stuart.Yoder@arm.com, paul.liu@linaro.org, u-boot@lists.denx.de
Subject: Re: [PATCH v2] efi_loader: Set variable attributes when EFI_BUFFER_TOO_SMALL is returned
Date: Wed, 16 Mar 2022 17:08:04 +0100	[thread overview]
Message-ID: <10c0b89a-16fe-88a1-fbfd-4e005a2741b6@gmx.de> (raw)
In-Reply-To: <20220316151337.1497396-1-ilias.apalodimas@linaro.org>

On 3/16/22 16:13, Ilias Apalodimas wrote:
> Starting UEFI Spec 2.8 we must fill in the variable attributes when
> GetVariable() returns EFI_BUFFER_TOO_SMALL and Attributes is non-NULL.
>
> This code was written with 2.7 in mind so let's move the code around a
> bit and fill in the attributes EFI_BUFFER_TOO_SMALL is returned
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
> Changes since v1:
> - tmp variables  switched to efi_status_t instead of int
> - switched (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL)
>    to (ret != EFI_SUCCESS && ret != EFI_BUFFER_TOO_SMALL) to
>    make the code easier to read
> - Only call get_property_int() if attributes != NULL
>
>   lib/efi_loader/efi_variable_tee.c | 31 ++++++++++++++++++++-----------
>   1 file changed, 20 insertions(+), 11 deletions(-)
>
> diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
> index 58931c4efd74..dfef18435dfa 100644
> --- a/lib/efi_loader/efi_variable_tee.c
> +++ b/lib/efi_loader/efi_variable_tee.c
> @@ -368,7 +368,7 @@ efi_status_t efi_get_variable_int(const u16 *variable_name,
>   	efi_uintn_t name_size;
>   	efi_uintn_t tmp_dsize;
>   	u8 *comm_buf = NULL;
> -	efi_status_t ret;
> +	efi_status_t ret, tmp;
>
>   	if (!variable_name || !vendor || !data_size) {
>   		ret = EFI_INVALID_PARAMETER;
> @@ -407,23 +407,32 @@ efi_status_t efi_get_variable_int(const u16 *variable_name,
>
>   	/* Communicate */
>   	ret = mm_communicate(comm_buf, payload_size);
> -	if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) {
> -		/* Update with reported data size for trimmed case */
> -		*data_size = var_acc->data_size;
> -	}
> -	if (ret != EFI_SUCCESS)
> -		goto out;
> -
> -	ret = get_property_int(variable_name, name_size, vendor, &var_property);
> -	if (ret != EFI_SUCCESS)
> +	if (ret != EFI_SUCCESS && ret != EFI_BUFFER_TOO_SMALL)
>   		goto out;
>
> +	/* Update with reported data size for trimmed case */
> +	*data_size = var_acc->data_size;
> +	/*
> +	 * UEFI > 2.7 needs the attributes set even if the buffer is
> +	 * smaller
> +	 */
>   	if (attributes) {
> +		tmp = get_property_int(variable_name, name_size, vendor,
> +				       &var_property);
> +		if (tmp != EFI_SUCCESS) {
> +			ret = tmp;
> +			goto out;
> +		}
>   		*attributes = var_acc->attr;
> -		if (var_property.property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY)
> +		if (var_property.property &
> +		    VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY)
>   			*attributes |= EFI_VARIABLE_READ_ONLY;
>   	}
>
> +	/* return if ret is EFI_BUFFER_TOO_SMALL */
> +	if (ret != EFI_SUCCESS)
> +		goto out;
> +
>   	if (data)
>   		memcpy(data, (u8 *)var_acc->name + var_acc->name_size,
>   		       var_acc->data_size);


      reply	other threads:[~2022-03-16 16:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 15:13 [PATCH v2] efi_loader: Set variable attributes when EFI_BUFFER_TOO_SMALL is returned Ilias Apalodimas
2022-03-16 16:08 ` Heinrich Schuchardt [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=10c0b89a-16fe-88a1-fbfd-4e005a2741b6@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=Stuart.Yoder@arm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=paul.liu@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.