Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1309567

[RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

From Borislav Petkov <bp@suse.de>
Newsgroups linux.kernel
Subject [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig
Date 2016-01-14 19:50 +0100
Message-ID <qQV86-2CA-5@gated-at.bofh.it> (permalink)
References (5 earlier) <qPQDw-6Sz-9@gated-at.bofh.it> <qPRgf-7mV-25@gated-at.bofh.it> <qPRSV-7T9-7@gated-at.bofh.it> <qPRSV-7T9-5@gated-at.bofh.it> <qPS2C-7X2-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Borislav Petkov <bp@suse.de>

Thomas Voegtle reported that doing oldconfig with a .config which has
CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the
microcode loading mechanism from being built.

Add a short script which hooks into the "make oldconfig" handling and
sanity-checks the config file for that discrepancy. It issues a message
which should hopefully sensitize the user to that issue and point her
into the right direction.

The other useful thing with this solution is that it can be extended to
other config file sanity-checking, should the need arise.

Reported-by: Thomas Voegtle <tv@lio96.de>
Cc: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: Måns Rullgård <mans@mansr.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/scripts/check-configs.sh | 44 +++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/Makefile          |  3 +++
 2 files changed, 47 insertions(+)
 create mode 100644 arch/x86/scripts/check-configs.sh

diff --git a/arch/x86/scripts/check-configs.sh b/arch/x86/scripts/check-configs.sh
new file mode 100644
index 000000000000..775d07e37df5
--- /dev/null
+++ b/arch/x86/scripts/check-configs.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+if [ "$1" != "oldconfig" ]; then
+	exit 0
+fi
+
+srctree=$2
+ARCH="$3"
+UNAME_RELEASE=$(uname -r)
+
+CONFIGS=".config /lib/modules/$UNAME_RELEASE/.config /etc/kernel-config /boot/config-$UNAME_RELEASE"
+
+if [ "$ARCH" = "X86_32" ]; then
+	CONFIGS="$CONFIGS $srctree/arch/x86/configs/i386_defconfig"
+else
+	CONFIGS="$CONFIGS $srctree/arch/x86/configs/x86_64_defconfig"
+fi
+
+for c in $CONFIGS;
+do
+	if [ -e $c ]; then
+		OLD_CONFIG=$c
+		break
+	fi
+done
+
+if [ -z "$OLD_CONFIG" ]; then exit 0; fi
+
+# Check optimal microcode loader .config settings
+if ! grep -v "^#" $OLD_CONFIG | grep -q MICROCODE; then
+	exit 0
+fi
+
+MSG="\nYou have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. The preferred\n\
+way is to enable it and make sure microcode is added to your initrd as\n\
+explained in Documentation/x86/early-microcode.txt. This is also the\n\
+most tested method as the majority of distros do it. Alternatively, and\n\
+if you don't want to enable modules, you should make sure the microcode\n\
+is built into the kernel.\n"
+
+if ! grep -v "^#" $OLD_CONFIG | grep -q BLK_DEV_INITRD; then
+	echo -e $MSG
+	read -p "Press any key... "
+fi
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index d79cba4ce3eb..136ae9744efc 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -81,6 +81,9 @@ simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
 PHONY += $(simple-targets)
 
 $(simple-targets): $(obj)/conf
+ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh),)
+	$(Q)$(CONFIG_SHELL) $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh $@ $(srctree) $(ARCH)
+endif
 	$< $(silent) --$@ $(Kconfig)
 
 PHONY += oldnoconfig savedefconfig defconfig
-- 
2.3.5

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-07 13:20 +0100
  Re: x86/microcode update on systems without INITRD Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-01-07 13:50 +0100
    Re: x86/microcode update on systems without INITRD Thomas Voegtle <tv@lio96.de> - 2016-01-08 10:40 +0100
    Re: x86/microcode update on systems without INITRD Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-01-08 13:30 +0100
    Re: x86/microcode update on systems without INITRD Mike Keehan <mike.keehan@blueyonder.co.uk> - 2016-01-08 14:30 +0100
  Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-08 12:00 +0100
    Re: x86/microcode update on systems without INITRD Måns Rullgård <mans@mansr.com> - 2016-01-08 12:20 +0100
      Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-08 12:40 +0100
        Re: x86/microcode update on systems without INITRD Måns Rullgård <mans@mansr.com> - 2016-01-08 12:50 +0100
          Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-08 13:10 +0100
            Re: x86/microcode update on systems without INITRD Måns Rullgård <mans@mansr.com> - 2016-01-08 13:20 +0100
            Re: x86/microcode update on systems without INITRD Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-01-08 13:20 +0100
              Re: x86/microcode update on systems without INITRD Måns Rullgård <mans@mansr.com> - 2016-01-08 13:30 +0100
              Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-08 13:30 +0100
                Re: x86/microcode update on systems without INITRD Michal Marek <mmarek@suse.cz> - 2016-01-08 13:50 +0100
                Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-08 14:40 +0100
                Re: x86/microcode update on systems without INITRD Michal Marek <mmarek@suse.cz> - 2016-01-08 15:50 +0100
                Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-11 20:50 +0100
                Re: x86/microcode update on systems without INITRD Måns Rullgård <mans@mansr.com> - 2016-01-11 21:30 +0100
                Re: x86/microcode update on systems without INITRD Måns Rullgård <mans@mansr.com> - 2016-01-11 22:10 +0100
                Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-11 22:20 +0100
                [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig Borislav Petkov <bp@suse.de> - 2016-01-14 19:50 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during  oldconfig Thomas Voegtle <tv@lio96.de> - 2016-01-18 14:40 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during  oldconfig Borislav Petkov <bp@suse.de> - 2016-01-18 15:10 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig Måns Rullgård <mans@mansr.com> - 2016-01-18 15:20 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during  oldconfig Borislav Petkov <bp@suse.de> - 2016-01-18 15:30 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during  oldconfig Borislav Petkov <bp@suse.de> - 2016-01-18 15:50 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig Måns Rullgård <mans@mansr.com> - 2016-01-18 16:00 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig Måns Rullgård <mans@mansr.com> - 2016-01-18 16:50 +0100
                Re: [RFC PATCH] x86/kconfig: Sanity-check config file during  oldconfig Borislav Petkov <bp@suse.de> - 2016-01-18 16:50 +0100
                [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) Ingo Molnar <mingo@kernel.org> - 2016-01-19 09:30 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-01-19 09:50 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) Ingo Molnar <mingo@kernel.org> - 2016-01-19 10:00 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) Borislav Petkov <bp@suse.de> - 2016-01-19 10:50 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) Peter Zijlstra <peterz@infradead.org> - 2016-01-19 10:10 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) Ingo Molnar <mingo@kernel.org> - 2016-01-19 10:20 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) Borislav Petkov <bp@suse.de> - 2016-01-19 10:50 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y Michal Marek <mmarek@suse.cz> - 2016-01-19 11:00 +0100
                Re: [RFC] CONFIG_GENERIC_BOOTABLE_CONFIG=y Ingo Molnar <mingo@kernel.org> - 2016-01-19 11:40 +0100
                Re: [RFC] CONFIG_GENERIC_BOOTABLE_CONFIG=y Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-19 18:30 +0100
                Re: [RFC] CONFIG_GENERIC_BOOTABLE_CONFIG=y "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2016-01-19 19:00 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y Måns Rullgård <mans@mansr.com> - 2016-01-19 13:30 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y Michal Marek <mmarek@suse.cz> - 2016-01-19 13:50 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y Måns Rullgård <mans@mansr.com> - 2016-01-19 14:00 +0100
                Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH]  x86/kconfig: Sanity-check config file during oldconfig) "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-01-21 23:10 +0100
                Re: x86/microcode update on systems without INITRD Borislav Petkov <bp@suse.de> - 2016-01-11 22:10 +0100

csiph-web