001-4.2-MIPS-Add-support-for-vmlinux.bin-appended-dtb.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. From 1da8f1798e307fb8422753984339beb00025f97d Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Sun, 12 Apr 2015 12:24:58 +0200
  4. Subject: [PATCH] MIPS: Add support for vmlinux.bin appended dtb
  5. Add support for detecting a vmlinux.bin appended dtb and overriding
  6. the boot arguments to match the UHI interface.
  7. Due to the PERCPU section being empty for !SMP, but still modifying
  8. the current address by aligning it to the page size, do not define
  9. it for !SMP builds to allow __appended_dtb to still point to
  10. the actual end of the data.
  11. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  12. Cc: linux-mips@linux-mips.org
  13. Cc: devicetree@vger.kernel.org
  14. Cc: John Crispin <blogic@openwrt.org>
  15. Cc: Kevin Cernekee <cernekee@gmail.com>
  16. Cc: Florian Fainelli <f.fainelli@gmail.com>
  17. Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
  18. Cc: Markos Chandras <markos.chandras@imgtec.com>
  19. Cc: Andrew Bresticker <abrestic@chromium.org>
  20. Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  21. Cc: Paul Burton <paul.burton@imgtec.com>
  22. Cc: James Hartley <James.Hartley@imgtec.com>
  23. Patchwork: https://patchwork.linux-mips.org/patch/9739/
  24. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  25. ---
  26. arch/mips/Kconfig | 27 +++++++++++++++++++++++++++
  27. arch/mips/kernel/head.S | 16 ++++++++++++++++
  28. arch/mips/kernel/vmlinux.lds.S | 8 +++++++-
  29. 3 files changed, 50 insertions(+), 1 deletion(-)
  30. --- a/arch/mips/Kconfig
  31. +++ b/arch/mips/Kconfig
  32. @@ -2703,6 +2703,33 @@ config BOOT_RAW
  33. +choice
  34. + prompt "Kernel appended dtb support" if OF
  35. + default MIPS_NO_APPENDED_DTB
  36. +
  37. + config MIPS_NO_APPENDED_DTB
  38. + bool "None"
  39. + help
  40. + Do not enable appended dtb support.
  41. +
  42. + config MIPS_RAW_APPENDED_DTB
  43. + bool "vmlinux.bin"
  44. + help
  45. + With this option, the boot code will look for a device tree binary
  46. + DTB) appended to raw vmlinux.bin (without decompressor).
  47. + (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb).
  48. +
  49. + This is meant as a backward compatibility convenience for those
  50. + systems with a bootloader that can't be upgraded to accommodate
  51. + the documented boot protocol using a device tree.
  52. +
  53. + Beware that there is very little in terms of protection against
  54. + this option being confused by leftover garbage in memory that might
  55. + look like a DTB header after a reboot if no actual DTB is appended
  56. + to vmlinux.bin. Do not leave this option active in a production kernel
  57. + if you don't intend to always append a DTB.
  58. +endchoice
  59. +
  60. endmenu
  61. config LOCKDEP_SUPPORT
  62. --- a/arch/mips/kernel/head.S
  63. +++ b/arch/mips/kernel/head.S
  64. @@ -100,6 +100,22 @@ NESTED(kernel_entry, 16, sp) # kernel
  65. jr t0
  66. 0:
  67. +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
  68. + PTR_LA t0, __appended_dtb
  69. +
  70. +#ifdef CONFIG_CPU_BIG_ENDIAN
  71. + li t1, 0xd00dfeed
  72. +#else
  73. + li t1, 0xedfe0dd0
  74. +#endif
  75. + lw t2, (t0)
  76. + bne t1, t2, not_found
  77. + nop
  78. +
  79. + move a1, t0
  80. + PTR_LI a0, -2
  81. +not_found:
  82. +#endif
  83. PTR_LA t0, __bss_start # clear .bss
  84. LONG_S zero, (t0)
  85. PTR_LA t1, __bss_stop - LONGSIZE
  86. --- a/arch/mips/kernel/vmlinux.lds.S
  87. +++ b/arch/mips/kernel/vmlinux.lds.S
  88. @@ -125,8 +125,14 @@ SECTIONS
  89. .exit.data : {
  90. EXIT_DATA
  91. }
  92. -
  93. +#ifdef CONFIG_SMP
  94. PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
  95. +#endif
  96. +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
  97. + __appended_dtb = .;
  98. + /* leave space for appended DTB */
  99. + . += 0x100000;
  100. +#endif
  101. /*
  102. * Align to 64K in attempt to eliminate holes before the
  103. * .bss..swapper_pg_dir section at the start of .bss. This