Received: by 10.192.165.156 with SMTP id m28csp59221imm; Tue, 10 Apr 2018 16:21:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48iPk7+XEqB0rHCYCN2RidwAwksTJHNV/b5JNs7cZI7ZMEpfCg45/VU9i2oJeR4h58YjI/8 X-Received: by 10.98.180.24 with SMTP id h24mr1933786pfn.213.1523402511816; Tue, 10 Apr 2018 16:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402511; cv=none; d=google.com; s=arc-20160816; b=0kX0aQBtaAAMYebOlM1SkyZPiK5F5Wq8vOqa0pVywanSz7kdmievPXTb80rZKKtgub 3e6Ec0T2yFSqte19c7oeQlY53GnU4g58to7VYjUfuwKmjEoHVfJ+b+PN6hJzdTVYJxRd z7byFgJnrBJOZnk9w1vs9HUHa5o03qey4bySVGNvF7um+pMJRhGtxpaMhaNfQ2J+xD+0 1vyNLc6jgkQIhcGJmXYL/hWig7TjzDpFPmetfcNweFsmlE+kUzf1JlGySfIPro3A/uwb JeaWk6J7lIMVHtpEi2458gVg0NdvEP/wZ9Vp7jTeux7UQM4FeB8k9+Icn4sUC0jgMeD/ YyEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=SUII8IWb0zhavL97uyfTXbnKwk2ffEezTCLesvTEC3o=; b=i/BBVKiqSQBKAZt7f1LYnRnE6sfR1v4Ja7BavyUpwxa73itl4GhuV5Bnk2EMETl1+L ruwUrcWIotuOMoyqFGQRzAvC8k/wYqpORO2M4hrc21zxjz0munDOOAqp5uT39KzuBtVq NLsZ3N9OgyTeno0X2vV1bvSDlRO1DZwfmiuUZnnABvIVyESpGiw9sGIXpIWHt1n5dSS5 8Afbao339GX88NFVcZxzD//dSWCAs2/YEcjz1c7Dc5n0Gaf9EhOLYAUVt3IY1O1ZumYB cYqbjBuQ4LT+gPT3+W8FgtJDPM/zHtzhK0la/A7fcid/UgCErcOvbM2hHnBFNjskiKUR l2kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8-v6si3894363plk.550.2018.04.10.16.21.15; Tue, 10 Apr 2018 16:21:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754865AbeDJWbt (ORCPT + 99 others); Tue, 10 Apr 2018 18:31:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40714 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752802AbeDJWbr (ORCPT ); Tue, 10 Apr 2018 18:31:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A96A78BF; Tue, 10 Apr 2018 22:31:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ashok Raj , Borislav Petkov , Thomas Gleixner , Tom Lendacky , Arjan Van De Ven Subject: [PATCH 4.15 115/168] x86/microcode: Do not upload microcode if CPUs are offline Date: Wed, 11 Apr 2018 00:24:17 +0200 Message-Id: <20180410212805.319101844@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ashok Raj commit 30ec26da9967d0d785abc24073129a34c3211777 upstream. 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. [ Borislav: Massage changelog. ] Signed-off-by: Ashok Raj Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Tested-by: Tom Lendacky Tested-by: Ashok Raj Reviewed-by: Tom Lendacky Cc: Arjan Van De Ven Link: http://lkml.kernel.org/r/1519352533-15992-4-git-send-email-ashok.raj@intel.com Link: https://lkml.kernel.org/r/20180228102846.13447-5-bp@alien8.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/microcode/core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- 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(vo /* 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 devic return size; get_online_cpus(); + + ret = check_online_cpus(); + if (ret) + goto put; + mutex_lock(µcode_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 devic microcode_check(); mutex_unlock(µcode_mutex); + +put: put_online_cpus(); if (!ret)