Messages in this thread | | | Date | Tue, 3 Jul 2012 06:37:17 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH -v2 1/2] x86, microcode: Sanitize per-cpu microcode reloading interface |
| |
On Tue, Jun 26, 2012 at 11:46:18PM +0200, Peter Zijlstra wrote: > --- a/arch/x86/kernel/microcode_core.c > +++ b/arch/x86/kernel/microcode_core.c > @@ -87,6 +87,7 @@ > #include <asm/microcode.h> > #include <asm/processor.h> > #include <asm/cpu_device_id.h> > +#include <asm/perf_event.h> > > MODULE_DESCRIPTION("Microcode Update Driver"); > MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>"); > @@ -277,7 +278,6 @@ static int reload_for_cpu(int cpu) > struct ucode_cpu_info *uci = ucode_cpu_info + cpu; > int err = 0; > > - mutex_lock(µcode_mutex); > if (uci->valid) { > enum ucode_state ustate; > > @@ -288,7 +288,6 @@ static int reload_for_cpu(int cpu) > if (ustate == UCODE_ERROR) > err = -EINVAL; > } > - mutex_unlock(µcode_mutex); > > return err; > } > @@ -309,6 +308,7 @@ static ssize_t reload_store(struct devic > return size; > > get_online_cpus(); > + mutex_lock(µcode_mutex); > for_each_online_cpu(cpu) { > tmp_ret = reload_for_cpu(cpu); > if (tmp_ret != 0) > @@ -318,6 +318,9 @@ static ssize_t reload_store(struct devic > if (!ret) > ret = tmp_ret; > } > + if (!ret) > + perf_check_microcode(); > + mutex_unlock(µcode_mutex);
In thinking about this a bit more, perf callback is only run from the reload_store interface but we don't run it on module init time.
In the situation where perf is enabled, _then_ the microcode driver is loaded as a module later, we don't get to run the callback perf_check_microcode() even when we're loading the module and there's new ucode on the system.
Maybe this needs to be called additionally in microcode_init() after subsys_interface_register call which does microcode_init_cpu down its path and should have updated the microcode when it is done registering all the cpus...
Hmm.
-- Regards/Gruss, Boris.
Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach GM: Alberto Bozzo Reg: Dornach, Landkreis Muenchen HRB Nr. 43632 WEEE Registernr: 129 19551
| |