All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@suse.de>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: Can't boot as Xen dom0 due to commit fe055896
Date: Fri, 16 Dec 2016 16:17:30 +0100	[thread overview]
Message-ID: <20161216151730.4y7orcyjknr6ljph@pd.tnic> (raw)
In-Reply-To: <24632cb2-b0e1-fb45-c814-8d567da5bc8a@oracle.com>

On Fri, Dec 16, 2016 at 09:40:59AM -0500, Boris Ostrovsky wrote:
> It works

Thanks. Added your Tested-by.

> but I think both of the bugs we talked about yesterday still
> need to be fixed, they are not related to Xen.

For the one issue with the eq_id, I have the below cleanup for all the
args passing lined up for testing. For native_cpuid() you could send me
a patch. Unless you don't have time, then I can do it myself.

---
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 6f353bdb3a25..122ed2249367 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.
  */
-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)
@@ -214,17 +216,18 @@ static int __apply_microcode_amd(struct microcode_amd *mc_amd)
  * and on 32-bit during save_microcode_in_initrd_amd() -- we can call
  * load_microcode_amd() to save equivalent cpu table and microcode patches in
  * kernel heap memory.
+ *
+ * Returns true if container found (sets @ret_cont), false otherwise.
  */
-static struct container
-apply_microcode_early_amd(void *ucode, size_t size, bool save_patch)
+static bool apply_microcode_early_amd(void *ucode, size_t size, bool save_patch,
+				      struct container *ret_cont)
 {
-	struct container ret = { NULL, 0 };
 	u8 (*patch)[PATCH_MAX_SIZE];
+	u32 rev, *header, *new_rev;
+	struct container ret;
 	int offset, left;
-	u32 rev, *header;
-	u8  *data;
 	u16 eq_id = 0;
-	u32 *new_rev;
+	u8  *data;
 
 #ifdef CONFIG_X86_32
 	new_rev = (u32 *)__pa_nodebug(&ucode_new_rev);
@@ -235,11 +238,11 @@ apply_microcode_early_amd(void *ucode, size_t size, bool save_patch)
 #endif
 
 	if (check_current_patch_level(&rev, true))
-		return (struct container){ NULL, 0 };
+		return false;
 
-	ret = find_proper_container(ucode, size, &eq_id);
+	eq_id = find_proper_container(ucode, size, &ret);
 	if (!eq_id)
-		return (struct container){ NULL, 0 };
+		return false;
 
 	this_equiv_id = eq_id;
 	header = (u32 *)ret.data;
@@ -273,7 +276,11 @@ apply_microcode_early_amd(void *ucode, size_t size, bool save_patch)
 		data   += offset;
 		left   -= offset;
 	}
-	return ret;
+
+	if (ret_cont)
+		*ret_cont = ret;
+
+	return true;
 }
 
 static bool get_builtin_microcode(struct cpio_data *cp, unsigned int family)
@@ -317,7 +324,7 @@ void __init load_ucode_amd_bsp(unsigned int family)
 	/* Get BSP's CPUID.EAX(1), needed in load_microcode_amd() */
 	uci->cpu_sig.sig = cpuid_eax(1);
 
-	apply_microcode_early_amd(cp.data, cp.size, true);
+	apply_microcode_early_amd(cp.data, cp.size, true, NULL);
 }
 
 #ifdef CONFIG_X86_32
@@ -349,7 +356,7 @@ void load_ucode_amd_ap(unsigned int family)
 	 * This would set amd_ucode_patch above so that the following APs can
 	 * use it directly instead of going down this path again.
 	 */
-	apply_microcode_early_amd(cp.data, cp.size, true);
+	apply_microcode_early_amd(cp.data, cp.size, true, NULL);
 }
 #else
 void load_ucode_amd_ap(unsigned int family)
@@ -387,8 +394,7 @@ void load_ucode_amd_ap(unsigned int family)
 			}
 		}
 
-		cont = apply_microcode_early_amd(cp.data, cp.size, false);
-		if (!(cont.data && cont.size)) {
+		if (apply_microcode_early_amd(cp.data, cp.size, false, &cont)) {
 			cont.size = -1;
 			return;
 		}
@@ -443,7 +449,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;

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

  reply	other threads:[~2016-12-16 15:17 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-15 16:12 Can't boot as Xen dom0 due to commit fe055896 Juergen Gross
2016-12-15 16:46 ` Borislav Petkov
2016-12-15 16:46   ` Borislav Petkov
2016-12-15 16:53   ` [Xen-devel] " Jan Beulich
2016-12-15 16:53     ` Jan Beulich
2016-12-15 16:59     ` Andrew Cooper
2016-12-15 16:59     ` [Xen-devel] " Andrew Cooper
2016-12-15 17:14       ` Borislav Petkov
2016-12-15 17:14         ` Borislav Petkov
2016-12-15 17:00   ` Boris Ostrovsky
2016-12-15 17:17     ` Borislav Petkov
2016-12-15 17:17     ` Borislav Petkov
2016-12-15 17:27       ` Boris Ostrovsky
2016-12-15 17:27         ` Boris Ostrovsky
2016-12-15 17:36         ` Borislav Petkov
2016-12-15 17:36           ` Borislav Petkov
2016-12-15 19:08           ` Boris Ostrovsky
2016-12-15 19:08           ` Boris Ostrovsky
2016-12-15 19:23             ` Borislav Petkov
2016-12-15 19:23               ` Borislav Petkov
2016-12-15 19:36               ` Boris Ostrovsky
2016-12-15 19:36                 ` Boris Ostrovsky
2016-12-15 20:03                 ` Borislav Petkov
2016-12-15 22:56                   ` Boris Ostrovsky
2016-12-15 22:56                     ` Boris Ostrovsky
2016-12-15 23:04                     ` Borislav Petkov
2016-12-16  3:56                       ` Boris Ostrovsky
2016-12-16  3:56                         ` Boris Ostrovsky
2016-12-16  9:01                         ` Borislav Petkov
2016-12-16  9:01                         ` Borislav Petkov
2016-12-16  9:14                           ` [Xen-devel] " Andrew Cooper
2016-12-16  9:14                             ` Andrew Cooper
2016-12-16  4:14                       ` Henrique de Moraes Holschuh
2016-12-16  4:14                         ` Henrique de Moraes Holschuh
2016-12-15 23:04                     ` Borislav Petkov
2016-12-15 20:03                 ` Borislav Petkov
2016-12-16  7:28           ` Juergen Gross
2016-12-16  7:28           ` Juergen Gross
2016-12-16  9:02             ` Borislav Petkov
2016-12-16  9:02             ` Borislav Petkov
2016-12-16  9:20               ` Juergen Gross
2016-12-16  9:20               ` Juergen Gross
2016-12-16  9:43                 ` Borislav Petkov
2016-12-16  9:43                 ` Borislav Petkov
2016-12-16 10:00                   ` Juergen Gross
2016-12-16 10:45                     ` Borislav Petkov
2016-12-16 10:45                       ` Borislav Petkov
2016-12-16 12:15                       ` Juergen Gross
2016-12-16 12:15                       ` Juergen Gross
2016-12-16 12:19                         ` Borislav Petkov
2016-12-16 12:19                           ` Borislav Petkov
2016-12-16 13:07                           ` Borislav Petkov
2016-12-16 13:07                           ` Borislav Petkov
2016-12-16 14:40                             ` Boris Ostrovsky
2016-12-16 14:40                               ` Boris Ostrovsky
2016-12-16 15:17                               ` Borislav Petkov [this message]
2016-12-16 15:17                               ` Borislav Petkov
2016-12-16 10:00                   ` Juergen Gross
2016-12-15 17:00   ` Boris Ostrovsky
2016-12-15 17:06   ` Juergen Gross
2016-12-15 17:06     ` Juergen Gross
  -- strict thread matches above, loose matches on Subject: below --
2016-12-15 16:12 Juergen Gross

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=20161216151730.4y7orcyjknr6ljph@pd.tnic \
    --to=bp@suse.de \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.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.