linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Jacob Shin <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	jacob.shin@amd.com, tglx@linutronix.de, hpa@linux.intel.com
Subject: [tip:x86/microcode] x86, microcode, amd: Another early loading fixup
Date: Wed, 26 Jun 2013 15:12:44 -0700	[thread overview]
Message-ID: <tip-9608d33b8210c993af4430d661a6474946480c9b@git.kernel.org> (raw)
In-Reply-To: <20130620152414.GA6676@jshin-Toonie>

Commit-ID:  9608d33b8210c993af4430d661a6474946480c9b
Gitweb:     http://git.kernel.org/tip/9608d33b8210c993af4430d661a6474946480c9b
Author:     Jacob Shin <jacob.shin@amd.com>
AuthorDate: Thu, 20 Jun 2013 09:52:50 -0500
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Wed, 26 Jun 2013 14:55:37 -0700

x86, microcode, amd: Another early loading fixup

commit cd1c32ca969ebfd65e61312c988223bb14f09c2e is an early premature
rendition of the patch. Augment it with this delta patch to:
  * correctly mark offset and size of the matching bin file
  * use __pa instead of __pa_nodebug during AP load
  * check for !initrd_start before using it

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
Link: http://lkml.kernel.org/r/20130620152414.GA6676@jshin-Toonie
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/kernel/microcode_amd_early.c | 40 +++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/microcode_amd_early.c b/arch/x86/kernel/microcode_amd_early.c
index 4c593c2..1ac6e9a 100644
--- a/arch/x86/kernel/microcode_amd_early.c
+++ b/arch/x86/kernel/microcode_amd_early.c
@@ -143,13 +143,17 @@ static void __cpuinit apply_ucode_in_initrd(void *ucode, size_t size)
 			left  -= offset;
 		}
 
-		offset = data - (u8 *)ucode;
+		/* mark where the next microcode container file starts */
+		offset    = data - (u8 *)ucode;
 		*uoffset += offset;
 		*usize   -= offset;
+		ucode     = data;
 	}
 
-	if (!eq_id)
+	if (!eq_id) {
+		*usize = 0;
 		return;
+	}
 
 	/* find ucode and update if needed */
 
@@ -166,15 +170,21 @@ static void __cpuinit apply_ucode_in_initrd(void *ucode, size_t size)
 		mc = (struct microcode_amd *)(data + SECTION_HDR_SIZE);
 		if (eq_id == mc->hdr.processor_rev_id && rev < mc->hdr.patch_id)
 			if (__apply_microcode_amd(mc) == 0) {
-				if (!(*new_rev))
-					*new_rev = mc->hdr.patch_id;
-				break;
+				rev = mc->hdr.patch_id;
+				*new_rev = rev;
 			}
 
 		offset  = header[1] + SECTION_HDR_SIZE;
 		data   += offset;
 		left   -= offset;
 	}
+
+	/* mark where this microcode container file ends */
+	offset  = *usize - (data - (u8 *)ucode);
+	*usize -= offset;
+
+	if (!(*new_rev))
+		*usize = 0;
 }
 
 void __init load_ucode_amd_bsp(void)
@@ -204,19 +214,20 @@ void __cpuinit load_ucode_amd_ap(void)
 	size_t *usize;
 	void *ucode;
 
-	mc = (struct microcode_amd *)__pa_nodebug(amd_bsp_mpb);
+	mc = (struct microcode_amd *)__pa(amd_bsp_mpb);
 	if (mc->hdr.patch_id && mc->hdr.processor_rev_id) {
 		__apply_microcode_amd(mc);
 		return;
 	}
 
-	initrd  = (unsigned long *)__pa_nodebug(&initrd_start);
-	uoffset = (unsigned long *)__pa_nodebug(&ucode_offset);
-	usize   = (size_t *)__pa_nodebug(&ucode_size);
-	if (!*usize)
+	initrd  = (unsigned long *)__pa(&initrd_start);
+	uoffset = (unsigned long *)__pa(&ucode_offset);
+	usize   = (size_t *)__pa(&ucode_size);
+
+	if (!*usize || !*initrd)
 		return;
 
-	ucode = (void *)((unsigned long)__pa_nodebug(*initrd) + *uoffset);
+	ucode = (void *)((unsigned long)__pa(*initrd) + *uoffset);
 	apply_ucode_in_initrd(ucode, *usize);
 }
 
@@ -250,7 +261,7 @@ void __cpuinit load_ucode_amd_ap(void)
 	if (cpu && !ucode_loaded) {
 		void *ucode;
 
-		if (!ucode_size)
+		if (!ucode_size || !initrd_start)
 			return;
 
 		ucode = (void *)(initrd_start + ucode_offset);
@@ -278,10 +289,7 @@ int __init save_microcode_in_initrd_amd(void)
 		pr_info("microcode: updated early to new patch_level=0x%08x\n",
 			ucode_new_rev);
 
-	if (ucode_loaded)
-		return 0;
-
-	if (!ucode_size)
+	if (ucode_loaded || !ucode_size || !initrd_start)
 		return 0;
 
 	ucode = (void *)(initrd_start + ucode_offset);

      parent reply	other threads:[~2013-06-26 22:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-08  2:22 [PATCH V3 0/2] x86/microcode/amd: early loading fixes Jacob Shin
2013-06-08  2:22 ` [PATCH V3 1/2] x86/microcode/amd: make find_ucode_in_initrd() __init Jacob Shin
2013-06-08  2:22 ` [PATCH V3 2/2] x86/microcode/amd: allow multiple families' bin files appended together Jacob Shin
2013-06-12 19:31 ` [PATCH V3 0/2] x86/microcode/amd: early loading fixes Jacob Shin
2013-06-20 10:30   ` Ingo Molnar
2013-06-20 15:16     ` Jacob Shin
2013-06-20 15:24       ` Jacob Shin
2013-06-26 15:37         ` Jacob Shin
2013-06-26 22:12         ` tip-bot for Jacob Shin [this message]

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-9608d33b8210c993af4430d661a6474946480c9b@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jacob.shin@amd.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).