Received: by 10.223.185.116 with SMTP id b49csp1043190wrg; Wed, 21 Feb 2018 11:05:28 -0800 (PST) X-Google-Smtp-Source: AH8x227wM0mTy44iy/oE8rTuWv8c5H2Xpf33CQ1DlVkxRcKESaAgBin+w6QGNXSl6sunQWKWoBm7 X-Received: by 2002:a17:902:8b88:: with SMTP id ay8-v6mr4057691plb.197.1519239928138; Wed, 21 Feb 2018 11:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519239928; cv=none; d=google.com; s=arc-20160816; b=OtgAZHDrXZe9gI6ipGO+T7gn+yBkErL95weZqfk8LQGbTLgcuMajrWBA+oo6P2Kk5q jnAgQlduDy+JAf8jCDKn0so8fRqmo8HKdf+YfrfzJkuFRrXoBAVrg4nihXB9WVM7zeig RZlQk8fo9oI8ypDCDqKDIpCplBo8ys85hZ+thMjbEdbwqGs2XwG2yy4EFjDx7P7sse+u tLptHxLkZsLdIf8Qe6ZllqRt1kM+ZM7XnVJNIdITzypRxIbWQpA8Ay2cBzU+Rg4AARGg EimRuWeUtTJJhuZqo4Qe/mgxz1kFms4jANuD4r8WNYfe+gdACUtoKMm45zuW7mjRgNUH mFWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7D0kdbAbYRFKQxQZWOmWPCzQB9h3o2SQiB2Wf7z4LTs=; b=sZ1dE3Xnu2CdEkW/GIFNYgNoOyUDcKLK8ZWuEOjjZsoTLFCiKGPwUV6WqqeDOisaUZ AtVF0P4x96omvdyjIVyWG9SIi89NJfkuo8qynXVQOSOmDcYehwfhczRJUILa6gHIRbK0 QGevhtIaJg++LpteYR205QhNQK/XZWvmRcMRqYdJGIXQN4Hf7/DueJAq34YfqyiM5v3C dmqUN5UkZmDTnKl0Dawn0pc0hX11pY864TnEwkzhCgp8XRiU1QWbFD4rhwNXed2fhdXw LHDT9a9ZCFm7cSh+NBbIX6MAhxHIMM8K+tUaoP+O8zOxQGP1W2cieavnN3ISRdSini+v V/Kw== 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 f127si834574pgc.49.2018.02.21.11.05.14; Wed, 21 Feb 2018 11:05:28 -0800 (PST) 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 S937643AbeBUQt6 (ORCPT + 99 others); Wed, 21 Feb 2018 11:49:58 -0500 Received: from mga11.intel.com ([192.55.52.93]:35006 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932778AbeBUQtz (ORCPT ); Wed, 21 Feb 2018 11:49:55 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2018 08:49:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,545,1511856000"; d="scan'208";a="20034209" Received: from otc-nc-03.jf.intel.com ([10.54.39.38]) by orsmga006.jf.intel.com with ESMTP; 21 Feb 2018 08:49:54 -0800 From: Ashok Raj To: bp@suse.de Cc: Ashok Raj , X86 ML , LKML , Thomas Gleixner , Ingo Molnar , Tony Luck , Andi Kleen , Tom Lendacky , Arjan Van De Ven Subject: [PATCH 1/3] x86/microcode/intel: Check microcode revision before updating sibling threads Date: Wed, 21 Feb 2018 08:49:42 -0800 Message-Id: <1519231784-9941-2-git-send-email-ashok.raj@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519231784-9941-1-git-send-email-ashok.raj@intel.com> References: <1519231784-9941-1-git-send-email-ashok.raj@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After updating microcode on one of the threads in the core, the thread sibling automatically gets the update since the microcode resources are shared. Check the ucode revision on the CPU before performing a ucode update. Signed-off-by: Ashok Raj Cc: X86 ML Cc: LKML Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Tony Luck Cc: Andi Kleen Cc: Tom Lendacky Cc: Arjan Van De Ven Updates: v2: Address Boris's to cleanup apply_microcode_intel v3: Fixups per Ingo: Spell Checks --- arch/x86/kernel/cpu/microcode/intel.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 09b95a7..eff80df 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -776,7 +776,7 @@ static enum ucode_state apply_microcode_intel(int cpu) { struct microcode_intel *mc; struct ucode_cpu_info *uci; - struct cpuinfo_x86 *c; + struct cpuinfo_x86 *c = &cpu_data(cpu); static int prev_rev; u32 rev; @@ -793,6 +793,18 @@ static enum ucode_state apply_microcode_intel(int cpu) return UCODE_NFOUND; } + rev = intel_get_microcode_revision(); + /* + * Its possible the microcode got updated + * because its sibling update was done earlier. + * Skip the update in that case. + */ + if (rev >= mc->hdr.rev) { + uci->cpu_sig.rev = rev; + c->microcode = rev; + return UCODE_OK; + } + /* write microcode via MSR 0x79 */ wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); @@ -813,8 +825,6 @@ static enum ucode_state apply_microcode_intel(int cpu) prev_rev = rev; } - c = &cpu_data(cpu); - uci->cpu_sig.rev = rev; c->microcode = rev; -- 2.7.4