From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756714AbcBCLoP (ORCPT ); Wed, 3 Feb 2016 06:44:15 -0500 Received: from mail.skyhub.de ([78.46.96.112]:60684 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932301AbcBCLdy (ORCPT ); Wed, 3 Feb 2016 06:33:54 -0500 From: Borislav Petkov To: X86 ML Cc: LKML Subject: [PATCH 10/17] x86/microcode/intel: Move the BUG_ON up and turn it into WARN_ON Date: Wed, 3 Feb 2016 12:33:38 +0100 Message-Id: <1454499225-21544-11-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1454499225-21544-1-git-send-email-bp@alien8.de> References: <1454499225-21544-1-git-send-email-bp@alien8.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov If we're going to BUG_ON() because we're running on the wrong CPU, we better do it as the first thing we do when entering that function. And also, turn it into a WARN_ON() because it is not worth to panic the system if we apply the microcode on the wrong CPU - we're simply going to exit early. Signed-off-by: Borislav Petkov --- arch/x86/kernel/cpu/microcode/intel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index d1b2f583f543..c029c2bb2a29 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -843,12 +843,12 @@ static int apply_microcode_intel(int cpu) int cpu_num = raw_smp_processor_id(); struct cpuinfo_x86 *c = &cpu_data(cpu_num); - uci = ucode_cpu_info + cpu; - mc = uci->mc; - /* We should bind the task to the CPU */ - BUG_ON(cpu_num != cpu); + if (WARN_ON(cpu_num != cpu)) + return -1; + uci = ucode_cpu_info + cpu; + mc = uci->mc; if (!mc) return 0; -- 2.3.5