linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Borislav Petkov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, jgross@suse.com, mingo@kernel.org,
	bp@suse.de, tglx@linutronix.de, boris.ostrovsky@oracle.com,
	hpa@zytor.com
Subject: [tip:x86/urgent] x86/microcode/AMD: Make find_proper_container() sane again
Date: Mon, 19 Dec 2016 01:55:13 -0800	[thread overview]
Message-ID: <tip-8feaa64a9a69652fdff87205f8a8cfe1bfd5b522@git.kernel.org> (raw)
In-Reply-To: <20161218164414.9649-2-bp@alien8.de>

Commit-ID:  8feaa64a9a69652fdff87205f8a8cfe1bfd5b522
Gitweb:     http://git.kernel.org/tip/8feaa64a9a69652fdff87205f8a8cfe1bfd5b522
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Sun, 18 Dec 2016 17:44:11 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Dec 2016 10:46:19 +0100

x86/microcode/AMD: Make find_proper_container() sane again

Fixup signature and retvals, return the container struct through the
passed in pointer, not as a function return value.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Jürgen Gross <jgross@suse.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: http://lkml.kernel.org/r/20161218164414.9649-2-bp@alien8.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/cpu/microcode/amd.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 6f353bd..31f4e3f 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -116,10 +116,11 @@ static inline u16 find_equiv_id(struct equiv_cpu_entry *equiv_cpu_table,
 
 /*
  * This scans the ucode blob for the proper container as we can have multiple
- * containers glued together.
+ * containers glued together. Returns the equivalence ID from the equivalence
+ * table or 0 if none found.
  */
-static struct container
-find_proper_container(u8 *ucode, size_t size, u16 *ret_id)
+static u16
+find_proper_container(u8 *ucode, size_t size, struct container *ret_cont)
 {
 	struct container ret = { NULL, 0 };
 	u32 eax, ebx, ecx, edx;
@@ -138,7 +139,7 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id)
 	if (header[0] != UCODE_MAGIC ||
 	    header[1] != UCODE_EQUIV_CPU_TABLE_TYPE || /* type */
 	    header[2] == 0)                            /* size */
-		return ret;
+		return eq_id;
 
 	eax = 0x00000001;
 	ecx = 0;
@@ -163,8 +164,9 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id)
 			 * ucode update loop below
 			 */
 			left = ret.size - offset;
-			*ret_id = eq_id;
-			return ret;
+
+			*ret_cont = ret;
+			return eq_id;
 		}
 
 		/*
@@ -189,7 +191,7 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id)
 		ucode     = data;
 	}
 
-	return ret;
+	return eq_id;
 }
 
 static int __apply_microcode_amd(struct microcode_amd *mc_amd)
@@ -237,7 +239,7 @@ apply_microcode_early_amd(void *ucode, size_t size, bool save_patch)
 	if (check_current_patch_level(&rev, true))
 		return (struct container){ NULL, 0 };
 
-	ret = find_proper_container(ucode, size, &eq_id);
+	eq_id = find_proper_container(ucode, size, &ret);
 	if (!eq_id)
 		return (struct container){ NULL, 0 };
 
@@ -443,7 +445,7 @@ int __init save_microcode_in_initrd_amd(unsigned int fam)
 				return -EINVAL;
 			}
 
-			cont = find_proper_container(cp.data, cp.size, &eq_id);
+			eq_id = find_proper_container(cp.data, cp.size, &cont);
 			if (!eq_id) {
 				cont.size = -1;
 				return -EINVAL;

  reply	other threads:[~2016-12-19  9:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-18 16:44 [PATCH 0/4] x86/microcode: Some 4.10 fixes Borislav Petkov
2016-12-18 16:44 ` [PATCH 1/4] x86/microcode/AMD: Make find_proper_container() sane again Borislav Petkov
2016-12-19  9:55   ` tip-bot for Borislav Petkov [this message]
2016-12-18 16:44 ` [PATCH 2/4] x86/microcode/AMD: Sanitize apply_microcode_early_amd() Borislav Petkov
2016-12-19  9:55   ` [tip:x86/urgent] " tip-bot for Borislav Petkov
2016-12-18 16:44 ` [PATCH 3/4] x86/microcode/AMD: Do not load when running on a hypervisor Borislav Petkov
2016-12-19  9:56   ` [tip:x86/urgent] " tip-bot for Borislav Petkov
2016-12-18 16:44 ` [PATCH 4/4] x86/microcode/AMD: Use native_cpuid() in load_ucode_amd_bsp() Borislav Petkov
2016-12-19  9:56   ` [tip:x86/urgent] " tip-bot for Boris Ostrovsky
  -- strict thread matches above, loose matches on Subject: below --
2016-12-16 16:39 [PATCH] x86/microcode: " Boris Ostrovsky
2016-12-16 16:37 ` 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=tip-8feaa64a9a69652fdff87205f8a8cfe1bfd5b522@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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).