Debian Codegraph @

linux-kernel-patches/05-c182d2b7d0ca48e0d6ff16f7d883161238c447ed.patch

raw
1 From c182d2b7d0ca48e0d6ff16f7d883161238c447ed Mon Sep 17 00:00:00 2001
2 From: Ashok Raj <[email protected]>
3 Date: Wed, 28 Feb 2018 11:28:41 +0100
4 Subject: x86/microcode/intel: Check microcode revision before updating sibling
5 threads
6
7 After updating microcode on one of the threads of a core, the other
8 thread sibling automatically gets the update since the microcode
9 resources on a hyperthreaded core are shared between the two threads.
10
11 Check the microcode revision on the CPU before performing a microcode
12 update and thus save us the WRMSR 0x79 because it is a particularly
13 expensive operation.
14
15 [ Borislav: Massage changelog and coding style. ]
16
17 Signed-off-by: Ashok Raj <[email protected]>
18 Signed-off-by: Borislav Petkov <[email protected]>
19 Signed-off-by: Thomas Gleixner <[email protected]>
20 Tested-by: Tom Lendacky <[email protected]>
21 Tested-by: Ashok Raj <[email protected]>
22 Cc: Arjan Van De Ven <[email protected]>
23 Link: http://lkml.kernel.org/r/[email protected]
24 Link: https://lkml.kernel.org/r/[email protected]
25 ---
26 arch/x86/kernel/cpu/microcode/intel.c | 27 ++++++++++++++++++++++++---
27 1 file changed, 24 insertions(+), 3 deletions(-)
28
29 diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
30 index 923054a..87bd6dc 100644
31 --- a/arch/x86/kernel/cpu/microcode/intel.c
32 +++ b/arch/x86/kernel/cpu/microcode/intel.c
33 @@ -589,6 +589,17 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
34 if (!mc)
35 return 0;
36
37 + /*
38 + * Save us the MSR write below - which is a particular expensive
39 + * operation - when the other hyperthread has updated the microcode
40 + * already.
41 + */
42 + rev = intel_get_microcode_revision();
43 + if (rev >= mc->hdr.rev) {
44 + uci->cpu_sig.rev = rev;
45 + return UCODE_OK;
46 + }
47 +
48 /* write microcode via MSR 0x79 */
49 native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits);
50
51 @@ -776,7 +787,7 @@ static enum ucode_state apply_microcode_intel(int cpu)
52 {
53 struct microcode_intel *mc;
54 struct ucode_cpu_info *uci;
55 - struct cpuinfo_x86 *c;
56 + struct cpuinfo_x86 *c = &cpu_data(cpu);
57 static int prev_rev;
58 u32 rev;
59
60 @@ -793,6 +804,18 @@ static enum ucode_state apply_microcode_intel(int cpu)
61 return UCODE_NFOUND;
62 }
63
64 + /*
65 + * Save us the MSR write below - which is a particular expensive
66 + * operation - when the other hyperthread has updated the microcode
67 + * already.
68 + */
69 + rev = intel_get_microcode_revision();
70 + if (rev >= mc->hdr.rev) {
71 + uci->cpu_sig.rev = rev;
72 + c->microcode = rev;
73 + return UCODE_OK;
74 + }
75 +
76 /* write microcode via MSR 0x79 */
77 wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits);
78
79 @@ -813,8 +836,6 @@ static enum ucode_state apply_microcode_intel(int cpu)
80 prev_rev = rev;
81 }
82
83 - c = &cpu_data(cpu);
84 -
85 uci->cpu_sig.rev = rev;
86 c->microcode = rev;
87
88 --
89 cgit v1.1
90