]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.9/0009-x86-microcode-Make-sure-boot_cpu_data.microcode-is-u.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.9 / 0009-x86-microcode-Make-sure-boot_cpu_data.microcode-is-u.patch
CommitLineData
6fa88700
GKH
1From 2d0ed07e828b0ff877ee45b50013f219014494a1 Mon Sep 17 00:00:00 2001
2From: Prarit Bhargava <prarit@redhat.com>
3Date: Tue, 31 Jul 2018 07:27:39 -0400
4Subject: [PATCH 09/76] x86/microcode: Make sure boot_cpu_data.microcode is
5 up-to-date
6
7commit 370a132bb2227ff76278f98370e0e701d86ff752 upstream.
8
9When preparing an MCE record for logging, boot_cpu_data.microcode is used
10to read out the microcode revision on the box.
11
12However, on systems where late microcode update has happened, the microcode
13revision output in a MCE log record is wrong because
14boot_cpu_data.microcode is not updated when the microcode gets updated.
15
16But, the microcode revision saved in boot_cpu_data's microcode member
17should be kept up-to-date, regardless, for consistency.
18
19Make it so.
20
21Fixes: fa94d0c6e0f3 ("x86/MCE: Save microcode revision in machine check records")
22Signed-off-by: Prarit Bhargava <prarit@redhat.com>
23Signed-off-by: Borislav Petkov <bp@suse.de>
24Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
25Cc: Tony Luck <tony.luck@intel.com>
26Cc: sironi@amazon.de
27Link: http://lkml.kernel.org/r/20180731112739.32338-1-prarit@redhat.com
28[bwh: Backported to 4.9: adjust context]
29Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
30Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31---
32 arch/x86/kernel/cpu/microcode/amd.c | 4 ++++
33 arch/x86/kernel/cpu/microcode/intel.c | 4 ++++
34 2 files changed, 8 insertions(+)
35
36diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
37index 732bb03fcf91..fdb750e76223 100644
38--- a/arch/x86/kernel/cpu/microcode/amd.c
39+++ b/arch/x86/kernel/cpu/microcode/amd.c
40@@ -724,6 +724,10 @@ int apply_microcode_amd(int cpu)
41 uci->cpu_sig.rev = mc_amd->hdr.patch_id;
42 c->microcode = mc_amd->hdr.patch_id;
43
44+ /* Update boot_cpu_data's revision too, if we're on the BSP: */
45+ if (c->cpu_index == boot_cpu_data.cpu_index)
46+ boot_cpu_data.microcode = mc_amd->hdr.patch_id;
47+
48 return 0;
49 }
50
51diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
52index 8faa5fa208d6..4748488bfaaf 100644
53--- a/arch/x86/kernel/cpu/microcode/intel.c
54+++ b/arch/x86/kernel/cpu/microcode/intel.c
55@@ -958,6 +958,10 @@ static int apply_microcode_intel(int cpu)
56 uci->cpu_sig.rev = rev;
57 c->microcode = rev;
58
59+ /* Update boot_cpu_data's revision too, if we're on the BSP: */
60+ if (c->cpu_index == boot_cpu_data.cpu_index)
61+ boot_cpu_data.microcode = rev;
62+
63 return 0;
64 }
65
66--
672.21.0
68