Merge tag 'kconfig-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Feb 2018 19:45:49 +0000 (11:45 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Feb 2018 19:45:49 +0000 (11:45 -0800)
Pull Kconfig updates from Masahiro Yamada:
 "A pretty big batch of Kconfig updates.

  I have to mention the lexer and parser of Kconfig are now built from
  real .l and .y sources. So, flex and bison are the requirement for
  building the kernel. Both of them (unlike gperf) have been stable for
  a long time. This change has been tested several weeks in linux-next,
  and I did not receive any problem report about this.

  Summary:

   - add checks for mistakes, like the choice default is not in choice,
     help is doubled

   - document data structure and complex code

   - fix various memory leaks

   - change Makefile to build lexer and parser instead of using
     pre-generated C files

   - drop 'boolean' keyword, which is equivalent to 'bool'

   - use default 'yy' prefix and remove unneeded Make variables

   - fix gettext() check for xconfig

   - announce that oldnoconfig will be finally removed

   - make 'Selected by:' and 'Implied by' readable in help and search
     result

   - hide silentoldconfig from 'make help' to stop confusing people

   - fix misc things and cleanups"

* tag 'kconfig-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (37 commits)
  kconfig: Remove silentoldconfig from help and docs; fix kconfig/conf's help
  kconfig: make "Selected by:" and "Implied by:" readable
  kconfig: announce removal of oldnoconfig if used
  kconfig: fix make xconfig when gettext is missing
  kconfig: Clarify menu and 'if' dependency propagation
  kconfig: Document 'if' flattening logic
  kconfig: Clarify choice dependency propagation
  kconfig: Document SYMBOL_OPTIONAL logic
  kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX
  kconfig: use default 'yy' prefix for lexer and parser
  kconfig: make conf_unsaved a local variable of conf_read()
  kconfig: make xfgets() really static
  kconfig: make input_mode static
  kconfig: Warn if there is more than one help text
  kconfig: drop 'boolean' keyword
  kconfig: use bool instead of boolean for type definition attributes, again
  kconfig: Remove menu_end_entry()
  kconfig: Document important expression functions
  kconfig: Document automatic submenu creation code
  kconfig: Fix choice symbol expression leak
  ...

1  2 
Makefile
drivers/firmware/efi/Kconfig
drivers/staging/rtlwifi/Kconfig
scripts/Makefile.lib
scripts/kconfig/expr.c

diff --combined Makefile
+++ b/Makefile
@@@ -2,7 -2,7 +2,7 @@@
  VERSION = 4
  PATCHLEVEL = 15
  SUBLEVEL = 0
 -EXTRAVERSION = -rc2
 +EXTRAVERSION =
  NAME = Fearless Coyote
  
  # *DOCUMENTATION*
@@@ -377,6 -377,8 +377,8 @@@ NM         = $(CROSS_COMPILE)n
  STRIP         = $(CROSS_COMPILE)strip
  OBJCOPY               = $(CROSS_COMPILE)objcopy
  OBJDUMP               = $(CROSS_COMPILE)objdump
+ LEX           = flex
+ YACC          = bison
  AWK           = awk
  GENKSYMS      = scripts/genksyms/genksyms
  INSTALLKERNEL  := installkernel
@@@ -428,7 -430,7 +430,7 @@@ GCC_PLUGINS_CFLAGS :
  
  export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
  export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES
- export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
+ export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
  export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
  
  export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
@@@ -484,6 -486,26 +486,6 @@@ CLANG_GCC_TC      := --gcc-toolchain=$(GCC_T
  endif
  KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
  KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 -KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
 -KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
 -KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 -KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
 -KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 -# Quiet clang warning: comparison of unsigned expression < 0 is always false
 -KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
 -# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
 -# source of a reference will be _MergedGlobals and not on of the whitelisted names.
 -# See modpost pattern 2
 -KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
 -KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
 -KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
 -KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 -else
 -
 -# These warnings generated too much noise in a regular build.
 -# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
 -KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 -KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
  endif
  
  ifeq ($(config-targets),1)
@@@ -696,29 -718,6 +698,29 @@@ ifdef CONFIG_CC_STACKPROTECTO
  endif
  KBUILD_CFLAGS += $(stackp-flag)
  
 +ifeq ($(cc-name),clang)
 +KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
 +KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
 +KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 +KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
 +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 +# Quiet clang warning: comparison of unsigned expression < 0 is always false
 +KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
 +# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
 +# source of a reference will be _MergedGlobals and not on of the whitelisted names.
 +# See modpost pattern 2
 +KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
 +KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
 +KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
 +KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 +else
 +
 +# These warnings generated too much noise in a regular build.
 +# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
 +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
 +endif
 +
  ifdef CONFIG_FRAME_POINTER
  KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
  else
@@@ -792,9 -791,6 +794,9 @@@ KBUILD_CFLAGS += $(call cc-disable-warn
  # disable invalid "can't wrap" optimizations for signed / pointers
  KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
  
 +# Make sure -fstack-check isn't enabled (like gentoo apparently did)
 +KBUILD_CFLAGS  += $(call cc-option,-fno-stack-check,)
 +
  # conserve stack if available
  KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
  
@@@ -113,7 -113,7 +113,7 @@@ config EFI_CAPSULE_LOADE
          Most users should say N.
  
  config EFI_CAPSULE_QUIRK_QUARK_CSH
-       boolean "Add support for Quark capsules with non-standard headers"
+       bool "Add support for Quark capsules with non-standard headers"
        depends on X86 && !64BIT
        select EFI_CAPSULE_LOADER
        default y
@@@ -159,21 -159,13 +159,21 @@@ config RESET_ATTACK_MITIGATIO
          using the TCG Platform Reset Attack Mitigation specification. This
          protects against an attacker forcibly rebooting the system while it
          still contains secrets in RAM, booting another OS and extracting the
 -        secrets.
 +        secrets. This should only be enabled when userland is configured to
 +        clear the MemoryOverwriteRequest flag on clean shutdown after secrets
 +        have been evicted, since otherwise it will trigger even on clean
 +        reboots.
  
  endmenu
  
  config UEFI_CPER
        bool
  
 +config UEFI_CPER_ARM
 +      bool
 +      depends on UEFI_CPER && ( ARM || ARM64 )
 +      default y
 +
  config EFI_DEV_PATH_PARSER
        bool
        depends on ACPI
@@@ -6,7 -6,17 +6,7 @@@ config R8822B
        This is the staging driver for Realtek RTL8822BE 802.11ac PCIe
        wireless network adapters.
  
 -config RTLHALMAC_ST
 -      tristate
 -      depends on R8822BE
 -      default m
 -
 -config RTLPHYDM_ST
 -      tristate
 -      depends on R8822BE
 -      default m
 -
  config RTLWIFI_DEBUG_ST
-       boolean
+       bool
        depends on R8822BE
        default y
diff --combined scripts/Makefile.lib
@@@ -186,39 -186,49 +186,49 @@@ $(foreach m, $(notdir $1), 
        $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
  endef
  
- ifdef REGENERATE_PARSERS
  # LEX
  # ---------------------------------------------------------------------------
- LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
  quiet_cmd_flex = LEX     $@
-       cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $<
+       cmd_flex = $(LEX) -o$@ -L $<
  
+ ifdef REGENERATE_PARSERS
  .PRECIOUS: $(src)/%.lex.c_shipped
  $(src)/%.lex.c_shipped: $(src)/%.l
        $(call cmd,flex)
+ endif
+ .PRECIOUS: $(obj)/%.lex.c
+ $(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE
+       $(call if_changed,flex)
  
  # YACC
  # ---------------------------------------------------------------------------
- YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
  quiet_cmd_bison = YACC    $@
-       cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $<
+       cmd_bison = $(YACC) -o$@ -t -l $<
  
+ ifdef REGENERATE_PARSERS
  .PRECIOUS: $(src)/%.tab.c_shipped
  $(src)/%.tab.c_shipped: $(src)/%.y
        $(call cmd,bison)
+ endif
+ .PRECIOUS: $(obj)/%.tab.c
+ $(filter %.tab.c,$(targets)): $(obj)/%.tab.c: $(src)/%.y FORCE
+       $(call if_changed,bison)
  
  quiet_cmd_bison_h = YACC    $@
        cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
  
+ ifdef REGENERATE_PARSERS
  .PRECIOUS: $(src)/%.tab.h_shipped
  $(src)/%.tab.h_shipped: $(src)/%.y
        $(call cmd,bison_h)
  endif
  
+ .PRECIOUS: $(obj)/%.tab.h
+ $(filter %.tab.h,$(targets)): $(obj)/%.tab.h: $(src)/%.y FORCE
+       $(call if_changed,bison_h)
  # Shipped files
  # ===========================================================================
  
@@@ -264,7 -274,7 +274,7 @@@ cmd_gzip = (cat $(filter-out FORCE,$^) 
  DTC ?= $(objtree)/scripts/dtc/dtc
  
  # Disable noisy checks by default
 -ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
 +ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
  DTC_FLAGS += -Wno-unit_address_vs_reg \
        -Wno-simple_bus_reg \
        -Wno-unit_address_format \
        -Wno-pci_device_reg
  endif
  
 -ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),2)
 +ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
  DTC_FLAGS += -Wnode_name_chars_strict \
        -Wproperty_name_chars_strict
  endif
diff --combined scripts/kconfig/expr.c
@@@ -113,7 -113,7 +113,7 @@@ void expr_free(struct expr *e
                break;
        case E_NOT:
                expr_free(e->left.expr);
-               return;
+               break;
        case E_EQUAL:
        case E_GEQ:
        case E_GTH:
@@@ -138,8 -138,18 +138,18 @@@ static int trans_count
  #define e1 (*ep1)
  #define e2 (*ep2)
  
+ /*
+  * expr_eliminate_eq() helper.
+  *
+  * Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does
+  * not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared
+  * against all other leaves. Two equal leaves are both replaced with either 'y'
+  * or 'n' as appropriate for 'type', to be eliminated later.
+  */
  static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2)
  {
+       /* Recurse down to leaves */
        if (e1->type == type) {
                __expr_eliminate_eq(type, &e1->left.expr, &e2);
                __expr_eliminate_eq(type, &e1->right.expr, &e2);
                __expr_eliminate_eq(type, &e1, &e2->right.expr);
                return;
        }
+       /* e1 and e2 are leaves. Compare them. */
        if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
            e1->left.sym == e2->left.sym &&
            (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no))
                return;
        if (!expr_eq(e1, e2))
                return;
+       /* e1 and e2 are equal leaves. Prepare them for elimination. */
        trans_count++;
        expr_free(e1); expr_free(e2);
        switch (type) {
        }
  }
  
+ /*
+  * Rewrites the expressions 'ep1' and 'ep2' to remove operands common to both.
+  * Example reductions:
+  *
+  *    ep1: A && B           ->  ep1: y
+  *    ep2: A && B && C      ->  ep2: C
+  *
+  *    ep1: A || B           ->  ep1: n
+  *    ep2: A || B || C      ->  ep2: C
+  *
+  *    ep1: A && (B && FOO)  ->  ep1: FOO
+  *    ep2: (BAR && B) && A  ->  ep2: BAR
+  *
+  *    ep1: A && (B || C)    ->  ep1: y
+  *    ep2: (C || B) && A    ->  ep2: y
+  *
+  * Comparisons are done between all operands at the same "level" of && or ||.
+  * For example, in the expression 'e1 && (e2 || e3) && (e4 || e5)', the
+  * following operands will be compared:
+  *
+  *    - 'e1', 'e2 || e3', and 'e4 || e5', against each other
+  *    - e2 against e3
+  *    - e4 against e5
+  *
+  * Parentheses are irrelevant within a single level. 'e1 && (e2 && e3)' and
+  * '(e1 && e2) && e3' are both a single level.
+  *
+  * See __expr_eliminate_eq() as well.
+  */
  void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
  {
        if (!e1 || !e2)
  #undef e1
  #undef e2
  
+ /*
+  * Returns true if 'e1' and 'e2' are equal, after minor simplification. Two
+  * &&/|| expressions are considered equal if every operand in one expression
+  * equals some operand in the other (operands do not need to appear in the same
+  * order), recursively.
+  */
  static int expr_eq(struct expr *e1, struct expr *e2)
  {
        int res, old_count;
        return 0;
  }
  
+ /*
+  * Recursively performs the following simplifications in-place (as well as the
+  * corresponding simplifications with swapped operands):
+  *
+  *    expr && n  ->  n
+  *    expr && y  ->  expr
+  *    expr || n  ->  expr
+  *    expr || y  ->  y
+  *
+  * Returns the optimized expression.
+  */
  static struct expr *expr_eliminate_yn(struct expr *e)
  {
        struct expr *tmp;
@@@ -516,12 -578,21 +578,21 @@@ static struct expr *expr_join_and(struc
        return NULL;
  }
  
+ /*
+  * expr_eliminate_dups() helper.
+  *
+  * Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does
+  * not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared
+  * against all other leaves to look for simplifications.
+  */
  static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
  {
  #define e1 (*ep1)
  #define e2 (*ep2)
        struct expr *tmp;
  
+       /* Recurse down to leaves */
        if (e1->type == type) {
                expr_eliminate_dups1(type, &e1->left.expr, &e2);
                expr_eliminate_dups1(type, &e1->right.expr, &e2);
                expr_eliminate_dups1(type, &e1, &e2->right.expr);
                return;
        }
+       /* e1 and e2 are leaves. Compare and process them. */
        if (e1 == e2)
                return;
  
  #undef e2
  }
  
+ /*
+  * Rewrites 'e' in-place to remove ("join") duplicate and other redundant
+  * operands.
+  *
+  * Example simplifications:
+  *
+  *    A || B || A    ->  A || B
+  *    A && B && A=y  ->  A=y && B
+  *
+  * Returns the deduplicated expression.
+  */
  struct expr *expr_eliminate_dups(struct expr *e)
  {
        int oldcount;
                        ;
                }
                if (!trans_count)
+                       /* No simplifications done in this pass. We're done */
                        break;
                e = expr_eliminate_yn(e);
        }
        return e;
  }
  
+ /*
+  * Performs various simplifications involving logical operators and
+  * comparisons.
+  *
+  * Allocates and returns a new expression.
+  */
  struct expr *expr_transform(struct expr *e)
  {
        struct expr *tmp;
@@@ -805,6 -897,20 +897,20 @@@ bool expr_depends_symbol(struct expr *d
        return false;
  }
  
+ /*
+  * Inserts explicit comparisons of type 'type' to symbol 'sym' into the
+  * expression 'e'.
+  *
+  * Examples transformations for type == E_UNEQUAL, sym == &symbol_no:
+  *
+  *    A              ->  A!=n
+  *    !A             ->  A=n
+  *    A && B         ->  !(A=n || B=n)
+  *    A || B         ->  !(A=n && B=n)
+  *    A && (B || C)  ->  !(A=n || (B=n && C=n))
+  *
+  * Allocates and returns a new expression.
+  */
  struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
  {
        struct expr *e1, *e2;
@@@ -893,10 -999,7 +999,10 @@@ static enum string_value_kind expr_pars
        switch (type) {
        case S_BOOLEAN:
        case S_TRISTATE:
 -              return k_string;
 +              val->s = !strcmp(str, "n") ? 0 :
 +                       !strcmp(str, "m") ? 1 :
 +                       !strcmp(str, "y") ? 2 : -1;
 +              return k_signed;
        case S_INT:
                val->s = strtoll(str, &tail, 10);
                kind = k_signed;
@@@ -1073,7 -1176,7 +1179,7 @@@ struct expr *expr_simplify_unmet_dep(st
        return expr_get_leftmost_symbol(ret);
  }
  
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep)
  {
        if (!e) {
                fn(data, NULL, "y");
                fn(data, e->right.sym, e->right.sym->name);
                break;
        case E_OR:
-               expr_print(e->left.expr, fn, data, E_OR);
-               fn(data, NULL, " || ");
-               expr_print(e->right.expr, fn, data, E_OR);
+               if (revdep && e->left.expr->type != E_OR)
+                       fn(data, NULL, "\n  - ");
+               __expr_print(e->left.expr, fn, data, E_OR, revdep);
+               if (revdep)
+                       fn(data, NULL, "\n  - ");
+               else
+                       fn(data, NULL, " || ");
+               __expr_print(e->right.expr, fn, data, E_OR, revdep);
                break;
        case E_AND:
                expr_print(e->left.expr, fn, data, E_AND);
                fn(data, NULL, ")");
  }
  
+ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
+ {
+       __expr_print(e, fn, data, prevtoken, false);
+ }
  static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
  {
        xfwrite(str, strlen(str), 1, data);
@@@ -1207,3 -1320,13 +1323,13 @@@ void expr_gstr_print(struct expr *e, st
  {
        expr_print(e, expr_print_gstr_helper, gs, E_NONE);
  }
+ /*
+  * Transform the top level "||" tokens into newlines and prepend each
+  * line with a minus. This makes expressions much easier to read.
+  * Suitable for reverse dependency expressions.
+  */
+ void expr_gstr_print_revdep(struct expr *e, struct gstr *gs)
+ {
+       __expr_print(e, expr_print_gstr_helper, gs, E_NONE, true);
+ }