[PATCH 4.14 092/138] x86/microcode/intel: Look into the patch cache first

2018-04-10 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Borislav Petkov 

commit d8c3b52c00a05036e0a6b315b4b17921a7b67997 upstream.

The cache might contain a newer patch - look in there first.

A follow-on change will make sure newest patches are loaded into the
cache of microcode patches.

Signed-off-by: Borislav Petkov 
Signed-off-by: Thomas Gleixner 
Tested-by: Tom Lendacky 
Tested-by: Ashok Raj 
Cc: Arjan Van De Ven 
Link: https://lkml.kernel.org/r/20180228102846.13447-6...@alien8.de
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/cpu/microcode/intel.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -791,9 +791,9 @@ static int collect_cpu_info(int cpu_num,
 
 static enum ucode_state apply_microcode_intel(int cpu)
 {
-   struct microcode_intel *mc;
-   struct ucode_cpu_info *uci;
+   struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
struct cpuinfo_x86 *c = _data(cpu);
+   struct microcode_intel *mc;
static int prev_rev;
u32 rev;
 
@@ -801,11 +801,10 @@ static enum ucode_state apply_microcode_
if (WARN_ON(raw_smp_processor_id() != cpu))
return UCODE_ERROR;
 
-   uci = ucode_cpu_info + cpu;
-   mc = uci->mc;
+   /* Look for a newer patch in our cache: */
+   mc = find_patch(uci);
if (!mc) {
-   /* Look for a newer patch in our cache: */
-   mc = find_patch(uci);
+   mc = uci->mc;
if (!mc)
return UCODE_NFOUND;
}




[PATCH 4.14 092/138] x86/microcode/intel: Look into the patch cache first

2018-04-10 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Borislav Petkov 

commit d8c3b52c00a05036e0a6b315b4b17921a7b67997 upstream.

The cache might contain a newer patch - look in there first.

A follow-on change will make sure newest patches are loaded into the
cache of microcode patches.

Signed-off-by: Borislav Petkov 
Signed-off-by: Thomas Gleixner 
Tested-by: Tom Lendacky 
Tested-by: Ashok Raj 
Cc: Arjan Van De Ven 
Link: https://lkml.kernel.org/r/20180228102846.13447-6...@alien8.de
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/cpu/microcode/intel.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -791,9 +791,9 @@ static int collect_cpu_info(int cpu_num,
 
 static enum ucode_state apply_microcode_intel(int cpu)
 {
-   struct microcode_intel *mc;
-   struct ucode_cpu_info *uci;
+   struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
struct cpuinfo_x86 *c = _data(cpu);
+   struct microcode_intel *mc;
static int prev_rev;
u32 rev;
 
@@ -801,11 +801,10 @@ static enum ucode_state apply_microcode_
if (WARN_ON(raw_smp_processor_id() != cpu))
return UCODE_ERROR;
 
-   uci = ucode_cpu_info + cpu;
-   mc = uci->mc;
+   /* Look for a newer patch in our cache: */
+   mc = find_patch(uci);
if (!mc) {
-   /* Look for a newer patch in our cache: */
-   mc = find_patch(uci);
+   mc = uci->mc;
if (!mc)
return UCODE_NFOUND;
}