x86 microcode: revert some work_on_cpu
Quoted 3 lines
Disclaimer: it's not even compilation-tested, consider it merely as an illustration of an approach. I'll be able to test it later.
And here is the version that works for me.
(Perhaps, will still take another round as some parts seem vague to me.)
---
arch/x86/include/asm/microcode.h +8 -2
@@ -13,10 +13,16 @@ struct microcode_ops {int (*request_microcode_user) (int cpu,const void __user *buf,size_t size);int (*request_microcode_fw) (int cpu,struct device *device); -void (*apply_microcode) (int cpu); +void (*microcode_fini_cpu) (int cpu); +/* +* The generic 'microcode_core' part guarantees that +* the callbacks below run on a target cpu when they +* are being called. +* See also the "Synchronization" section in microcode_core.c. +*/ +void (*apply_microcode) (int cpu);int (*collect_cpu_info) (int cpu,struct cpu_signature *csig); -void (*microcode_fini_cpu) (int cpu); };struct ucode_cpu_info {
arch/x86/kernel/microcode_amd.c +0 -10
@@ -17,7 +17,6 @@#include <linux/capability.h> #include <linux/miscdevice.h> #include <linux/firmware.h> -#include <linux/spinlock.h> #include <linux/cpumask.h> #include <linux/pci_ids.h> #include <linux/uaccess.h>
@@ -79,9 +78,6 @@ struct microcode_amd {#define UCODE_CONTAINER_SECTION_HDR 8#define UCODE_CONTAINER_HEADER_SIZE 12 -/* serialize access to the physical write */ -static DEFINE_SPINLOCK (microcode_update_lock); -static struct equiv_cpu_entry *equiv_cpu_table;static int collect_cpu_info_amd (int cpu,struct cpu_signature *csig)
@@ -146,7 +142,6 @@ static int get_matching_microcode(int cpu, void *mc, int rev)static void apply_microcode_amd (int cpu) { -unsigned long flags;u32 rev, dummy;int cpu_num =raw_smp_processor_id ();struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
@@ -158,11 +153,9 @@ static void apply_microcode_amd(int cpu)if (mc_amd ==NULL )return ; -spin_lock_irqsave (µcode_update_lock, flags);wrmsrl (MSR_AMD64_PATCH_LOADER , (u64)(long)&mc_amd->hdr.data_code);/* get patch id after patching */ rdmsr (MSR_AMD64_PATCH_LEVEL , rev, dummy); -spin_unlock_irqrestore (µcode_update_lock, flags);/* check current patch id and patch's id for match */ if (rev != mc_amd->hdr.patch_id) {
@@ -327,9 +320,6 @@ static int request_microcode_fw(int cpu, struct device *device)const struct firmware *firmware;int ret; -/* We should bind the task to the CPU */ -BUG_ON (cpu !=raw_smp_processor_id ()); - ret =request_firmware (&firmware, fw_name, device);if (ret) {printk (KERN_ERR "microcode: failed to load file %s\n" , fw_name);
arch/x86/kernel/microcode_core.c +132 -92
344 lines not on this page · raw message
arch/x86/kernel/microcode_intel.c +0 -19
@@ -75,7 +75,6 @@#include <linux/miscdevice.h> #include <linux/firmware.h> #include <linux/smp_lock.h> -#include <linux/spinlock.h> #include <linux/cpumask.h> #include <linux/uaccess.h> #include <linux/vmalloc.h>
@@ -150,13 +149,9 @@ struct extended_sigtable {#define exttable_size (et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) -/* serialize access to the physical write to MSR 0x79 */ -static DEFINE_SPINLOCK (microcode_update_lock); -static int collect_cpu_info (int cpu_num,struct cpu_signature *csig) {struct cpuinfo_x86 *c = &cpu_data (cpu_num); -unsigned long flags;unsigned int val[2 ];memset (csig,0 ,sizeof (*csig));
@@ -176,15 +171,11 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) csig->pf =1 << ((val[1 ] >>18 ) &7 ); } -/* serialize access to the physical write to MSR 0x79 */ -spin_lock_irqsave (µcode_update_lock, flags); -wrmsr (MSR_IA32_UCODE_REV ,0 ,0 );/* see notes above for revision 1.07. Apparent chip bug */ sync_core ();/* get the current revision from MSR 0x8B */ rdmsr (MSR_IA32_UCODE_REV , val[0 ], csig->rev); -spin_unlock_irqrestore (µcode_update_lock, flags);pr_debug ("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n" , csig->sig, csig->pf, csig->rev);
@@ -322,7 +313,6 @@ static void apply_microcode(int cpu) {struct microcode_intel *mc_intel;struct ucode_cpu_info *uci; -unsigned long flags;unsigned int val[2 ];int cpu_num;
@@ -336,9 +326,6 @@ static void apply_microcode(int cpu)if (mc_intel ==NULL )return ; -/* serialize access to the physical write to MSR 0x79 */ -spin_lock_irqsave (µcode_update_lock, flags); -/* write microcode via MSR 0x79 */ wrmsr(MSR_IA32_UCODE_WRITE, (unsigned long) mc_intel->bits,
@@ -351,7 +338,6 @@ static void apply_microcode(int cpu)/* get the current revision from MSR 0x8B */ rdmsr (MSR_IA32_UCODE_REV , val[0 ], val[1 ]); -spin_unlock_irqrestore (µcode_update_lock, flags);if (val[1 ] != mc_intel->hdr.rev) { printk(KERN_ERR "microcode: CPU%d update from revision " "0x%x to 0x%x failed\n",
@@ -445,8 +431,6 @@ static int request_microcode_fw(int cpu, struct device *device)const struct firmware *firmware;int ret; -/* We should bind the task to the CPU */ -BUG_ON (cpu !=raw_smp_processor_id ());sprintf (name,"intel-ucode/%02x-%02x-%02x" , c->x86, c->x86_model, c->x86_mask); ret =request_firmware (&firmware, name, device);
@@ -470,9 +454,6 @@ static int get_ucode_user(void *to, const void *from, size_t n)static int request_microcode_user (int cpu,const void __user *buf,size_t size) { -/* We should bind the task to the CPU */ -BUG_ON (cpu !=raw_smp_processor_id ()); -return generic_load_microcode (cpu, (void *)buf, size, &get_ucode_user); }