ath79: fix incorrect identation in qca9557.dtsi
[oweals/openwrt.git] / target / linux / generic / pending-4.19 / 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 @@ -526,7 +526,7 @@ void __init handle_uboot_args(void)
46  ignore_uboot_args:
47  
48         if (use_embedded_dtb) {
49 -               machine_desc = setup_machine_fdt(__dtb_start);
50 +               machine_desc = setup_machine_fdt(&__image_dtb);
51                 if (!machine_desc)
52                         panic("Embedded DT invalid\n");
53         }
54 @@ -542,6 +542,8 @@ ignore_uboot_args:
55         }
56  }
57  
58 +extern struct boot_param_header __image_dtb;
59 +
60  void __init setup_arch(char **cmdline_p)
61  {
62         handle_uboot_args();
63 --- a/arch/arc/kernel/vmlinux.lds.S
64 +++ b/arch/arc/kernel/vmlinux.lds.S
65 @@ -30,6 +30,19 @@ SECTIONS
66  
67         . = CONFIG_LINUX_LINK_BASE;
68  
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         _int_vec_base_lds = .;
83         .vector : {
84                 *(.vector)