All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: X86 ML <x86@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 01/17] x86/microcode: Untangle from BLK_DEV_INITRD
Date: Wed,  3 Feb 2016 12:33:29 +0100	[thread overview]
Message-ID: <1454499225-21544-2-git-send-email-bp@alien8.de> (raw)
In-Reply-To: <1454499225-21544-1-git-send-email-bp@alien8.de>

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.

So untangle it from the BLK_DEV_INITRD dependency so that oldconfig
doesn't turn it off and add an explanatory text to its Kconfig help what
the supported methods for supplying microcode are.

Reported-by: Thomas Voegtle <tv@lio96.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org> # 4.4
---
 arch/x86/Kconfig                      | 27 ++++++++++++++-------------
 arch/x86/include/asm/microcode.h      | 26 ++++++++++++++++++++++++++
 arch/x86/kernel/cpu/microcode/intel.c | 14 ++++----------
 3 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 9af2e6338400..405b1858134b 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1159,22 +1159,23 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	depends on BLK_DEV_INITRD
 	select FW_LOADER
 	---help---
-
 	  If you say Y here, you will be able to update the microcode on
-	  certain Intel and AMD processors. The Intel support is for the
-	  IA32 family, e.g. Pentium Pro, Pentium II, Pentium III, Pentium 4,
-	  Xeon etc. The AMD support is for families 0x10 and later. You will
-	  obviously need the actual microcode binary data itself which is not
-	  shipped with the Linux kernel.
-
-	  This option selects the general module only, you need to select
-	  at least one vendor specific module as well.
-
-	  To compile this driver as a module, choose M here: the module
-	  will be called microcode.
+	  Intel and AMD processors. The Intel support is for the IA32 family,
+	  e.g. Pentium Pro, Pentium II, Pentium III, Pentium 4, Xeon etc. The
+	  AMD support is for families 0x10 and later. You will obviously need
+	  the actual microcode binary data itself which is not shipped with
+	  the Linux kernel.
+
+	  The preferred method to load microcode from a detached initrd is described
+	  in Documentation/x86/early-microcode.txt. For that you need to enable
+	  CONFIG_BLK_DEV_INITRD in order for the loader to be able to scan the
+	  initrd for microcode blobs.
+
+	  In addition, you can build-in the microcode into the kernel. For that you
+	  need to enable FIRMWARE_IN_KERNEL and add the vendor-supplied microcode
+	  to the CONFIG_EXTRA_FIRMWARE config option.
 
 config MICROCODE_INTEL
 	bool "Intel microcode loading support"
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index 1e1b07a5a738..9d3a96c4da78 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -3,6 +3,7 @@
 
 #include <asm/cpu.h>
 #include <linux/earlycpio.h>
+#include <linux/initrd.h>
 
 #define native_rdmsr(msr, val1, val2)			\
 do {							\
@@ -143,4 +144,29 @@ static inline void reload_early_microcode(void)			{ }
 static inline bool
 get_builtin_firmware(struct cpio_data *cd, const char *name)	{ return false; }
 #endif
+
+static inline unsigned long get_initrd_start(void)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+	return initrd_start;
+#else
+	return 0;
+#endif
+}
+
+static inline unsigned long get_initrd_start_addr(void)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+#ifdef CONFIG_X86_32
+	unsigned long *initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
+
+	return (unsigned long)__pa_nodebug(*initrd_start_p);
+#else
+	return get_initrd_start();
+#endif
+#else /* CONFIG_BLK_DEV_INITRD */
+	return 0;
+#endif
+}
+
 #endif /* _ASM_X86_MICROCODE_H */
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index ee81c544ee0d..044bbbbcbaf1 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -690,7 +690,7 @@ int __init save_microcode_in_initrd_intel(void)
 	if (count == 0)
 		return ret;
 
-	copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, initrd_start, count);
+	copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, get_initrd_start(), count);
 	ret = save_microcode(&mc_saved_data, mc_saved, count);
 	if (ret)
 		pr_err("Cannot save microcode patches from initrd.\n");
@@ -748,20 +748,14 @@ void load_ucode_intel_ap(void)
 	struct mc_saved_data *mc_saved_data_p;
 	struct ucode_cpu_info uci;
 	unsigned long *mc_saved_in_initrd_p;
-	unsigned long initrd_start_addr;
 	enum ucode_state ret;
 #ifdef CONFIG_X86_32
-	unsigned long *initrd_start_p;
 
-	mc_saved_in_initrd_p =
-		(unsigned long *)__pa_nodebug(mc_saved_in_initrd);
+	mc_saved_in_initrd_p = (unsigned long *)__pa_nodebug(mc_saved_in_initrd);
 	mc_saved_data_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
-	initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
-	initrd_start_addr = (unsigned long)__pa_nodebug(*initrd_start_p);
 #else
-	mc_saved_data_p = &mc_saved_data;
 	mc_saved_in_initrd_p = mc_saved_in_initrd;
-	initrd_start_addr = initrd_start;
+	mc_saved_data_p = &mc_saved_data;
 #endif
 
 	/*
@@ -773,7 +767,7 @@ void load_ucode_intel_ap(void)
 
 	collect_cpu_info_early(&uci);
 	ret = load_microcode(mc_saved_data_p, mc_saved_in_initrd_p,
-			     initrd_start_addr, &uci);
+			     get_initrd_start_addr(), &uci);
 
 	if (ret != UCODE_OK)
 		return;
-- 
2.3.5

  reply	other threads:[~2016-02-03 11:47 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 11:33 [PATCH 00/17] x86/microcode: Untangle loader from BLK_DEV_INITRD Borislav Petkov
2016-02-03 11:33 ` Borislav Petkov [this message]
2016-02-09 12:20   ` [tip:x86/microcode] x86/microcode: Untangle " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 02/17] x86/microcode/intel: Make early loader look for builtin microcode too Borislav Petkov
2016-02-09 12:20   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 03/17] x86/microcode: Remove redundant __setup() param parsing Borislav Petkov
2016-02-09 12:21   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 04/17] x86/microcode: Remove an unneeded NULL check Borislav Petkov
2014-01-20 10:30   ` [patch] x86, microcode: remove " Dan Carpenter
2016-02-09 12:21     ` [tip:x86/microcode] x86/microcode: Remove " tip-bot for Dan Carpenter
2016-02-03 11:33 ` [PATCH 05/17] x86/microcode: Issue update message only once Borislav Petkov
2016-02-09 12:21   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 06/17] x86/microcode/AMD: Drop redundant printk prefix Borislav Petkov
2016-02-09 12:22   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 07/17] x86/microcode/intel: Rename local variables of type struct mc_saved_data Borislav Petkov
2016-02-09 12:22   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 08/17] x86/microcode/intel: Rename mc_saved_count to num_saved Borislav Petkov
2016-02-09 12:22   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 09/17] x86/microcode/intel: Rename mc_intel variable to mc Borislav Petkov
2016-02-09 12:23   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 10/17] x86/microcode/intel: Move the BUG_ON up and turn it into WARN_ON Borislav Petkov
2016-02-09 12:23   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 11/17] x86/microcode/intel: Cleanup apply_microcode_intel() Borislav Petkov
2016-02-09 12:24   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 12/17] x86/microcode/intel: Use *wrmsrl variants Borislav Petkov
2016-02-09 12:24   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 13/17] x86/microcode/intel: Rename mc_saved_in_initrd Borislav Petkov
2016-02-09 12:24   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 14/17] x86/microcode/intel: Remove unused arg of get_matching_model_microcode() Borislav Petkov
2016-02-09 12:25   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 15/17] x86/microcode/intel: Cleanup get_matching_model_microcode() Borislav Petkov
2016-02-09 12:25   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 16/17] x86/microcode/AMD: Issue microcode updated message later Borislav Petkov
2016-02-09 12:25   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` [PATCH 17/17] x86/microcode: Document builtin microcode loading method Borislav Petkov
2016-02-09 12:26   ` [tip:x86/microcode] " tip-bot for Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454499225-21544-2-git-send-email-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.