24 Sep, 2020

1 commit

  • PowerPC allmodconfig often fails to build as follows:

    LD .tmp_vmlinux.kallsyms1
    KSYM .tmp_vmlinux.kallsyms1.o
    LD .tmp_vmlinux.kallsyms2
    KSYM .tmp_vmlinux.kallsyms2.o
    LD .tmp_vmlinux.kallsyms3
    KSYM .tmp_vmlinux.kallsyms3.o
    LD vmlinux
    SORTTAB vmlinux
    SYSMAP System.map
    Inconsistent kallsyms data
    Try make KALLSYMS_EXTRA_PASS=1 as a workaround
    make[2]: *** [../Makefile:1162: vmlinux] Error 1

    Setting KALLSYMS_EXTRA_PASS=1 does not help.

    This is caused by the compiler inserting stubs such as *.long_branch.*
    and *.plt_branch.*

    $ powerpc-linux-nm -n .tmp_vmlinux.kallsyms2
    [ snip ]
    c00000000210c010 t 00000075.plt_branch.da9:19
    c00000000210c020 t 00000075.plt_branch.1677:5
    c00000000210c030 t 00000075.long_branch.memmove
    c00000000210c034 t 00000075.plt_branch.9e0:5
    c00000000210c044 t 00000075.plt_branch.free_initrd_mem
    ...

    Actually, the problem mentioned in scripts/link-vmlinux.sh comments;
    "In theory it's possible this results in even more stubs, but unlikely"
    is happening here, and ends up with another kallsyms step required.

    scripts/kallsyms.c already ignores various compiler stubs. Let's do
    similar to make kallsysms for PowerPC always succeed in 2 steps.

    Reported-by: Guenter Roeck
    Signed-off-by: Masahiro Yamada
    Tested-by: Guenter Roeck

    Masahiro Yamada
     

06 Jul, 2020

1 commit

  • Add new folders arch/arm64/kvm/hyp/{vhe,nvhe} and Makefiles for building code
    that runs in EL2 under VHE/nVHE KVM, repsectivelly. Add an include folder for
    hyp-specific header files which will include code common to VHE/nVHE.

    Build nVHE code with -D__KVM_NVHE_HYPERVISOR__, VHE code with
    -D__KVM_VHE_HYPERVISOR__.

    Under nVHE compile each source file into a `.hyp.tmp.o` object first, then
    prefix all its symbols with "__kvm_nvhe_" using `objcopy` and produce
    a `.hyp.o`. Suffixes were chosen so that it would be possible for VHE and nVHE
    to share some source files, but compiled with different CFLAGS.

    The nVHE ELF symbol prefix is added to kallsyms.c as ignored. EL2-only symbols
    will never appear in EL1 stack traces.

    Due to symbol prefixing, add a section in image-vars.h for aliases of symbols
    that are defined in nVHE EL2 and accessed by kernel in EL1 or vice versa.

    Signed-off-by: David Brazdil
    Signed-off-by: Marc Zyngier
    Link: https://lore.kernel.org/r/20200625131420.71444-4-dbrazdil@google.com

    David Brazdil
     

05 May, 2020

1 commit

  • Due to a bug-report that was compiler-dependent, I updated one of my
    machines to gcc-10. That shows a lot of new warnings. Happily they
    seem to be mostly the valid kind, but it's going to cause a round of
    churn for getting rid of them..

    This is the really low-hanging fruit of removing a couple of zero-sized
    arrays in some core code. We have had a round of these patches before,
    and we'll have many more coming, and there is nothing special about
    these except that they were particularly trivial, and triggered more
    warnings than most.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

19 Mar, 2020

1 commit

  • There is the code in the read_symbol function in 'scripts/kallsyms.c':

    if (is_ignored_symbol(name, type))
    return NULL;

    /* Ignore most absolute/undefined (?) symbols. */
    if (strcmp(name, "_text") == 0)
    _text = addr;

    But the is_ignored_symbol function returns true for name="_text" and
    type='A'. So the next condition is not executed and the _text variable
    is always zero.

    It makes the wrong kallsyms_relative_base symbol as a result of the code
    (CONFIG_KALLSYMS_BASE_RELATIVE is defined):

    if (base_relative) {
    output_label("kallsyms_relative_base");
    output_address(relative_base);
    printf("\n");
    }

    Because the output_address function uses the _text variable.

    So the kallsyms_lookup function and all related functions in the kernel
    do not work properly. For example, the stack trace in oops:

    Call Trace:
    [aa095e58] [809feab8] kobj_ns_ops_tbl+0x7ff09ac8/0x7ff1c1c4 (unreliable)
    [aa095e98] [80002b64] kobj_ns_ops_tbl+0x7f50db74/0x80000010
    [aa095ef8] [809c3d24] kobj_ns_ops_tbl+0x7feced34/0x7ff1c1c4
    [aa095f28] [80002ed0] kobj_ns_ops_tbl+0x7f50dee0/0x80000010
    [aa095f38] [8000f238] kobj_ns_ops_tbl+0x7f51a248/0x80000010

    The right stack trace:

    Call Trace:
    [aa095e58] [809feab8] module_vdu_video_init+0x2fc/0x3bc (unreliable)
    [aa095e98] [80002b64] do_one_initcall+0x40/0x1f0
    [aa095ef8] [809c3d24] kernel_init_freeable+0x164/0x1d8
    [aa095f28] [80002ed0] kernel_init+0x14/0x124
    [aa095f38] [8000f238] ret_from_kernel_thread+0x14/0x1c

    [masahiroy@kernel.org:

    This issue happens on binutils = 2.23
    The minimal supported binutils version for the kernel build is 2.21
    ]

    Signed-off-by: Mikhail Petrov
    Signed-off-by: Masahiro Yamada

    Mikhail Petrov
     

11 Feb, 2020

1 commit


04 Feb, 2020

2 commits


14 Dec, 2019

1 commit

  • Since commit 5e5c4fa78745 ("scripts/kallsyms: shrink table before
    sorting it"), kallsyms_relative_base can be larger than _text, which
    causes overflow when building the 32-bit kernel.

    https://lkml.org/lkml/2019/12/7/156

    This is because _text is, unless --all-symbols is specified, now
    trimmed from the symbol table before record_relative_base() is called.

    Handle the offset signedness also for kallsyms_relative_base. Introduce
    a new helper, output_address(), to reduce the code duplication.

    Fixes: 5e5c4fa78745 ("scripts/kallsyms: shrink table before sorting it")
    Reported-by: Olof Johansson
    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

25 Nov, 2019

16 commits


08 Jul, 2019

1 commit

  • gcc asan instrumentation emits the following sequence to store frame pc
    when the kernel is built with CONFIG_RELOCATABLE:
    debug/vsprintf.s:
    .section .data.rel.ro.local,"aw"
    .align 8
    .LC3:
    .quad .LASANPC4826@GOTOFF
    .text
    .align 8
    .type number, @function
    number:
    .LASANPC4826:

    and in case reloc is issued for LASANPC label it also gets into .symtab
    with the same address as actual function symbol:
    $ nm -n vmlinux | grep 0000000001397150
    0000000001397150 t .LASANPC4826
    0000000001397150 t number

    In the end kernel backtraces are almost unreadable:
    [ 143.748476] Call Trace:
    [ 143.748484] ([] .LASANPC2671+0x114/0x190)
    [ 143.748492] [] .LASANPC2612+0x110/0x160
    [ 143.748502] [] print_address_description+0x80/0x3b0
    [ 143.748511] [] __kasan_report+0x15c/0x1c8
    [ 143.748521] [] strrchr+0x34/0x60
    [ 143.748534] [] kasan_strings+0xb0/0x148 [test_kasan]
    [ 143.748547] [] kmalloc_tests_init+0xe2/0x528 [test_kasan]
    [ 143.748555] [] .LASANPC4069+0x354/0x748
    [ 143.748563] [] do_init_module+0x136/0x3b0
    [ 143.748571] [] .LASANPC3191+0x2164/0x25d0
    [ 143.748580] [] .LASANPC3196+0x184/0x1b8
    [ 143.748587] [] system_call+0xd8/0x2d8

    Since LASANPC labels are not even unique and get into .symtab only due
    to relocs filter them out in kallsyms.

    Signed-off-by: Vasily Gorbik
    Signed-off-by: Masahiro Yamada

    Vasily Gorbik
     

11 Mar, 2019

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - do not generate unneeded top-level built-in.a

    - let git ignore O= directory entirely

    - optimize scripts/kallsyms slightly

    - exclude DWARF info from *.s regardless of config options

    - fix GCC toolchain search path for Clang to prepare ld.lld support

    - do not generate modules.order when CONFIG_MODULES is disabled

    - simplify single target rules and remove VPATH for external module
    build

    - allow to add optional flags to dpkg-buildpackage when building
    deb-pkg

    - move some compiler option tests from Makefile to Kconfig

    - various Makefile cleanups

    * tag 'kbuild-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (40 commits)
    kbuild: remove scripts/basic/% build target
    kbuild: use -Werror=implicit-... instead of -Werror-implicit-...
    kbuild: clean up scripts/gcc-version.sh
    kbuild: remove cc-version macro
    kbuild: update comment block of scripts/clang-version.sh
    kbuild: remove commented-out INITRD_COMPRESS
    kbuild: move -gsplit-dwarf, -gdwarf-4 option tests to Kconfig
    kbuild: [bin]deb-pkg: add DPKG_FLAGS variable
    kbuild: move ".config not found!" message from Kconfig to Makefile
    kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing
    kbuild: simplify single target rules
    kbuild: remove empty rules for makefiles
    kbuild: make -r/-R effective in top Makefile for old Make versions
    kbuild: move tools_silent to a more relevant place
    kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig
    kbuild: refactor cc-cross-prefix implementation
    kbuild: hardcode genksyms path and remove GENKSYMS variable
    scripts/gdb: refactor rules for symlink creation
    kbuild: create symlink to vmlinux-gdb.py in scripts_gdb target
    scripts/gdb: do not descend into scripts/gdb from scripts
    ...

    Linus Torvalds
     

19 Feb, 2019

3 commits


28 Jan, 2019

1 commit


06 Jan, 2019

1 commit

  • As mentioned in the info pages of gas, the '.align' pseudo op's
    interpretation of the alignment value is architecture specific.
    It might either be a byte value or taken to the power of two.

    On ARM it's actually the latter which leads to unnecessary large
    alignments of 16 bytes for 32 bit builds or 256 bytes for 64 bit
    builds.

    Fix this by switching to '.balign' instead which is consistent
    across all architectures.

    Signed-off-by: Mathias Krause
    Cc: Catalin Marinas
    Cc: Will Deacon
    Signed-off-by: Masahiro Yamada

    Mathias Krause
     

10 Sep, 2018

2 commits


29 May, 2018

1 commit

  • scripts/kallsyms.c: function write_src:
    "printf", the #1 format specifier "d" need arg type "int",
    but the according arg "table_cnt" has type "unsigned int"

    scripts/recordmcount.c: function do_file:
    "fprintf", the #1 format specifier "d" need arg type "int",
    but the according arg "(*w2)(ehdr->e_machine)" has type "unsigned int"

    scripts/recordmcount.h: function find_secsym_ndx:
    "fprintf", the #1 format specifier "d" need arg type "int",
    but the according arg "txtndx" has type "unsigned int"

    Signed-off-by: nixiaoming
    Acked-by: Steven Rostedt (VMware)
    Signed-off-by: Masahiro Yamada

    nixiaoming
     

17 May, 2018

1 commit

  • CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX was selected by BLACKFIN, METAG.
    They were removed by commit 4ba66a976072 ("arch: remove blackfin port"),
    commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively.

    No more architecture enables CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX,
    hence the --symbol-prefix option is unnecessary.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Sam Ravnborg

    Masahiro Yamada
     

05 Apr, 2018

1 commit

  • Pull arm64 updates from Will Deacon:
    "Nothing particularly stands out here, probably because people were
    tied up with spectre/meltdown stuff last time around. Still, the main
    pieces are:

    - Rework of our CPU features framework so that we can whitelist CPUs
    that don't require kpti even in a heterogeneous system

    - Support for the IDC/DIC architecture extensions, which allow us to
    elide instruction and data cache maintenance when writing out
    instructions

    - Removal of the large memory model which resulted in suboptimal
    codegen by the compiler and increased the use of literal pools,
    which could potentially be used as ROP gadgets since they are
    mapped as executable

    - Rework of forced signal delivery so that the siginfo_t is
    well-formed and handling of show_unhandled_signals is consolidated
    and made consistent between different fault types

    - More siginfo cleanup based on the initial patches from Eric
    Biederman

    - Workaround for Cortex-A55 erratum #1024718

    - Some small ACPI IORT updates and cleanups from Lorenzo Pieralisi

    - Misc cleanups and non-critical fixes"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (70 commits)
    arm64: uaccess: Fix omissions from usercopy whitelist
    arm64: fpsimd: Split cpu field out from struct fpsimd_state
    arm64: tlbflush: avoid writing RES0 bits
    arm64: cmpxchg: Include linux/compiler.h in asm/cmpxchg.h
    arm64: move percpu cmpxchg implementation from cmpxchg.h to percpu.h
    arm64: cmpxchg: Include build_bug.h instead of bug.h for BUILD_BUG
    arm64: lse: Include compiler_types.h and export.h for out-of-line LL/SC
    arm64: fpsimd: include in fpsimd.h
    drivers/perf: arm_pmu_platform: do not warn about affinity on uniprocessor
    perf: arm_spe: include linux/vmalloc.h for vmap()
    Revert "arm64: Revert L1_CACHE_SHIFT back to 6 (64-byte cache line size)"
    arm64: cpufeature: Avoid warnings due to unused symbols
    arm64: Add work around for Arm Cortex-A55 Erratum 1024718
    arm64: Delay enabling hardware DBM feature
    arm64: Add MIDR encoding for Arm Cortex-A55 and Cortex-A35
    arm64: capabilities: Handle shared entries
    arm64: capabilities: Add support for checks based on a list of MIDRs
    arm64: Add helpers for checking CPU MIDR against a range
    arm64: capabilities: Clean up midr range helpers
    arm64: capabilities: Change scope of VHE to Boot CPU feature
    ...

    Linus Torvalds
     

07 Mar, 2018

1 commit

  • On arm64, the EFI stub and the kernel proper are essentially the same
    binary, although the EFI stub executes at a different virtual address
    as the kernel. For this reason, the EFI stub is restricted in the
    symbols it can link to, which is ensured by prefixing all EFI stub
    symbols with __efistub_ (and emitting __efistub_ prefixed aliases for
    routines that may be shared between the core kernel and the stub)

    These symbols are leaking into kallsyms, polluting the namespace, so
    let's filter them explicitly.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon

    Ard Biesheuvel
     

02 Mar, 2018

1 commit


14 Oct, 2017

1 commit

  • gcc on aarch64 may emit synbols of type 'n' if the kernel is built with
    '-frecord-gcc-switches'. In most cases, those symbols are reported with
    nm as

    000000000000000e n $d

    and with objdump as

    0000000000000000 l d .GCC.command.line 0000000000000000 .GCC.command.line
    000000000000000e l .GCC.command.line 0000000000000000 $d

    Those symbols are detected in is_arm_mapping_symbol() and ignored.
    However, if "--prefix-symbols=" is configured as well, the
    situation is different. For example, in efi/libstub, arm64 images are
    built with

    '--prefix-alloc-sections=.init --prefix-symbols=__efistub_'.

    In combination with '-frecord-gcc-switches', the symbols are now reported
    by nm as:

    000000000000000e n __efistub_$d
    and by objdump as:
    0000000000000000 l d .GCC.command.line 0000000000000000 .GCC.command.line
    000000000000000e l .GCC.command.line 0000000000000000 __efistub_$d

    Those symbols are no longer ignored and included in the base address
    calculation. This results in a base address of 000000000000000e, which
    in turn causes kallsyms to abort with

    kallsyms failure:
    relative symbol value 0xffffff900800a000 out of range in relative mode

    The problem is seen in little endian arm64 builds with CONFIG_EFI
    enabled and with '-frecord-gcc-switches' set in KCFLAGS.

    Explicitly ignore symbols of type 'n' since those are clearly debug
    symbols.

    Link: http://lkml.kernel.org/r/1507136063-3139-1-git-send-email-linux@roeck-us.net
    Signed-off-by: Guenter Roeck
    Acked-by: Ard Biesheuvel
    Cc: Josh Poimboeuf
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Guenter Roeck
     

04 Feb, 2017

1 commit

  • This add the kbuild infrastructure that will allow architectures to emit
    vmlinux symbol CRCs as 32-bit offsets to another location in the kernel
    where the actual value is stored. This works around problems with CRCs
    being mistaken for relocatable symbols on kernels that self relocate at
    runtime (i.e., powerpc with CONFIG_RELOCATABLE=y)

    For the kbuild side of things, this comes down to the following:

    - introducing a Kconfig symbol MODULE_REL_CRCS

    - adding a -R switch to genksyms to instruct it to emit the CRC symbols
    as references into the .rodata section

    - making modpost distinguish such references from absolute CRC symbols
    by the section index (SHN_ABS)

    - making kallsyms disregard non-absolute symbols with a __crc_ prefix

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Linus Torvalds

    Ard Biesheuvel