From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Fri, 11 Oct 2013 18:00:30 +0200 Subject: [U-Boot] [PATCH] disk:efi: avoid unaligned access on efi partition In-Reply-To: <1381498270-24342-1-git-send-email-p.wilczek@samsung.com> References: <1381498270-24342-1-git-send-email-p.wilczek@samsung.com> Message-ID: <20131011180030.5937d351@lilith> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Piotr, On Fri, 11 Oct 2013 15:31:10 +0200, Piotr Wilczek wrote: > In this patch static variable and memcpy instead of an assignment > are used to avoid unaligned access exception on some ARM platforms. > > Signed-off-by: Piotr Wilczek > Signed-off-by: Kyungmin Park > CC: Tom Rini > --- > disk/part_efi.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/disk/part_efi.c b/disk/part_efi.c > index b7524d6..303b8af 100644 > --- a/disk/part_efi.c > +++ b/disk/part_efi.c > @@ -224,7 +224,8 @@ static int set_protective_mbr(block_dev_desc_t *dev_desc) > p_mbr->signature = MSDOS_MBR_SIGNATURE; > p_mbr->partition_record[0].sys_ind = EFI_PMBR_OSTYPE_EFI_GPT; > p_mbr->partition_record[0].start_sect = 1; > - p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba; > + memcpy(&p_mbr->partition_record[0].nr_sects, &dev_desc->lba, > + sizeof(dev_desc->lba)); > > /* Write MBR sector to the MMC device */ > if (dev_desc->block_write(dev_desc->dev, 0, 1, p_mbr) != 1) { > @@ -387,8 +388,9 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e, > gpt_e[i].ending_lba = cpu_to_le64(offset - 1); > > /* partition type GUID */ > + static efi_guid_t basic_guid = PARTITION_BASIC_DATA_GUID; > memcpy(gpt_e[i].partition_type_guid.b, > - &PARTITION_BASIC_DATA_GUID, 16); > + &basic_guid, 16); Usually, an all-caps symbol is a macro, which makes taking its address a no-no. Besides, doing a memcpy() for 32-bit quantities seems like overkill for me. Any reason you cannot simply use asm/unaligned.h and either get_unaligned or put_unaligned depending on where the alignment issue lies? > #ifdef CONFIG_PARTITION_UUIDS > str_uuid = partitions[i].uuid; Amicalement, -- Albert.