linux-kernel.vger.kernel.org archive mirror
 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 02/17] x86/microcode/intel: Make early loader look for builtin microcode too
Date: Wed,  3 Feb 2016 12:33:30 +0100	[thread overview]
Message-ID: <1454499225-21544-3-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>

Set the initrd @start depending on the presence of an initrd. Otherwise,
builtin microcode loading doesn't work as the start is wrong and we're
using it to compute offset to the microcode blobs.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org> # 4.4
---
 arch/x86/kernel/cpu/microcode/intel.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 044bbbbcbaf1..4f4735bd8698 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -551,10 +551,14 @@ scan_microcode(struct mc_saved_data *mc_saved_data, unsigned long *initrd,
 	cd.data = NULL;
 	cd.size = 0;
 
-	cd = find_cpio_data(p, (void *)start, size, &offset);
-	if (!cd.data) {
+	/* try built-in microcode if no initrd */
+	if (!size) {
 		if (!load_builtin_intel_microcode(&cd))
 			return UCODE_ERROR;
+	} else {
+		cd = find_cpio_data(p, (void *)start, size, &offset);
+		if (!cd.data)
+			return UCODE_ERROR;
 	}
 
 	return get_matching_model_microcode(0, start, cd.data, cd.size,
@@ -728,16 +732,20 @@ void __init load_ucode_intel_bsp(void)
 	struct boot_params *p;
 
 	p	= (struct boot_params *)__pa_nodebug(&boot_params);
-	start	= p->hdr.ramdisk_image;
 	size	= p->hdr.ramdisk_size;
 
-	_load_ucode_intel_bsp(
-			(struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
-			(unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
-			start, size);
+	/*
+	 * Set start only if we have an initrd image. We cannot use initrd_start
+	 * because it is not set that early yet.
+	 */
+	start	= (size ? p->hdr.ramdisk_image : 0);
+
+	_load_ucode_intel_bsp((struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
+			      (unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
+			      start, size);
 #else
-	start	= boot_params.hdr.ramdisk_image + PAGE_OFFSET;
 	size	= boot_params.hdr.ramdisk_size;
+	start	= (size ? boot_params.hdr.ramdisk_image + PAGE_OFFSET : 0);
 
 	_load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd, start, size);
 #endif
-- 
2.3.5

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

Thread overview: 35+ 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 ` [PATCH 01/17] x86/microcode: Untangle " Borislav Petkov
2016-02-09 12:20   ` [tip:x86/microcode] " tip-bot for Borislav Petkov
2016-02-03 11:33 ` Borislav Petkov [this message]
2016-02-09 12:20   ` [tip:x86/microcode] x86/microcode/intel: Make early loader look for builtin microcode too 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
     [not found]   ` <20140120103046.GC14233@elgon.mountain>
2016-02-09 12:21     ` [tip:x86/microcode] " 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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).