diff options
| -rw-r--r-- | arch/x86/kernel/microcode_core.c | 19 | ||||
| -rw-r--r-- | arch/x86/kernel/microcode_intel.c | 6 |
2 files changed, 20 insertions, 5 deletions
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c index 82fb2809ce3..c4b5b24e021 100644 --- a/arch/x86/kernel/microcode_core.c +++ b/arch/x86/kernel/microcode_core.c | |||
| @@ -272,13 +272,18 @@ static struct attribute_group mc_attr_group = { | |||
| 272 | .name = "microcode", | 272 | .name = "microcode", |
| 273 | }; | 273 | }; |
| 274 | 274 | ||
| 275 | static void microcode_fini_cpu(int cpu) | 275 | static void __microcode_fini_cpu(int cpu) |
| 276 | { | 276 | { |
| 277 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; | 277 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; |
| 278 | 278 | ||
| 279 | mutex_lock(µcode_mutex); | ||
| 280 | microcode_ops->microcode_fini_cpu(cpu); | 279 | microcode_ops->microcode_fini_cpu(cpu); |
| 281 | uci->valid = 0; | 280 | uci->valid = 0; |
| 281 | } | ||
| 282 | |||
| 283 | static void microcode_fini_cpu(int cpu) | ||
| 284 | { | ||
| 285 | mutex_lock(µcode_mutex); | ||
| 286 | __microcode_fini_cpu(cpu); | ||
| 282 | mutex_unlock(µcode_mutex); | 287 | mutex_unlock(µcode_mutex); |
| 283 | } | 288 | } |
| 284 | 289 | ||
| @@ -306,12 +311,16 @@ static int microcode_resume_cpu(int cpu) | |||
| 306 | * to this cpu (a bit of paranoia): | 311 | * to this cpu (a bit of paranoia): |
| 307 | */ | 312 | */ |
| 308 | if (microcode_ops->collect_cpu_info(cpu, &nsig)) { | 313 | if (microcode_ops->collect_cpu_info(cpu, &nsig)) { |
| 309 | microcode_fini_cpu(cpu); | 314 | __microcode_fini_cpu(cpu); |
| 315 | printk(KERN_ERR "failed to collect_cpu_info for resuming cpu #%d\n", | ||
| 316 | cpu); | ||
| 310 | return -1; | 317 | return -1; |
| 311 | } | 318 | } |
| 312 | 319 | ||
| 313 | if (memcmp(&nsig, &uci->cpu_sig, sizeof(nsig))) { | 320 | if ((nsig.sig != uci->cpu_sig.sig) || (nsig.pf != uci->cpu_sig.pf)) { |
| 314 | microcode_fini_cpu(cpu); | 321 | __microcode_fini_cpu(cpu); |
| 322 | printk(KERN_ERR "cached ucode doesn't match the resuming cpu #%d\n", | ||
| 323 | cpu); | ||
| 315 | /* Should we look for a new ucode here? */ | 324 | /* Should we look for a new ucode here? */ |
| 316 | return 1; | 325 | return 1; |
| 317 | } | 326 | } |
diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c index 622dc4a2178..a8e62792d17 100644 --- a/arch/x86/kernel/microcode_intel.c +++ b/arch/x86/kernel/microcode_intel.c | |||
| @@ -155,6 +155,7 @@ static DEFINE_SPINLOCK(microcode_update_lock); | |||
| 155 | static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) | 155 | static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) |
| 156 | { | 156 | { |
| 157 | struct cpuinfo_x86 *c = &cpu_data(cpu_num); | 157 | struct cpuinfo_x86 *c = &cpu_data(cpu_num); |
| 158 | unsigned long flags; | ||
| 158 | unsigned int val[2]; | 159 | unsigned int val[2]; |
| 159 | 160 | ||
| 160 | memset(csig, 0, sizeof(*csig)); | 161 | memset(csig, 0, sizeof(*csig)); |
| @@ -174,11 +175,16 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) | |||
| 174 | csig->pf = 1 << ((val[1] >> 18) & 7); | 175 | csig->pf = 1 << ((val[1] >> 18) & 7); |
| 175 | } | 176 | } |
| 176 | 177 | ||
| 178 | /* serialize access to the physical write to MSR 0x79 */ | ||
| 179 | spin_lock_irqsave(µcode_update_lock, flags); | ||
| 180 | |||
| 177 | wrmsr(MSR_IA32_UCODE_REV, 0, 0); | 181 | wrmsr(MSR_IA32_UCODE_REV, 0, 0); |
| 178 | /* see notes above for revision 1.07. Apparent chip bug */ | 182 | /* see notes above for revision 1.07. Apparent chip bug */ |
| 179 | sync_core(); | 183 | sync_core(); |
| 180 | /* get the current revision from MSR 0x8B */ | 184 | /* get the current revision from MSR 0x8B */ |
| 181 | rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev); | 185 | rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev); |
| 186 | spin_unlock_irqrestore(µcode_update_lock, flags); | ||
| 187 | |||
| 182 | pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", | 188 | pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", |
| 183 | csig->sig, csig->pf, csig->rev); | 189 | csig->sig, csig->pf, csig->rev); |
| 184 | 190 | ||
