path: root/scripts (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-12-28scripts: add spdxcheck.py self testThierry Reding1-0/+12
Add a script that will run spdxcheck.py through a couple of self tests to simplify validation in the future. The tests are run for both Python 2 and Python 3 to make sure all changes to the script remain compatible across both versions. The script tests a regular text file (Makefile) for basic sanity checks and then runs it on a binary file (Documentation/logo.gif) to make sure it works in both cases. It also tests opening files passed on the command line as well as piped files read from standard input. Finally a run on the complete tree will be performed to catch any other potential issues. Link: http://lkml.kernel.org/r/20181212131210.28024-2-thierry.reding@gmail.com Signed-off-by: Thierry Reding <treding@nvidia.com> Thomas Gleixner <tglx@linutronix.de> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Joe Perches <joe@perches.com> Cc: Jeremy Cline <jcline@redhat.com> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-28scripts/checkstack.pl: dynamic stack growth for aarch64Qian Cai1-0/+2
This is to track dynamic amount of stack growth for aarch64, so it is possible to print out offensive functions that may consume too much stack. For example, 0xffff2000084d1270 try_to_unmap_one [vmlinux]: Dynamic (0xcf0) 0xffff200008538358 migrate_page_move_mapping [vmlinux]: Dynamic (0xc60) 0xffff2000081276c8 copy_process.isra.2 [vmlinux]: Dynamic (0xb20) 0xffff200008424958 show_free_areas [vmlinux]: Dynamic (0xb40) 0xffff200008545178 __split_huge_pmd_locked [vmlinux]: Dynamic (0xb30) 0xffff200008555120 collapse_shmem [vmlinux]: Dynamic (0xbc0) 0xffff20000862e0d0 do_direct_IO [vmlinux]: Dynamic (0xb70) 0xffff200008cc0aa0 md_do_sync [vmlinux]: Dynamic (0xb90) Link: http://lkml.kernel.org/r/20181208025143.39363-1-cai@lca.pw Signed-off-by: Qian Cai <cai@lca.pw> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-28scripts/decode_stacktrace: only strip base path when a prefix of the pathMarc Zyngier1-1/+1
Running something like: decodecode vmlinux . leads to interested results where not only the leading "." gets stripped from the displayed paths, but also anywhere in the string, displaying something like: kvm_vcpu_check_block (arch/arm64/kvm/virt/kvm/kvm_mainc:2141) which doesn't help further processing. Fix it by only stripping the base path if it is a prefix of the path. Link: http://lkml.kernel.org/r/20181210174659.31054-3-marc.zyngier@arm.com Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-28scripts/decodecode: set ARCH when running natively on arm/arm64Marc Zyngier1-0/+7
When running decodecode natively on arm64, ARCH is likely not to be set, and we end-up with .4byte instead of .inst when generating the disassembly. Similar effects would occur if running natively on a 32bit ARM platform, although that's even less popular. A simple workaround is to populate ARCH when it is not set and that we're running on an arm/arm64 system. Link: http://lkml.kernel.org/r/20181210174659.31054-2-marc.zyngier@arm.com Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-28bloat-o-meter: ignore __addressable_ symbolsRasmus Villemoes1-0/+1
Since __LINE__ is part of the symbol created by __ADDRESSABLE, almost any change causes those symbols to disappear and get reincarnated, e.g. add/remove: 4/4 grow/shrink: 0/3 up/down: 32/-171 (-139) Function old new delta __addressable_tracing_set_default_clock8649 - 8 +8 __addressable_tracer_init_tracefs8631 - 8 +8 __addressable_ftrace_dump8383 - 8 +8 __addressable_clear_boot_tracer8632 - 8 +8 __addressable_tracing_set_default_clock8650 8 - -8 __addressable_tracer_init_tracefs8632 8 - -8 __addressable_ftrace_dump8384 8 - -8 __addressable_clear_boot_tracer8633 8 - -8 trace_default_header 663 642 -21 tracing_mark_raw_write 406 355 -51 tracing_mark_write 624 557 -67 Total: Before=63889, After=63750, chg -0.22% They're small and in .discard, so ignore them, leading to more useful add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-139 (-139) Function old new delta trace_default_header 663 642 -21 tracing_mark_raw_write 406 355 -51 tracing_mark_write 624 557 -67 Total: Before=63721, After=63582, chg -0.22% Link: http://lkml.kernel.org/r/20181102210030.8383-1-linux@rasmusvillemoes.dk Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Dominik Brodowski <linux@dominikbrodowski.net> Cc: Maninder Singh <maninder1.s@samsung.com> Cc: Matteo Croce <mcroce@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-28kasan: add CONFIG_KASAN_GENERIC and CONFIG_KASAN_SW_TAGSAndrey Konovalov1-22/+31
This commit splits the current CONFIG_KASAN config option into two: 1. CONFIG_KASAN_GENERIC, that enables the generic KASAN mode (the one that exists now); 2. CONFIG_KASAN_SW_TAGS, that enables the software tag-based KASAN mode. The name CONFIG_KASAN_SW_TAGS is chosen as in the future we will have another hardware tag-based KASAN mode, that will rely on hardware memory tagging support in arm64. With CONFIG_KASAN_SW_TAGS enabled, compiler options are changed to instrument kernel files with -fsantize=kernel-hwaddress (except the ones for which KASAN_SANITIZE := n is set). Both CONFIG_KASAN_GENERIC and CONFIG_KASAN_SW_TAGS support both CONFIG_KASAN_INLINE and CONFIG_KASAN_OUTLINE instrumentation modes. This commit also adds empty placeholder (for now) implementation of tag-based KASAN specific hooks inserted by the compiler and adjusts common hooks implementation. While this commit adds the CONFIG_KASAN_SW_TAGS config option, this option is not selectable, as it depends on HAVE_ARCH_KASAN_SW_TAGS, which we will enable once all the infrastracture code has been added. Link: http://lkml.kernel.org/r/b2550106eb8a68b10fefbabce820910b115aa853.1544099024.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Cc: Christoph Lameter <cl@linux.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-28kconfig: surround dbg_sym_flags with #ifdef DEBUG to fix gconf warningMasahiro Yamada1-1/+2
Fix the following warning: no previous prototype for ‘dbg_sym_flags’ [-Wmissing-prototypes] Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-28kconfig: split images.c out of qconf.cc/gconf.c to fix gconf warningsMasahiro Yamada5-19/+54
Currently, images.c is included by qconf.cc and gconf.c. qconf.cc uses all of xpm_* arrays, but gconf.c only some of them. Hence, lots of "... defined but not used" warnings are displayed while compiling gconf.c Splitting out images.c fixes the warnings. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-28kconfig: add static qualifiers to fix gconf warningsMasahiro Yamada1-10/+10
Add "static" to functions that are locally used in gconf.c This fixes some "no previous prototype for ..." warnings. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-28kconfig: split the lexer out of zconf.yMasahiro Yamada4-8/+6
Compile zconf.lex.c independently of the other files. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-28kconfig: split some C files out of zconf.yMasahiro Yamada7-15/+16
I want to compile each C file independently instead of including all of them from zconf.y. Split out confdata.c, expr.c, symbol.c, and preprocess.c . These are low-hanging fruits. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-28kconfig: convert to SPDX License IdentifierMasahiro Yamada42-140/+57
All files in lxdialog/ are licensed under GPL-2.0+, and the rest are under GPL-2.0. I added GPL-2.0 tags to test scripts in tests/. Documentation/process/license-rules.rst does not suggest anything about the flex/bison files. Because flex does not accept the C++ comment style at the very top of a file, I used the C style for zconf.l, and so for zconf.y for consistency. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-28kconfig: remove keyword lookup table entirelyMasahiro Yamada4-147/+69
Commit 7a88488bbc23 ("[PATCH] kconfig: use gperf for kconfig keywords") introduced gperf for the keyword lookup. Then, commit bb3290d91695 ("Remove gperf usage from toolchain") killed the gperf use. As a result, the linear keyword search was left behind. If we do not use gperf, there is no reason to have the separate table of the keywords. Move all keywords back to the lexer. I also refactored the lexer to remove the COMMAND and PARAM states. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-27Merge tag 'gcc-plugins-v4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxLinus Torvalds3-0/+113
Pull gcc-plugins update from Kees Cook: "Both arm and arm64 are gaining per-task stack canaries (to match x86), but arm is being done with a gcc plugin, hence it going through the gcc-plugins tree. New gcc-plugin: - Enable per-task stack protector for ARM (Ard Biesheuvel)" * tag 'gcc-plugins-v4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: ARM: smp: add support for per-task stack canaries
2018-12-26Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tipLinus Torvalds1-0/+35
Pull RCU updates from Ingo Molnar: "The biggest RCU changes in this cycle were: - Convert RCU's BUG_ON() and similar calls to WARN_ON() and similar. - Replace calls of RCU-bh and RCU-sched update-side functions to their vanilla RCU counterparts. This series is a step towards complete removal of the RCU-bh and RCU-sched update-side functions. ( Note that some of these conversions are going upstream via their respective maintainers. ) - Documentation updates, including a number of flavor-consolidation updates from Joel Fernandes. - Miscellaneous fixes. - Automate generation of the initrd filesystem used for rcutorture testing. - Convert spin_is_locked() assertions to instead use lockdep. ( Note that some of these conversions are going upstream via their respective maintainers. ) - SRCU updates, especially including a fix from Dennis Krein for a bag-on-head-class bug. - RCU torture-test updates" * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (112 commits) rcutorture: Don't do busted forward-progress testing rcutorture: Use 100ms buckets for forward-progress callback histograms rcutorture: Recover from OOM during forward-progress tests rcutorture: Print forward-progress test age upon failure rcutorture: Print time since GP end upon forward-progress failure rcutorture: Print histogram of CB invocation at OOM time rcutorture: Print GP age upon forward-progress failure rcu: Print per-CPU callback counts for forward-progress failures rcu: Account for nocb-CPU callback counts in RCU CPU stall warnings rcutorture: Dump grace-period diagnostics upon forward-progress OOM rcutorture: Prepare for asynchronous access to rcu_fwd_startat torture: Remove unnecessary "ret" variables rcutorture: Affinity forward-progress test to avoid housekeeping CPUs rcutorture: Break up too-long rcu_torture_fwd_prog() function rcutorture: Remove cbflood facility torture: Bring any extra CPUs online during kernel startup rcutorture: Add call_rcu() flooding forward-progress tests rcutorture/formal: Replace synchronize_sched() with synchronize_rcu() tools/kernel.h: Replace synchronize_sched() with synchronize_rcu() net/decnet: Replace rcu_barrier_bh() with rcu_barrier() ...
2018-12-26Merge branch 'parisc-4.21-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linuxLinus Torvalds1-0/+1
Pull parisc updates from Helge Deller: "The major change in this patchset is the new system call table generation support from Firoz Khan" * 'parisc-4.21-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux: parisc: syscalls: ignore nfsservctl for other architectures parisc: generate uapi header and system call table files parisc: add system call table generation support parisc: remove __NR_Linux from uapi header file. parisc: add __NR_syscalls along with __NR_Linux_syscalls parisc: move __IGNORE* entries to non uapi header parisc: Fix HP SDC hpa address output parisc: Fix serio address output parisc: Split out alternative live patching code
2018-12-25Merge tag 'drm-next-2018-12-14' of git://anongit.freedesktop.org/drm/drmLinus Torvalds1-78/+0
Pull drm updates from Dave Airlie: "Core: - shared fencing staging removal - drop transactional atomic helpers and move helpers to new location - DP/MST atomic cleanup - Leasing cleanups and drop EXPORT_SYMBOL - Convert drivers to atomic helpers and generic fbdev. - removed deprecated obj_ref/unref in favour of get/put - Improve dumb callback documentation - MODESET_LOCK_BEGIN/END helpers panels: - CDTech panels, Banana Pi Panel, DLC1010GIG, - Olimex LCD-O-LinuXino, Samsung S6D16D0, Truly NT35597 WQXGA, - Himax HX8357D, simulated RTSM AEMv8. - GPD Win2 panel - AUO G101EVN010 vgem: - render node support ttm: - move global init out of drivers - fix LRU handling for ghost objects - Support for simultaneous submissions to multiple engines scheduler: - timeout/fault handling changes to help GPU recovery - helpers for hw with preemption support i915: - Scaler/Watermark fixes - DP MST + powerwell fixes - PSR fixes - Break long get/put shmemfs pages - Icelake fixes - Icelake DSI video mode enablement - Engine workaround improvements amdgpu: - freesync support - GPU reset enabled on CI, VI, SOC15 dGPUs - ABM support in DC - KFD support for vega12/polaris12 - SDMA paging queue on vega - More amdkfd code sharing - DCC scanout on GFX9 - DC kerneldoc - Updated SMU firmware for GFX8 chips - XGMI PSP + hive reset support - GPU reset - DC trace support - Powerplay updates for newer Polaris - Cursor plane update fast path - kfd dma-buf support virtio-gpu: - add EDID support vmwgfx: - pageflip with damage support nouveau: - Initial Turing TU104/TU106 modesetting support msm: - a2xx gpu support for apq8060 and imx5 - a2xx gpummu support - mdp4 display support for apq8060 - DPU fixes and cleanups - enhanced profiling support - debug object naming interface - get_iova/page pinning decoupling tegra: - Tegra194 host1x, VIC and display support enabled - Audio over HDMI for Tegra186 and Tegra194 exynos: - DMA/IOMMU refactoring - plane alpha + blend mode support - Color format fixes for mixer driver rcar-du: - R8A7744 and R8A77470 support - R8A77965 LVDS support imx: - fbdev emulation fix - multi-tiled scalling fixes - SPDX identifiers rockchip - dw_hdmi support - dw-mipi-dsi + dual dsi support - mailbox read size fix qxl: - fix cursor pinning vc4: - YUV support (scaling + cursor) v3d: - enable TFU (Texture Formatting Unit) mali-dp: - add support for linear tiled formats sun4i: - Display Engine 3 support - H6 DE3 mixer 0 support - H6 display engine support - dw-hdmi support - H6 HDMI phy support - implicit fence waiting - BGRX8888 support meson: - Overlay plane support - implicit fence waiting - HDMI 1.4 4k modes bridge: - i2c fixes for sii902x" * tag 'drm-next-2018-12-14' of git://anongit.freedesktop.org/drm/drm: (1403 commits) drm/amd/display: Add fast path for cursor plane updates drm/amdgpu: Enable GPU recovery by default for CI drm/amd/display: Fix duplicating scaling/underscan connector state drm/amd/display: Fix unintialized max_bpc state values Revert "drm/amd/display: Set RMX_ASPECT as default" drm/amdgpu: Fix stub function name drm/msm/dpu: Fix clock issue after bind failure drm/msm/dpu: Clean up dpu_media_info.h static inline functions drm/msm/dpu: Further cleanups for static inline functions drm/msm/dpu: Cleanup the debugfs functions drm/msm/dpu: Remove dpu_irq and unused functions drm/msm: Make irq_postinstall optional drm/msm/dpu: Cleanup callers of dpu_hw_blk_init drm/msm/dpu: Remove unused functions drm/msm/dpu: Remove dpu_crtc_is_enabled() drm/msm/dpu: Remove dpu_crtc_get_mixer_height drm/msm/dpu: Remove dpu_dbg drm/msm: dpu: Remove crtc_lock drm/msm: dpu: Remove vblank_requested flag from dpu_crtc drm/msm: dpu: Separate crtc assignment from vblank enable ...
2018-12-21Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tipLinus Torvalds2-5/+1
Pull x86 fixes from Ingo Molnar: "The biggest part is a series of reverts for the macro based GCC inlining workarounds. It caused regressions in distro build and other kernel tooling environments, and the GCC project was very receptive to fixing the underlying inliner weaknesses - so as time ran out we decided to do a reasonably straightforward revert of the patches. The plan is to rely on the 'asm inline' GCC 9 feature, which might be backported to GCC 8 and could thus become reasonably widely available on modern distros. Other than those reverts, there's misc fixes from all around the place. I wish our final x86 pull request for v4.20 was smaller..." * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: Revert "kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs" Revert "x86/objtool: Use asm macros to work around GCC inlining bugs" Revert "x86/refcount: Work around GCC inlining bug" Revert "x86/alternatives: Macrofy lock prefixes to work around GCC inlining bugs" Revert "x86/bug: Macrofy the BUG table section handling, to work around GCC inlining bugs" Revert "x86/paravirt: Work around GCC inlining bugs when compiling paravirt ops" Revert "x86/extable: Macrofy inline assembly code to work around GCC inlining bugs" Revert "x86/cpufeature: Macrofy inline assembly code to work around GCC inlining bugs" Revert "x86/jump-labels: Macrofy inline assembly code to work around GCC inlining bugs" x86/mtrr: Don't copy uninitialized gentry fields back to userspace x86/fsgsbase/64: Fix the base write helper functions x86/mm/cpa: Fix cpa_flush_array() TLB invalidation x86/vdso: Pass --eh-frame-hdr to the linker x86/mm: Fix decoy address handling vs 32-bit builds x86/intel_rdt: Ensure a CPU remains online for the region's pseudo-locking sequence x86/dump_pagetables: Fix LDT remap address marker x86/mm: Fix guard hole handling
2018-12-22scripts: remove unnecessary ihex2fw and check-lc_ctypes from .gitignoreMasahiro Yamada1-2/+0
Commit c512d2544c68 ("gitignore: ignore scripts/ihex2fw") was unneeded. ihex2fw was generated in firmware/ instead of scripts/ at that time although ihex2fw.c was pushed back and forth between those directories in the past. check-lc_ctype was removed by commit cb43fb5775df ("docs: remove DocBook from the building system"). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: update current_pos in the second lexerMasahiro Yamada1-5/+15
To simplify the generated lexer, let the hand-made lexer update the file name and line number for the parser. I tested this with DEBUG_PARSE, and confirmed the same file names and line numbers were dumped. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: switch to ASSIGN_VAL state in the second lexerMasahiro Yamada1-3/+9
To simplify the generated lexer, switch to the ASSIGN_VAL state in the hand-made lexer. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: stop associating kconf_id with yylvalMasahiro Yamada2-23/+20
The lexer has conventionally associated kconf_id data with yylval to carry additional information to the parser. No token is relying on this any more. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: refactor end token rulesMasahiro Yamada1-28/+15
T_ENDMENU, T_ENDCHOICE, T_ENDIF are the last users of kconf_id associated with yylval. Refactor them to not use it. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: stop supporting '.' and '/' in unquoted wordsMasahiro Yamada2-4/+3
In my understanding, special characters such as '.' and '/' are supported in unquoted words to use bare file paths in the "source" statement. With the previous commit surrounding all file paths with double quotes, we can drop this. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: use T_WORD instead of T_VARIABLE for variablesMasahiro Yamada2-4/+3
There is no grammatical ambiguity by using T_WORD for variables. The parser can distinguish variables from symbols from the context. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: use specific tokens instead of T_ASSIGN for assignmentsMasahiro Yamada2-5/+13
Currently, the lexer returns T_ASSIGN for all of =, :=, and += associating yylval with the flavor. I want to make the generated lexer as simple as possible. So, the lexer should convert keywords to tokens without thinking about the meaning. = -> T_EQUAL := -> T_COLON_EQUAL += -> T_PLUS_EQUAL Unfortunately, Kconfig uses = instead of == for the equal operator. So, the same token T_EQUAL is used for assignment and comparison. The parser can still distinguish them from the context. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: refactor scanning and parsing "option" propertiesMasahiro Yamada5-52/+41
For the keywords "modules", "defconfig_list", and "allnoconfig_y", the lexer should pass specific tokens instead of generic T_WORD. This simplifies both the lexer and the parser. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-22kconfig: use distinct tokens for type and default propertiesMasahiro Yamada3-32/+47
This commit removes kconf_id::stype to prepare for the entire removal of kconf_id.c To simplify the lexer, I want keywords straight-mapped to tokens. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-19scripts: add a tool to produce a compile_commands.json fileTom Roeder1-0/+151
The LLVM/Clang project provides many tools for analyzing C source code. Many of these tools are based on LibTooling (https://clang.llvm.org/docs/LibTooling.html), which depends on a database of compiler flags. The standard container for this database is compile_commands.json, which consists of a list of JSON objects, each with "directory", "file", and "command" fields. Some build systems, like cmake or bazel, produce this compilation information directly. Naturally, Makefiles don't. However, the kernel makefiles already create .<target>.o.cmd files that contain all the information needed to build a compile_commands.json file. So, this commit adds scripts/gen_compile_commands.py, which recursively searches through a directory for .<target>.o.cmd files and extracts appropriate compile commands from them. It writes a compile_commands.json file that LibTooling-based tools can use. By default, gen_compile_commands.py starts its search in its working directory and (over)writes compile_commands.json in the working directory. However, it also supports --output and --directory flags for out-of-tree use. Note that while gen_compile_commands.py enables the use of clang-based tools, it does not require the kernel to be compiled with clang. E.g., the following sequence of commands produces a compile_commands.json file that works correctly with LibTooling. make defconfig make scripts/gen_compile_commands.py Also note that this script is written to work correctly in both Python 2 and Python 3, so it does not specify the Python version in its first line. For an example of the utility of this script: after running gen_compile_commands.json on the latest kernel version, I was able to use Vim + the YouCompleteMe pluging + clangd to automatically jump to definitions and declarations. Obviously, cscope and ctags provide some of this functionality; the advantage of supporting LibTooling is that it opens the door to many other clang-based tools that understand the code directly and do not rely on regular expressions and heuristics. Tested: Built several recent kernel versions and ran the script against them, testing tools like clangd (for editor/LSP support) and clang-check (for static analysis). Also extracted some test .cmd files from a kernel build and wrote a test script to check that the script behaved correctly with all permutations of the --output and --directory flags. Signed-off-by: Tom Roeder <tmroeder@google.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-19Revert "kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs"Ingo Molnar2-5/+1
This reverts commit 77b0bf55bc675233d22cd5df97605d516d64525e. See this commit for details about the revert: e769742d3584 ("Revert "x86/jump-labels: Macrofy inline assembly code to work around GCC inlining bugs"") Conflicts: arch/x86/Makefile Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Borislav Petkov <bp@alien8.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Juergen Gross <jgross@suse.com> Cc: Richard Biener <rguenther@suse.de> Cc: Kees Cook <keescook@chromium.org> Cc: Segher Boessenkool <segher@kernel.crashing.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Nadav Amit <namit@vmware.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-12-17scripts: coccinelle: Correct warning messageJulia Lawall1-6/+6
"Assignment" requires the assigned value before the place that value is stored into. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17scripts: coccinelle: only suggest true/false in files that already use themJulia Lawall1-10/+21
Some code may overall use 0 and 1, so don't introduce occasional uses of true and false in these cases. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17kbuild: handle part-of-module correctly for *.ll and *.symtypesMasahiro Yamada1-1/+1
The single targets *.ll and *.symtypes have never been treated as a module. Fix it. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17kbuild: refactor part-of-moduleMasahiro Yamada1-5/+3
Use $(foreach ...) to make it shorter. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17kbuild: refactor quiet_modtagMasahiro Yamada1-6/+1
part-of-module and quiet_modtag are set for the same targets. Define quiet_modtag based on part-of-module. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17kbuild: remove redundant quiet_modtag for $(obj-m)Masahiro Yamada1-2/+0
All objects in $(obj-m) are contained in $(real-obj-m) as well. It is true composite objects are only contained in $(obj-m), but [M] is hard-coded in quiet_cmd_link_multi-m. This line is redundant. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17kbuild: refactor Makefile.asm-genericMasahiro Yamada1-18/+19
- Use conventional $(MAKE) $(asm-generic)=<dir> style for directory descending - Remove unneeded FORCE since "all" is a phony target - Remove unneeded "_dummy :=" assignment - Skip $(shell mkdir ...) when headers exist in the directory - Misc cleanups Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Sam Ravnborg <sam@ravnborg.org>
2018-12-15kconfig: remove redundant token definesMasahiro Yamada1-5/+0
These are already defined as %left. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-15kconfig: rename depends_list to comment_option_listMasahiro Yamada1-6/+6
Now the comment_stmt is the only user of depends_list. Rename it to comment_option_list Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-15kconfig: loosen the order of "visible" and "depends on" in menu entryMasahiro Yamada1-7/+7
Currently, "visible" and "depends on", if defined in a menu entry, must appear in that order. The real example is in drivers/media/tuners/Kconfig: menu "Customize TV tuners" visible if <expr1> depends on <expr2> ... is fine, but you cannot change the property order like this: menu "Customize TV tuners" depends on <expr2> visible if <expr1> Kconfig does not require a specific order of properties. In this case, menu_add_visibility(() and menu_add_dep() are orthogonal. Loosen this unreasonable restriction. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-15kconfig: remove redundant menu_block ruleMasahiro Yamada1-8/+1
The code block surrounded by "menu" ... "endmenu" is stmt_list. Remove the redundant menu_block symbol entirely. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-15kconfig: remove redundant if_block ruleMasahiro Yamada1-9/+1
The code block surrounded by "if" ... "endif" is stmt_list. Remove the redundant if_block symbol entirely. Remove "stmt_list: stmt_list end" rule as well since it would obviously cause conflicts. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-15kconfig: remove grammatically ambiguous option_errorMasahiro Yamada1-10/+0
This commit decreases 6 shift/reduce conflicts, and finally achieves conflict-free parser. Since Kconfig has no terminator for a config block, detecting the end of config_stmt is not easy. For example, there are two ways for handling the error in the following code: 1 config FOO 2 = [A] Print "unknown option" error, assuming the line 2 is a part of config_option_list [B] Print "invalid statement", assuming the line 1 is reduced into a config_stmt by itself Bison actually chooses [A] because it performs the shift rather than the reduction where both are possible. However, there is no reason to choose one over the other. Let's remove the option_error, and let it fall back to [B]. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-15kconfig: remove grammatically ambiguous "unexpected option" diagnosticMasahiro Yamada1-10/+1
This commit decreases 15 shift/reduce conflicts. The location of this error recovery is ambiguous. For example, there are two ways to interpret the following code: 1 config FOO 2 bool "foo" [A] Both lines are reduced together into a config_stmt. [B] The only line 1 is reduced into a config_stmt, and the line 2 matches to "option_name error T_EOL" Of course, we expect [A], but [B] could be grammatically possible. Kconfig has no terminator for a config block. So, we cannot detect its end until we see a non-property keyword. People often insert a blank line between two config blocks, but it is just a coding convention. Blank lines are actually allowed anywhere in Kconfig files. The real error is when a property keyword appears right after "endif", "endchoice", "endmenu", "source", "comment", or variable assignment. Instead of fixing the grammatical ambiguity, I chose to simply remove this error recovery. The difference is unexpected option "bool" ... is turned into a more generic message: invalid statement Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-15kconfig: warn no new line at end of fileMasahiro Yamada1-0/+4
It would be nice to warn if a new line is missing at end of file. We could do this by checkpatch.pl for arbitrary files, but new line is rather essential as a statement terminator in Kconfig. The warning message looks like this: kernel/Kconfig.preempt:60:warning: no new line at end of file Currently, kernel/Kconfig.preempt is the only file with no new line at end of file. Fix it. I know there are some false negative cases. For example, no warning is displayed when the last line contains some whitespaces/comments, but no new line. Yet, this commit works well for most cases. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-14scripts/spdxcheck.py: always open files in binary modeThierry Reding1-2/+4
The spdxcheck script currently falls over when confronted with a binary file (such as Documentation/logo.gif). To avoid that, always open files in binary mode and decode line-by-line, ignoring encoding errors. One tricky case is when piping data into the script and reading it from standard input. By default, standard input will be opened in text mode, so we need to reopen it in binary mode. The breakage only happens with python3 and results in a UnicodeDecodeError (according to Uwe). Link: http://lkml.kernel.org/r/20181212131210.28024-1-thierry.reding@gmail.com Fixes: 6f4d29df66ac ("scripts/spdxcheck.py: make python3 compliant") Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Jeremy Cline <jcline@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Joe Perches <joe@perches.com> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-14checkstack.pl: fix for aarch64Qian Cai1-2/+2
There is actually a space after "sp," like this, ffff2000080813c8: a9bb7bfd stp x29, x30, [sp, #-80]! Right now, checkstack.pl isn't able to print anything on aarch64, because it won't be able to match the stating objdump line of a function due to this missing space. Hence, it displays every stack as zero-size. After this patch, checkpatch.pl is able to match the start of a function's objdump, and is then able to calculate each function's stack correctly. Link: http://lkml.kernel.org/r/20181207195843.38528-1-cai@lca.pw Signed-off-by: Qian Cai <cai@lca.pw> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-13Merge branch 'yaml-bindings-for-v4.21' into dt/nextRob Herring7-16/+45
2018-12-13kbuild: Add support for DT binding schema checksRob Herring2-2/+26
This adds the build infrastructure for checking DT binding schema documents and validating dts files using the binding schema. Check DT binding schema documents: make dt_binding_check Build dts files and check using DT binding schema: make dtbs_check Optionally, DT_SCHEMA_FILES can be passed in with a schema file(s) to use for validation. This makes it easier to find and fix errors generated by a specific schema. Currently, the validation targets are separate from a normal build to avoid a hard dependency on the external DT schema project and because there are lots of warnings generated. Cc: Jonathan Corbet <corbet@lwn.net> Cc: Mark Rutland <mark.rutland@arm.com> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Michal Marek <michal.lkml@markovi.net> Cc: linux-doc@vger.kernel.org Cc: devicetree@vger.kernel.org Cc: linux-kbuild@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2018-12-12ARM: smp: add support for per-task stack canariesArd Biesheuvel3-0/+113
On ARM, we currently only change the value of the stack canary when switching tasks if the kernel was built for UP. On SMP kernels, this is impossible since the stack canary value is obtained via a global symbol reference, which means a) all running tasks on all CPUs must use the same value b) we can only modify the value when no kernel stack frames are live on any CPU, which is effectively never. So instead, use a GCC plugin to add a RTL pass that replaces each reference to the address of the __stack_chk_guard symbol with an expression that produces the address of the 'stack_canary' field that is added to struct thread_info. This way, each task will use its own randomized value. Cc: Russell King <linux@armlinux.org.uk> Cc: Kees Cook <keescook@chromium.org> Cc: Emese Revfy <re.emese@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Laura Abbott <labbott@redhat.com> Cc: kernel-hardening@lists.openwall.com Acked-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Kees Cook <keescook@chromium.org>