I need to pick up the independent changes made to Documentation/core-api/memory-allocation.rst to be able to merge further work without creating a total mess.
Showing the changes to scripts (13 of 976 files). Show all
Unified · Split
| @@ -143,11 +143,6 @@ cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || e · 142 unmodified lines | ||
| 143 | 143 | # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) |
| 144 | 144 | ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) |
| 145 | 145 | |
| 146 | −# ar-option | |
| 147 | −# Usage: KBUILD_ARFLAGS := $(call ar-option,D) | |
| 148 | −# Important: no spaces around options | |
| 149 | −ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) | |
| 150 | − | |
| 151 | 146 | # ld-version |
| 152 | 147 | # Note this is mainly for HJ Lu's 3 number binutil versions |
| 153 | 148 | ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) |
| @@ -389,7 +389,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; · 388 unmodified lines | ||
| 389 | 389 | ifdef builtin-target |
| 390 | 390 | |
| 391 | 391 | quiet_cmd_ar_builtin = AR $@ |
| 392 | − cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) | |
| 392 | + cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs) | |
| 393 | 393 | |
| 394 | 394 | $(builtin-target): $(real-obj-y) FORCE |
| 395 | 395 | $(call if_changed,ar_builtin) |
| @@ -232,7 +232,7 @@ quiet_cmd_ld = LD $@ · 231 unmodified lines | ||
| 232 | 232 | # --------------------------------------------------------------------------- |
| 233 | 233 | |
| 234 | 234 | quiet_cmd_ar = AR $@ |
| 235 | − cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) | |
| 235 | + cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs) | |
| 236 | 236 | |
| 237 | 237 | # Objcopy |
| 238 | 238 | # --------------------------------------------------------------------------- |
| @@ -1,60 +0,0 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0 | |
| 2 | −/// Use devm_platform_ioremap_resource helper which wraps | |
| 3 | −/// platform_get_resource() and devm_ioremap_resource() together. | |
| 4 | −/// | |
| 5 | −// Confidence: High | |
| 6 | −// Copyright: (C) 2019 Himanshu Jha GPLv2. | |
| 7 | −// Copyright: (C) 2019 Julia Lawall, Inria/LIP6. GPLv2. | |
| 8 | −// Keywords: platform_get_resource, devm_ioremap_resource, | |
| 9 | −// Keywords: devm_platform_ioremap_resource | |
| 10 | − | |
| 11 | −virtual patch | |
| 12 | −virtual report | |
| 13 | − | |
| 14 | −@r depends on patch && !report@ | |
| 15 | −expression e1, e2, arg1, arg2, arg3; | |
| 16 | −identifier id; | |
| 17 | −@@ | |
| 18 | − | |
| 19 | −( | |
| 20 | −- id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | |
| 21 | −| | |
| 22 | −- struct resource *id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | |
| 23 | −) | |
| 24 | − ... when != id | |
| 25 | −- e1 = devm_ioremap_resource(arg3, id); | |
| 26 | −+ e1 = devm_platform_ioremap_resource(arg1, arg2); | |
| 27 | − ... when != id | |
| 28 | −? id = e2 | |
| 29 | − | |
| 30 | −@r1 depends on patch && !report@ | |
| 31 | −identifier r.id; | |
| 32 | −type T; | |
| 33 | −@@ | |
| 34 | − | |
| 35 | −- T *id; | |
| 36 | − ...when != id | |
| 37 | − | |
| 38 | −@r2 depends on report && !patch@ | |
| 39 | −identifier id; | |
| 40 | −expression e1, e2, arg1, arg2, arg3; | |
| 41 | −position j0; | |
| 42 | −@@ | |
| 43 | − | |
| 44 | −( | |
| 45 | − id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | |
| 46 | −| | |
| 47 | − struct resource *id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | |
| 48 | −) | |
| 49 | − ... when != id | |
| 50 | − e1@j0 = devm_ioremap_resource(arg3, id); | |
| 51 | − ... when != id | |
| 52 | −? id = e2 | |
| 53 | − | |
| 54 | −@script:python depends on report && !patch@ | |
| 55 | −e1 << r2.e1; | |
| 56 | −j0 << r2.j0; | |
| 57 | −@@ | |
| 58 | − | |
| 59 | −msg = "WARNING: Use devm_platform_ioremap_resource for %s" % (e1) | |
| 60 | −coccilib.report.print_report(j0[0], msg) | |
| @@ -6,6 +6,8 @@ · 5 unmodified lines | ||
| 6 | 6 | /// add a missing namespace tag to a module source file. |
| 7 | 7 | /// |
| 8 | 8 | |
| 9 | +virtual report | |
| 10 | + | |
| 9 | 11 | @has_ns_import@ |
| 10 | 12 | declarer name MODULE_IMPORT_NS; |
| 11 | 13 | identifier virtual.ns; |
| @@ -16,6 +16,8 @@ import sys · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | from linux import utils |
| 18 | 18 | |
| 19 | +printk_log_type = utils.CachedType("struct printk_log") | |
| 20 | + | |
| 19 | 21 | |
| 20 | 22 | class LxDmesg(gdb.Command): |
| 21 | 23 | """Print Linux kernel log buffer.""" |
| @@ -42,9 +44,14 @@ class LxDmesg(gdb.Command): · 20 unmodified lines | ||
| 42 | 44 | b = utils.read_memoryview(inf, log_buf_addr, log_next_idx) |
| 43 | 45 | log_buf = a.tobytes() + b.tobytes() |
| 44 | 46 | |
| 47 | + length_offset = printk_log_type.get_type()['len'].bitpos // 8 | |
| 48 | + text_len_offset = printk_log_type.get_type()['text_len'].bitpos // 8 | |
| 49 | + time_stamp_offset = printk_log_type.get_type()['ts_nsec'].bitpos // 8 | |
| 50 | + text_offset = printk_log_type.get_type().sizeof | |
| 51 | + | |
| 45 | 52 | pos = 0 |
| 46 | 53 | while pos < log_buf.__len__(): |
| 47 | − length = utils.read_u16(log_buf[pos + 8:pos + 10]) | |
| 54 | + length = utils.read_u16(log_buf, pos + length_offset) | |
| 48 | 55 | if length == 0: |
| 49 | 56 | if log_buf_2nd_half == -1: |
| 50 | 57 | gdb.write("Corrupted log buffer!\n") |
| @@ -52,10 +59,11 @@ class LxDmesg(gdb.Command): · 1 unmodified line | ||
| 52 | 59 | pos = log_buf_2nd_half |
| 53 | 60 | continue |
| 54 | 61 | |
| 55 | − text_len = utils.read_u16(log_buf[pos + 10:pos + 12]) | |
| 56 | − text = log_buf[pos + 16:pos + 16 + text_len].decode( | |
| 62 | + text_len = utils.read_u16(log_buf, pos + text_len_offset) | |
| 63 | + text_start = pos + text_offset | |
| 64 | + text = log_buf[text_start:text_start + text_len].decode( | |
| 57 | 65 | encoding='utf8', errors='replace') |
| 58 | − time_stamp = utils.read_u64(log_buf[pos:pos + 8]) | |
| 66 | + time_stamp = utils.read_u64(log_buf, pos + time_stamp_offset) | |
| 59 | 67 | |
| 60 | 68 | for line in text.splitlines(): |
| 61 | 69 | msg = u"[{time:12.6f}] {line}\n".format( |
| @@ -15,7 +15,7 @@ import gdb · 14 unmodified lines | ||
| 15 | 15 | import os |
| 16 | 16 | import re |
| 17 | 17 | |
| 18 | −from linux import modules | |
| 18 | +from linux import modules, utils | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | if hasattr(gdb, 'Breakpoint'): |
| @@ -116,6 +116,12 @@ lx-symbols command.""" · 94 unmodified lines | ||
| 116 | 116 | module_file = self._get_module_file(module_name) |
| 117 | 117 | |
| 118 | 118 | if module_file: |
| 119 | + if utils.is_target_arch('s390'): | |
| 120 | + # Module text is preceded by PLT stubs on s390. | |
| 121 | + module_arch = module['arch'] | |
| 122 | + plt_offset = int(module_arch['plt_offset']) | |
| 123 | + plt_size = int(module_arch['plt_size']) | |
| 124 | + module_addr = hex(int(module_addr, 0) + plt_offset + plt_size) | |
| 119 | 125 | gdb.write("loading @{addr}: {filename}\n".format( |
| 120 | 126 | addr=module_addr, filename=module_file)) |
| 121 | 127 | cmdline = "add-symbol-file {filename} {addr}{sections}".format( |
| @@ -92,15 +92,16 @@ def read_memoryview(inf, start, length): · 91 unmodified lines | ||
| 92 | 92 | return memoryview(inf.read_memory(start, length)) |
| 93 | 93 | |
| 94 | 94 | |
| 95 | −def read_u16(buffer): | |
| 95 | +def read_u16(buffer, offset): | |
| 96 | + buffer_val = buffer[offset:offset + 2] | |
| 96 | 97 | value = [0, 0] |
| 97 | 98 | |
| 98 | − if type(buffer[0]) is str: | |
| 99 | − value[0] = ord(buffer[0]) | |
| 100 | − value[1] = ord(buffer[1]) | |
| 99 | + if type(buffer_val[0]) is str: | |
| 100 | + value[0] = ord(buffer_val[0]) | |
| 101 | + value[1] = ord(buffer_val[1]) | |
| 101 | 102 | else: |
| 102 | − value[0] = buffer[0] | |
| 103 | − value[1] = buffer[1] | |
| 103 | + value[0] = buffer_val[0] | |
| 104 | + value[1] = buffer_val[1] | |
| 104 | 105 | |
| 105 | 106 | if get_target_endianness() == LITTLE_ENDIAN: |
| 106 | 107 | return value[0] + (value[1] << 8) |
| @@ -108,18 +109,18 @@ def read_u16(buffer): · 1 unmodified line | ||
| 108 | 109 | return value[1] + (value[0] << 8) |
| 109 | 110 | |
| 110 | 111 | |
| 111 | −def read_u32(buffer): | |
| 112 | +def read_u32(buffer, offset): | |
| 112 | 113 | if get_target_endianness() == LITTLE_ENDIAN: |
| 113 | − return read_u16(buffer[0:2]) + (read_u16(buffer[2:4]) << 16) | |
| 114 | + return read_u16(buffer, offset) + (read_u16(buffer, offset + 2) << 16) | |
| 114 | 115 | else: |
| 115 | − return read_u16(buffer[2:4]) + (read_u16(buffer[0:2]) << 16) | |
| 116 | + return read_u16(buffer, offset + 2) + (read_u16(buffer, offset) << 16) | |
| 116 | 117 | |
| 117 | 118 | |
| 118 | −def read_u64(buffer): | |
| 119 | +def read_u64(buffer, offset): | |
| 119 | 120 | if get_target_endianness() == LITTLE_ENDIAN: |
| 120 | − return read_u32(buffer[0:4]) + (read_u32(buffer[4:8]) << 32) | |
| 121 | + return read_u32(buffer, offset) + (read_u32(buffer, offset + 4) << 32) | |
| 121 | 122 | else: |
| 122 | − return read_u32(buffer[4:8]) + (read_u32(buffer[0:4]) << 32) | |
| 123 | + return read_u32(buffer, offset + 4) + (read_u32(buffer, offset) << 32) | |
| 123 | 124 | |
| 124 | 125 | |
| 125 | 126 | target_arch = None |
| @@ -166,7 +166,7 @@ struct symbol { · 165 unmodified lines | ||
| 166 | 166 | struct module *module; |
| 167 | 167 | unsigned int crc; |
| 168 | 168 | int crc_valid; |
| 169 | − const char *namespace; | |
| 169 | + char *namespace; | |
| 170 | 170 | unsigned int weak:1; |
| 171 | 171 | unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ |
| 172 | 172 | unsigned int kernel:1; /* 1 if symbol is from kernel |
| @@ -348,20 +348,18 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) · 175 unmodified lines | ||
| 348 | 348 | return export_unknown; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | −static const char *sym_extract_namespace(const char **symname) | |
| 351 | +static char *sym_extract_namespace(const char **symname) | |
| 352 | 352 | { |
| 353 | − size_t n; | |
| 354 | − char *dupsymname; | |
| 353 | + char *namespace = NULL; | |
| 354 | + char *ns_separator; | |
| 355 | 355 | |
| 356 | − n = strcspn(*symname, "."); | |
| 357 | − if (n < strlen(*symname) - 1) { | |
| 358 | − dupsymname = NOFAIL(strdup(*symname)); | |
| 359 | − dupsymname[n] = '\0'; | |
| 360 | − *symname = dupsymname; | |
| 361 | − return dupsymname + n + 1; | |
| 356 | + ns_separator = strchr(*symname, '.'); | |
| 357 | + if (ns_separator) { | |
| 358 | + namespace = NOFAIL(strndup(*symname, ns_separator - *symname)); | |
| 359 | + *symname = ns_separator + 1; | |
| 362 | 360 | } |
| 363 | 361 | |
| 364 | − return NULL; | |
| 362 | + return namespace; | |
| 365 | 363 | } |
| 366 | 364 | |
| 367 | 365 | /** |
| @@ -375,7 +373,6 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace, · 7 unmodified lines | ||
| 375 | 373 | |
| 376 | 374 | if (!s) { |
| 377 | 375 | s = new_symbol(name, mod, export); |
| 378 | − s->namespace = namespace; | |
| 379 | 376 | } else { |
| 380 | 377 | if (!s->preloaded) { |
| 381 | 378 | warn("%s: '%s' exported twice. Previous export was in %s%s\n", |
| @@ -386,6 +383,8 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace, · 4 unmodified lines | ||
| 386 | 383 | s->module = mod; |
| 387 | 384 | } |
| 388 | 385 | } |
| 386 | + free(s->namespace); | |
| 387 | + s->namespace = namespace ? strdup(namespace) : NULL; | |
| 389 | 388 | s->preloaded = 0; |
| 390 | 389 | s->vmlinux = is_vmlinux(mod->name); |
| 391 | 390 | s->kernel = 0; |
| @@ -672,7 +671,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info, · 280 unmodified lines | ||
| 672 | 671 | unsigned int crc; |
| 673 | 672 | enum export export; |
| 674 | 673 | bool is_crc = false; |
| 675 | − const char *name, *namespace; | |
| 674 | + const char *name; | |
| 675 | + char *namespace; | |
| 676 | 676 | |
| 677 | 677 | if ((!is_vmlinux(mod->name) || mod->is_dot_o) && |
| 678 | 678 | strstarts(symname, "__ksymtab")) |
| @@ -747,6 +747,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, · 68 unmodified lines | ||
| 747 | 747 | name = symname + strlen("__ksymtab_"); |
| 748 | 748 | namespace = sym_extract_namespace(&name); |
| 749 | 749 | sym_add_exported(name, namespace, mod, export); |
| 750 | + free(namespace); | |
| 750 | 751 | } |
| 751 | 752 | if (strcmp(symname, "init_module") == 0) |
| 752 | 753 | mod->has_init = 1; |
| @@ -2195,7 +2196,7 @@ static int check_exports(struct module *mod) · 1442 unmodified lines | ||
| 2195 | 2196 | else |
| 2196 | 2197 | basename = mod->name; |
| 2197 | 2198 | |
| 2198 | − if (exp->namespace) { | |
| 2199 | + if (exp->namespace && exp->namespace[0]) { | |
| 2199 | 2200 | add_namespace(&mod->required_namespaces, |
| 2200 | 2201 | exp->namespace); |
| 2201 | 2202 | |
| @@ -2652,15 +2653,20 @@ int main(int argc, char **argv) · 450 unmodified lines | ||
| 2652 | 2653 | fatal("modpost: Section mismatches detected.\n" |
| 2653 | 2654 | "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n"); |
| 2654 | 2655 | for (n = 0; n < SYMBOL_HASH_SIZE; n++) { |
| 2655 | − struct symbol *s = symbolhash[n]; | |
| 2656 | + struct symbol *s; | |
| 2657 | + | |
| 2658 | + for (s = symbolhash[n]; s; s = s->next) { | |
| 2659 | + /* | |
| 2660 | + * Do not check "vmlinux". This avoids the same warnings | |
| 2661 | + * shown twice, and false-positives for ARCH=um. | |
| 2662 | + */ | |
| 2663 | + if (is_vmlinux(s->module->name) && !s->module->is_dot_o) | |
| 2664 | + continue; | |
| 2656 | 2665 | |
| 2657 | − while (s) { | |
| 2658 | 2666 | if (s->is_static) |
| 2659 | 2667 | warn("\"%s\" [%s] is a static %s\n", |
| 2660 | 2668 | s->name, s->module->name, |
| 2661 | 2669 | export_str(s->export)); |
| 2662 | − | |
| 2663 | − s = s->next; | |
| 2664 | 2670 | } |
| 2665 | 2671 | } |
| 2666 | 2672 | |
| @@ -65,13 +65,14 @@ · 64 unmodified lines | ||
| 65 | 65 | use warnings; |
| 66 | 66 | use strict; |
| 67 | 67 | use File::Find; |
| 68 | +use File::Spec; | |
| 68 | 69 | |
| 69 | 70 | my $nm = ($ENV{'NM'} || "nm") . " -p"; |
| 70 | 71 | my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; |
| 71 | −my $srctree = ""; | |
| 72 | −my $objtree = ""; | |
| 73 | −$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); | |
| 74 | −$objtree = "$ENV{'objtree'}/" if (exists($ENV{'objtree'})); | |
| 72 | +my $srctree = File::Spec->curdir(); | |
| 73 | +my $objtree = File::Spec->curdir(); | |
| 74 | +$srctree = File::Spec->rel2abs($ENV{'srctree'}) if (exists($ENV{'srctree'})); | |
| 75 | +$objtree = File::Spec->rel2abs($ENV{'objtree'}) if (exists($ENV{'objtree'})); | |
| 75 | 76 | |
| 76 | 77 | if ($#ARGV != -1) { |
| 77 | 78 | print STDERR "usage: $0 takes no parameters\n"; |
| @@ -231,9 +232,9 @@ sub do_nm · 153 unmodified lines | ||
| 231 | 232 | } |
| 232 | 233 | ($source = $basename) =~ s/\.o$//; |
| 233 | 234 | if (-e "$source.c" || -e "$source.S") { |
| 234 | − $source = "$objtree$File::Find::dir/$source"; | |
| 235 | + $source = File::Spec->catfile($objtree, $File::Find::dir, $source) | |
| 235 | 236 | } else { |
| 236 | − $source = "$srctree$File::Find::dir/$source"; | |
| 237 | + $source = File::Spec->catfile($srctree, $File::Find::dir, $source) | |
| 237 | 238 | } |
| 238 | 239 | if (! -e "$source.c" && ! -e "$source.S") { |
| 239 | 240 | # No obvious source, exclude the object if it is conglomerate |
| @@ -1,4 +1,4 @@ | ||
| 1 | −#!/bin/bash | |
| 1 | +#!/bin/sh | |
| 2 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | 3 | # Linux kernel symbol namespace import generator |
| 4 | 4 | # |
| @@ -41,7 +41,7 @@ generate_deps() { · 36 unmodified lines | ||
| 41 | 41 | for source_file in $mod_source_files; do |
| 42 | 42 | sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp |
| 43 | 43 | offset=$(wc -l ${source_file}.tmp | awk '{print $1;}') |
| 44 | − cat $source_file | grep MODULE_IMPORT_NS | sort -u >> ${source_file}.tmp | |
| 44 | + cat $source_file | grep MODULE_IMPORT_NS | LANG=C sort -u >> ${source_file}.tmp | |
| 45 | 45 | tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp |
| 46 | 46 | if ! diff -q ${source_file} ${source_file}.tmp; then |
| 47 | 47 | mv ${source_file}.tmp ${source_file} |
| @@ -389,11 +389,8 @@ static int nop_mcount(Elf_Shdr const *const relhdr, · 388 unmodified lines | ||
| 389 | 389 | mcountsym = get_mcountsym(sym0, relp, str0); |
| 390 | 390 | |
| 391 | 391 | if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { |
| 392 | − if (make_nop) { | |
| 392 | + if (make_nop) | |
| 393 | 393 | ret = make_nop((void *)ehdr, _w(shdr->sh_offset) + _w(relp->r_offset)); |
| 394 | − if (ret < 0) | |
| 395 | − return -1; | |
| 396 | − } | |
| 397 | 394 | if (warn_on_notrace_sect && !once) { |
| 398 | 395 | printf("Section %s has mcount callers being ignored\n", |
| 399 | 396 | txtname); |
| @@ -93,7 +93,7 @@ scm_version() · 92 unmodified lines | ||
| 93 | 93 | # Check for mercurial and a mercurial repo. |
| 94 | 94 | if test -d .hg && hgid=`hg id 2>/dev/null`; then |
| 95 | 95 | # Do we have an tagged version? If so, latesttagdistance == 1 |
| 96 | − if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then | |
| 96 | + if [ "`hg log -r . --template '{latesttagdistance}'`" = "1" ]; then | |
| 97 | 97 | id=`hg log -r . --template '{latesttag}'` |
| 98 | 98 | printf '%s%s' -hg "$id" |
| 99 | 99 | else |
| @@ -126,7 +126,7 @@ scm_version() · 26 unmodified lines | ||
| 126 | 126 | |
| 127 | 127 | collect_files() |
| 128 | 128 | { |
| 129 | − local file res | |
| 129 | + local file res= | |
| 130 | 130 | |
| 131 | 131 | for file; do |
| 132 | 132 | case "$file" in |