Skip to contentSkip to conversation

efi_loader: enable unaligned access on arm11

PATCH New Heinrich Schuchardt 2 participants 6 messages Nov 19, 2019 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover efi_loader: enable unaligned access on arm11

The UEFI specification mandates that unaligned access must be enabled on systems supporting it.

Function unaligned access is implemented for arm1136 and arm1176. EFI_LOADER is enabled for these architectures.

Heinrich Schuchardt (2):
arm: arm11: allow unaligned memory access
efi_loader: enable EFI_LOADER on arm1136 and arm1176

 arch/arm/cpu/arm11/Makefile |  4 ++++
 arch/arm/cpu/arm11/sctlr.S  | 25 +++++++++++++++++++++++++
 lib/efi_loader/Kconfig      |  6 ++++--
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/cpu/arm11/sctlr.S

--
2.24.0

#1 lore raw

PATCH 1/2 arm: arm11: allow unaligned memory access

The UEFI spec mandates that unaligned memory access should be enabled if supported by the CPU architecture.

This patch implements the function unaligned_access() to set the enable unaligned data support flag and to clear the aligned flag in the system control register (SCTLR). It is called when UEFI related commands like bootefi are invoked.

---
 arch/arm/cpu/arm11/Makefile |  4 ++++
 arch/arm/cpu/arm11/sctlr.S  | 25 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 arch/arm/cpu/arm11/sctlr.S
arch/arm/cpu/arm11/Makefile +4 -0
index 5d721fce12..5dfa01ae8d 100644
@@ -4,3 +4,7 @@
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 
 obj-y	= cpu.o
+
+ifneq ($(CONFIG_SPL_BUILD),y)
+obj-$(CONFIG_EFI_LOADER) += sctlr.o
+endif
arch/arm/cpu/arm11/sctlr.S new file +25 -0
new file mode 100644
index 0000000000..74a7fc4a25
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier:	GPL-2.0+ */
+/*
+ *  Routines to access the system control register
+ *
+ *  Copyright (c) 2019 Heinrich Schuchardt
+ */
+
+#include <linux/linkage.h>
+
+/*
+ * void allow_unaligned(void) - allow unaligned access
+ *
+ * This routine sets the enable unaligned data support flag and clears the
+ * aligned flag in the system control register.
+ * After calling this routine unaligned access does no longer leads to a
+ * data abort or undefined behavior but is handled by the CPU.
+ * For details see the "ARM Architecture Reference Manual" for ARMv6.
+ */
+ENTRY(allow_unaligned)
+	mrc	p15, 0, r0, c1, c0, 0	@ load system control register
+	orr	r0, r0, #1 << 22	@ set unaligned data support flag
+	bic	r0, r0, #2		@ clear aligned flag
+	mcr	p15, 0, r0, c1, c0, 0	@ write system control register
+	bx	lr			@ return
+ENDPROC(allow_unaligned)

--
2.24.0

#2 lore raw

PATCH 2/2 efi_loader: enable EFI_LOADER on arm1136 and arm1176

In reply to Heinrich Schuchardt

With an implementation for allow_unaligned() available for arm1136 and arm1176 UEFI can be supported on these architectures.

---
 lib/efi_loader/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/efi_loader/Kconfig +4 -2
index 2f40e485ef..7984d6f42d 100644
@@ -1,8 +1,10 @@
 config EFI_LOADER
 	bool "Support running UEFI applications"
 	depends on OF_LIBFDT && ( \
-		ARM && (SYS_CPU = armv7 || \
-			SYS_CPU = armv8) || \
+		ARM && (SYS_CPU = arm1136 || \
+			SYS_CPU = arm1176 || \
+			SYS_CPU = armv7   || \
+			SYS_CPU = armv8)  || \
 		X86 || RISCV || SANDBOX)
 	# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT

--
2.24.0

#3 lore raw

PATCH 2/2 efi_loader: enable EFI_LOADER on arm1136 and arm1176

Quoted 15 lines · Heinrich Schuchardt

With an implementation for allow_unaligned() available for arm1136 and arm1176 UEFI can be supported on these architectures.

---
 lib/efi_loader/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/efi_loader/Kconfig +0 -0
index 2f40e485ef..7984d6f42d 100644
@@ -1,8 +1,10 @@
 config EFI_LOADER
 	bool "Support running UEFI applications"

lib/efi_loader/Kconfig line 10

Quoted 10 lines
lib/efi_loader/Kconfig +4 -2
 	depends on OF_LIBFDT && ( \
-		ARM && (SYS_CPU = armv7 || \
-			SYS_CPU = armv8) || \
+		ARM && (SYS_CPU = arm1136 || \
+			SYS_CPU = arm1176 || \
+			SYS_CPU = armv7   || \
+			SYS_CPU = armv8)  || \
 		X86 || RISCV || SANDBOX)
 	# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT

My concern is that while it's good and important we're correcting the dependencies for ARM, non-ARMv7 hardware is much more legacy than new design and we maybe don't want to have it enabled by default there. One of the biggest pieces of feedback I have gotten over the overall EFI support is that it being on by default on legacy systems causes a lot of unwanted size growth. Does Kconfig work sanely with something like:

	default y if !ARM
	default y if ARM && (SYS_CPU = armv7 || SYS_CPU == arv8)

? Then we could allow other older ARM systems to enable it still and now function (again, good work) without the size growth by default. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191119/d3080d1f/attachment.sig>
#4 lore raw

PATCH 2/2 efi_loader: enable EFI_LOADER on arm1136 and arm1176

Quoted 33 lines · Tom Rini
Quoted 15 lines · Heinrich Schuchardt

With an implementation for allow_unaligned() available for arm1136 and arm1176 UEFI can be supported on these architectures.

---
  lib/efi_loader/Kconfig | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
lib/efi_loader/Kconfig +0 -0
index 2f40e485ef..7984d6f42d 100644
@@ -1,8 +1,10 @@
  config EFI_LOADER
  	bool "Support running UEFI applications"

lib/efi_loader/Kconfig line 10

Quoted 10 lines
lib/efi_loader/Kconfig +4 -2
  	depends on OF_LIBFDT && ( \
-		ARM && (SYS_CPU = armv7 || \
-			SYS_CPU = armv8) || \
+		ARM && (SYS_CPU = arm1136 || \
+			SYS_CPU = arm1176 || \
+			SYS_CPU = armv7   || \
+			SYS_CPU = armv8)  || \
  		X86 || RISCV || SANDBOX)
  	# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
  	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT

My concern is that while it's goodk and important we're correcting the dependencies for ARM, non-ARMv7 hardware is much more legacy than new design and we maybe don't want to have it enabled by default there. One of the biggest pieces of feedback I have gotten over the overall EFI support is that it being on by default on legacy systems causes a lot of unwanted size growth. Does Kconfig work sanely with something like:

Quoted 5 lines
	default y if !ARM
	default y if ARM && (SYS_CPU = armv7 || SYS_CPU == arv8)

? Then we could allow other older ARM systems to enable it still and now function (again, good work) without the size growth by default. Thanks!

These are the only ARM11 boards:

evb-ast2500_defconfig
flea3_defconfig
integratorcp_cm1136_defconfig
mx31pdk_defconfig
mx35pdk_defconfig
rpi_0_w_defconfig
rpi_defconfig
woodburn_defconfig
woodburn_sd_defconfig

Which one poses a problem?

Best regards

Heinrich

#5 lore raw

PATCH 2/2 efi_loader: enable EFI_LOADER on arm1136 and arm1176

Quoted 52 lines · Heinrich Schuchardt
Quoted 33 lines · Tom Rini
Quoted 15 lines · Heinrich Schuchardt

With an implementation for allow_unaligned() available for arm1136 and arm1176 UEFI can be supported on these architectures.

---
  lib/efi_loader/Kconfig | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
lib/efi_loader/Kconfig +0 -0
index 2f40e485ef..7984d6f42d 100644
@@ -1,8 +1,10 @@
  config EFI_LOADER
  	bool "Support running UEFI applications"

lib/efi_loader/Kconfig line 10

Quoted 10 lines
lib/efi_loader/Kconfig +4 -2
  	depends on OF_LIBFDT && ( \
-		ARM && (SYS_CPU = armv7 || \
-			SYS_CPU = armv8) || \
+		ARM && (SYS_CPU = arm1136 || \
+			SYS_CPU = arm1176 || \
+			SYS_CPU = armv7   || \
+			SYS_CPU = armv8)  || \
  		X86 || RISCV || SANDBOX)
  	# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
  	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT

My concern is that while it's goodk and important we're correcting the dependencies for ARM, non-ARMv7 hardware is much more legacy than new design and we maybe don't want to have it enabled by default there. One of the biggest pieces of feedback I have gotten over the overall EFI support is that it being on by default on legacy systems causes a lot of unwanted size growth. Does Kconfig work sanely with something like:

Quoted 5 lines
	default y if !ARM
	default y if ARM && (SYS_CPU = armv7 || SYS_CPU == arv8)

? Then we could allow other older ARM systems to enable it still and now function (again, good work) without the size growth by default. Thanks!

These are the only ARM11 boards:

evb-ast2500_defconfig
flea3_defconfig
integratorcp_cm1136_defconfig
mx31pdk_defconfig
mx35pdk_defconfig
rpi_0_w_defconfig
rpi_defconfig
woodburn_defconfig
woodburn_sd_defconfig

Quoted 1 line

Which one poses a problem?

Of those, I would assume the two Pi boards might opt-in, maybe the aspeed board and not the rest.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191119/868c137e/attachment.sig>