[PATCH] ARM64: support reserving the x18 platform register

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Dec 15 00:47:10 PST 2025


Linux helpfully complained about "register x18 corrupted by EFI" with
the upcoming EFI loader support as this register is apparently the
platform register and is meant to be usable by the OS without other
firmware like the EFI runtime services clobbering it.

Provide a hidden AAPCS64 symbol that will be usable for this purpose.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/arm/Kconfig  | 11 +++++++++++
 arch/arm/Makefile |  1 +
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index afa6de3cd0b1..d2d81a4f90d6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -313,6 +313,17 @@ config AEABI
 
 	  To use this you need GCC version 4.0.0 or later.
 
+config AAPCS64
+	bool "Observe ARM64 Procedure Call Standard" if COMPILE_TEST
+	depends on CPU_V8
+	help
+	  This option instructs barebox to observe the AAPCS64 for
+	  interoperability with other firmware.
+
+	  The only effect this currently has is reserving x18 (the
+	  platform register), so Linux can call back into a barebox
+	  EFI runtime service without it getting clobbered.
+
 config THUMB2_BAREBOX
 	select AEABI
 	depends on !ARCH_TEGRA && !ARCH_AT91
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index d6ae6b648f65..4d84f3bf9c72 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -68,6 +68,7 @@ CFLAGS_ABI-$(CONFIG_CPU_32)	:=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call
 CFLAGS_ABI-$(CONFIG_AEABI)	:=-mabi=aapcs-linux
 
 CFLAGS_ABI-$(CONFIG_ARM_UNWIND)	+=-funwind-tables
+CFLAGS_ABI-$(CONFIG_AAPCS64)	+=-ffixed-x18
 
 ifeq ($(CONFIG_THUMB2_BAREBOX),y)
 AFLAGS_AUTOIT	:=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it)
-- 
2.47.3




More information about the barebox mailing list