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 14/16] x86/microcode/AMD: Simplify saving from initrd
Date: Fri, 20 Jan 2017 21:29:53 +0100	[thread overview]
Message-ID: <20170120202955.4091-15-bp@alien8.de> (raw)
In-Reply-To: <20170120202955.4091-1-bp@alien8.de>

From: Borislav Petkov <bp@suse.de>

No need to use the previously stashed info in the container - simply go
ahead and parse the initrd once more. It simplifies and streamlines the
code a whole lot.

Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/cpu/microcode/amd.c | 43 +++++++++++--------------------------
 1 file changed, 13 insertions(+), 30 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index fe9e865480af..2a194e384207 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -372,43 +372,26 @@ load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size);
 
 int __init save_microcode_in_initrd_amd(unsigned int cpuid_1_eax)
 {
+	struct cont_desc desc = { 0 };
 	enum ucode_state ret;
-	int retval = 0;
-
-	if (!cont.data) {
-		if (IS_ENABLED(CONFIG_X86_32) && (cont.size != -1)) {
-			struct cpio_data cp;
-
-			cp = find_microcode_in_initrd(ucode_path, false);
-			if (!(cp.data && cp.size)) {
-				cont.size = -1;
-				return -EINVAL;
-			}
+	struct cpio_data cp;
 
-			cont.cpuid_1_eax = cpuid_1_eax;
+	cp = find_microcode_in_initrd(ucode_path, false);
+	if (!(cp.data && cp.size))
+		return -EINVAL;
 
-			scan_containers(cp.data, cp.size, &cont);
-			if (!cont.eq_id) {
-				cont.size = -1;
-				return -EINVAL;
-			}
+	desc.cpuid_1_eax = cpuid_1_eax;
 
-		} else
-			return -EINVAL;
-	}
+	scan_containers(cp.data, cp.size, &desc);
+	if (!desc.eq_id)
+		return -EINVAL;
 
-	ret = load_microcode_amd(smp_processor_id(), x86_family(cpuid_1_eax), cont.data, cont.size);
+	ret = load_microcode_amd(smp_processor_id(), x86_family(cpuid_1_eax),
+				 desc.data, desc.size);
 	if (ret != UCODE_OK)
-		retval = -EINVAL;
-
-	/*
-	 * This will be freed any msec now, stash patches for the current
-	 * family and switch to patch cache for cpu hotplug, etc later.
-	 */
-	cont.data = NULL;
-	cont.size = 0;
+		return -EINVAL;
 
-	return retval;
+	return 0;
 }
 
 void reload_ucode_amd(void)
-- 
2.11.0

  parent reply	other threads:[~2017-01-20 20:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 20:29 [PATCH 00/16 v2] x86/microcode: 4.11 queue Borislav Petkov
2017-01-20 20:29 ` [PATCH 01/16] x86/microcode/intel: Drop stashed AP patch pointer optimization Borislav Petkov
2017-01-23  9:07   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 02/16] x86/MSR: Carve out bare minimum accessors Borislav Petkov
2017-01-23  9:07   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 03/16] x86/microcode: Convert to bare minimum MSR accessors Borislav Petkov
2017-01-23  9:08   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 04/16] x86/microcode/AMD: Clean up find_equiv_id() Borislav Petkov
2017-01-23  9:08   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 05/16] x86/microcode/AMD: Shorten function parameter's name Borislav Petkov
2017-01-23  9:09   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 06/16] x86/microcode/AMD: Extend the container struct Borislav Petkov
2017-01-23  9:09   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 07/16] x86/microcode/AMD: Rework container parsing Borislav Petkov
2017-01-23  9:10   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 08/16] x86/microcode: Decrease CPUID use Borislav Petkov
2017-01-23  9:10   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 09/16] x86/microcode/AMD: Get rid of global this_equiv_id Borislav Petkov
2017-01-23  9:11   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 10/16] x86/microcode/AMD: Use find_microcode_in_initrd() Borislav Petkov
2017-01-23  9:11   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 11/16] x86/microcode: Remove local vendor variable Borislav Petkov
2017-01-23  9:12   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 12/16] x86/microcode/AMD: Check patch level only on the BSP Borislav Petkov
2017-01-23  9:12   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 13/16] x86/microcode/AMD: Unify load_ucode_amd_ap() Borislav Petkov
2017-01-23  9:13   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` Borislav Petkov [this message]
2017-01-23  9:13   ` [tip:x86/mce] x86/microcode/AMD: Simplify saving from initrd tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 15/16] x86/microcode/AMD: Remove AP scanning optimization Borislav Petkov
2017-01-23  9:14   ` [tip:x86/mce] " tip-bot for Borislav Petkov
2017-01-20 20:29 ` [PATCH 16/16] x86/microcode/AMD: Remove struct cont_desc.eq_id Borislav Petkov
2017-01-23  9:14   ` [tip:x86/mce] " 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=20170120202955.4091-15-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.