Received: by 10.223.185.116 with SMTP id b49csp1829035wrg; Thu, 22 Feb 2018 03:57:22 -0800 (PST) X-Google-Smtp-Source: AH8x2260D+vQNqJcL1CdN95v3Gh0MnojSd325Az7L5+sioDhdycMOC4+9Nk9ZX9aq8Qtv6Slt4PG X-Received: by 10.99.160.80 with SMTP id u16mr5392006pgn.389.1519300642204; Thu, 22 Feb 2018 03:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519300642; cv=none; d=google.com; s=arc-20160816; b=aWVFDnNaWg3fS3ZCtSAxgRnSx4cJ0U1dGflG8ahCWuV/LN3Gfj4CtAmzt1rSGxMDNO 86mrD1sLbpy9JP8IMGCGn22L7k5bN9D79gVXTtjvoDY1LNKh5kZh4EYr/eFH0Yn+mEj4 pLwHjvmRR7qCrjSrcH+aQxjouqnYULa0OiSnM5vwCpjnS8d809ZTMjH0e4GaESpYKIk1 GV/cIAf6ICYInr2zhC15uZ6+3yg/0NpaBcaAnmVXF0/VsHEQWqnfRh6WJK3it3XnlrKQ SUmt7hSBWMI4Tu9iUnpg9fhKLkmzEQgPn2tx5tZI4UgBW3vDkH0AjJ/yS3QJLCjpRSS7 0kHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=QP+Wm9QjiAIJKL8aYeru5mejFnJCpksWY5MMoIZGM3s=; b=Sql/hKsJVtdzY6hcrviIyRDFMOWYeYPCnhv5c+XygTLRwX4BBec7rcNj6ko05mLGbB Q2KKvOpokBjwE5bQEPpFq3lSvUl32RJFj+1CyRNefWuoOuRbIDm94ZViohv2xGqd4qLO LLMCMVDuJ6S5j5ePNc+4DXfGoMc+e3HBak3lYMuL3Jsz1FGZtgUE5GIH69GsctXi9TOc 5PDNrbiGZN0jKfjVXWKm5vsqMj5ATk0rHh+uo46/9jryjLD7FRZYdMZHbUeWsGvf1agW 2J8jXa3F+Lqq6VusANwrMtNLN09XWJ6Ru5IvRPnfjqknPNhKDr/HNhtGX4YOc5N6HEeZ uRGw== 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 b8si8088737pgt.383.2018.02.22.03.57.07; Thu, 22 Feb 2018 03:57:22 -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 S932149AbeBVLz5 (ORCPT + 99 others); Thu, 22 Feb 2018 06:55:57 -0500 Received: from mga18.intel.com ([134.134.136.126]:6880 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932073AbeBVLz4 (ORCPT ); Thu, 22 Feb 2018 06:55:56 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Feb 2018 03:55:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,377,1515484800"; d="scan'208";a="20246429" Received: from araj-mobl1.jf.intel.com ([10.254.107.230]) by orsmga006.jf.intel.com with ESMTP; 22 Feb 2018 03:55:54 -0800 Date: Thu, 22 Feb 2018 03:55:54 -0800 From: "Raj, Ashok" To: Borislav Petkov Cc: X86 ML , LKML , Thomas Gleixner , Ingo Molnar , Tony Luck , Andi Kleen , Tom Lendacky , Arjan Van De Ven , Ashok Raj Subject: Re: [v2 1/3] x86/microcode/intel: Check microcode revision before updating sibling threads Message-ID: <20180222115554.GA3797@araj-mobl1.jf.intel.com> References: <1519281205-58951-1-git-send-email-ashok.raj@intel.com> <1519281205-58951-2-git-send-email-ashok.raj@intel.com> <20180222110056.GA27489@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180222110056.GA27489@pd.tnic> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 22, 2018 at 12:00:57PM +0100, Borislav Petkov wrote: > > > > Updates: > > v2: Address Boris's to cleanup apply_microcode_intel > > v3: Fixups per Ingo: Spell Checks > > That changelog... > > > --- > > ... comes under this line so that it can be ignored by tools. Oops! using stg, and try to not remember too many things and write it up here. Will remember to move things next time around. > > > arch/x86/kernel/cpu/microcode/intel.c | 28 +++++++++++++++++++++++++--- > > 1 file changed, 25 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c > > index 09b95a7..137c9f5 100644 > > --- a/arch/x86/kernel/cpu/microcode/intel.c > > +++ b/arch/x86/kernel/cpu/microcode/intel.c > > @@ -589,6 +589,18 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) > > if (!mc) > > return 0; > > > > + rev = intel_get_microcode_revision(); > > Ok, so I'm still wondering what this patch is trying to achieve. > > intel_get_microcode_revision() does already *two* MSR reads and a CPUID. > So it is not speed improvements - it actually makes loading slower due to that > checking. Not a speed improvement.. Hopefully i didn't mislead somewhere :-( > > So why are we doing this again? When you have two HT threads of the same core. Updating microcode on one of the threads is just good enough. The recommendation for HT siblings is as follows. Core C0 has two threads C0T0, and C0T1 - Not to simultaneously load microcode on both threads. - (NEW) not to perform ucode load when the other HT thread is active. Its safe to spin on a cached variable (like what the patch3 is trying to achieve) The current code wasn't trying to enforce checking the loaded microcode revision on a thread before attempting to load the microcode. While you comeback from resume, if C0T0 already is up, and we loaded the early microcode, then when handling C0T1 there is no need to do a wrmsrl to reapply microcode since its already loaded as part of C0T0. This way we don't need any quiese of C0T0 while bringing up C0T1. We need to skip the loading process avoid doing the ucode load in this case. Hope this helps.. and if you need this as part of the file/commit log, we should add that. 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;<----- Maybe we can avoid this in early load? return UCODE_OK; } /* * Microcode updates can be safer if the caches are clean. * Some of the issues around in certain Broadwell parts * can be addressed by doing a full cache flush. */ native_wbinvd(); /* write microcode via MSR 0x79 */ native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits);