diff mbox

[2/8] arm64/kernel: reuse boot_args array to get to __fdt_pointer

Message ID 1459781544-14310-3-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel April 4, 2016, 2:52 p.m. UTC
Since we record the boot_args [x0 .. x3] early at boot anyway, there is
no need to keep the FDT address in a callee saved register with file scope
in head.S. So simply refer to boot_args[0] directly in the call to
setup_machine(), and drop the handling of x21 from head.S entirely.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 arch/arm64/kernel/head.S  | 14 ++++++--------
 arch/arm64/kernel/setup.c |  4 +---
 2 files changed, 7 insertions(+), 11 deletions(-)

-- 
2.5.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Comments

Ard Biesheuvel April 4, 2016, 3:19 p.m. UTC | #1
On 4 April 2016 at 17:13, James Morse <james.morse@arm.com> wrote:
> Hi Ard,

>

> On 04/04/16 15:52, Ard Biesheuvel wrote:

>> Since we record the boot_args [x0 .. x3] early at boot anyway, there is

>> no need to keep the FDT address in a callee saved register with file scope

>> in head.S. So simply refer to boot_args[0] directly in the call to

>> setup_machine(), and drop the handling of x21 from head.S entirely.

>

> Won't this break Big Endian?

> (or more accurately: bootloader-endian != kernel-endian)

>

> The stores in preserve_boot_args happen before the EE/E0E bits have been

> set/cleared by el2_setup(), so they happen with boot-loader:endianness. The

> loads after el2_setup() happen with kernel:endianness.

>


That is a very good point.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Ard Biesheuvel April 5, 2016, 11:09 a.m. UTC | #2
On 4 April 2016 at 17:19, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> On 4 April 2016 at 17:13, James Morse <james.morse@arm.com> wrote:

>> Hi Ard,

>>

>> On 04/04/16 15:52, Ard Biesheuvel wrote:

>>> Since we record the boot_args [x0 .. x3] early at boot anyway, there is

>>> no need to keep the FDT address in a callee saved register with file scope

>>> in head.S. So simply refer to boot_args[0] directly in the call to

>>> setup_machine(), and drop the handling of x21 from head.S entirely.

>>

>> Won't this break Big Endian?

>> (or more accurately: bootloader-endian != kernel-endian)

>>

>> The stores in preserve_boot_args happen before the EE/E0E bits have been

>> set/cleared by el2_setup(), so they happen with boot-loader:endianness. The

>> loads after el2_setup() happen with kernel:endianness.

>>

>

> That is a very good point.


I think it would not be unreasonable to factor out the configuration
of the endianness at the current exception level, and invoke it first
before recording the boot args, since we now rely on el2_setup() to do
that. That would also fix the 'bug' where the boot_args are recorded
in the endianness of the bootloader, although I doubt anyone cares
deeply about that one.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff mbox

Patch

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 69b33535911e..9d8f928c355c 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -234,16 +234,15 @@  ENDPROC(stext)
  * Preserve the arguments passed by the bootloader in x0 .. x3
  */
 preserve_boot_args:
-	mov	x21, x0				// x21=FDT
-
-	adr_l	x0, boot_args			// record the contents of
-	stp	x21, x1, [x0]			// x0 .. x3 at kernel entry
-	stp	x2, x3, [x0, #16]
+	adr_l	x4, boot_args			// record the contents of
+	stp	x0, x1, [x4]			// x0 .. x3 at kernel entry
+	stp	x2, x3, [x4, #16]
 
 	dmb	sy				// needed before dc ivac with
 						// MMU off
 
-	add	x1, x0, #0x20			// 4 x 8 bytes
+	mov	x0, x4
+	add	x1, x4, #0x20			// 4 x 8 bytes
 	b	__inval_cache_range		// tail call
 ENDPROC(preserve_boot_args)
 
@@ -480,7 +479,6 @@  __mmap_switched:
 	mov	x4, sp
 	and	x4, x4, #~(THREAD_SIZE - 1)
 	msr	sp_el0, x4			// Save thread_info
-	str_l	x21, __fdt_pointer, x5		// Save FDT pointer
 
 	ldr_l	x4, kimage_vaddr		// Save the offset between
 	sub	x4, x4, x24			// the kernel virtual and
@@ -492,7 +490,7 @@  __mmap_switched:
 #endif
 #ifdef CONFIG_RANDOMIZE_BASE
 	cbnz	x23, 0f				// already running randomized?
-	mov	x0, x21				// pass FDT address in x0
+	ldr_l	x0, boot_args			// pass FDT address in x0
 	bl	kaslr_early_init		// parse FDT for KASLR options
 	cbz	x0, 0f				// KASLR disabled? just proceed
 	mov	x23, x0				// record KASLR offset
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 9dc67769b6a4..83a3e484a90a 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -64,8 +64,6 @@ 
 #include <asm/xen/hypervisor.h>
 #include <asm/mmu_context.h>
 
-phys_addr_t __fdt_pointer __initdata;
-
 /*
  * Standard memory resources
  */
@@ -304,7 +302,7 @@  void __init setup_arch(char **cmdline_p)
 	early_fixmap_init();
 	early_ioremap_init();
 
-	setup_machine_fdt(__fdt_pointer);
+	setup_machine_fdt(boot_args[0]);
 
 	parse_early_param();