From patchwork Fri Feb 17 06:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 58361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp737442wrn; Thu, 16 Feb 2023 22:58:08 -0800 (PST) X-Google-Smtp-Source: AK7set/969hhui/sPOLaUINsCoM0qVoM0pP3qYh9ZRzcpVa1xNinY1t3fW6mEernSlwtf5HKKoI4 X-Received: by 2002:a17:906:e10e:b0:8b1:7569:b51a with SMTP id gj14-20020a170906e10e00b008b17569b51amr3561707ejb.53.1676617088480; Thu, 16 Feb 2023 22:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676617088; cv=none; d=google.com; s=arc-20160816; b=nrR2rVscCvvqlXJkOGpfWeZEalx4hji+TM85VOJT0t+SXzau79R3V4ElWlpJXLpZEn ZAVKEP/q+8U20VKTocEGCCI7xGm+ujtKYnAyYnHsh/f076VGq+NuN8C0G1ZiEFvo96XX CNIVrfYY8gugMNDAnzuD2vnGDH7QN80DgyClugXe7Q+lFYb2t6Di77vnIwo9+BOGzek/ DmYECRkepKoGZ0VJ8rCdIHv/etGxZtZeJY5idJdLw7sm4bCTd1V8MPTry/NTBZfswWuD yekpKtOIqfcC2Bi/7G92jCnqYy6Ut27CYc8GBmkWSKEM+jjGvHMpOawvyqWTvks04sxD lmpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3MXiOLMWRtJD23oH9F/40s9M46/u8K6XofKqR2bDpsA=; b=qnKUR8kel6Z8HGRkgtKlFrE+X1LRVNgikerC/BA9yupqNAxXbNjqO7RL9Wm4D2YV8P fKfFxtY0YZfJAlXc66yPJT3dGduL/ayb3/uP6Te4zF94B/r8cCwc+m9+8IFRr270Btoj M0bvgPjEjAFUUZJNAd0FsThaLsa3vsKDSPMqCkOJFMgt4fwsQURiVbGoNWRz+8X43MIE B6A6VfIhPp0JR/n7btrFTIb56MlvXjh1rR8WsJ+kPzu5ac8NqSpNXBPOBNDcjkGwAmgt 9d3Fy3C2AWbRyjB/9kwb0Ai1AzV3zd4r/K0WNYvXjz3zKewBMqVb0quaPZ9EenR1bXMA WuSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=00Mnt2ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fg8-20020a1709069c4800b0087859d78883si3804408ejc.823.2023.02.16.22.57.44; Thu, 16 Feb 2023 22:58:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=00Mnt2ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbjBQGwu (ORCPT + 99 others); Fri, 17 Feb 2023 01:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjBQGws (ORCPT ); Fri, 17 Feb 2023 01:52:48 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E0564E5C0; Thu, 16 Feb 2023 22:52:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=3MXiOLMWRtJD23oH9F/40s9M46/u8K6XofKqR2bDpsA=; b=00Mnt2kysIg+bzgyhA80LOqscE 6rjvBbtLzNqEOsmcKtrXf/XDzGnp/Rm96ruVGllpt/hBM2Ih3G7wYUL3NjQgk5TxSIG5oZIwdR+ox +uN3sDr1LYymMOvagabaNC85OX3lEchyxChlnFTq+yenXkcjHCHt9YfElQB6F4NTWDRdHVPis65HC z68F0y+CvqkFiIPsyooeoTBnJU5McNpEs/ZrBE8K4fAivg/rWYFBPAuLsXM5k27eKgrmE7zsxWu9/ a9cQ+9WRuXZ7K9CHNMQJzXQGaif23eokcY4tujdAw7Bs62DnOMXq58cxvLTFi9TISk0MfysiUrek7 qQYLY1RA==; Received: from [2601:1c2:980:9ec0::df2f] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSubv-00Cz1N-1e; Fri, 17 Feb 2023 06:52:47 +0000 From: Randy Dunlap To: linux-kernel@vger.kernel.org Cc: Randy Dunlap , Masahiro Yamada , linux-kbuild@vger.kernel.org Subject: [PATCH] kconfig: save the KCONFIG_SEED value in the config file Date: Thu, 16 Feb 2023 22:52:46 -0800 Message-Id: <20230217065246.31641-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758060439822430359?= X-GMAIL-MSGID: =?utf-8?q?1758060439822430359?= Save (print) the randconfig seed value in the kernel .config file. This enables someone to see easily that the .config file is a randconfig file. It also allows the randconfig file to be recreated by using the KCONFIG_SEED environment variable, as long as KCONFIG_PROBABILITY was not specified (the default probability values were used) and as long as the file was not edited. Signed-off-by: Randy Dunlap Cc: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org --- scripts/kconfig/conf.c | 3 +++ scripts/kconfig/confdata.c | 2 ++ scripts/kconfig/lkc.h | 2 ++ 3 files changed, 7 insertions(+) diff -- a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -83,6 +83,8 @@ static void xfgets(char *str, int size, printf("%s", str); } +unsigned int rand_seed; + static void set_randconfig_seed(void) { unsigned int seed; @@ -109,6 +111,7 @@ static void set_randconfig_seed(void) seed = (now.tv_sec + 1) * (now.tv_usec + 1); } + rand_seed = seed; printf("KCONFIG_SEED=0x%X\n", seed); srand(seed); } diff -- a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -621,6 +621,8 @@ static void conf_write_heading(FILE *fp, cs->decoration); fprintf(fp, "%s %s\n", cs->decoration, rootmenu.prompt->text); + if (rand_seed) + fprintf(fp, "%s KCONFIG_SEED=0x%X\n", cs->decoration, rand_seed); fprintf(fp, "%s\n", cs->postfix); } diff -- a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -43,6 +43,8 @@ const char *zconf_curname(void); const char *conf_get_configname(void); void set_all_choice_values(struct symbol *csym); +extern unsigned int rand_seed; + /* confdata.c and expr.c */ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) {