All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeffrey Hugo <jhugo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	takahiro.akashi-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	Sameer Goel <sgoel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Subject: Re: [PATCH v2] efi/libstub/arm*: Set default address and size cells values for an empty dtb
Date: Fri, 24 Feb 2017 07:33:28 -0700	[thread overview]
Message-ID: <34b69972-d5fb-fd86-75eb-319bbfc609a0@codeaurora.org> (raw)
In-Reply-To: <1486502360-18071-1-git-send-email-jhugo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

On 2/7/2017 2:19 PM, Jeffrey Hugo wrote:
> From: Sameer Goel <sgoel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
>
> In cases where a device tree is not provided (ie ACPI based system), an
> empty fdt is generated by efistub.  #address-cells and #size-cells are not
> set in the empty fdt, so they default to 1 (4 byte wide).  This can be an
> issue on 64-bit systems where values representing addresses, etc may be
> 8 bytes wide as the default value does not align with the general
> requirements for an empty DTB, and is fragile when passed to other agents
> as extra care is required to read the entire width of a value.
>
> This issue is observed on Qualcomm Technologies QDF24XX platforms when
> kexec-tools inserts 64-bit addresses into the "linux,elfcorehdr" and
> "linux,usable-memory-range" properties of the fdt.  When the values are
> later consumed, they are truncated to 32-bit.
>
> Setting #address-cells and #size-cells to 2 at creation of the empty fdt
> resolves the observed issue, and makes the fdt less fragile.
>
> Signed-off-by: Sameer Goel <sgoel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
> Signed-off-by: Jeffrey Hugo <jhugo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
> ---

Ping?

>
> [v2]
> -Add braces to an if when the corresponding else has braces
> -Remove print statements
> -Reword commit text
> -Removed gerrit tag
>
>  drivers/firmware/efi/libstub/fdt.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
> index 921dfa0..22ea73b 100644
> --- a/drivers/firmware/efi/libstub/fdt.c
> +++ b/drivers/firmware/efi/libstub/fdt.c
> @@ -16,6 +16,22 @@
>
>  #include "efistub.h"
>
> +#define EFI_DT_ADDR_CELLS_DEFAULT 2
> +#define EFI_DT_SIZE_CELLS_DEFAULT 2
> +
> +static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt)
> +{
> +	int offset;
> +
> +	offset = fdt_path_offset(fdt, "/");
> +	/* Set the #address-cells and #size-cells values for an empty tree */
> +
> +	fdt_setprop_u32(fdt, offset, "#address-cells",
> +			EFI_DT_ADDR_CELLS_DEFAULT);
> +
> +	fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT);
> +}
> +
>  static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
>  			       unsigned long orig_fdt_size,
>  			       void *fdt, int new_fdt_size, char *cmdline_ptr,
> @@ -42,10 +58,18 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
>  		}
>  	}
>
> -	if (orig_fdt)
> +	if (orig_fdt) {
>  		status = fdt_open_into(orig_fdt, fdt, new_fdt_size);
> -	else
> +	} else {
>  		status = fdt_create_empty_tree(fdt, new_fdt_size);
> +		if (status == 0) {
> +			/*
> +			 * Any failure from the following function is non
> +			 * critical
> +			 */
> +			fdt_update_cell_size(sys_table, fdt);
> +		}
> +	}
>
>  	if (status != 0)
>  		goto fdt_set_fail;
>


-- 
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

WARNING: multiple messages have this Message-ID (diff)
From: jhugo@codeaurora.org (Jeffrey Hugo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] efi/libstub/arm*: Set default address and size cells values for an empty dtb
Date: Fri, 24 Feb 2017 07:33:28 -0700	[thread overview]
Message-ID: <34b69972-d5fb-fd86-75eb-319bbfc609a0@codeaurora.org> (raw)
In-Reply-To: <1486502360-18071-1-git-send-email-jhugo@codeaurora.org>

On 2/7/2017 2:19 PM, Jeffrey Hugo wrote:
> From: Sameer Goel <sgoel@codeaurora.org>
>
> In cases where a device tree is not provided (ie ACPI based system), an
> empty fdt is generated by efistub.  #address-cells and #size-cells are not
> set in the empty fdt, so they default to 1 (4 byte wide).  This can be an
> issue on 64-bit systems where values representing addresses, etc may be
> 8 bytes wide as the default value does not align with the general
> requirements for an empty DTB, and is fragile when passed to other agents
> as extra care is required to read the entire width of a value.
>
> This issue is observed on Qualcomm Technologies QDF24XX platforms when
> kexec-tools inserts 64-bit addresses into the "linux,elfcorehdr" and
> "linux,usable-memory-range" properties of the fdt.  When the values are
> later consumed, they are truncated to 32-bit.
>
> Setting #address-cells and #size-cells to 2 at creation of the empty fdt
> resolves the observed issue, and makes the fdt less fragile.
>
> Signed-off-by: Sameer Goel <sgoel@codeaurora.org>
> Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
> ---

Ping?

>
> [v2]
> -Add braces to an if when the corresponding else has braces
> -Remove print statements
> -Reword commit text
> -Removed gerrit tag
>
>  drivers/firmware/efi/libstub/fdt.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
> index 921dfa0..22ea73b 100644
> --- a/drivers/firmware/efi/libstub/fdt.c
> +++ b/drivers/firmware/efi/libstub/fdt.c
> @@ -16,6 +16,22 @@
>
>  #include "efistub.h"
>
> +#define EFI_DT_ADDR_CELLS_DEFAULT 2
> +#define EFI_DT_SIZE_CELLS_DEFAULT 2
> +
> +static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt)
> +{
> +	int offset;
> +
> +	offset = fdt_path_offset(fdt, "/");
> +	/* Set the #address-cells and #size-cells values for an empty tree */
> +
> +	fdt_setprop_u32(fdt, offset, "#address-cells",
> +			EFI_DT_ADDR_CELLS_DEFAULT);
> +
> +	fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT);
> +}
> +
>  static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
>  			       unsigned long orig_fdt_size,
>  			       void *fdt, int new_fdt_size, char *cmdline_ptr,
> @@ -42,10 +58,18 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
>  		}
>  	}
>
> -	if (orig_fdt)
> +	if (orig_fdt) {
>  		status = fdt_open_into(orig_fdt, fdt, new_fdt_size);
> -	else
> +	} else {
>  		status = fdt_create_empty_tree(fdt, new_fdt_size);
> +		if (status == 0) {
> +			/*
> +			 * Any failure from the following function is non
> +			 * critical
> +			 */
> +			fdt_update_cell_size(sys_table, fdt);
> +		}
> +	}
>
>  	if (status != 0)
>  		goto fdt_set_fail;
>


-- 
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

  parent reply	other threads:[~2017-02-24 14:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07 21:19 [PATCH v2] efi/libstub/arm*: Set default address and size cells values for an empty dtb Jeffrey Hugo
2017-02-07 21:19 ` Jeffrey Hugo
     [not found] ` <1486502360-18071-1-git-send-email-jhugo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-02-24 14:33   ` Jeffrey Hugo [this message]
2017-02-24 14:33     ` Jeffrey Hugo
2017-02-24 15:36   ` Robin Murphy
2017-02-24 15:36     ` Robin Murphy
2017-03-02 15:23     ` Goel, Sameer
2017-03-02 15:23       ` Goel, Sameer
     [not found]       ` <9084badb-3340-fdca-9b41-8ab657d4bb15-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-03-08 23:32         ` Timur Tabi
2017-03-08 23:32           ` Timur Tabi
2017-02-24 15:36   ` Mark Rutland
2017-02-24 15:36     ` Mark Rutland
2017-02-24 15:54     ` Jeffrey Hugo
2017-02-24 15:54       ` Jeffrey Hugo
2017-03-02 10:23     ` AKASHI Takahiro
2017-03-02 10:23       ` AKASHI Takahiro
2017-03-02 14:38       ` Timur Tabi
2017-03-02 14:38         ` Timur Tabi

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=34b69972-d5fb-fd86-75eb-319bbfc609a0@codeaurora.org \
    --to=jhugo-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
    --cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=sgoel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=takahiro.akashi-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.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 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.