LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH] x86/microcode: Don't duplicate code to update ucode cpu info and cpu info
@ 2018-07-31 15:29 Filippo Sironi
  2018-07-31 15:41 ` Greg KH
  2018-09-02 12:16 ` [tip:x86/urgent] x86/microcode: Update the new microcode revision unconditionally tip-bot for Filippo Sironi
  0 siblings, 2 replies; 5+ messages in thread
From: Filippo Sironi @ 2018-07-31 15:29 UTC (permalink / raw)
  To: sironi, bp, prarit, linux-kernel, linux-edac, stable

... on late microcode loading when handling a CPU that's already been
updated and a CPU that's yet to be updated.

Signed-off-by: Filippo Sironi <sironi@amazon.de>
---
 arch/x86/kernel/cpu/microcode/amd.c   | 15 +++++++++------
 arch/x86/kernel/cpu/microcode/intel.c | 10 ++++++----
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 0624957aa068..77758e10f16f 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -505,6 +505,7 @@ static enum ucode_state apply_microcode_amd(int cpu)
 	struct ucode_cpu_info *uci;
 	struct ucode_patch *p;
 	u32 rev, dummy;
+	enum ucode_state ret;
 
 	BUG_ON(raw_smp_processor_id() != cpu);
 
@@ -521,9 +522,8 @@ static enum ucode_state apply_microcode_amd(int cpu)
 
 	/* need to apply patch? */
 	if (rev >= mc_amd->hdr.patch_id) {
-		c->microcode = rev;
-		uci->cpu_sig.rev = rev;
-		return UCODE_OK;
+		ret = UCODE_OK;
+		goto out;
 	}
 
 	if (__apply_microcode_amd(mc_amd)) {
@@ -534,10 +534,13 @@ static enum ucode_state apply_microcode_amd(int cpu)
 	pr_info("CPU%d: new patch_level=0x%08x\n", cpu,
 		mc_amd->hdr.patch_id);
 
-	uci->cpu_sig.rev = mc_amd->hdr.patch_id;
-	c->microcode = mc_amd->hdr.patch_id;
+	ret = UCODE_UPDATED;
+	rev = mc_amd->hdr.patch_id;
+out:
+	uci->cpu_sig.rev = rev;
+	c->microcode = rev;
 
-	return UCODE_UPDATED;
+	return ret;
 }
 
 static int install_equiv_cpu_table(const u8 *buf)
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 97ccf4c3b45b..4bc869e829eb 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -797,6 +797,7 @@ static enum ucode_state apply_microcode_intel(int cpu)
 	struct microcode_intel *mc;
 	static int prev_rev;
 	u32 rev;
+	enum ucode_state ret;
 
 	/* We should bind the task to the CPU */
 	if (WARN_ON(raw_smp_processor_id() != cpu))
@@ -817,9 +818,8 @@ static enum ucode_state apply_microcode_intel(int cpu)
 	 */
 	rev = intel_get_microcode_revision();
 	if (rev >= mc->hdr.rev) {
-		uci->cpu_sig.rev = rev;
-		c->microcode = rev;
-		return UCODE_OK;
+		ret = UCODE_OK;
+		goto out;
 	}
 
 	/*
@@ -848,10 +848,12 @@ static enum ucode_state apply_microcode_intel(int cpu)
 		prev_rev = rev;
 	}
 
+	ret = UCODE_UPDATED;
+out:
 	uci->cpu_sig.rev = rev;
 	c->microcode = rev;
 
-	return UCODE_UPDATED;
+	return ret;
 }
 
 static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/microcode: Don't duplicate code to update ucode cpu info and cpu info
  2018-07-31 15:29 [PATCH] x86/microcode: Don't duplicate code to update ucode cpu info and cpu info Filippo Sironi
@ 2018-07-31 15:41 ` Greg KH
  2018-07-31 16:23   ` Sironi, Filippo
  2018-09-02 12:16 ` [tip:x86/urgent] x86/microcode: Update the new microcode revision unconditionally tip-bot for Filippo Sironi
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2018-07-31 15:41 UTC (permalink / raw)
  To: Filippo Sironi; +Cc: bp, prarit, linux-kernel, linux-edac, stable

On Tue, Jul 31, 2018 at 05:29:30PM +0200, Filippo Sironi wrote:
> ... on late microcode loading when handling a CPU that's already been
> updated and a CPU that's yet to be updated.
> 
> Signed-off-by: Filippo Sironi <sironi@amazon.de>
> ---
>  arch/x86/kernel/cpu/microcode/amd.c   | 15 +++++++++------
>  arch/x86/kernel/cpu/microcode/intel.c | 10 ++++++----
>  2 files changed, 15 insertions(+), 10 deletions(-)

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/microcode: Don't duplicate code to update ucode cpu info and cpu info
  2018-07-31 15:41 ` Greg KH
@ 2018-07-31 16:23   ` Sironi, Filippo
  2018-07-31 17:50     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Sironi, Filippo @ 2018-07-31 16:23 UTC (permalink / raw)
  To: Greg KH; +Cc: Borislav Petkov, prarit, linux-kernel, linux-edac, stable


> On 31. Jul 2018, at 17:41, Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> On Tue, Jul 31, 2018 at 05:29:30PM +0200, Filippo Sironi wrote:
>> ... on late microcode loading when handling a CPU that's already been
>> updated and a CPU that's yet to be updated.
>> 
>> Signed-off-by: Filippo Sironi <sironi@amazon.de>
>> ---
>> arch/x86/kernel/cpu/microcode/amd.c   | 15 +++++++++------
>> arch/x86/kernel/cpu/microcode/intel.c | 10 ++++++----
>> 2 files changed, 15 insertions(+), 10 deletions(-)
> 
> <formletter>
> 
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree.  Please read:
>    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
> 
> </formletter>

Greg,

If you're concerned that this isn't a fix, keep in mind that this is going
to be a prerequisite for https://lore.kernel.org/patchwork/patch/969070/ ,
which is a bug and was sent to stable.

Filippo


Amazon Development Center Germany GmbH
Berlin - Dresden - Aachen
main office: Krausenstr. 38, 10117 Berlin
Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger
Ust-ID: DE289237879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/microcode: Don't duplicate code to update ucode cpu info and cpu info
  2018-07-31 16:23   ` Sironi, Filippo
@ 2018-07-31 17:50     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2018-07-31 17:50 UTC (permalink / raw)
  To: Sironi, Filippo; +Cc: Borislav Petkov, prarit, linux-kernel, linux-edac, stable

On Tue, Jul 31, 2018 at 04:23:00PM +0000, Sironi, Filippo wrote:
> 
> > On 31. Jul 2018, at 17:41, Greg KH <gregkh@linuxfoundation.org> wrote:
> > 
> > On Tue, Jul 31, 2018 at 05:29:30PM +0200, Filippo Sironi wrote:
> >> ... on late microcode loading when handling a CPU that's already been
> >> updated and a CPU that's yet to be updated.
> >> 
> >> Signed-off-by: Filippo Sironi <sironi@amazon.de>
> >> ---
> >> arch/x86/kernel/cpu/microcode/amd.c   | 15 +++++++++------
> >> arch/x86/kernel/cpu/microcode/intel.c | 10 ++++++----
> >> 2 files changed, 15 insertions(+), 10 deletions(-)
> > 
> > <formletter>
> > 
> > This is not the correct way to submit patches for inclusion in the
> > stable kernel tree.  Please read:
> >    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> > for how to do this properly.
> > 
> > </formletter>
> 
> Greg,
> 
> If you're concerned that this isn't a fix, keep in mind that this is going
> to be a prerequisite for https://lore.kernel.org/patchwork/patch/969070/ ,
> which is a bug and was sent to stable.

{sigh}  No, go read the file please...

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:x86/urgent] x86/microcode: Update the new microcode revision unconditionally
  2018-07-31 15:29 [PATCH] x86/microcode: Don't duplicate code to update ucode cpu info and cpu info Filippo Sironi
  2018-07-31 15:41 ` Greg KH
@ 2018-09-02 12:16 ` tip-bot for Filippo Sironi
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Filippo Sironi @ 2018-09-02 12:16 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: mingo, tglx, bp, linux-kernel, sironi, hpa

Commit-ID:  8da38ebaad23fe1b0c4a205438676f6356607cfc
Gitweb:     https://git.kernel.org/tip/8da38ebaad23fe1b0c4a205438676f6356607cfc
Author:     Filippo Sironi <sironi@amazon.de>
AuthorDate: Tue, 31 Jul 2018 17:29:30 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 2 Sep 2018 14:10:54 +0200

x86/microcode: Update the new microcode revision unconditionally

Handle the case where microcode gets loaded on the BSP's hyperthread
sibling first and the boot_cpu_data's microcode revision doesn't get
updated because of early exit due to the siblings sharing a microcode
engine.

For that, simply write the updated revision on all CPUs unconditionally.

Signed-off-by: Filippo Sironi <sironi@amazon.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: prarit@redhat.com
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1533050970-14385-1-git-send-email-sironi@amazon.de
---
 arch/x86/kernel/cpu/microcode/amd.c   | 22 +++++++++++++---------
 arch/x86/kernel/cpu/microcode/intel.c | 13 ++++++++-----
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 602f17134103..07b5fc00b188 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -504,6 +504,7 @@ static enum ucode_state apply_microcode_amd(int cpu)
 	struct microcode_amd *mc_amd;
 	struct ucode_cpu_info *uci;
 	struct ucode_patch *p;
+	enum ucode_state ret;
 	u32 rev, dummy;
 
 	BUG_ON(raw_smp_processor_id() != cpu);
@@ -521,9 +522,8 @@ static enum ucode_state apply_microcode_amd(int cpu)
 
 	/* need to apply patch? */
 	if (rev >= mc_amd->hdr.patch_id) {
-		c->microcode = rev;
-		uci->cpu_sig.rev = rev;
-		return UCODE_OK;
+		ret = UCODE_OK;
+		goto out;
 	}
 
 	if (__apply_microcode_amd(mc_amd)) {
@@ -531,17 +531,21 @@ static enum ucode_state apply_microcode_amd(int cpu)
 			cpu, mc_amd->hdr.patch_id);
 		return UCODE_ERROR;
 	}
-	pr_info("CPU%d: new patch_level=0x%08x\n", cpu,
-		mc_amd->hdr.patch_id);
 
-	uci->cpu_sig.rev = mc_amd->hdr.patch_id;
-	c->microcode = mc_amd->hdr.patch_id;
+	rev = mc_amd->hdr.patch_id;
+	ret = UCODE_UPDATED;
+
+	pr_info("CPU%d: new patch_level=0x%08x\n", cpu, rev);
+
+out:
+	uci->cpu_sig.rev = rev;
+	c->microcode	 = rev;
 
 	/* Update boot_cpu_data's revision too, if we're on the BSP: */
 	if (c->cpu_index == boot_cpu_data.cpu_index)
-		boot_cpu_data.microcode = mc_amd->hdr.patch_id;
+		boot_cpu_data.microcode = rev;
 
-	return UCODE_UPDATED;
+	return ret;
 }
 
 static int install_equiv_cpu_table(const u8 *buf)
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 256d336cbc04..16936a24795c 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -795,6 +795,7 @@ static enum ucode_state apply_microcode_intel(int cpu)
 	struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
 	struct microcode_intel *mc;
+	enum ucode_state ret;
 	static int prev_rev;
 	u32 rev;
 
@@ -817,9 +818,8 @@ static enum ucode_state apply_microcode_intel(int cpu)
 	 */
 	rev = intel_get_microcode_revision();
 	if (rev >= mc->hdr.rev) {
-		uci->cpu_sig.rev = rev;
-		c->microcode = rev;
-		return UCODE_OK;
+		ret = UCODE_OK;
+		goto out;
 	}
 
 	/*
@@ -848,14 +848,17 @@ static enum ucode_state apply_microcode_intel(int cpu)
 		prev_rev = rev;
 	}
 
+	ret = UCODE_UPDATED;
+
+out:
 	uci->cpu_sig.rev = rev;
-	c->microcode = rev;
+	c->microcode	 = rev;
 
 	/* Update boot_cpu_data's revision too, if we're on the BSP: */
 	if (c->cpu_index == boot_cpu_data.cpu_index)
 		boot_cpu_data.microcode = rev;
 
-	return UCODE_UPDATED;
+	return ret;
 }
 
 static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 15:29 [PATCH] x86/microcode: Don't duplicate code to update ucode cpu info and cpu info Filippo Sironi
2018-07-31 15:41 ` Greg KH
2018-07-31 16:23   ` Sironi, Filippo
2018-07-31 17:50     ` Greg KH
2018-09-02 12:16 ` [tip:x86/urgent] x86/microcode: Update the new microcode revision unconditionally tip-bot for Filippo Sironi

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox