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 13/17] x86/microcode/intel: Rename mc_saved_in_initrd
Date: Wed,  3 Feb 2016 12:33:41 +0100	[thread overview]
Message-ID: <1454499225-21544-14-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>

Rename it to mc_tmp_ptrs to denote better what it is - a temporary array
for saving pointers to microcode blobs. And "initrd" is not accurate
anymore since initrd is not the only source for early microcode.
Therefore, rename copy_initrd_ptrs() to copy_ptrs() simply and
"initrd_start" to "offset".

And then do the following convention: the global variable is called
"mc_tmp_ptrs" and the local function arguments "mc_ptrs" for
differentiation.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/kernel/cpu/microcode/intel.c | 52 +++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index ff0b44951d12..5970758bbcdd 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -39,7 +39,13 @@
 #include <asm/setup.h>
 #include <asm/msr.h>
 
-static unsigned long mc_saved_in_initrd[MAX_UCODE_COUNT];
+/*
+ * Temporary microcode blobs pointers storage. We note here the pointers to
+ * microcode blobs we've got from whatever storage (detached initrd, builtin).
+ * Later on, we put those into final storage mc_saved_data.mc_saved.
+ */
+static unsigned long mc_tmp_ptrs[MAX_UCODE_COUNT];
+
 static struct mc_saved_data {
 	unsigned int num_saved;
 	struct microcode_intel **mc_saved;
@@ -78,13 +84,13 @@ load_microcode_early(struct microcode_intel **saved,
 }
 
 static inline void
-copy_initrd_ptrs(struct microcode_intel **mc_saved, unsigned long *initrd,
-		  unsigned long off, int num_saved)
+copy_ptrs(struct microcode_intel **mc_saved, unsigned long *mc_ptrs,
+	  unsigned long off, int num_saved)
 {
 	int i;
 
 	for (i = 0; i < num_saved; i++)
-		mc_saved[i] = (struct microcode_intel *)(initrd[i] + off);
+		mc_saved[i] = (struct microcode_intel *)(mc_ptrs[i] + off);
 }
 
 #ifdef CONFIG_X86_32
@@ -106,14 +112,14 @@ microcode_phys(struct microcode_intel **mc_saved_tmp, struct mc_saved_data *mcs)
 #endif
 
 static enum ucode_state
-load_microcode(struct mc_saved_data *mcs, unsigned long *initrd,
-	       unsigned long initrd_start, struct ucode_cpu_info *uci)
+load_microcode(struct mc_saved_data *mcs, unsigned long *mc_ptrs,
+	       unsigned long offset, struct ucode_cpu_info *uci)
 {
 	struct microcode_intel *mc_saved_tmp[MAX_UCODE_COUNT];
 	unsigned int count = mcs->num_saved;
 
 	if (!mcs->mc_saved) {
-		copy_initrd_ptrs(mc_saved_tmp, initrd, initrd_start, count);
+		copy_ptrs(mc_saved_tmp, mc_ptrs, offset, count);
 
 		return load_microcode_early(mc_saved_tmp, count, uci);
 	} else {
@@ -284,7 +290,7 @@ static enum ucode_state __init
 get_matching_model_microcode(int cpu, unsigned long start,
 			     void *data, size_t size,
 			     struct mc_saved_data *mcs,
-			     unsigned long *mc_saved_in_initrd,
+			     unsigned long *mc_ptrs,
 			     struct ucode_cpu_info *uci)
 {
 	u8 *ucode_ptr = data;
@@ -337,7 +343,7 @@ get_matching_model_microcode(int cpu, unsigned long start,
 	}
 
 	for (i = 0; i < num_saved; i++)
-		mc_saved_in_initrd[i] = (unsigned long)mc_saved_tmp[i] - start;
+		mc_ptrs[i] = (unsigned long)mc_saved_tmp[i] - start;
 
 	mcs->num_saved = num_saved;
 out:
@@ -533,7 +539,7 @@ static bool __init load_builtin_intel_microcode(struct cpio_data *cp)
 
 static __initdata char ucode_name[] = "kernel/x86/microcode/GenuineIntel.bin";
 static __init enum ucode_state
-scan_microcode(struct mc_saved_data *mcs, unsigned long *initrd,
+scan_microcode(struct mc_saved_data *mcs, unsigned long *mc_ptrs,
 	       unsigned long start, unsigned long size,
 	       struct ucode_cpu_info *uci)
 {
@@ -559,7 +565,7 @@ scan_microcode(struct mc_saved_data *mcs, unsigned long *initrd,
 	}
 
 	return get_matching_model_microcode(0, start, cd.data, cd.size,
-					    mcs, initrd, uci);
+					    mcs, mc_ptrs, uci);
 }
 
 /*
@@ -675,7 +681,7 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
 
 /*
  * This function converts microcode patch offsets previously stored in
- * mc_saved_in_initrd to pointers and stores the pointers in mc_saved_data.
+ * mc_tmp_ptrs to pointers and stores the pointers in mc_saved_data.
  */
 int __init save_microcode_in_initrd_intel(void)
 {
@@ -686,7 +692,7 @@ int __init save_microcode_in_initrd_intel(void)
 	if (!count)
 		return ret;
 
-	copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, get_initrd_start(), count);
+	copy_ptrs(mc_saved, mc_tmp_ptrs, get_initrd_start(), count);
 
 	ret = save_microcode(&mc_saved_data, mc_saved, count);
 	if (ret)
@@ -698,7 +704,7 @@ int __init save_microcode_in_initrd_intel(void)
 }
 
 static void __init
-_load_ucode_intel_bsp(struct mc_saved_data *mcs, unsigned long *initrd,
+_load_ucode_intel_bsp(struct mc_saved_data *mcs, unsigned long *mc_ptrs,
 		      unsigned long start, unsigned long size)
 {
 	struct ucode_cpu_info uci;
@@ -706,11 +712,11 @@ _load_ucode_intel_bsp(struct mc_saved_data *mcs, unsigned long *initrd,
 
 	collect_cpu_info_early(&uci);
 
-	ret = scan_microcode(mcs, initrd, start, size, &uci);
+	ret = scan_microcode(mcs, mc_ptrs, start, size, &uci);
 	if (ret != UCODE_OK)
 		return;
 
-	ret = load_microcode(mcs, initrd, start, &uci);
+	ret = load_microcode(mcs, mc_ptrs, start, &uci);
 	if (ret != UCODE_OK)
 		return;
 
@@ -733,28 +739,28 @@ void __init load_ucode_intel_bsp(void)
 	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),
+			      (unsigned long *)__pa_nodebug(&mc_tmp_ptrs),
 			      start, size);
 #else
 	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);
+	_load_ucode_intel_bsp(&mc_saved_data, mc_tmp_ptrs, start, size);
 #endif
 }
 
 void load_ucode_intel_ap(void)
 {
-	unsigned long *mc_saved_in_initrd_p;
+	unsigned long *mcs_tmp_p;
 	struct mc_saved_data *mcs_p;
 	struct ucode_cpu_info uci;
 	enum ucode_state ret;
 #ifdef CONFIG_X86_32
 
-	mc_saved_in_initrd_p = (unsigned long *)__pa_nodebug(mc_saved_in_initrd);
+	mcs_tmp_p = (unsigned long *)__pa_nodebug(mc_tmp_ptrs);
 	mcs_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
 #else
-	mc_saved_in_initrd_p = mc_saved_in_initrd;
+	mcs_tmp_p = mc_tmp_ptrs;
 	mcs_p = &mc_saved_data;
 #endif
 
@@ -766,9 +772,7 @@ void load_ucode_intel_ap(void)
 		return;
 
 	collect_cpu_info_early(&uci);
-	ret = load_microcode(mcs_p, mc_saved_in_initrd_p,
-			     get_initrd_start_addr(), &uci);
-
+	ret = load_microcode(mcs_p, mcs_tmp_p, get_initrd_start_addr(), &uci);
 	if (ret != UCODE_OK)
 		return;
 
-- 
2.3.5

  parent reply	other threads:[~2016-02-03 11:41 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 ` [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 ` [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 ` Borislav Petkov [this message]
2016-02-09 12:24   ` [tip:x86/microcode] x86/microcode/intel: Rename mc_saved_in_initrd 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-14-git-send-email-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH 13/17] x86/microcode/intel: Rename mc_saved_in_initrd' \
    /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

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.