1 | #!/bin/bash
|
---|
2 | # $Id: build-kernel.sh 96416 2022-08-22 20:36:29Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Script for build a linux kernel with a default configuration.
|
---|
5 | #
|
---|
6 | # This script assumes gcc-6, gcc-4.9 and gcc-3.3 are available on the system.
|
---|
7 | #
|
---|
8 | # For really old kernels make 3.80 and 3.76 will need to be built and put in
|
---|
9 | # a specific place relative to the kernel sources.
|
---|
10 | #
|
---|
11 | # This script may patch the kernel source a little to work around issues with
|
---|
12 | # newere binutils, perl, glibc and maybe compilers.
|
---|
13 | #
|
---|
14 | # It is recommended to use a overlayfs setup and kDeDup the kernel sources to
|
---|
15 | # save disk space.
|
---|
16 | #
|
---|
17 |
|
---|
18 | #
|
---|
19 | # Copyright (C) 2019-2022 Oracle and/or its affiliates.
|
---|
20 | #
|
---|
21 | # This file is part of VirtualBox base platform packages, as
|
---|
22 | # available from https://www.virtualbox.org.
|
---|
23 | #
|
---|
24 | # This program is free software; you can redistribute it and/or
|
---|
25 | # modify it under the terms of the GNU General Public License
|
---|
26 | # as published by the Free Software Foundation, in version 3 of the
|
---|
27 | # License.
|
---|
28 | #
|
---|
29 | # This program is distributed in the hope that it will be useful, but
|
---|
30 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
31 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
32 | # General Public License for more details.
|
---|
33 | #
|
---|
34 | # You should have received a copy of the GNU General Public License
|
---|
35 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
36 | #
|
---|
37 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
38 | #
|
---|
39 |
|
---|
40 | #
|
---|
41 | # /etc/apt/sources.list clues:
|
---|
42 | #
|
---|
43 | # # for gcc-4.8
|
---|
44 | # deb http://deb.debian.org/debian/ oldstable main contrib non-free
|
---|
45 | # deb-src http://deb.debian.org/debian/ oldstable main contrib non-free
|
---|
46 | #
|
---|
47 | # # for gcc-6
|
---|
48 | # deb http://deb.debian.org/debian/ stable main contrib non-free
|
---|
49 | # deb-src http://deb.debian.org/debian/ stable main contrib non-free
|
---|
50 | #
|
---|
51 | # # for gcc 3.4.x
|
---|
52 | # deb [ allow-insecure=yes ] http://archive.debian.org/debian/ lenny main contrib non-free
|
---|
53 | # deb-src [ allow-insecure=yes ] http://archive.debian.org/debian/ lenny main contrib non-free
|
---|
54 | #
|
---|
55 | # # for gcc 3.3.x
|
---|
56 | # deb [ allow-insecure=yes ] http://archive.debian.org/debian/ etch main contrib non-free
|
---|
57 | # deb-src [ allow-insecure=yes ] http://archive.debian.org/debian/ etch main contrib non-free
|
---|
58 | #
|
---|
59 | # # for gcc 3.2.x
|
---|
60 | # deb [ allow-insecure=yes arch=i386] http://archive.debian.org/debian/ woody main contrib non-free
|
---|
61 | # deb-src [ allow-insecure=yes arch=i386 ] http://archive.debian.org/debian/ woody main contrib non-free
|
---|
62 | #
|
---|
63 | #
|
---|
64 | # Clue for /etc/fstab:
|
---|
65 | # overlay /mnt/bldlnx/amd64 overlay lowerdir=/mnt/big/virgin-lnx/,upperdir=/mnt/big/bldlnx/amd64,workdir=/mnt/big/workdir/bldlnx-amd64,noauto 0 0
|
---|
66 | #
|
---|
67 |
|
---|
68 | if [ -z "${JOBS}" ]; then JOBS=42; fi
|
---|
69 |
|
---|
70 | #
|
---|
71 | # The path argument.
|
---|
72 | #
|
---|
73 | if [ "$#" -lt "1" ]; then
|
---|
74 | echo "usage: build.sh <dir> [clean]"
|
---|
75 | exit 2
|
---|
76 | fi
|
---|
77 |
|
---|
78 | set -e
|
---|
79 | echo "********************************************************************************"
|
---|
80 | echo "* $1"
|
---|
81 | echo "********************************************************************************"
|
---|
82 | set -x
|
---|
83 | shopt -s extglob
|
---|
84 |
|
---|
85 | # Enter it.
|
---|
86 | cd "$1"
|
---|
87 |
|
---|
88 | # Change the terminal title (ASSUMES xterm-like TERM).
|
---|
89 | KERN_SUBDIR=`basename $1`
|
---|
90 | export PS1="\$ ";
|
---|
91 | echo -ne "\033]0;build.sh - ${KERN_SUBDIR}\007"
|
---|
92 |
|
---|
93 | # Derive the version from it.
|
---|
94 | KERN_VER=`echo $1 | sed -e 's/^.*linux-\([0-9][0-9.]*\).*$/\1/'`
|
---|
95 | case "${KERN_VER}" in
|
---|
96 | [0-9].[0-9]|[0-9].[0-9][0-9]|[0-9][0-9].[0-9]|[0-9][0-9].[0-9][0-9])
|
---|
97 | KERN_VER_3PLUS_DOTS="${KERN_VER}.0";;
|
---|
98 | *)
|
---|
99 | KERN_VER_3PLUS_DOTS=${KERN_VER};;
|
---|
100 | esac
|
---|
101 | echo "debug: KERN_VER=${KERN_VER} --> KERN_VER_3PLUS_DOTS=${KERN_VER_3PLUS_DOTS}"
|
---|
102 |
|
---|
103 | # Determin tool overrides.
|
---|
104 | OVERRIDES=
|
---|
105 | MAKE=/usr/bin/make
|
---|
106 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
107 | 4.9.*|4.1[0-7].*)
|
---|
108 | OVERRIDES="CC=gcc-6 CXX=g++-6"
|
---|
109 | ;;
|
---|
110 | 2.6.3[789]*|3.*|4.[0-8].*)
|
---|
111 | OVERRIDES="CC=gcc-4.9 CXX=g++-4.9"
|
---|
112 | ;;
|
---|
113 | 2.6.29*|2.6.3[0-9]*)
|
---|
114 | OVERRIDES="CC=gcc-3.3 CXX=g++-3.3"
|
---|
115 | ;;
|
---|
116 | 2.6.[89]*|2.6.12[0-9]*|2.6.2[0-8]*)
|
---|
117 | OVERRIDES="CC=gcc-3.3 CXX=g++-3.3"
|
---|
118 | MAKE=../../make-3.80/installed/bin/make
|
---|
119 | ;;
|
---|
120 | 2.6.*)
|
---|
121 | OVERRIDES="CC=gcc-3.3 CXX=g++-3.3"
|
---|
122 | MAKE=../../make-3.80/installed/bin/make
|
---|
123 | ;;
|
---|
124 | esac
|
---|
125 | echo "debug: OVERRIDES=${OVERRIDES} MAKE=${MAKE}"
|
---|
126 |
|
---|
127 | echo "${OVERRIDES}" > .bird-overrides
|
---|
128 | ln -sf "${MAKE}" .bird-make
|
---|
129 |
|
---|
130 | # Done with arg #1.
|
---|
131 | shift
|
---|
132 |
|
---|
133 |
|
---|
134 | #
|
---|
135 | # Apply patches for newer tools and stuff.
|
---|
136 | #
|
---|
137 |
|
---|
138 | # perl --annoying
|
---|
139 | if [ -f kernel/timeconst.pl ]; then
|
---|
140 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
141 | --- a/kernel/timeconst.pl 2019-04-15 13:44:55.434946090 +0200
|
---|
142 | +++ b/kernel/timeconst.pl 2019-04-15 13:57:29.330140587 +0200
|
---|
143 | @@ -372,5 +372,5 @@
|
---|
144 | @val = @{\$canned_values{\$hz}};
|
---|
145 | - if (!defined(@val)) {
|
---|
146 | + if (!@val) {
|
---|
147 | @val = compute_values(\$hz);
|
---|
148 | }
|
---|
149 | output(\$hz, @val);
|
---|
150 | EOF
|
---|
151 | then
|
---|
152 | cp /tmp/build.$$ kernel/timeconst.pl
|
---|
153 | fi
|
---|
154 | fi
|
---|
155 |
|
---|
156 | # binutils PLT32
|
---|
157 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
158 | 4.10.*|4.11.*|4.12.*|4.13.*|4.14.*|4.15.*|4.16.*)
|
---|
159 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
160 | diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
|
---|
161 | index 1f790cf9d38f..3b7427aa7d85 100644
|
---|
162 | --- a/arch/x86/kernel/machine_kexec_64.c
|
---|
163 | +++ b/arch/x86/kernel/machine_kexec_64.c
|
---|
164 | @@ -542,6 +542,7 @@ int arch_kexec_apply_relocations_add(const Elf64_Ehdr *ehdr,
|
---|
165 | goto overflow;
|
---|
166 | break;
|
---|
167 | case R_X86_64_PC32:
|
---|
168 | + case R_X86_64_PLT32:
|
---|
169 | value -= (u64)address;
|
---|
170 | *(u32 *)location = value;
|
---|
171 | break;
|
---|
172 | EOF
|
---|
173 | then
|
---|
174 | cp /tmp/build.$$ arch/x86/kernel/machine_kexec_64.c
|
---|
175 | fi
|
---|
176 | case "${KERN_VER}" in
|
---|
177 | 4.10.*|4.11.*|4.12.*|4.13.*)
|
---|
178 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
179 | diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
|
---|
180 | index da0c160e5589..f58336af095c 100644
|
---|
181 | --- a/arch/x86/kernel/module.c
|
---|
182 | +++ b/arch/x86/kernel/module.c
|
---|
183 | @@ -191,6 +191,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
|
---|
184 | goto overflow;
|
---|
185 | break;
|
---|
186 | case R_X86_64_PC32:
|
---|
187 | + case R_X86_64_PLT32:
|
---|
188 | val -= (u64)loc;
|
---|
189 | *(u32 *)loc = val;
|
---|
190 | #if 0
|
---|
191 | EOF
|
---|
192 | then
|
---|
193 | cp /tmp/build.$$ arch/x86/kernel/module.c
|
---|
194 | fi;;
|
---|
195 | **)
|
---|
196 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
197 | diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
|
---|
198 | index da0c160e5589..f58336af095c 100644
|
---|
199 | --- a/arch/x86/kernel/module.c
|
---|
200 | +++ b/arch/x86/kernel/module.c
|
---|
201 | @@ -191,6 +191,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
|
---|
202 | goto overflow;
|
---|
203 | break;
|
---|
204 | case R_X86_64_PC32:
|
---|
205 | + case R_X86_64_PLT32:
|
---|
206 | if (*(u32 *)loc != 0)
|
---|
207 | goto invalid_relocation;
|
---|
208 | val -= (u64)loc;
|
---|
209 | EOF
|
---|
210 | then
|
---|
211 | cp /tmp/build.$$ arch/x86/kernel/module.c
|
---|
212 | fi;;
|
---|
213 | esac
|
---|
214 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
215 | diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
|
---|
216 | index 5d73c443e778..220e97841e49 100644
|
---|
217 | --- a/arch/x86/tools/relocs.c
|
---|
218 | +++ b/arch/x86/tools/relocs.c
|
---|
219 | @@ -770,9 +770,12 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym,
|
---|
220 | break;
|
---|
221 |
|
---|
222 | case R_X86_64_PC32:
|
---|
223 | + case R_X86_64_PLT32:
|
---|
224 | /*
|
---|
225 | * PC relative relocations don't need to be adjusted unless
|
---|
226 | * referencing a percpu symbol.
|
---|
227 | + *
|
---|
228 | + * NB: R_X86_64_PLT32 can be treated as R_X86_64_PC32.
|
---|
229 | */
|
---|
230 | if (is_percpu_sym(sym, symname))
|
---|
231 | add_reloc(&relocs32neg, offset);
|
---|
232 | EOF
|
---|
233 | then
|
---|
234 | cp /tmp/build.$$ arch/x86/tools/relocs.c
|
---|
235 | fi
|
---|
236 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
237 | --- linux-4.15/tools/lib/subcmd/pager.c 2017-11-12 19:46:13.000000000 +0100
|
---|
238 | +++ linux-4.17/tools/lib/subcmd/pager.c 2018-06-03 23:15:21.000000000 +0200
|
---|
239 | @@ -30,10 +30,13 @@
|
---|
240 | * have real input
|
---|
241 | */
|
---|
242 | fd_set in;
|
---|
243 | + fd_set exception;
|
---|
244 |
|
---|
245 | FD_ZERO(&in);
|
---|
246 | + FD_ZERO(&exception);
|
---|
247 | FD_SET(0, &in);
|
---|
248 | - select(1, &in, NULL, &in, NULL);
|
---|
249 | + FD_SET(0, &exception);
|
---|
250 | + select(1, &in, NULL, &exception, NULL);
|
---|
251 |
|
---|
252 | setenv("LESS", "FRSX", 0);
|
---|
253 | }
|
---|
254 | EOF
|
---|
255 | then
|
---|
256 | cp /tmp/build.$$ tools/lib/subcmd/pager.c
|
---|
257 | fi
|
---|
258 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
259 | --- linux-4.16/tools/lib/str_error_r.c 2019-04-15 06:04:50.978464217 +0200
|
---|
260 | +++ linux-4.17/tools/lib/str_error_r.c 2018-06-03 23:15:21.000000000 +0200
|
---|
261 | @@ -22,6 +22,6 @@
|
---|
262 | {
|
---|
263 | int err = strerror_r(errnum, buf, buflen);
|
---|
264 | if (err)
|
---|
265 | - snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err);
|
---|
266 | + snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, [buf], %zd)=%d", errnum, buflen, err);
|
---|
267 | return buf;
|
---|
268 | }
|
---|
269 | EOF
|
---|
270 | then
|
---|
271 | cp /tmp/build.$$ tools/lib/str_error_r.c
|
---|
272 | fi
|
---|
273 | ;;
|
---|
274 | esac
|
---|
275 |
|
---|
276 | # Undefined ____ilog2_NaN symbol:
|
---|
277 | if [ -f include/linux/log2.h ]; then
|
---|
278 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
279 | 4.10.*|4.[9].*)
|
---|
280 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
281 | --- linux-4.10/include/linux/log2.h 2017-02-19 23:34:00.000000000 +0100
|
---|
282 | +++ linux-4.11/include/linux/log2.h 2017-11-12 19:46:13.000000000 +0100
|
---|
283 | @@ -15,14 +15,8 @@
|
---|
284 | #include <linux/types.h>
|
---|
285 | #include <linux/bitops.h>
|
---|
286 |
|
---|
287 | /*
|
---|
288 | - * deal with unrepresentable constant logarithms
|
---|
289 | - */
|
---|
290 | -extern __attribute__((const, noreturn))
|
---|
291 | -int ____ilog2_NaN(void);
|
---|
292 | -
|
---|
293 | -/*
|
---|
294 | * non-constant log of base 2 calculators
|
---|
295 | * - the arch may override these in asm/bitops.h if they can be implemented
|
---|
296 | * more efficiently than using fls() and fls64()
|
---|
297 | * - the arch is not required to handle n==0 if implementing the fallback
|
---|
298 | @@ -84,9 +78,9 @@
|
---|
299 | */
|
---|
300 | #define ilog2(n) \\
|
---|
301 | ( \\
|
---|
302 | __builtin_constant_p(n) ? ( \\
|
---|
303 | - (n) < 1 ? ____ilog2_NaN() : \\
|
---|
304 | + (n) < 2 ? 0 : \\
|
---|
305 | (n) & (1ULL << 63) ? 63 : \\
|
---|
306 | (n) & (1ULL << 62) ? 62 : \\
|
---|
307 | (n) & (1ULL << 61) ? 61 : \\
|
---|
308 | (n) & (1ULL << 60) ? 60 : \\
|
---|
309 | @@ -147,12 +141,9 @@
|
---|
310 | (n) & (1ULL << 5) ? 5 : \\
|
---|
311 | (n) & (1ULL << 4) ? 4 : \\
|
---|
312 | (n) & (1ULL << 3) ? 3 : \\
|
---|
313 | (n) & (1ULL << 2) ? 2 : \\
|
---|
314 | - (n) & (1ULL << 1) ? 1 : \\
|
---|
315 | - (n) & (1ULL << 0) ? 0 : \\
|
---|
316 | - ____ilog2_NaN() \\
|
---|
317 | - ) : \\
|
---|
318 | + 1 ) : \\
|
---|
319 | (sizeof(n) <= 4) ? \\
|
---|
320 | __ilog2_u32(n) : \\
|
---|
321 | __ilog2_u64(n) \\
|
---|
322 | )
|
---|
323 | EOF
|
---|
324 | then
|
---|
325 | cp /tmp/build.$$ include/linux/log2.h
|
---|
326 | fi
|
---|
327 | ;;
|
---|
328 | esac
|
---|
329 | fi
|
---|
330 |
|
---|
331 | # extern then static current_menu.
|
---|
332 | if [ -f scripts/kconfig/lkc.h -a -f scripts/kconfig/mconf.c ]; then
|
---|
333 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
334 | 2.6.1[0-9]*|2.6.2[0-9]*|2.6.3[0-9]*|2.6.4[0-9]*)
|
---|
335 | ;;
|
---|
336 | 2.5.*|2.6.[012345678])
|
---|
337 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
338 | --- linux-2.6.8/scripts/kconfig/mconf.c 2004-08-14 07:36:32.000000000 +0200
|
---|
339 | +++ linux-2.6.8/scripts/kconfig/mconf.c 2019-04-15 15:52:42.143587966 +0200
|
---|
340 | @@ -88,5 +88,5 @@
|
---|
341 | static struct termios ios_org;
|
---|
342 | static int rows = 0, cols = 0;
|
---|
343 | -static struct menu *current_menu;
|
---|
344 | +struct menu *current_menu;
|
---|
345 | static int child_count;
|
---|
346 | static int do_resize;
|
---|
347 | EOF
|
---|
348 | then
|
---|
349 | cp /tmp/build.$$ scripts/kconfig/mconf.c
|
---|
350 | fi
|
---|
351 | ;;
|
---|
352 | esac
|
---|
353 | fi
|
---|
354 |
|
---|
355 | # Incorrect END label in arch/x86/lib/copy_user_64.S
|
---|
356 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
357 | 2.6.2[456]*)
|
---|
358 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
359 | --- linux-2.6.26/arch/x86/lib/copy_user_64.S 2019-04-15 16:21:49.475846822 +0200
|
---|
360 | +++ linux-2.6.26/arch/x86/lib/copy_user_64.S 2019-04-15 16:21:50.883863141 +0200
|
---|
361 | @@ -341,7 +341,7 @@
|
---|
362 | 11: pop %rax
|
---|
363 | 7: ret
|
---|
364 | CFI_ENDPROC
|
---|
365 | -END(copy_user_generic_c)
|
---|
366 | +END(copy_user_generic_string)
|
---|
367 |
|
---|
368 | .section __ex_table,"a"
|
---|
369 | .quad 1b,3b
|
---|
370 | EOF
|
---|
371 | then
|
---|
372 | cp /tmp/build.$$ arch/x86/lib/copy_user_64.S
|
---|
373 | fi
|
---|
374 | ;;
|
---|
375 | 2.6.2[0123]*|2.6.19*)
|
---|
376 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
377 | --- linux-2.6.23/arch/x86_64/lib/copy_user.S 2019-04-15 16:42:16.898006203 +0200
|
---|
378 | +++ linux-2.6.23/arch/x86_64/lib/copy_user.S 2019-04-15 16:42:25.906109885 +0200
|
---|
379 | @@ -344,7 +344,7 @@
|
---|
380 | 11: pop %rax
|
---|
381 | 7: ret
|
---|
382 | CFI_ENDPROC
|
---|
383 | -END(copy_user_generic_c)
|
---|
384 | +END(copy_user_generic_string)
|
---|
385 |
|
---|
386 | .section __ex_table,"a"
|
---|
387 | .quad 1b,3b
|
---|
388 | EOF
|
---|
389 | then
|
---|
390 | cp /tmp/build.$$ arch/x86_64/lib/copy_user.S
|
---|
391 | fi
|
---|
392 | ;;
|
---|
393 | esac
|
---|
394 |
|
---|
395 | # Increase vdso text segment limit as newer tools/whatever causes it to be too large.
|
---|
396 | if [ -f arch/x86_64/vdso/vdso.lds.S ]; then
|
---|
397 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
398 | --- linux-2.6.23/arch/x86_64/vdso/vdso.lds.S 2019-04-15 17:20:27.567440594 +0200
|
---|
399 | +++ linux-2.6.23/arch/x86_64/vdso/vdso.lds.S 2019-04-15 17:20:29.635463886 +0200
|
---|
400 | @@ -28,5 +28,5 @@
|
---|
401 | .text : { *(.text) } :text
|
---|
402 | .text.ptr : { *(.text.ptr) } :text
|
---|
403 | - . = VDSO_PRELINK + 0x900;
|
---|
404 | + . = VDSO_PRELINK + 0xa00;
|
---|
405 | .data : { *(.data) } :text
|
---|
406 | .bss : { *(.bss) } :text
|
---|
407 | EOF
|
---|
408 | then
|
---|
409 | cp /tmp/build.$$ arch/x86_64/vdso/vdso.lds.S
|
---|
410 | fi
|
---|
411 | fi
|
---|
412 |
|
---|
413 | # glibc PATH_MAX cleanup affect 2.6.21 and earlier:
|
---|
414 | if [ -f scripts/mod/sumversion.c ]; then
|
---|
415 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
416 | 2.6.[0-9]!([0-9])*|2.6.1[0-9]*|2.6.2[01]*)
|
---|
417 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
418 | --- linux-2.6.21/scripts/mod/sumversion.c 2007-02-04 19:44:54.000000000 +0100
|
---|
419 | +++ linux-2.6.21/scripts/mod/sumversion.c 2019-02-15 16:10:12.956678862 +0100
|
---|
420 | @@ -7,4 +7,5 @@
|
---|
421 | #include <ctype.h>
|
---|
422 | #include <errno.h>
|
---|
423 | #include <string.h>
|
---|
424 | +#include <linux/limits.h>
|
---|
425 | #include "modpost.h"
|
---|
426 | EOF
|
---|
427 | then
|
---|
428 | cp /tmp/build.$$ scripts/mod/sumversion.c
|
---|
429 | fi
|
---|
430 | esac
|
---|
431 | fi
|
---|
432 |
|
---|
433 | # Problem with "System too big" messages in 2.6.17 and earlier:
|
---|
434 | if [ -f arch/x86_64/boot/tools/build.c ]; then
|
---|
435 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
436 | 2.6.[0-9]!([0-9])*|2.6.1[0-7]*)
|
---|
437 | if patch --output /tmp/build.$$ -Np1 <<EOF
|
---|
438 | --- linux-2.6.17/arch/x86_64/boot/tools/build.c 2006-01-03 04:21:10.000000000 +0100
|
---|
439 | +++ linux-2.6.18/arch/x86_64/boot/tools/build.c 2007-02-04 19:44:54.000000000 +0100
|
---|
440 | @@ -149,9 +149,7 @@
|
---|
441 | sz = sb.st_size;
|
---|
442 | fprintf (stderr, "System is %d kB\n", sz/1024);
|
---|
443 | sys_size = (sz + 15) / 16;
|
---|
444 | - /* 0x40000*16 = 4.0 MB, reasonable estimate for the current maximum */
|
---|
445 | - if (sys_size > (is_big_kernel ? 0x40000 : DEF_SYSSIZE))
|
---|
446 | - die("System is too big. Try using %smodules.",
|
---|
447 | - is_big_kernel ? "" : "bzImage or ");
|
---|
448 | + if (!is_big_kernel && sys_size > DEF_SYSSIZE)
|
---|
449 | + die("System is too big. Try using bzImage or modules.");
|
---|
450 | while (sz > 0) {
|
---|
451 | int l, n;
|
---|
452 | EOF
|
---|
453 | then
|
---|
454 | cp /tmp/build.$$ arch/x86_64/boot/tools/build.c
|
---|
455 | fi
|
---|
456 | esac
|
---|
457 | fi
|
---|
458 |
|
---|
459 | # Problem with incorrect mov sizes for segments in 2.6.11 and earlier:
|
---|
460 | if [ -f arch/x86_64/kernel/process.c ]; then
|
---|
461 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
462 | 2.6.[0-9]!([0-9])*|2.6.1[01]*)
|
---|
463 | if patch --output /tmp/build.$$ -lNp1 <<EOF
|
---|
464 | --- linux-2.6.11/arch/x86_64/kernel/process.c 2005-03-02 08:38:10.000000000 +0100
|
---|
465 | +++ linux-2.6.11/arch/x86_64/kernel/process.c 2019-02-15 16:57:47.653585327 +0100
|
---|
466 | @@ -390,10 +390,10 @@
|
---|
467 | p->thread.fs = me->thread.fs;
|
---|
468 | p->thread.gs = me->thread.gs;
|
---|
469 |
|
---|
470 | - asm("movl %%gs,%0" : "=m" (p->thread.gsindex));
|
---|
471 | - asm("movl %%fs,%0" : "=m" (p->thread.fsindex));
|
---|
472 | - asm("movl %%es,%0" : "=m" (p->thread.es));
|
---|
473 | - asm("movl %%ds,%0" : "=m" (p->thread.ds));
|
---|
474 | + asm("movw %%gs,%0" : "=m" (p->thread.gsindex));
|
---|
475 | + asm("movw %%fs,%0" : "=m" (p->thread.fsindex));
|
---|
476 | + asm("movw %%es,%0" : "=m" (p->thread.es));
|
---|
477 | + asm("movw %%ds,%0" : "=m" (p->thread.ds));
|
---|
478 |
|
---|
479 | if (unlikely(me->thread.io_bitmap_ptr != NULL)) {
|
---|
480 | p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
|
---|
481 | @@ -456,11 +456,11 @@
|
---|
482 | * Switch DS and ES.
|
---|
483 | * This won't pick up thread selector changes, but I guess that is ok.
|
---|
484 | */
|
---|
485 | - asm volatile("movl %%es,%0" : "=m" (prev->es));
|
---|
486 | + asm volatile("movw %%es,%0" : "=m" (prev->es));
|
---|
487 | if (unlikely(next->es | prev->es))
|
---|
488 | loadsegment(es, next->es);
|
---|
489 |
|
---|
490 | - asm volatile ("movl %%ds,%0" : "=m" (prev->ds));
|
---|
491 | + asm volatile ("movw %%ds,%0" : "=m" (prev->ds));
|
---|
492 | if (unlikely(next->ds | prev->ds))
|
---|
493 | loadsegment(ds, next->ds);
|
---|
494 | EOF
|
---|
495 | then
|
---|
496 | cp /tmp/build.$$ arch/x86_64/kernel/process.c
|
---|
497 | fi
|
---|
498 | esac
|
---|
499 | fi
|
---|
500 |
|
---|
501 |
|
---|
502 | #
|
---|
503 | # Other arguments.
|
---|
504 | #
|
---|
505 | while [ "$#" -gt 0 ];
|
---|
506 | do
|
---|
507 | case "$1" in
|
---|
508 | clean)
|
---|
509 | time ./.bird-make ${OVERRIDES} -j ${JOBS} clean
|
---|
510 | ;;
|
---|
511 |
|
---|
512 | *)
|
---|
513 | echo "syntax error: $1" 1>&2
|
---|
514 | ;;
|
---|
515 | esac
|
---|
516 | shift
|
---|
517 | done
|
---|
518 |
|
---|
519 | #
|
---|
520 | # Configure.
|
---|
521 | #
|
---|
522 | if [ -f .config ]; then
|
---|
523 | mv -f .config .bird-previous-config
|
---|
524 | fi
|
---|
525 | nice ./.bird-make ${OVERRIDES} -j ${JOBS} defconfig
|
---|
526 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
527 | 2.[012345].*|2.6.[0-9]!([0-9])*|2.6.[12][0-9]*)
|
---|
528 | ;;
|
---|
529 | *)
|
---|
530 | echo CONFIG_DRM_TTM=m >> .config;
|
---|
531 | echo CONFIG_DRM_RADEON=m >> .config
|
---|
532 | echo CONFIG_DRM_RADEON_UMS=y >> .config
|
---|
533 | echo CONFIG_DRM_RADEON_USERPTR=y >> .config
|
---|
534 | echo CONFIG_DRM_RADEON_KMS=y >> .config
|
---|
535 | ;;
|
---|
536 | esac
|
---|
537 | case "${KERN_VER_3PLUS_DOTS}" in
|
---|
538 | 2.4.*) ;;
|
---|
539 | 4.2[0-9].*|4.1[789].*|[5-9].*)
|
---|
540 | nice ./.bird-make ${OVERRIDES} syncconfig;;
|
---|
541 | *) nice ./.bird-make ${OVERRIDES} silentoldconfig;;
|
---|
542 | esac
|
---|
543 | if [ -f .bird-previous-config ]; then
|
---|
544 | if cmp -s .config .bird-previous-config; then
|
---|
545 | mv -f .bird-previous-config .config
|
---|
546 | fi
|
---|
547 | fi
|
---|
548 |
|
---|
549 | #
|
---|
550 | # Build all.
|
---|
551 | #
|
---|
552 | if time nice ./.bird-make ${OVERRIDES} -j ${JOBS} all -k; then
|
---|
553 | rm -f .bird-failed
|
---|
554 | echo -ne "\033]0;build.sh - ${KERN_SUBDIR} - done\007"
|
---|
555 | else
|
---|
556 | touch .bird-failed
|
---|
557 | echo -ne "\033]0;build.sh - ${KERN_SUBDIR} - failed\007"
|
---|
558 | exit 1
|
---|
559 | fi
|
---|
560 |
|
---|