21 Jan, 2016

1 commit

  • PowerPC64 uses the symbol .TOC. much as other targets use
    _GLOBAL_OFFSET_TABLE_. It identifies the value of the GOT pointer (or in
    powerpc parlance, the TOC pointer). Global offset tables are generally
    local to an executable or shared library, or in the kernel, module. Thus
    it does not make sense for a module to resolve a relocation against
    .TOC. to the kernel's .TOC. value. A module has its own .TOC., and
    indeed the powerpc64 module relocation processing ignores the kernel
    value of .TOC. and instead calculates a module-local value.

    This patch removes code involved in exporting the kernel .TOC., tweaks
    modpost to ignore an undefined .TOC., and the module loader to twiddle
    the section symbol so that .TOC. isn't seen as undefined.

    Note that if the kernel was compiled with -msingle-pic-base then ELFv2
    would not have function global entry code setting up r2. In that case
    the module call stubs would need to be modified to set up r2 using the
    kernel .TOC. value, requiring some of this code to be reinstated.

    mpe: Furthermore a change in binutils master (not yet released) causes
    the current way we handle the TOC to no longer work when building with
    MODVERSIONS=y and RELOCATABLE=n. The symptom is that modules can not be
    loaded due to there being no version found for TOC.

    Cc: stable@vger.kernel.org # 3.16+
    Signed-off-by: Alan Modra
    Signed-off-by: Michael Ellerman

    Alan Modra
     

26 Oct, 2015

1 commit

  • In our ARC toolchain the default linker script includes special
    sections used for code and data located in special fast memory.
    To avoid warnings we add these sections i.e. .cmem* and .fmt_slot*
    to white list.

    Signed-off-by: Noam Camus
    Cc: Rusty Russell
    Cc: Quentin Casasnovas
    Signed-off-by: Rusty Russell

    Noam Camus
     

06 Oct, 2015

1 commit

  • The section mismatch warning can be easy to miss during the kernel build
    process. Allow it to be marked as fatal to be easily caught and prevent
    bugs from slipping in.

    Setting CONFIG_SECTION_MISMATCH_WARN_ONLY=y causes these warnings to be
    non-fatal, since there are a number of section mismatches when using
    allmodconfig on some architectures, and we do not want to break these
    builds by default.

    Signed-off-by: Nicolas Boichat
    Change-Id: Ic346706e3297c9f0d790e3552aa94e5cff9897a6
    Signed-off-by: Rusty Russell

    Nicolas Boichat
     

08 Aug, 2015

1 commit

  • Module symbols have a limited length, but currently the build system
    allows the build finishing even if the driver code contains a too long
    symbol name, which eventually overflows the modversion_info[] item.
    The compiler may catch at compiling *.mod.c like
    CC xxx.mod.o
    xxx.mod.c:18:16: warning: initializer-string for array of chars is too long
    but it's merely a warning.

    This patch adds the check of the symbol length in modpost and stops
    the build properly.

    Currently MODULE_NAME_LEN is defined in modpost.c instead of referring
    to the definition in kernel header because including linux/module.h is
    messy and we must cover cross-compilation.

    Signed-off-by: Takashi Iwai
    Signed-off-by: Rusty Russell

    Takashi Iwai
     

09 Jul, 2015

1 commit

  • The tilegx and tilepro compilers use .coldtext for their unlikely
    executed text section name, so an __attribute__((cold)) function
    will (when compiled with higher optimization levels) land in
    the .coldtext section.

    Modify modpost to add .coldtext to the set of OTHER_TEXT_SECTIONS
    so we don't get warnings about referencing such a section in an
    __ex_table block, and then also modify arch/tile/lib/memcpy_user_64.c
    so that it uses plain ".coldtext" instead of ".coldtext.memcpy".
    The latter naming is a relic of an earlier use of -ffunction-sections,
    which we no longer use by default.

    Signed-off-by: Chris Metcalf
    Acked-by: Rusty Russell

    Chris Metcalf
     

22 Apr, 2015

7 commits

  • Currently an allyesconfig build [gcc-4.9.1] can generate the following:

    WARNING: vmlinux.o(.text.unlikely+0x3864): Section mismatch in
    reference from the function cpumask_empty.constprop.3() to the
    variable .init.data:nmi_ipi_mask

    which comes from the cpumask_empty usage in arch/x86/kernel/nmi_selftest.c.

    Normally we would not see a symbol entry for cpumask_empty since it is:

    static inline bool cpumask_empty(const struct cpumask *srcp)

    however in this case, the variant of the symbol gets emitted when GCC does
    constant propagation optimization.

    Fix things up so that any locally optimized constprop variants don't warn
    when accessing variables that live in the __init sections.

    Signed-off-by: Paul Gortmaker
    Signed-off-by: Rusty Russell

    Paul Gortmaker
     
  • Currently the match() function supports a leading * to match any
    prefix and a trailing * to match any suffix. However there currently
    is not a combination of both that can be used to target matches of
    whole families of functions that share a common substring.

    Here we expand the *foo and foo* match to also support *foo* with
    the goal of targeting compiler generated symbol names that contain
    strings like ".constprop." and ".isra."

    Signed-off-by: Paul Gortmaker
    Signed-off-by: Rusty Russell

    Paul Gortmaker
     
  • Trying to match the SHT_NUL section isn't useful and causes build failures
    on parisc and mn10300 since the addition of section strict white-listing
    and __ex_table sanitizing.

    Signed-off-by: Quentin Casasnovas
    Reported-by: Guenter Roeck
    Fixes: 050e57fd5936 ("modpost: add strict white-listing when referencing....")
    Fixes: 52dc0595d540 ("modpost: handle relocations mismatch in __ex_table.")
    Tested-by: Guenter Roeck
    Signed-off-by: Rusty Russell

    Quentin Casasnovas
     
  • As Guenter pointed out, we were never really calculating the extable entry
    size because the pointer arithmetic was simply wrong. We want to check
    we're handling the second relocation in __ex_table to infer an entry size,
    but we were using (void*) pointers instead of Elf_Rel[a]* ones.

    This fixes the problem by moving that check in the caller (since we can
    deal with different types of relocations) and add is_second_extable_reloc()
    to make the whole thing more readable.

    Signed-off-by: Quentin Casasnovas
    Reported-by: Guenter Roeck
    CC: Rusty Russell
    Signed-off-by: Rusty Russell

    Quentin Casasnovas
     
  • As Guenter pointed out, we want to assert that extable_entry_size has been
    discovered and not the other way around. Moreover, this sanity check is
    only valid when we're not dealing with the first relocation in __ex_table,
    since we have not discovered the extable entry size at that point.

    This was leading to a divide-by-zero on some architectures and make the
    build fail.

    Signed-off-by: Quentin Casasnovas
    Reported-by: Guenter Roeck
    CC: Rusty Russell
    Signed-off-by: Rusty Russell

    Quentin Casasnovas
     
  • 52dc0595d540 introduced OTHER_TEXT_SECTIONS for identifying what
    sections could validly have __ex_table entries. Unfortunately, it
    wasn't tested with -ffunction-sections, which some architectures
    use.

    Reported-by: kbuild test robot
    Cc: Quentin Casasnovas
    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • 32-bit and 64-bit ARM use these sections to store executable code, so
    they must be whitelisted in modpost's table of valid text sections.

    Signed-off-by: Thierry Reding
    Signed-off-by: Rusty Russell

    Thierry Reding
     

13 Apr, 2015

7 commits


08 Oct, 2014

1 commit

  • Pull arm64 updates from Catalin Marinas:
    - eBPF JIT compiler for arm64
    - CPU suspend backend for PSCI (firmware interface) with standard idle
    states defined in DT (generic idle driver to be merged via a
    different tree)
    - Support for CONFIG_DEBUG_SET_MODULE_RONX
    - Support for unmapped cpu-release-addr (outside kernel linear mapping)
    - set_arch_dma_coherent_ops() implemented and bus notifiers removed
    - EFI_STUB improvements when base of DRAM is occupied
    - Typos in KGDB macros
    - Clean-up to (partially) allow kernel building with LLVM
    - Other clean-ups (extern keyword, phys_addr_t usage)

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (51 commits)
    arm64: Remove unneeded extern keyword
    ARM64: make of_device_ids const
    arm64: Use phys_addr_t type for physical address
    aarch64: filter $x from kallsyms
    arm64: Use DMA_ERROR_CODE to denote failed allocation
    arm64: Fix typos in KGDB macros
    arm64: insn: Add return statements after BUG_ON()
    arm64: debug: don't re-enable debug exceptions on return from el1_dbg
    Revert "arm64: dmi: Add SMBIOS/DMI support"
    arm64: Implement set_arch_dma_coherent_ops() to replace bus notifiers
    of: amba: use of_dma_configure for AMBA devices
    arm64: dmi: Add SMBIOS/DMI support
    arm64: Correct ftrace calls to aarch64_insn_gen_branch_imm()
    arm64:mm: initialize max_mapnr using function set_max_mapnr
    setup: Move unmask of async interrupts after possible earlycon setup
    arm64: LLVMLinux: Fix inline arm64 assembly for use with clang
    arm64: pageattr: Correctly adjust unaligned start addresses
    net: bpf: arm64: fix module memory leak when JIT image build fails
    arm64: add PSCI CPU_SUSPEND based cpu_suspend support
    arm64: kernel: introduce cpu_init_idle CPU operation
    ...

    Linus Torvalds
     

03 Oct, 2014

1 commit

  • Similar to ARM, AArch64 is generating $x and $d syms... which isn't
    terribly helpful when looking at %pF output and the like. Filter those
    out in kallsyms, modpost and when looking at module symbols.

    Seems simplest since none of these check EM_ARM anyway, to just add it
    to the strchr used, rather than trying to make things overly
    complicated.

    initcall_debug improves:
    dmesg_before.txt: initcall $x+0x0/0x154 [sg] returned 0 after 26331 usecs
    dmesg_after.txt: initcall init_sg+0x0/0x154 [sg] returned 0 after 15461 usecs

    Signed-off-by: Kyle McMartin
    Acked-by: Rusty Russell
    Signed-off-by: Catalin Marinas

    Kyle McMartin
     

27 Aug, 2014

2 commits

  • Avoid the variable length array (vla), just use PATH_MAX instead.
    This not only makes this code clang friedly, it also leads to a
    code size reduction:

    text data bss dec hex filename
    51765 2224 12416 66405 10365 scripts/mod/modpost.old
    51677 2224 12416 66317 1030d scripts/mod/modpost.new

    Signed-off-by: Mathias Krause
    Signed-off-by: Rusty Russell

    Mathias Krause
     
  • Internally used symbols of modpost don't need to be externally visible;
    make them static. Also constify the string arrays so they resist in the
    r/o section instead of being runtime writable.

    Those changes lead to a small size reduction as can be seen below:

    text data bss dec hex filename
    51381 2640 12416 66437 10385 scripts/mod/modpost.old
    51765 2224 12416 66405 10365 scripts/mod/modpost.new

    Signed-off-by: Mathias Krause
    Signed-off-by: Rusty Russell

    Mathias Krause
     

27 Jul, 2014

2 commits

  • For several years, the pattern "foo$" has effectively been treated as
    equivalent to "foo" due to a bug in the (misnamed) helper
    number_prefix(). This hasn't been observed to cause any problems, so
    remove the broken $ functionality and change all foo$ patterns to foo.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Rusty Russell

    Rasmus Villemoes
     
  • The scripts/mod/modpost.c triggers the following warning:

    scripts/mod/modpost.c: In function ‘remove_dot’:
    scripts/mod/modpost.c:1710:10: warning: ignoring return value of ‘strtoul’, declared with attribute warn_unused_result [-Wunused-result]

    The remove_dot function that calls strtoul does not care about the
    numeric value of the string that is parsed but only looks for the
    end of the numeric sequence. As such, it's equivalent to just skip
    over all digits.

    Signed-off-by: Michal Nazarewicz
    Signed-off-by: Rusty Russell

    Michal Nazarewicz
     

13 Jun, 2014

1 commit

  • Pull kbuild misc updates from Michal Marek:
    "This is the non-critical part of kbuild for v3.16-rc1:
    - make deb-pkg can do s390x and arm64
    - new patterns in scripts/tags.sh
    - scripts/tags.sh skips userspace tools' sources (which sometimes
    have copies of kernel structures) and symlinks
    - improvements to the objdiff tool
    - two new coccinelle patches
    - other minor fixes"

    * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
    scripts: objdiff: support directories for the augument of record command
    scripts: objdiff: fix a comment
    scripts: objdiff: change the extension of disassembly from .o to .dis
    scripts: objdiff: improve path flexibility for record command
    scripts: objdiff: remove unnecessary code
    scripts: objdiff: direct error messages to stderr
    scripts: objdiff: get the path to .tmp_objdiff more simply
    deb-pkg: Add automatic support for s390x architecture
    coccicheck: Add unneeded return variable test
    kbuild: Fix a typo in documentation
    kbuild: trivial - use tabs for code indent where possible
    kbuild: trivial - remove trailing empty lines
    coccinelle: Check for missing NULL terminators in of_device_id tables
    scripts/tags.sh: ignore symlink'ed source files
    scripts/tags.sh: add regular expression replacement pattern for memcg
    builddeb: add arm64 in the supported architectures
    builddeb: use $OBJCOPY variable instead of objcopy
    scripts/tags.sh: ignore code of user space tools
    scripts/tags.sh: add pattern for DEFINE_HASHTABLE
    .gitignore: ignore Module.symvers in all directories

    Linus Torvalds
     

12 Jun, 2014

1 commit

  • Pull module updates from Rusty Russell:
    "Most of this is cleaning up various driver sysfs permissions so we can
    re-add the perm check (we unified the module param and sysfs checks,
    but the module ones were stronger so we weakened them temporarily).

    Param parsing gets documented, and also "--" now forces args to be
    handed to init (and ignored by the kernel).

    Module NX/RO protections get tightened: we now set them before calling
    parse_args()"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    module: set nx before marking module MODULE_STATE_COMING.
    samples/kobject/: avoid world-writable sysfs files.
    drivers/hid/hid-picolcd_fb: avoid world-writable sysfs files.
    drivers/staging/speakup/: avoid world-writable sysfs files.
    drivers/regulator/virtual: avoid world-writable sysfs files.
    drivers/scsi/pm8001/pm8001_ctl.c: avoid world-writable sysfs files.
    drivers/hid/hid-lg4ff.c: avoid world-writable sysfs files.
    drivers/video/fbdev/sm501fb.c: avoid world-writable sysfs files.
    drivers/mtd/devices/docg3.c: avoid world-writable sysfs files.
    speakup: fix incorrect perms on speakup_acntsa.c
    cpumask.h: silence warning with -Wsign-compare
    Documentation: Update kernel-parameters.tx
    param: hand arguments after -- straight to init
    modpost: Fix resource leak in read_dump()

    Linus Torvalds
     

10 Jun, 2014

1 commit


05 May, 2014

1 commit


28 Apr, 2014

1 commit


01 Apr, 2014

1 commit

  • Pull x86 LTO changes from Peter Anvin:
    "More infrastructure work in preparation for link-time optimization
    (LTO). Most of these changes is to make sure symbols accessed from
    assembly code are properly marked as visible so the linker doesn't
    remove them.

    My understanding is that the changes to support LTO are still not
    upstream in binutils, but are on the way there. This patchset should
    conclude the x86-specific changes, and remaining patches to actually
    enable LTO will be fed through the Kbuild tree (other than keeping up
    with changes to the x86 code base, of course), although not
    necessarily in this merge window"

    * 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits)
    Kbuild, lto: Handle basic LTO in modpost
    Kbuild, lto: Disable LTO for asm-offsets.c
    Kbuild, lto: Add a gcc-ld script to let run gcc as ld
    Kbuild, lto: add ld-version and ld-ifversion macros
    Kbuild, lto: Drop .number postfixes in modpost
    Kbuild, lto, workaround: Don't warn for initcall_reference in modpost
    lto: Disable LTO for sys_ni
    lto: Handle LTO common symbols in module loader
    lto, workaround: Add workaround for initcall reordering
    lto: Make asmlinkage __visible
    x86, lto: Disable LTO for the x86 VDSO
    initconst, x86: Fix initconst mistake in ts5500 code
    initconst: Fix initconst mistake in dcdbas
    asmlinkage: Make trace_hardirqs_on/off_caller visible
    asmlinkage, x86: Fix 32bit memcpy for LTO
    asmlinkage Make __stack_chk_failed and memcmp visible
    asmlinkage: Mark rwsem functions that can be called from assembler asmlinkage
    asmlinkage: Make main_extable_sort_needed visible
    asmlinkage, mutex: Mark __visible
    asmlinkage: Make trace_hardirq visible
    ...

    Linus Torvalds
     

19 Feb, 2014

1 commit


14 Feb, 2014

3 commits

  • - Don't warn about LTO marker symbols. modpost runs before
    the linker, so the module is not necessarily LTOed yet.
    - Don't complain about .gnu.lto* sections

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-13-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • LTO turns all global symbols effectively into statics. This
    has the side effect that they all have a .NUMBER postfix to make
    them unique. In modpost drop this postfix because it confuses
    it.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-8-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • This reference is discarded, but can cause warnings when it refers to
    exit. Ignore for now.

    This is a workaround and can be removed once we get rid of
    -fno-toplevel-reorder

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-7-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     

15 Jan, 2014

1 commit


15 Nov, 2013

1 commit

  • Pull module updates from Rusty Russell:
    "Mainly boring here, too. rmmod --wait finally removed, though"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    modpost: fix bogus 'exported twice' warnings.
    init: fix in-place parameter modification regression
    asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible
    kernel: add support for init_array constructors
    modpost: Optionally ignore secondary errors seen if a single module build fails
    module: remove rmmod --wait option.

    Linus Torvalds
     

13 Nov, 2013

1 commit

  • For some reason I managed to trick gcc into create CRC symbols that are
    not absolute anymore, but weak.

    Make modpost handle this case.

    Signed-off-by: Andi Kleen
    Cc: Al Viro
    Cc: Geert Uytterhoeven
    Cc: Tetsuo Handa
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     

07 Nov, 2013

1 commit

  • Andi's change in e0f244c63fc9 ("asmlinkage, module: Make ksymtab and
    kcrctab symbols and __this_module __visible") make the crc appear
    first in the symbol table.

    modpost creates an entry when it sees the CRC, then when it sees the
    actual symbol, it complains that it's seen it before. The preloaded
    flag already exists for the equivalent case where we loaded from
    Module.symvers, so use that.

    Reported-by: Stephen Rothwell
    Tested-by: The Awesome Power Of linux-next
    Signed-off-by: Rusty Russell

    Rusty Russell
     

29 Oct, 2013

1 commit