[U-Boot] [PATCH v2 1/3] efi_loader: allow unaligned memory access

Alexander Graf agraf at suse.de
Wed Apr 4 12:32:42 UTC 2018



On 03.04.18 21:59, Heinrich Schuchardt wrote:
> The UEFI spec mandates that unaligned memory access should be enabled if
> supported by the CPU architecture.
> 
> This patch adds an empty weak function unaligned_access() that can be
> overridden by an architecture specific routine.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>  cmd/bootefi.c                   | 13 +++++++++++++
>  include/asm-generic/unaligned.h |  3 +++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index ba258ac9f3..412e6519ba 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -18,6 +18,7 @@
>  #include <memalign.h>
>  #include <asm/global_data.h>
>  #include <asm-generic/sections.h>
> +#include <asm-generic/unaligned.h>
>  #include <linux/linkage.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -89,6 +90,15 @@ out:
>  	return ret;
>  }
>  
> +/*
> + * Allow unaligned memory access.
> + *
> + * This routine is overridden by architectures providing this feature.
> + */
> +void __weak allow_unaligned(void)
> +{
> +}
> +

I'd prefer to guard the body of the function with an #ifdef CONFIG_ARM
so everyone knows why it's there. Then call straight into a function
provided in the ARM core code:

static void allow_unaligned(void)
{
/* On ARM we prohibit unaligned accesses by default, enable them here */
#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64) &&
!defined(CONFIG_CPU_V7M)
  mmu_enable_unaligned();
#endif
}

And then in arch/arm/lib/cache-cp15.c:

void mmu_enable_unaligned(void)
{
  set_cr(get_cr() & ~CR_A);
}

I basically want to make sure this is as explicit as it gets :).


Alex


More information about the U-Boot mailing list