Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp473838ybi; Thu, 11 Jul 2019 23:09:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOA9HEb5MnsCqwZ9kpERJ+Tq1hVsTh4W1H64Tca43UopGmwTL0kaNk6VPVqPiM5q4oySG4 X-Received: by 2002:a17:90a:eb04:: with SMTP id j4mr7799145pjz.103.1562911756192; Thu, 11 Jul 2019 23:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562911756; cv=none; d=google.com; s=arc-20160816; b=GRu+fMEzt6Y2wbYk+DETRMgvXHBy8OXCL5W5MZfVFtT0wqtPdqdP2DbXatmT9YOjzt zUioFhgqtxBj0tDNGGF81SAm3oClqg3aq7foiEe7Un7EZlT/p7euAnsErfHwAnrGb/Gi 35AHkczRwJbqCfHe0bBp6gRaU1oPciS9AgHFrWlyqVSMJnx3s5Hm2JcajQUWTJOrNxOU P2TbC2mf1UyES+IW/59EP4d1O0Qy6m1uAef5hUWvP4lMLYbnJvXaSKPPDxGCQsIm47Gw 2Kzy7T9Lqf7/xBJmIeiwI9acjq9fPyvvkwS4YrWJsEHy4M6oKZnQxYnglMrcRQYPNOQH Q0Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=DNuQzHn+OIKUIOau4E/Lk/DJbbhem5IcUbtMTebzYys=; b=WzUOTYUQQwv8FK7ZSxmryfAEzMEiOa95/DHhzNO+QTxTYNBDsLRe6ILnkD8xMwJ6D8 i2RMD6RBPvmvvd+vmI6gnbDdS4x+Gj4zUlRXBS+h5lh9M43xpZgf/5Q5gS47z25IxUgR 2LuuH1VsyLSdIBz/t7pHJtPw/y2IKyN6kq6RuMOGVOTq13JibbP8kPDEXg6aA4j2KXBR UNAyZTQlEoocnep/DOO+rPNBGG7WA1spAVpIeCuTh68dEVJAACGMEr2csh7vaNL39tfq 7NwW0BhV9wJVlmGLo/4vh533KdWV/V94MfpUFbJU8miAwml6rPf/y/U4+zuEYGiDWFI7 +RIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=njop8InN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b41si6894962pla.409.2019.07.11.23.09.00; Thu, 11 Jul 2019 23:09:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=njop8InN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725987AbfGLGIm (ORCPT + 99 others); Fri, 12 Jul 2019 02:08:42 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:42652 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbfGLGIm (ORCPT ); Fri, 12 Jul 2019 02:08:42 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x6C67CGj006351; Fri, 12 Jul 2019 15:07:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x6C67CGj006351 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1562911633; bh=DNuQzHn+OIKUIOau4E/Lk/DJbbhem5IcUbtMTebzYys=; h=From:To:Cc:Subject:Date:From; b=njop8InNKgrhUWeNEiLlitdYGHFbavRnEoEQcMaiP5MNjiH4JD48I/rK7M5zch6KE eRE+Rp58omN412mkPEZZI1uQrwpnlatT0uh7k14YdhFfOhSBV5U/tjMF4eElfPGH5d j0Dy+A9ze1wmEXnEecZS8Wastnd/xM7dQIdoftowzq5K8fpZAjzOanoY2rfpd6za6s 0qtA+rEkodL9x/VoAVwc1gZbCFPEIyvUHQfJencJjasSM0cpMFxhYYfwmDSBoNXodA odqfqq/LfffTsAcSS0tR/1bGWcxOL65AzRbjwbXl7hRbl8rVThMoXOwurJrKwflb0Z tLxH0s0hCZO4g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: =?UTF-8?q?Joonas=20Kylm=8F=AB=A3l=8F=AB=A3?= , Ulf Magnusson , Masahiro Yamada , linux-stable , linux-kernel@vger.kernel.org Subject: [PATCH] kconfig: fix missing choice values in auto.conf Date: Fri, 12 Jul 2019 15:07:09 +0900 Message-Id: <20190712060709.20609-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing"), Kconfig creates include/config/auto.conf in the defconfig stage when it is missing. Joonas Kylmälä reported incorrect auto.conf generation under some circumstances. Apply the following diff: | --- a/arch/arm/configs/imx_v6_v7_defconfig | +++ b/arch/arm/configs/imx_v6_v7_defconfig | @@ -345,14 +345,7 @@ CONFIG_USB_CONFIGFS_F_MIDI=y | CONFIG_USB_CONFIGFS_F_HID=y | CONFIG_USB_CONFIGFS_F_UVC=y | CONFIG_USB_CONFIGFS_F_PRINTER=y | -CONFIG_USB_ZERO=m | -CONFIG_USB_AUDIO=m | -CONFIG_USB_ETH=m | -CONFIG_USB_G_NCM=m | -CONFIG_USB_GADGETFS=m | -CONFIG_USB_FUNCTIONFS=m | -CONFIG_USB_MASS_STORAGE=m | -CONFIG_USB_G_SERIAL=m | +CONFIG_USB_FUNCTIONFS=y | CONFIG_MMC=y | CONFIG_MMC_SDHCI=y | CONFIG_MMC_SDHCI_PLTFM=y And then, run: $ make ARCH=arm mrproper imx_v6_v7_defconfig CONFIG_USB_FUNCTIONFS=y is correctly contained in the .config, but not in the auto.conf. Please note drivers/usb/gadget/legacy/Kconfig is included from a choice block in drivers/usb/gadget/Kconfig. So USB_FUNCTIONFS is a choice value. This is probably a similar situation described in commit beaaddb62540 ("kconfig: tests: test defconfig when two choices interact"). When sym_calc_choice() is called, the choice symbol forgets the SYMBOL_DEF_USER unless all of its choice values are explicitly set by the user. The choice symbol is given just one chance to recall it because set_all_choice_values() is called if SYMBOL_NEED_SET_CHOICE_VALUES is set. When sym_calc_choice() is called again, the choice symbol forgets it forever, since SYMBOL_NEED_SET_CHOICE_VALUES is a one-time aid. Hence, we cannot call sym_clear_all_valid() again and again. It is crazy to set and clear internal flags. However, we cannot simply get rid of "sym->flags &= flags | ~SYMBOL_DEF_USER;" Doing so would re-introduce the problem solved by commit 5d09598d488f ("kconfig: fix new choices being skipped upon config update"). To work around the issue, conf_write_autoconf() stopped calling sym_clear_all_valid(). conf_write() must be changed accordingly. Currently, it clears SYMBOL_WRITE after the symbol is written into the .config file. This is needed to prevent it from writing the same symbol multiple times in case the symbol is declared in two or more locations. I added the new flag SYMBOL_WRITTEN, to track the symbols that have been written. Anyway, this is a cheesy workaround in order to suppress the issue as far as defconfig is concerned. Handling of choices is totally broken. sym_clear_all_valid() is called every time a user touches a symbol from the GUI interface. To reproduce it, just add a new symbol drivers/usb/gadget/legacy/Kconfig, then touch around unrelated symbols from menuconfig. USB_FUNCTIONFS will disappear from the .config file. I added the Fixes tag since it is more fatal than before. But, this has been broken since long long time before, and still it is. We should take a closer look to fix this correctly somehow. Fixes: 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing") Cc: linux-stable # 4.19+ Reported-by: Joonas Kylmälä Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 7 +++---- scripts/kconfig/expr.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index cbb6efa4a5a6..e0972b255aac 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -895,7 +895,8 @@ int conf_write(const char *name) "# %s\n" "#\n", str); need_newline = false; - } else if (!(sym->flags & SYMBOL_CHOICE)) { + } else if (!(sym->flags & SYMBOL_CHOICE) && + !(sym->flags & SYMBOL_WRITTEN)) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE)) goto next; @@ -903,7 +904,7 @@ int conf_write(const char *name) fprintf(out, "\n"); need_newline = false; } - sym->flags &= ~SYMBOL_WRITE; + sym->flags |= SYMBOL_WRITTEN; conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } @@ -1063,8 +1064,6 @@ int conf_write_autoconf(int overwrite) if (!overwrite && is_present(autoconf_name)) return 0; - sym_clear_all_valid(); - conf_write_dep("include/config/auto.conf.cmd"); if (conf_touch_deps()) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 8dde65bc3165..017843c9a4f4 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -141,6 +141,7 @@ struct symbol { #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400 /* ? */ +#define SYMBOL_WRITTEN 0x0800 /* track info to avoid double-write to .config */ #define SYMBOL_NO_WRITE 0x1000 /* Symbol for internal use only; it will not be written */ #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ #define SYMBOL_WARNED 0x8000 /* warning has been issued */ -- 2.17.1