All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] disk: fix unaligned access in efi partitions
Date: Fri, 29 Mar 2013 13:32:26 +0100	[thread overview]
Message-ID: <20130329133226.3483be02@lilith> (raw)
In-Reply-To: <6ff0548717babcbc52d225394549106e659cc303.1364556523.git.marvin24@gmx.de>

Hi Marc,

On Fri, 29 Mar 2013 12:28:58 +0100, Marc Dietrich <marvin24@gmx.de>
wrote:

> start_sect is not aligned to a 4 byte boundary thus causing exceptions
> on ARM platforms. Access this field via the get_unaligned macro.
> 
> Signed-off-by: Marc Dietrich <marvin24@gmx.de>
> ---
>  disk/part_efi.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index b3fd0e9..6678a4c 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -30,6 +30,7 @@
>   *
>   * This limits the maximum size of addressable storage to < 2 Terra Bytes
>   */
> +#include <asm/unaligned.h>
>  #include <common.h>
>  #include <command.h>
>  #include <ide.h>
> @@ -505,7 +506,7 @@ err:
>  static int pmbr_part_valid(struct partition *part)
>  {
>  	if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT &&
> -		le32_to_cpu(part->start_sect) == 1UL) {
> +		le32_to_cpu(get_unaligned(&part->start_sect)) == 1UL) {
>  		return 1;
>  	}

Suits me :) but did you not say the same issue was also affecting
nr_sects?

Also, beside the asm/unaligned.h file I gave as an example, other header
files in include/linux/unaligned/ exist that provide alignment-related
macros, notably with _le and _be versions. Maybe you can find one that
combines the effects of both le32_to_cpu() and get_unaligned()?

Amicalement,
-- 
Albert.

  reply	other threads:[~2013-03-29 12:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-29 11:28 [U-Boot] [PATCH] disk: fix unaligned access in efi partitions Marc Dietrich
2013-03-29 12:32 ` Albert ARIBAUD [this message]
2013-03-29 15:13   ` Marc Dietrich
2013-03-29 15:57     ` Stephen Warren

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=20130329133226.3483be02@lilith \
    --to=albert.u.boot@aribaud.net \
    --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.