aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build5
-rw-r--r--scripts/Makefile.clean16
-rw-r--r--scripts/Makefile.kasan25
-rw-r--r--scripts/Makefile.lib10
-rw-r--r--scripts/asn1_compiler.c30
-rwxr-xr-xscripts/checkpatch.pl147
-rwxr-xr-xscripts/diffconfig1
-rw-r--r--scripts/module-common.lds23
-rwxr-xr-xscripts/recordmcount.pl10
9 files changed, 206 insertions, 61 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 649ce6844033..01df30af4d4a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -234,8 +234,9 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH
234 "$(if $(part-of-module),1,0)" "$(@)"; 234 "$(if $(part-of-module),1,0)" "$(@)";
235recordmcount_source := $(srctree)/scripts/recordmcount.pl 235recordmcount_source := $(srctree)/scripts/recordmcount.pl
236endif 236endif
237cmd_record_mcount = \ 237cmd_record_mcount = \
238 if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \ 238 if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \
239 "$(CC_FLAGS_FTRACE)" ]; then \
239 $(sub_cmd_record_mcount) \ 240 $(sub_cmd_record_mcount) \
240 fi; 241 fi;
241endif 242endif
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 1bca180db8ad..627f8cbbedb8 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -42,19 +42,19 @@ __clean-files := $(extra-y) $(extra-m) $(extra-) \
42 42
43__clean-files := $(filter-out $(no-clean-files), $(__clean-files)) 43__clean-files := $(filter-out $(no-clean-files), $(__clean-files))
44 44
45# as clean-files is given relative to the current directory, this adds 45# clean-files is given relative to the current directory, unless it
46# a $(obj) prefix, except for absolute paths 46# starts with $(objtree)/ (which means "./", so do not add "./" unless
47# you want to delete a file from the toplevel object directory).
47 48
48__clean-files := $(wildcard \ 49__clean-files := $(wildcard \
49 $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \ 50 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
50 $(filter /%, $(__clean-files))) 51 $(filter $(objtree)/%, $(__clean-files)))
51 52
52# as clean-dirs is given relative to the current directory, this adds 53# same as clean-files
53# a $(obj) prefix, except for absolute paths
54 54
55__clean-dirs := $(wildcard \ 55__clean-dirs := $(wildcard \
56 $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \ 56 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \
57 $(filter /%, $(clean-dirs))) 57 $(filter $(objtree)/%, $(clean-dirs)))
58 58
59# ========================================================================== 59# ==========================================================================
60 60
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
new file mode 100644
index 000000000000..631619b2b118
--- /dev/null
+++ b/scripts/Makefile.kasan
@@ -0,0 +1,25 @@
1ifdef CONFIG_KASAN
2ifdef CONFIG_KASAN_INLINE
3 call_threshold := 10000
4else
5 call_threshold := 0
6endif
7
8CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
9
10CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \
11 -fasan-shadow-offset=$(CONFIG_KASAN_SHADOW_OFFSET) \
12 --param asan-stack=1 --param asan-globals=1 \
13 --param asan-instrumentation-with-call-threshold=$(call_threshold))
14
15ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),)
16 $(warning Cannot use CONFIG_KASAN: \
17 -fsanitize=kernel-address is not supported by compiler)
18else
19 ifeq ($(CFLAGS_KASAN),)
20 $(warning CONFIG_KASAN: compiler does not support all options.\
21 Trying minimal configuration)
22 CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
23 endif
24endif
25endif
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 511755200634..044eb4f89a91 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -119,6 +119,16 @@ _c_flags += $(if $(patsubst n%,, \
119 $(CFLAGS_GCOV)) 119 $(CFLAGS_GCOV))
120endif 120endif
121 121
122#
123# Enable address sanitizer flags for kernel except some files or directories
124# we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE)
125#
126ifeq ($(CONFIG_KASAN),y)
127_c_flags += $(if $(patsubst n%,, \
128 $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
129 $(CFLAGS_KASAN))
130endif
131
122# If building the kernel in a separate objtree expand all occurrences 132# If building the kernel in a separate objtree expand all occurrences
123# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 133# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
124 134
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index 91c4117637ae..7750e9c31483 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -311,6 +311,9 @@ struct token {
311 311
312static struct token *token_list; 312static struct token *token_list;
313static unsigned nr_tokens; 313static unsigned nr_tokens;
314static _Bool verbose;
315
316#define debug(fmt, ...) do { if (verbose) printf(fmt, ## __VA_ARGS__); } while (0)
314 317
315static int directive_compare(const void *_key, const void *_pdir) 318static int directive_compare(const void *_key, const void *_pdir)
316{ 319{
@@ -322,21 +325,21 @@ static int directive_compare(const void *_key, const void *_pdir)
322 dlen = strlen(dir); 325 dlen = strlen(dir);
323 clen = (dlen < token->size) ? dlen : token->size; 326 clen = (dlen < token->size) ? dlen : token->size;
324 327
325 //printf("cmp(%*.*s,%s) = ", 328 //debug("cmp(%*.*s,%s) = ",
326 // (int)token->size, (int)token->size, token->value, 329 // (int)token->size, (int)token->size, token->value,
327 // dir); 330 // dir);
328 331
329 val = memcmp(token->value, dir, clen); 332 val = memcmp(token->value, dir, clen);
330 if (val != 0) { 333 if (val != 0) {
331 //printf("%d [cmp]\n", val); 334 //debug("%d [cmp]\n", val);
332 return val; 335 return val;
333 } 336 }
334 337
335 if (dlen == token->size) { 338 if (dlen == token->size) {
336 //printf("0\n"); 339 //debug("0\n");
337 return 0; 340 return 0;
338 } 341 }
339 //printf("%d\n", (int)dlen - (int)token->size); 342 //debug("%d\n", (int)dlen - (int)token->size);
340 return dlen - token->size; /* shorter -> negative */ 343 return dlen - token->size; /* shorter -> negative */
341} 344}
342 345
@@ -515,13 +518,13 @@ static void tokenise(char *buffer, char *end)
515 } 518 }
516 519
517 nr_tokens = tix; 520 nr_tokens = tix;
518 printf("Extracted %u tokens\n", nr_tokens); 521 debug("Extracted %u tokens\n", nr_tokens);
519 522
520#if 0 523#if 0
521 { 524 {
522 int n; 525 int n;
523 for (n = 0; n < nr_tokens; n++) 526 for (n = 0; n < nr_tokens; n++)
524 printf("Token %3u: '%*.*s'\n", 527 debug("Token %3u: '%*.*s'\n",
525 n, 528 n,
526 (int)token_list[n].size, (int)token_list[n].size, 529 (int)token_list[n].size, (int)token_list[n].size,
527 token_list[n].value); 530 token_list[n].value);
@@ -542,6 +545,7 @@ int main(int argc, char **argv)
542 ssize_t readlen; 545 ssize_t readlen;
543 FILE *out, *hdr; 546 FILE *out, *hdr;
544 char *buffer, *p; 547 char *buffer, *p;
548 char *kbuild_verbose;
545 int fd; 549 int fd;
546 550
547 if (argc != 4) { 551 if (argc != 4) {
@@ -550,6 +554,10 @@ int main(int argc, char **argv)
550 exit(2); 554 exit(2);
551 } 555 }
552 556
557 kbuild_verbose = getenv("KBUILD_VERBOSE");
558 if (kbuild_verbose)
559 verbose = atoi(kbuild_verbose);
560
553 filename = argv[1]; 561 filename = argv[1];
554 outputname = argv[2]; 562 outputname = argv[2];
555 headername = argv[3]; 563 headername = argv[3];
@@ -748,11 +756,11 @@ static void build_type_list(void)
748 756
749 qsort(type_index, nr, sizeof(type_index[0]), type_index_compare); 757 qsort(type_index, nr, sizeof(type_index[0]), type_index_compare);
750 758
751 printf("Extracted %u types\n", nr_types); 759 debug("Extracted %u types\n", nr_types);
752#if 0 760#if 0
753 for (n = 0; n < nr_types; n++) { 761 for (n = 0; n < nr_types; n++) {
754 struct type *type = type_index[n]; 762 struct type *type = type_index[n];
755 printf("- %*.*s\n", 763 debug("- %*.*s\n",
756 (int)type->name->size, 764 (int)type->name->size,
757 (int)type->name->size, 765 (int)type->name->size,
758 type->name->value); 766 type->name->value);
@@ -793,7 +801,7 @@ static void parse(void)
793 801
794 } while (type++, !(type->flags & TYPE_STOP_MARKER)); 802 } while (type++, !(type->flags & TYPE_STOP_MARKER));
795 803
796 printf("Extracted %u actions\n", nr_actions); 804 debug("Extracted %u actions\n", nr_actions);
797} 805}
798 806
799static struct element *element_list; 807static struct element *element_list;
@@ -1284,7 +1292,7 @@ static void render(FILE *out, FILE *hdr)
1284 } 1292 }
1285 1293
1286 /* We do two passes - the first one calculates all the offsets */ 1294 /* We do two passes - the first one calculates all the offsets */
1287 printf("Pass 1\n"); 1295 debug("Pass 1\n");
1288 nr_entries = 0; 1296 nr_entries = 0;
1289 root = &type_list[0]; 1297 root = &type_list[0];
1290 render_element(NULL, root->element, NULL); 1298 render_element(NULL, root->element, NULL);
@@ -1295,7 +1303,7 @@ static void render(FILE *out, FILE *hdr)
1295 e->flags &= ~ELEMENT_RENDERED; 1303 e->flags &= ~ELEMENT_RENDERED;
1296 1304
1297 /* And then we actually render */ 1305 /* And then we actually render */
1298 printf("Pass 2\n"); 1306 debug("Pass 2\n");
1299 fprintf(out, "\n"); 1307 fprintf(out, "\n");
1300 fprintf(out, "static const unsigned char %s_machine[] = {\n", 1308 fprintf(out, "static const unsigned char %s_machine[] = {\n",
1301 grammar_name); 1309 grammar_name);
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f0bb6d60c07b..d12435992dea 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -278,6 +278,7 @@ our $Attribute = qr{
278 __noreturn| 278 __noreturn|
279 __used| 279 __used|
280 __cold| 280 __cold|
281 __pure|
281 __noclone| 282 __noclone|
282 __deprecated| 283 __deprecated|
283 __read_mostly| 284 __read_mostly|
@@ -298,6 +299,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?};
298our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?}; 299our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
299our $Int = qr{[0-9]+$Int_type?}; 300our $Int = qr{[0-9]+$Int_type?};
300our $Octal = qr{0[0-7]+$Int_type?}; 301our $Octal = qr{0[0-7]+$Int_type?};
302our $String = qr{"[X\t]*"};
301our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; 303our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
302our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; 304our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
303our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; 305our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
@@ -337,6 +339,11 @@ our $UTF8 = qr{
337 | $NON_ASCII_UTF8 339 | $NON_ASCII_UTF8
338}x; 340}x;
339 341
342our $typeOtherOSTypedefs = qr{(?x:
343 u_(?:char|short|int|long) | # bsd
344 u(?:nchar|short|int|long) # sysv
345)};
346
340our $typeTypedefs = qr{(?x: 347our $typeTypedefs = qr{(?x:
341 (?:__)?(?:u|s|be|le)(?:8|16|32|64)| 348 (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
342 atomic_t 349 atomic_t
@@ -473,6 +480,7 @@ sub build_types {
473 (?:$Modifier\s+|const\s+)* 480 (?:$Modifier\s+|const\s+)*
474 (?: 481 (?:
475 (?:typeof|__typeof__)\s*\([^\)]*\)| 482 (?:typeof|__typeof__)\s*\([^\)]*\)|
483 (?:$typeOtherOSTypedefs\b)|
476 (?:$typeTypedefs\b)| 484 (?:$typeTypedefs\b)|
477 (?:${all}\b) 485 (?:${all}\b)
478 ) 486 )
@@ -490,6 +498,7 @@ sub build_types {
490 (?: 498 (?:
491 (?:typeof|__typeof__)\s*\([^\)]*\)| 499 (?:typeof|__typeof__)\s*\([^\)]*\)|
492 (?:$typeTypedefs\b)| 500 (?:$typeTypedefs\b)|
501 (?:$typeOtherOSTypedefs\b)|
493 (?:${allWithAttr}\b) 502 (?:${allWithAttr}\b)
494 ) 503 )
495 (?:\s+$Modifier|\s+const)* 504 (?:\s+$Modifier|\s+const)*
@@ -517,7 +526,7 @@ our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
517 526
518our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; 527our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
519our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*}; 528our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
520our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)}; 529our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
521 530
522our $declaration_macros = qr{(?x: 531our $declaration_macros = qr{(?x:
523 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(| 532 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|
@@ -632,6 +641,8 @@ sub git_commit_info {
632 $output =~ s/^\s*//gm; 641 $output =~ s/^\s*//gm;
633 my @lines = split("\n", $output); 642 my @lines = split("\n", $output);
634 643
644 return ($id, $desc) if ($#lines < 0);
645
635 if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) { 646 if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) {
636# Maybe one day convert this block of bash into something that returns 647# Maybe one day convert this block of bash into something that returns
637# all matching commit ids, but it's very slow... 648# all matching commit ids, but it's very slow...
@@ -2159,6 +2170,13 @@ sub process {
2159 } 2170 }
2160 } 2171 }
2161 2172
2173# Check email subject for common tools that don't need to be mentioned
2174 if ($in_header_lines &&
2175 $line =~ /^Subject:.*\b(?:checkpatch|sparse|smatch)\b[^:]/i) {
2176 WARN("EMAIL_SUBJECT",
2177 "A patch subject line should describe the change not the tool that found it\n" . $herecurr);
2178 }
2179
2162# Check for old stable address 2180# Check for old stable address
2163 if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) { 2181 if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) {
2164 ERROR("STABLE_ADDRESS", 2182 ERROR("STABLE_ADDRESS",
@@ -2171,21 +2189,49 @@ sub process {
2171 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); 2189 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
2172 } 2190 }
2173 2191
2174# Check for improperly formed commit descriptions 2192# Check for git id commit length and improperly formed commit descriptions
2175 if ($in_commit_log && 2193 if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) {
2176 $line =~ /\bcommit\s+[0-9a-f]{5,}/i &&
2177 !($line =~ /\b[Cc]ommit [0-9a-f]{12,40} \("/ ||
2178 ($line =~ /\b[Cc]ommit [0-9a-f]{12,40}\s*$/ &&
2179 defined $rawlines[$linenr] &&
2180 $rawlines[$linenr] =~ /^\s*\("/))) {
2181 $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i;
2182 my $init_char = $1; 2194 my $init_char = $1;
2183 my $orig_commit = lc($2); 2195 my $orig_commit = lc($2);
2184 my $id = '01234567890ab'; 2196 my $short = 1;
2185 my $desc = 'commit description'; 2197 my $long = 0;
2186 ($id, $desc) = git_commit_info($orig_commit, $id, $desc); 2198 my $case = 1;
2187 ERROR("GIT_COMMIT_ID", 2199 my $space = 1;
2188 "Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr); 2200 my $hasdesc = 0;
2201 my $hasparens = 0;
2202 my $id = '0123456789ab';
2203 my $orig_desc = "commit description";
2204 my $description = "";
2205
2206 $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
2207 $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
2208 $space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
2209 $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
2210 if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
2211 $orig_desc = $1;
2212 $hasparens = 1;
2213 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
2214 defined $rawlines[$linenr] &&
2215 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
2216 $orig_desc = $1;
2217 $hasparens = 1;
2218 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
2219 defined $rawlines[$linenr] &&
2220 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
2221 $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
2222 $orig_desc = $1;
2223 $rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
2224 $orig_desc .= " " . $1;
2225 $hasparens = 1;
2226 }
2227
2228 ($id, $description) = git_commit_info($orig_commit,
2229 $id, $orig_desc);
2230
2231 if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) {
2232 ERROR("GIT_COMMIT_ID",
2233 "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
2234 }
2189 } 2235 }
2190 2236
2191# Check for added, moved or deleted files 2237# Check for added, moved or deleted files
@@ -2355,6 +2401,13 @@ sub process {
2355 "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n"); 2401 "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
2356 } 2402 }
2357 2403
2404# discourage the use of boolean for type definition attributes of Kconfig options
2405 if ($realfile =~ /Kconfig/ &&
2406 $line =~ /^\+\s*\bboolean\b/) {
2407 WARN("CONFIG_TYPE_BOOLEAN",
2408 "Use of boolean is deprecated, please use bool instead.\n" . $herecurr);
2409 }
2410
2358 if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && 2411 if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
2359 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { 2412 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
2360 my $flag = $1; 2413 my $flag = $1;
@@ -2499,7 +2552,7 @@ sub process {
2499 } 2552 }
2500 } 2553 }
2501 2554
2502 if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;\({\[\<\>])/ && 2555 if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;:\?\(\{\}\[\<\>]|&&|\|\||\\$)/ &&
2503 (!defined($1) || $1 !~ /sizeof\s*/)) { 2556 (!defined($1) || $1 !~ /sizeof\s*/)) {
2504 if (CHK("SPACING", 2557 if (CHK("SPACING",
2505 "No space is necessary after a cast\n" . $herecurr) && 2558 "No space is necessary after a cast\n" . $herecurr) &&
@@ -3124,6 +3177,7 @@ sub process {
3124 $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && 3177 $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
3125 $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && 3178 $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
3126 $line !~ /\b$typeTypedefs\b/ && 3179 $line !~ /\b$typeTypedefs\b/ &&
3180 $line !~ /\b$typeOtherOSTypedefs\b/ &&
3127 $line !~ /\b__bitwise(?:__|)\b/) { 3181 $line !~ /\b__bitwise(?:__|)\b/) {
3128 WARN("NEW_TYPEDEFS", 3182 WARN("NEW_TYPEDEFS",
3129 "do not add new typedefs\n" . $herecurr); 3183 "do not add new typedefs\n" . $herecurr);
@@ -3200,7 +3254,7 @@ sub process {
3200# check for uses of printk_ratelimit 3254# check for uses of printk_ratelimit
3201 if ($line =~ /\bprintk_ratelimit\s*\(/) { 3255 if ($line =~ /\bprintk_ratelimit\s*\(/) {
3202 WARN("PRINTK_RATELIMITED", 3256 WARN("PRINTK_RATELIMITED",
3203"Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); 3257 "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
3204 } 3258 }
3205 3259
3206# printk should use KERN_* levels. Note that follow on printk's on the 3260# printk should use KERN_* levels. Note that follow on printk's on the
@@ -3646,7 +3700,22 @@ sub process {
3646 $op eq '*' or $op eq '/' or 3700 $op eq '*' or $op eq '/' or
3647 $op eq '%') 3701 $op eq '%')
3648 { 3702 {
3649 if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { 3703 if ($check) {
3704 if (defined $fix_elements[$n + 2] && $ctx !~ /[EW]x[EW]/) {
3705 if (CHK("SPACING",
3706 "spaces preferred around that '$op' $at\n" . $hereptr)) {
3707 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
3708 $fix_elements[$n + 2] =~ s/^\s+//;
3709 $line_fixed = 1;
3710 }
3711 } elsif (!defined $fix_elements[$n + 2] && $ctx !~ /Wx[OE]/) {
3712 if (CHK("SPACING",
3713 "space preferred before that '$op' $at\n" . $hereptr)) {
3714 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]);
3715 $line_fixed = 1;
3716 }
3717 }
3718 } elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
3650 if (ERROR("SPACING", 3719 if (ERROR("SPACING",
3651 "need consistent spacing around '$op' $at\n" . $hereptr)) { 3720 "need consistent spacing around '$op' $at\n" . $hereptr)) {
3652 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; 3721 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
@@ -4251,6 +4320,7 @@ sub process {
4251 $ctx = $dstat; 4320 $ctx = $dstat;
4252 4321
4253 $dstat =~ s/\\\n.//g; 4322 $dstat =~ s/\\\n.//g;
4323 $dstat =~ s/$;/ /g;
4254 4324
4255 if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) { 4325 if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) {
4256 my $stmts = $2; 4326 my $stmts = $2;
@@ -4417,12 +4487,18 @@ sub process {
4417 4487
4418# check for unnecessary blank lines around braces 4488# check for unnecessary blank lines around braces
4419 if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) { 4489 if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
4420 CHK("BRACES", 4490 if (CHK("BRACES",
4421 "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); 4491 "Blank lines aren't necessary before a close brace '}'\n" . $hereprev) &&
4492 $fix && $prevrawline =~ /^\+/) {
4493 fix_delete_line($fixlinenr - 1, $prevrawline);
4494 }
4422 } 4495 }
4423 if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { 4496 if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
4424 CHK("BRACES", 4497 if (CHK("BRACES",
4425 "Blank lines aren't necessary after an open brace '{'\n" . $hereprev); 4498 "Blank lines aren't necessary after an open brace '{'\n" . $hereprev) &&
4499 $fix) {
4500 fix_delete_line($fixlinenr, $rawline);
4501 }
4426 } 4502 }
4427 4503
4428# no volatiles please 4504# no volatiles please
@@ -4545,7 +4621,7 @@ sub process {
4545 } 4621 }
4546 4622
4547# check for logging functions with KERN_<LEVEL> 4623# check for logging functions with KERN_<LEVEL>
4548 if ($line !~ /printk\s*\(/ && 4624 if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ &&
4549 $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) { 4625 $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
4550 my $level = $1; 4626 my $level = $1;
4551 if (WARN("UNNECESSARY_KERN_LEVEL", 4627 if (WARN("UNNECESSARY_KERN_LEVEL",
@@ -4804,7 +4880,8 @@ sub process {
4804# check for seq_printf uses that could be seq_puts 4880# check for seq_printf uses that could be seq_puts
4805 if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) { 4881 if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) {
4806 my $fmt = get_quoted_string($line, $rawline); 4882 my $fmt = get_quoted_string($line, $rawline);
4807 if ($fmt ne "" && $fmt !~ /[^\\]\%/) { 4883 $fmt =~ s/%%//g;
4884 if ($fmt !~ /%/) {
4808 if (WARN("PREFER_SEQ_PUTS", 4885 if (WARN("PREFER_SEQ_PUTS",
4809 "Prefer seq_puts to seq_printf\n" . $herecurr) && 4886 "Prefer seq_puts to seq_printf\n" . $herecurr) &&
4810 $fix) { 4887 $fix) {
@@ -5089,6 +5166,12 @@ sub process {
5089 } 5166 }
5090 } 5167 }
5091 5168
5169# check for uses of __DATE__, __TIME__, __TIMESTAMP__
5170 while ($line =~ /\b(__(?:DATE|TIME|TIMESTAMP)__)\b/g) {
5171 ERROR("DATE_TIME",
5172 "Use of the '$1' macro makes the build non-deterministic\n" . $herecurr);
5173 }
5174
5092# check for use of yield() 5175# check for use of yield()
5093 if ($line =~ /\byield\s*\(\s*\)/) { 5176 if ($line =~ /\byield\s*\(\s*\)/) {
5094 WARN("YIELD", 5177 WARN("YIELD",
@@ -5140,8 +5223,9 @@ sub process {
5140 "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr); 5223 "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
5141 } 5224 }
5142 5225
5143# check for various ops structs, ensure they are const. 5226# check for various structs that are normally const (ops, kgdb, device_tree)
5144 my $struct_ops = qr{acpi_dock_ops| 5227 my $const_structs = qr{
5228 acpi_dock_ops|
5145 address_space_operations| 5229 address_space_operations|
5146 backlight_ops| 5230 backlight_ops|
5147 block_device_operations| 5231 block_device_operations|
@@ -5164,6 +5248,7 @@ sub process {
5164 mtrr_ops| 5248 mtrr_ops|
5165 neigh_ops| 5249 neigh_ops|
5166 nlmsvc_binding| 5250 nlmsvc_binding|
5251 of_device_id|
5167 pci_raw_ops| 5252 pci_raw_ops|
5168 pipe_buf_operations| 5253 pipe_buf_operations|
5169 platform_hibernation_ops| 5254 platform_hibernation_ops|
@@ -5179,7 +5264,7 @@ sub process {
5179 usb_mon_operations| 5264 usb_mon_operations|
5180 wd_ops}x; 5265 wd_ops}x;
5181 if ($line !~ /\bconst\b/ && 5266 if ($line !~ /\bconst\b/ &&
5182 $line =~ /\bstruct\s+($struct_ops)\b/) { 5267 $line =~ /\bstruct\s+($const_structs)\b/) {
5183 WARN("CONST_STRUCT", 5268 WARN("CONST_STRUCT",
5184 "struct $1 should normally be const\n" . 5269 "struct $1 should normally be const\n" .
5185 $herecurr); 5270 $herecurr);
@@ -5204,6 +5289,13 @@ sub process {
5204 "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr); 5289 "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
5205 } 5290 }
5206 5291
5292# likely/unlikely comparisons similar to "(likely(foo) > 0)"
5293 if ($^V && $^V ge 5.10.0 &&
5294 $line =~ /\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) {
5295 WARN("LIKELY_MISUSE",
5296 "Using $1 should generally have parentheses around the comparison\n" . $herecurr);
5297 }
5298
5207# whine mightly about in_atomic 5299# whine mightly about in_atomic
5208 if ($line =~ /\bin_atomic\s*\(/) { 5300 if ($line =~ /\bin_atomic\s*\(/) {
5209 if ($realfile =~ m@^drivers/@) { 5301 if ($realfile =~ m@^drivers/@) {
@@ -5255,6 +5347,9 @@ sub process {
5255 length($val) ne 4)) { 5347 length($val) ne 4)) {
5256 ERROR("NON_OCTAL_PERMISSIONS", 5348 ERROR("NON_OCTAL_PERMISSIONS",
5257 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr); 5349 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);
5350 } elsif ($val =~ /^$Octal$/ && (oct($val) & 02)) {
5351 ERROR("EXPORTED_WORLD_WRITABLE",
5352 "Exporting writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
5258 } 5353 }
5259 } 5354 }
5260 } 5355 }
diff --git a/scripts/diffconfig b/scripts/diffconfig
index 6d672836e187..0db267d0adc9 100755
--- a/scripts/diffconfig
+++ b/scripts/diffconfig
@@ -28,7 +28,6 @@ If no config files are specified, .config and .config.old are used.
28Example usage: 28Example usage:
29 $ diffconfig .config config-with-some-changes 29 $ diffconfig .config config-with-some-changes
30-EXT2_FS_XATTR n 30-EXT2_FS_XATTR n
31-EXT2_FS_XIP n
32 CRAMFS n -> y 31 CRAMFS n -> y
33 EXT2_FS y -> n 32 EXT2_FS y -> n
34 LOG_BUF_SHIFT 14 -> 16 33 LOG_BUF_SHIFT 14 -> 16
diff --git a/scripts/module-common.lds b/scripts/module-common.lds
index 0865b3e752be..73a2c7da0e55 100644
--- a/scripts/module-common.lds
+++ b/scripts/module-common.lds
@@ -6,14 +6,17 @@
6SECTIONS { 6SECTIONS {
7 /DISCARD/ : { *(.discard) } 7 /DISCARD/ : { *(.discard) }
8 8
9 __ksymtab : { *(SORT(___ksymtab+*)) } 9 __ksymtab 0 : { *(SORT(___ksymtab+*)) }
10 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) } 10 __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
11 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) } 11 __ksymtab_unused 0 : { *(SORT(___ksymtab_unused+*)) }
12 __ksymtab_unused_gpl : { *(SORT(___ksymtab_unused_gpl+*)) } 12 __ksymtab_unused_gpl 0 : { *(SORT(___ksymtab_unused_gpl+*)) }
13 __ksymtab_gpl_future : { *(SORT(___ksymtab_gpl_future+*)) } 13 __ksymtab_gpl_future 0 : { *(SORT(___ksymtab_gpl_future+*)) }
14 __kcrctab : { *(SORT(___kcrctab+*)) } 14 __kcrctab 0 : { *(SORT(___kcrctab+*)) }
15 __kcrctab_gpl : { *(SORT(___kcrctab_gpl+*)) } 15 __kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
16 __kcrctab_unused : { *(SORT(___kcrctab_unused+*)) } 16 __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) }
17 __kcrctab_unused_gpl : { *(SORT(___kcrctab_unused_gpl+*)) } 17 __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) }
18 __kcrctab_gpl_future : { *(SORT(___kcrctab_gpl_future+*)) } 18 __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) }
19
20 . = ALIGN(8);
21 .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) }
19} 22}
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 56ea99a12ab7..826470d7f000 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -242,8 +242,13 @@ if ($arch eq "x86_64") {
242 $cc .= " -m32"; 242 $cc .= " -m32";
243 243
244} elsif ($arch eq "s390" && $bits == 64) { 244} elsif ($arch eq "s390" && $bits == 64) {
245 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_(PC|PLT)32DBL\\s+_mcount\\+0x2\$"; 245 if ($cc =~ /-DCC_USING_HOTPATCH/) {
246 $mcount_adjust = -14; 246 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*c0 04 00 00 00 00\\s*brcl\\s*0,[0-9a-f]+ <([^\+]*)>\$";
247 $mcount_adjust = 0;
248 } else {
249 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_(PC|PLT)32DBL\\s+_mcount\\+0x2\$";
250 $mcount_adjust = -14;
251 }
247 $alignment = 8; 252 $alignment = 8;
248 $type = ".quad"; 253 $type = ".quad";
249 $ld .= " -m elf64_s390"; 254 $ld .= " -m elf64_s390";
@@ -255,7 +260,6 @@ if ($arch eq "x86_64") {
255 # force flags for this arch 260 # force flags for this arch
256 $ld .= " -m shlelf_linux"; 261 $ld .= " -m shlelf_linux";
257 $objcopy .= " -O elf32-sh-linux"; 262 $objcopy .= " -O elf32-sh-linux";
258 $cc .= " -m32";
259 263
260} elsif ($arch eq "powerpc") { 264} elsif ($arch eq "powerpc") {
261 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; 265 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";