1. 11 6月, 2018 1 次提交
    • M
      kcov: test compiler capability in Kconfig and correct dependency · 5aadfdeb
      Masahiro Yamada 提交于
      As Documentation/kbuild/kconfig-language.txt notes, 'select' should be
      be used with care - it forces a lower limit of another symbol, ignoring
      the dependency.  Currently, KCOV can select GCC_PLUGINS even if arch
      does not select HAVE_GCC_PLUGINS.  This could cause the unmet direct
      dependency.
      
      Now that Kconfig can test compiler capability, let's handle this in a
      more sophisticated way.
      
      There are two ways to enable KCOV; use the compiler that natively
      supports -fsanitize-coverage=trace-pc, or build the SANCOV plugin if
      the compiler has ability to build GCC plugins.  Hence, the correct
      dependency for KCOV is:
      
        depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
      
      You do not need to build the SANCOV plugin if the compiler already
      supports -fsanitize-coverage=trace-pc.  Hence, the select should be:
      
        select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
      
      With this, GCC_PLUGIN_SANCOV is selected only when necessary, so
      scripts/Makefile.gcc-plugins can be cleaner.
      
      I also cleaned up Kconfig and scripts/Makefile.kcov as well.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      5aadfdeb
  2. 08 6月, 2018 2 次提交
  3. 06 6月, 2018 1 次提交
  4. 05 6月, 2018 4 次提交
  5. 01 6月, 2018 1 次提交
  6. 29 5月, 2018 20 次提交
    • N
      scripts: Fixed printf format mismatch · ac5db1fc
      nixiaoming 提交于
      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: Nnixiaoming <nixiaoming@huawei.com>
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      ac5db1fc
    • M
      kconfig: add basic helper macros to scripts/Kconfig.include · e1cfdc0e
      Masahiro Yamada 提交于
      Kconfig got text processing tools like we see in Make.  Add Kconfig
      helper macros to scripts/Kconfig.include like we collect Makefile
      macros in scripts/Kbuild.include.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      e1cfdc0e
    • M
      kconfig: test: add Kconfig macro language tests · 2bece88f
      Masahiro Yamada 提交于
      Here are the test cases I used for developing the text expansion
      feature.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      2bece88f
    • M
      kconfig: error out if a recursive variable references itself · 915f6490
      Masahiro Yamada 提交于
      When using a recursively expanded variable, it is a common mistake
      to make circular reference.
      
      For example, Make terminates the following code:
      
        X = $(X)
        Y := $(X)
      
      Let's detect the circular expansion in Kconfig, too.
      
      On the other hand, a function that recurses itself is a commonly-used
      programming technique.  So, Make does not check recursion in the
      reference with 'call'.  For example, the following code continues
      running eternally:
      
        X = $(call X)
        Y := $(X)
      
      Kconfig allows circular expansion if one or more arguments are given,
      but terminates when the same function is recursively invoked 1000 times,
      assuming it is a programming mistake.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      915f6490
    • M
      kconfig: add 'filename' and 'lineno' built-in variables · a702a617
      Masahiro Yamada 提交于
      The special variables, $(filename) and $(lineno), are expanded to a
      file name and its line number being parsed, respectively.
      Suggested-by: NRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      a702a617
    • M
      kconfig: add 'info', 'warning-if', and 'error-if' built-in functions · 1d6272e6
      Masahiro Yamada 提交于
      Syntax:
        $(info,<text>)
        $(warning-if,<condition>,<text>)
        $(error-if,<condition>,<text)
      
      The 'info' function prints a message to stdout as in Make.
      
      The 'warning-if' and 'error-if' are similar to 'warning' and 'error'
      in Make, but take the condition parameter.  They are effective only
      when the <condition> part is y.
      
      Kconfig does not implement the lazy expansion as used in the 'if'
      'and, 'or' functions in Make.  In other words, Kconfig does not
      support conditional expansion.  The unconditional 'error' function
      would always terminate the parsing, hence would be useless in Kconfig.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      1d6272e6
    • M
      kconfig: expand lefthand side of assignment statement · 82bc8bd8
      Masahiro Yamada 提交于
      Make expands the lefthand side of assignment statements.  In fact,
      Kbuild relies on it since kernel makefiles mostly look like this:
      
        obj-$(CONFIG_FOO) += foo.o
      
      Do likewise in Kconfig.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      82bc8bd8
    • M
      kconfig: support append assignment operator · ed2a22f2
      Masahiro Yamada 提交于
      Support += operator.  This appends a space and the text on the
      righthand side to a variable.
      
      The timing of the evaluation of the righthand side depends on the
      flavor of the variable.  If the lefthand side was originally defined
      as a simple variable, the righthand side is expanded immediately.
      Otherwise, the expansion is deferred.  Appending something to an
      undefined variable results in a recursive variable.
      
      To implement this, we need to remember the flavor of variables.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      ed2a22f2
    • M
      kconfig: support simply expanded variable · 1175c025
      Masahiro Yamada 提交于
      The previous commit added variable and user-defined function.  They
      work similarly in the sense that the evaluation is deferred until
      they are used.
      
      This commit adds another type of variable, simply expanded variable,
      as we see in Make.
      
      The := operator defines a simply expanded variable, expanding the
      righthand side immediately.  This works like traditional programming
      language variables.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      1175c025
    • M
      kconfig: support user-defined function and recursively expanded variable · 9ced3bdd
      Masahiro Yamada 提交于
      Now, we got a basic ability to test compiler capability in Kconfig.
      
      config CC_HAS_STACKPROTECTOR
              def_bool $(shell,($(CC) -Werror -fstack-protector -E -x c /dev/null -o /dev/null 2>/dev/null) && echo y || echo n)
      
      This works, but it is ugly to repeat this long boilerplate.
      
      We want to describe like this:
      
      config CC_HAS_STACKPROTECTOR
              bool
              default $(cc-option,-fstack-protector)
      
      It is straight-forward to add a new function, but I do not like to
      hard-code specialized functions like that.  Hence, here is another
      feature, user-defined function.  This works as a textual shorthand
      with parameterization.
      
      A user-defined function is defined by using the = operator, and can
      be referenced in the same way as built-in functions.  A user-defined
      function in Make is referenced like $(call my-func,arg1,arg2), but I
      omitted the 'call' to make the syntax shorter.
      
      The definition of a user-defined function contains $(1), $(2), etc.
      in its body to reference the parameters.  It is grammatically valid
      to pass more or fewer arguments when calling it.  We already exploit
      this feature in our makefiles; scripts/Kbuild.include defines cc-option
      which takes two arguments at most, but most of the callers pass only
      one argument.
      
      By the way, a variable is supported as a subset of this feature since
      a variable is "a user-defined function with zero argument".  In this
      context, I mean "variable" as recursively expanded variable.  I will
      add a different flavored variable in the next commit.
      
      The code above can be written as follows:
      
      [Example Code]
      
        success = $(shell,($(1)) >/dev/null 2>&1 && echo y || echo n)
        cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
      
        config CC_HAS_STACKPROTECTOR
                def_bool $(cc-option,-fstack-protector)
      
      [Result]
        $ make -s alldefconfig && tail -n 1 .config
        CONFIG_CC_HAS_STACKPROTECTOR=y
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      9ced3bdd
    • M
      kconfig: begin PARAM state only when seeing a command keyword · 9de07153
      Masahiro Yamada 提交于
      Currently, any statement line starts with a keyword with TF_COMMAND
      flag.  So, the following three lines are dead code.
      
              alloc_string(yytext, yyleng);
              zconflval.string = text;
              return T_WORD;
      
      If a T_WORD token is returned in this context, it will cause syntax
      error in the parser anyway.
      
      The next commit will support the assignment statement where a line
      starts with an arbitrary identifier.  So, I want the lexer to switch
      to the PARAM state only when it sees a command keyword.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      9de07153
    • M
      kconfig: add 'shell' built-in function · 2fd5b09c
      Masahiro Yamada 提交于
      This accepts a single command to execute.  It returns the standard
      output from it.
      
      [Example code]
      
        config HELLO
                string
                default "$(shell,echo hello world)"
      
        config Y
                def_bool $(shell,echo y)
      
      [Result]
      
        $ make -s alldefconfig && tail -n 2 .config
        CONFIG_HELLO="hello world"
        CONFIG_Y=y
      
      Caveat:
      Like environments, functions are expanded in the lexer.  You cannot
      pass symbols to function arguments.  This is a limitation to simplify
      the implementation.  I want to avoid the dynamic function evaluation,
      which would introduce much more complexity.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      2fd5b09c
    • M
      kconfig: add built-in function support · e298f3b4
      Masahiro Yamada 提交于
      This commit adds a new concept 'function' to do more text processing
      in Kconfig.
      
      A function call looks like this:
      
        $(function,arg1,arg2,arg3,...)
      
      This commit adds the basic infrastructure to expand functions.
      Change the text expansion helpers to take arguments.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      e298f3b4
    • M
      kconfig: make default prompt of mainmenu less specific · 137c0118
      Masahiro Yamada 提交于
      If "mainmenu" is not specified, "Linux Kernel Configuration" is used
      as a default prompt.
      
      Given that Kconfig is used in other projects than Linux, let's use
      a more generic prompt, "Main menu".
      Suggested-by: NSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      137c0118
    • M
      kconfig: remove sym_expand_string_value() · 5b31a974
      Masahiro Yamada 提交于
      There is no more caller of sym_expand_string_value().
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      5b31a974
    • M
      kconfig: remove string expansion for mainmenu after yyparse() · 96d8e48d
      Masahiro Yamada 提交于
      Now that environments are expanded in the lexer, conf_parse() does
      not need to expand them explicitly.
      
      The hack introduced by commit 0724a7c3 ("kconfig: Don't leak
      main menus during parsing") can go away.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      96d8e48d
    • M
      kconfig: remove string expansion in file_lookup() · bb222cee
      Masahiro Yamada 提交于
      There are two callers of file_lookup(), but there is no more reason
      to expand the given path.
      
      [1] zconf_initscan()
          This is used to open the first Kconfig.  sym_expand_string_value()
          has never been used in a useful way here; before opening the first
          Kconfig file, obviously there is no symbol to expand.  If you use
          expand_string_value() instead, environments in KBUILD_KCONFIG would
          be expanded, but I do not see practical benefits for that.
      
      [2] zconf_nextfile()
          This is used to open the next file from 'source' statement.
          Symbols in the path like "arch/$SRCARCH/Kconfig" needed expanding,
          but it was replaced with the direct environment expansion.  The
          environment has already been expanded before the token is passed
          to the parser.
      
      By the way, file_lookup() was already buggy; it expanded a given path,
      but it used the path before expansion for look-up:
              if (!strcmp(name, file->name)) {
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      bb222cee
    • M
      kconfig: reference environment variables directly and remove 'option env=' · 104daea1
      Masahiro Yamada 提交于
      To get access to environment variables, Kconfig needs to define a
      symbol using "option env=" syntax.  It is tedious to add a symbol entry
      for each environment variable given that we need to define much more
      such as 'CC', 'AS', 'srctree' etc. to evaluate the compiler capability
      in Kconfig.
      
      Adding '$' for symbol references is grammatically inconsistent.
      Looking at the code, the symbols prefixed with 'S' are expanded by:
       - conf_expand_value()
         This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list'
       - sym_expand_string_value()
         This is used to expand strings in 'source' and 'mainmenu'
      
      All of them are fixed values independent of user configuration.  So,
      they can be changed into the direct expansion instead of symbols.
      
      This change makes the code much cleaner.  The bounce symbols 'SRCARCH',
      'ARCH', 'SUBARCH', 'KERNELVERSION' are gone.
      
      sym_init() hard-coding 'UNAME_RELEASE' is also gone.  'UNAME_RELEASE'
      should be replaced with an environment variable.
      
      ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced
      without '$' prefix.
      
      The new syntax is addicted by Make.  The variable reference needs
      parentheses, like $(FOO), but you can omit them for single-letter
      variables, like $F.  Yet, in Makefiles, people tend to use the
      parenthetical form for consistency / clarification.
      
      At this moment, only the environment variable is supported, but I will
      extend the concept of 'variable' later on.
      
      The variables are expanded in the lexer so we can simplify the token
      handling on the parser side.
      
      For example, the following code works.
      
      [Example code]
      
        config MY_TOOLCHAIN_LIST
                string
                default "My tools: CC=$(CC), AS=$(AS), CPP=$(CPP)"
      
      [Result]
      
        $ make -s alldefconfig && tail -n 1 .config
        CONFIG_MY_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E"
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      104daea1
    • M
      kbuild: remove kbuild cache · e08d6de4
      Masahiro Yamada 提交于
      The kbuild cache was introduced to remember the result of shell
      commands, some of which are expensive to compute, such as
      $(call cc-option,...).
      
      However, this turned out not so clever as I had first expected.
      Actually, it is problematic.  For example, "$(CC) -print-file-name"
      is cached.  If the compiler is updated, the stale search path causes
      build error, which is difficult to figure out.  Another problem
      scenario is cache files could be touched while install targets are
      running under the root permission.  We can patch them if desired,
      but the build infrastructure is getting uglier and uglier.
      
      Now, we are going to move compiler flag tests to the configuration
      phase.  If this is completed, the result of compiler tests will be
      naturally cached in the .config file.  We will not have performance
      issues of incremental building since this testing only happens at
      Kconfig time.
      
      To start this work with a cleaner code base, remove the kbuild
      cache first.
      
      Revert the following commits:
      Commit 9a234a2e ("kbuild: create directory for make cache only when necessary")
      Commit e17c400a ("kbuild: shrink .cache.mk when it exceeds 1000 lines")
      Commit 4e562071 ("kbuild: Cache a few more calls to the compiler")
      Commit 3298b690 ("kbuild: Add a cache for generated variables")
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      e08d6de4
    • A
      trace: Use -mcount-record for dynamic ftrace · 96f60dfa
      Andi Kleen 提交于
      gcc 5 supports a new -mcount-record option to generate ftrace
      tables directly. This avoids the need to run record_mcount
      manually.
      
      Use this option when available.
      
      So far doesn't use -mcount-nop, which also exists now.
      
      This is needed to make ftrace work with LTO because the
      normal record-mcount script doesn't run over the link
      time output.
      
      It should also improve build times slightly in the general
      case.
      Link: http://lkml.kernel.org/r/20171127213423.27218-12-andi@firstfloor.orgSigned-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      96f60dfa
  7. 28 5月, 2018 5 次提交
  8. 26 5月, 2018 1 次提交
  9. 22 5月, 2018 3 次提交
  10. 17 5月, 2018 2 次提交
    • Q
      bpf: change eBPF helper doc parsing script to allow for smaller indent · eeacb716
      Quentin Monnet 提交于
      Documentation for eBPF helpers can be parsed from bpf.h and eventually
      turned into a man page. Commit 6f96674d ("bpf: relax constraints on
      formatting for eBPF helper documentation") changed the script used to
      parse it, in order to allow for different indent style and to ease the
      work for writing documentation for future helpers.
      
      The script currently considers that the first tab can be replaced by 6
      to 8 spaces. But the documentation for bpf_fib_lookup() uses a mix of
      tabs (for the "Description" part) and of spaces ("Return" part), and
      only has 5 space long indent for the latter.
      
      We probably do not want to change the values accepted by the script each
      time a new helper gets a new indent style. However, it is worth noting
      that with those 5 spaces, the "Description" and "Return" part *look*
      aligned in the generated patch and in `git show`, so it is likely other
      helper authors will use the same length. Therefore, allow for helper
      documentation to use 5 spaces only for the first indent level.
      Signed-off-by: NQuentin Monnet <quentin.monnet@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      eeacb716
    • M
      modpost: constify *modname function argument where possible · 8b185743
      Masahiro Yamada 提交于
      Neither find_module() nor read_symbols() does change *modname.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      8b185743