| 1 |
From 91df9fdf51492aec9fed6b4cbd33160886740f47 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Ashok Raj <[email protected]> |
| 3 |
Date: Wed, 28 Feb 2018 11:28:42 +0100 |
| 4 |
Subject: x86/microcode/intel: Writeback and invalidate caches before updating |
| 5 |
microcode |
| 6 |
|
| 7 |
Updating microcode is less error prone when caches have been flushed and |
| 8 |
depending on what exactly the microcode is updating. For example, some |
| 9 |
of the issues around certain Broadwell parts can be addressed by doing a |
| 10 |
full cache flush. |
| 11 |
|
| 12 |
[ Borislav: Massage it and use native_wbinvd() in both cases. ] |
| 13 |
|
| 14 |
Signed-off-by: Ashok Raj <[email protected]> |
| 15 |
Signed-off-by: Borislav Petkov <[email protected]> |
| 16 |
Signed-off-by: Thomas Gleixner <[email protected]> |
| 17 |
Tested-by: Tom Lendacky <[email protected]> |
| 18 |
Tested-by: Ashok Raj <[email protected]> |
| 19 |
Cc: Arjan Van De Ven <[email protected]> |
| 20 |
Link: http://lkml.kernel.org/r/[email protected] |
| 21 |
Link: https://lkml.kernel.org/r/[email protected] |
| 22 |
--- |
| 23 |
arch/x86/kernel/cpu/microcode/intel.c | 12 ++++++++++++ |
| 24 |
1 file changed, 12 insertions(+) |
| 25 |
|
| 26 |
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c |
| 27 |
index 87bd6dc..e2864bc 100644 |
| 28 |
--- a/arch/x86/kernel/cpu/microcode/intel.c |
| 29 |
+++ b/arch/x86/kernel/cpu/microcode/intel.c |
| 30 |
@@ -600,6 +600,12 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) |
| 31 |
return UCODE_OK; |
| 32 |
} |
| 33 |
|
| 34 |
+ /* |
| 35 |
+ * Writeback and invalidate caches before updating microcode to avoid |
| 36 |
+ * internal issues depending on what the microcode is updating. |
| 37 |
+ */ |
| 38 |
+ native_wbinvd(); |
| 39 |
+ |
| 40 |
/* write microcode via MSR 0x79 */ |
| 41 |
native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); |
| 42 |
|
| 43 |
@@ -816,6 +822,12 @@ static enum ucode_state apply_microcode_intel(int cpu) |
| 44 |
return UCODE_OK; |
| 45 |
} |
| 46 |
|
| 47 |
+ /* |
| 48 |
+ * Writeback and invalidate caches before updating microcode to avoid |
| 49 |
+ * internal issues depending on what the microcode is updating. |
| 50 |
+ */ |
| 51 |
+ native_wbinvd(); |
| 52 |
+ |
| 53 |
/* write microcode via MSR 0x79 */ |
| 54 |
wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); |
| 55 |
|
| 56 |
-- |
| 57 |
cgit v1.1 |
| 58 |
|