lkml.org 
[lkml]   [2018]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4/7] x86/microcode: Do not upload microcode if CPUs are offline
From
Date
On 2/28/2018 4:28 AM, Borislav Petkov wrote:
> From: Ashok Raj <ashok.raj@intel.com>
>
> Avoid loading microcode if any of the CPUs are offline, and issue a
> warning. Having different microcode revisions on the system at any time
> is outright dangerous.
>
> Signed-off-by: Ashok Raj <ashok.raj@intel.com>
> Cc: x86-ml <x86@kernel.org>
> Link: http://lkml.kernel.org/r/1519352533-15992-4-git-send-email-ashok.raj@intel.com
> [ Massage it. ]
> Signed-off-by: Borislav Petkov <bp@suse.de>
> ---
> arch/x86/kernel/cpu/microcode/core.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> index 63370651e376..fa32cb3dcca5 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c
> @@ -486,6 +486,16 @@ static void __exit microcode_dev_exit(void)
> /* fake device for request_firmware */
> static struct platform_device *microcode_pdev;
>
> +static int check_online_cpus(void)
> +{
> + if (num_online_cpus() == num_present_cpus())
> + return 0;
> +
> + pr_err("Not all CPUs online, aborting microcode update.\n");
> +
> + return -EINVAL;
> +}
> +
> static enum ucode_state reload_for_cpu(int cpu)
> {
> struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
> @@ -519,7 +529,13 @@ static ssize_t reload_store(struct device *dev,
> return size;
>
> get_online_cpus();
> +
> + ret = check_online_cpus();
> + if (ret)
> + goto put;
> +
> mutex_lock(&microcode_mutex);
> +
> for_each_online_cpu(cpu) {
> tmp_ret = reload_for_cpu(cpu);
> if (tmp_ret > UCODE_NFOUND) {
> @@ -538,6 +554,8 @@ static ssize_t reload_store(struct device *dev,
> microcode_check();
>
> mutex_unlock(&microcode_mutex);
> +
> +put:
> put_online_cpus();
>
> if (!ret)
>

\
 
 \ /
  Last update: 2018-03-05 23:07    [W:0.118 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site