kernel/4.3: update to version 4.3.3
[openwrt.git] / target / linux / arc770 / patches-4.3 / 0002-openwrt-arc-add-OWRTDTB-section.patch
1 From 142abc9f7b8860638e39cf3850cf7ba328c26b42 Mon Sep 17 00:00:00 2001
2 From: Alexey Brodkin <abrodkin@synopsys.com>
3 Date: Sat, 31 Oct 2015 15:58:20 +0300
4 Subject: [PATCH] openwrt: 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: Alexey Brodkin <abrodkin@synopsys.com>
16 ---
17  arch/arc/kernel/head.S        | 10 ++++++++++
18  arch/arc/kernel/setup.c       |  4 +++-
19  arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++
20  3 files changed, 26 insertions(+), 1 deletion(-)
21
22 --- a/arch/arc/kernel/head.S
23 +++ b/arch/arc/kernel/head.S
24 @@ -49,6 +49,16 @@
25  1:
26  .endm
27  
28 +; Here "patch-dtb" will embed external .dtb
29 +; Note "patch-dtb" searches for ASCII "OWRTDTB:" string
30 +; and pastes .dtb right after it, hense the string precedes
31 +; __image_dtb symbol.
32 +       .section .owrt, "aw",@progbits
33 +       .ascii  "OWRTDTB:"
34 +ENTRY(__image_dtb)
35 +       .fill   0x4000
36 +END(__image_dtb)
37 +
38         .section .init.text, "ax",@progbits
39         .type stext, @function
40         .globl stext
41 --- a/arch/arc/kernel/setup.c
42 +++ b/arch/arc/kernel/setup.c
43 @@ -374,6 +374,8 @@ static inline int is_kernel(unsigned lon
44         return 0;
45  }
46  
47 +extern struct boot_param_header __image_dtb;
48 +
49  void __init setup_arch(char **cmdline_p)
50  {
51  #ifdef CONFIG_ARC_UBOOT_SUPPORT
52 @@ -387,7 +389,7 @@ void __init setup_arch(char **cmdline_p)
53  #endif
54         {
55                 /* No, so try the embedded one */
56 -               machine_desc = setup_machine_fdt(__dtb_start);
57 +               machine_desc = setup_machine_fdt(&__image_dtb);
58                 if (!machine_desc)
59                         panic("Embedded DT invalid\n");
60  
61 --- a/arch/arc/kernel/vmlinux.lds.S
62 +++ b/arch/arc/kernel/vmlinux.lds.S
63 @@ -30,6 +30,19 @@ SECTIONS
64  
65         . = CONFIG_LINUX_LINK_BASE;
66  
67 +       /*
68 +        * In OpenWRT we want to patch built binary embedding .dtb of choice.
69 +        * This is implemented with "patch-dtb" utility which searches for
70 +        * "OWRTDTB:" string in first 16k of image and if it is found
71 +        * copies .dtb right after mentioned string.
72 +        *
73 +        * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
74 +        */
75 +       .owrt : {
76 +               *(.owrt)
77 +               . = ALIGN(PAGE_SIZE);
78 +       }
79 +
80         _int_vec_base_lds = .;
81         .vector : {
82                 *(.vector)