[PATCH] MIPS: Octeon: byteswap initramfs in little endian mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The initramfs if loaded in memory by U-Boot running in big endian mode.
When the kernel is running in little endian mode, we need to byteswap it
as it is accessed byte by byte.

Cc: David Daney <david.daney@xxxxxxxxxx>
Signed-off-by: Aurelien Jarno <aurelien@xxxxxxxxxxx>
---
 arch/mips/kernel/setup.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Note: It might not be the best place to byteswap the initramfs not the
best way to do it. At least it shows the problem and what shoudl be done.
Suggestions to improve the patch are welcome.

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 4f60734..e7d015e 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -263,6 +263,16 @@ static void __init finalize_initrd(void)
 		goto disable;
 	}
 
+#if defined(CONFIG_CPU_CAVIUM_OCTEON) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+	{
+		unsigned long i;
+		pr_info("Cavium Octeon kernel in little endian mode "
+			"detected, byteswapping ramdisk\n");
+		for (i = initrd_start; i < ALIGN(initrd_end, 8); i += 8)
+			*((unsigned long *)i) = swab64(*((unsigned long *)i));
+	}
+#endif
+
 	reserve_bootmem(__pa(initrd_start), size, BOOTMEM_DEFAULT);
 	initrd_below_start_ok = 1;
 
-- 
2.8.1





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux