kernel: Reorder generic configuration
[openwrt/staging/dedeckeh.git] / target / linux / generic / pending-4.14 / 332-arc-add-OWRTDTB-section.patch
1 From 34ef04f3845ed2b47d57dd9d3b795b16e1f8185a Mon Sep 17 00:00:00 2001
2 From: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
3 Date: Fri, 15 Mar 2019 18:53:38 +0300
4 Subject: [PATCH] arc add OWRTDTB section
5
6 This change allows OpenWRT to patch resulting kernel binary with
7 external .dtb.
8
9 That allows us to re-use exactky the same vmlinux on different boards
10 given its ARC core configurations match (at least cache line sizes etc).
11
12 ""patch-dtb" searches for ASCII "OWRTDTB:" strign and copies external
13 .dtb right after it, keeping the string in place.
14
15 Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
16 Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
17 Signed-off-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
18 ---
19 arch/arc/kernel/head.S | 10 ++++++++++
20 arch/arc/kernel/setup.c | 4 +++-
21 arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++
22 3 files changed, 26 insertions(+), 1 deletion(-)
23
24 --- a/arch/arc/kernel/head.S
25 +++ b/arch/arc/kernel/head.S
26 @@ -59,6 +59,16 @@
27 #endif
28 .endm
29
30 + ; Here "patch-dtb" will embed external .dtb
31 + ; Note "patch-dtb" searches for ASCII "OWRTDTB:" string
32 + ; and pastes .dtb right after it, hense the string precedes
33 + ; __image_dtb symbol.
34 + .section .owrt, "aw",@progbits
35 + .ascii "OWRTDTB:"
36 +ENTRY(__image_dtb)
37 + .fill 0x4000
38 +END(__image_dtb)
39 +
40 .section .init.text, "ax",@progbits
41
42 ;----------------------------------------------------------------
43 --- a/arch/arc/kernel/setup.c
44 +++ b/arch/arc/kernel/setup.c
45 @@ -437,6 +437,8 @@ static inline bool uboot_arg_invalid(uns
46 /* We always pass 0 as magic from U-boot */
47 #define UBOOT_MAGIC_VALUE 0
48
49 +extern struct boot_param_header __image_dtb;
50 +
51 void __init handle_uboot_args(void)
52 {
53 bool use_embedded_dtb = true;
54 @@ -477,7 +479,7 @@ ignore_uboot_args:
55 #endif
56
57 if (use_embedded_dtb) {
58 - machine_desc = setup_machine_fdt(__dtb_start);
59 + machine_desc = setup_machine_fdt(&__image_dtb);
60 if (!machine_desc)
61 panic("Embedded DT invalid\n");
62 }
63 --- a/arch/arc/kernel/vmlinux.lds.S
64 +++ b/arch/arc/kernel/vmlinux.lds.S
65 @@ -29,6 +29,19 @@ SECTIONS
66 */
67
68 . = CONFIG_LINUX_LINK_BASE;
69 + /*
70 + * In OpenWRT we want to patch built binary embedding .dtb of choice.
71 + * This is implemented with "patch-dtb" utility which searches for
72 + * "OWRTDTB:" string in first 16k of image and if it is found
73 + * copies .dtb right after mentioned string.
74 + *
75 + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
76 + */
77 + .owrt : {
78 + *(.owrt)
79 + . = ALIGN(PAGE_SIZE);
80 + }
81 +
82
83 _int_vec_base_lds = .;
84 .vector : {