Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3436428pxb; Mon, 16 Nov 2020 14:54:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWGKVfs0FYXTxBG8qFwzNqGQsjD5GOHWdaQI/1Ut4978SedxB7SdOC9tthlnUcSo+1zbNp X-Received: by 2002:a17:906:f247:: with SMTP id gy7mr16861369ejb.48.1605567247652; Mon, 16 Nov 2020 14:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605567247; cv=none; d=google.com; s=arc-20160816; b=qThVtd4eY65ZXLfKZjcooEUfL79geaG5Oh2V7SscgzAMqiGpmjcuRajQ/Eukt6s/9w siRIytEoulIb/TixC72142DPh1+bYxPW/RnlbJAyRCLmTqg4t/zZwZ/Gg4TmuzIKHakL P2Zz8CVfkLItJHm4bDre+4xTd/CoOvVBFSPFa1CUbbASBLqZXXdAEQ0685vWHf9bey8n jihrot3SOlYo3YpOq0VvbZnO7xE0LpA2sYtl7M+EKH3fxbdmEijnUWYGv4ShGbJ/HORC qZI0G+kKC+N53xqucfSKU7AZmJB6v6qH58Ehk0Ezmu+NL1iDSzYtvvkqdbrnc0CiasWU Ungw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=gM6RMCFatnTy3i+AJeQJLibC5NQkldo+5AGhunp0Wtg=; b=MC22Udlgc5t5Bqcfj5zu+/7jx8Dtm4XVO3vWHRQHfBkJxiBWrIhJkQ795t2y9rQBDo cvqomzvHq1L8mZJ1OgQ95T0M/KL3WgUkV06yZZiCoMMGBswULjD18qpYsLDe9QBGLVzv LNXzlIbSVwTHg1HjHRXg/m+kf051zJ5con9SSVGgNDlfLVbDfnTfmAmKkk6Sfh4D/LqH QmJgvf+GZzttEUolssMU+RoOB3D0io6AfMGVsdnZrTwQf0qaBeSMVVcLNBtxJWN2URca q6NyssoNNukoTXidVatTzADTpHn+ppkdp6o4lkrJnwyS3iDST+Cj3qvS58mgYCyFsCBf Uohw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr7si13441011ejb.592.2020.11.16.14.53.45; Mon, 16 Nov 2020 14:54:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729153AbgKPVag (ORCPT + 99 others); Mon, 16 Nov 2020 16:30:36 -0500 Received: from mga18.intel.com ([134.134.136.126]:60550 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbgKPVag (ORCPT ); Mon, 16 Nov 2020 16:30:36 -0500 IronPort-SDR: fbzVzJPh71d24eMHaY6krkcgoV5kxc2154mao955jsNNq1QY/gVe45gpmCiuPcEbw4kkrgzYGL o5EN/mjgPsDA== X-IronPort-AV: E=McAfee;i="6000,8403,9807"; a="158594019" X-IronPort-AV: E=Sophos;i="5.77,483,1596524400"; d="scan'208";a="158594019" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2020 13:30:21 -0800 IronPort-SDR: nYvSDaJbDRJyoLEJ6aQ61vfzzlpFBHHD4PSUhCZg66AKhOnVsH+pggjhEXWSmrEHKXizkel/rk u8U1GBMTtTqw== X-IronPort-AV: E=Sophos;i="5.77,483,1596524400"; d="scan'208";a="543755912" Received: from otc-nc-03.jf.intel.com (HELO otc-nc-03) ([10.54.39.36]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2020 13:30:21 -0800 Date: Mon, 16 Nov 2020 13:30:19 -0800 From: "Raj, Ashok" To: Borislav Petkov Cc: Chen Yu , Andy Lutomirski , "Hansen, Dave" , Len Brown , "Rafael J. Wysocki" , Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org, Ashok Raj Subject: Re: [PATCH][v2] x86/microcode/intel: check cpu stepping and processor flag before saving microcode Message-ID: <20201116213019.GB76389@otc-nc-03> References: <20201113015923.13960-1-yu.c.chen@intel.com> <20201116122735.GA1131@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201116122735.GA1131@zn.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris On Mon, Nov 16, 2020 at 01:27:35PM +0100, Borislav Petkov wrote: > ( drop stable@ from Cc because this is not how fixes get added to stable@ ) Stable is still left below. with #v4.10+ Do you want to keep this? Also do you want him to resend or you have that covered? > > On Fri, Nov 13, 2020 at 09:59:23AM +0800, Chen Yu wrote: > > Currently scan_microcode() leverages microcode_matches() to check if the > > microcode matches the CPU by comparing the family and model. However before > > saving the microcode in scan_microcode(), the processor stepping and flag > > of the microcode signature should also be considered in order to avoid > > incompatible update and caused the failure of microcode update. > > This is going in the right direction but needs to take care of one > more angle. I've extended your fix to the version below. Lemme know if > something's not clear or still missing. > Seems clear to me, and the commit log cleanup also makes sense. I don't have a system myself,. Will wait for Chen Yu to confirm if it works for him as well. > Thx. > > --- > From: Chen Yu > Date: Fri, 13 Nov 2020 09:59:23 +0800 > Subject: [PATCH] x86/microcode/intel: Check patch signature before saving microcode for early loading > > Currently, scan_microcode() leverages microcode_matches() to check > if the microcode matches the CPU by comparing the family and model. > However, the processor stepping and flags of the microcode signature > should also be considered when saving a microcode patch for early > update. > > Use find_matching_signature() in scan_microcode() and get rid of the > now-unused microcode_matches() which is a good cleanup in itself. > > Complete the verification of the patch being saved for early loading in > save_microcode_patch() directly. This needs to be done there too because > save_mc_for_early() will call save_microcode_patch() too. > > The second reason why this needs to be done is because the loader still > tries to support, at least hypothetically, mixed-steppings systems and > thus adds all patches to the cache that belong to the same CPU model > albeit with different steppings. > > For example: > > microcode: CPU: sig=0x906ec, pf=0x2, rev=0xd6 > microcode: mc_saved[0]: sig=0x906e9, pf=0x2a, rev=0xd6, total size=0x19400, date = 2020-04-23 > microcode: mc_saved[1]: sig=0x906ea, pf=0x22, rev=0xd6, total size=0x19000, date = 2020-04-27 > microcode: mc_saved[2]: sig=0x906eb, pf=0x2, rev=0xd6, total size=0x19400, date = 2020-04-23 > microcode: mc_saved[3]: sig=0x906ec, pf=0x22, rev=0xd6, total size=0x19000, date = 2020-04-27 > microcode: mc_saved[4]: sig=0x906ed, pf=0x22, rev=0xd6, total size=0x19400, date = 2020-04-23 > > The patch which is being saved for early loading, however, can only be > the one which fits the CPU this runs on so do the signature verification > before saving. > > [ bp: Do signature verification in save_microcode_patch() > and rewrite commit message. ] > > Fixes: 06b8534cb728 ("x86/microcode: Rework microcode loading") > Signed-off-by: Chen Yu > Signed-off-by: Borislav Petkov > Cc: stable@vger.kernel.org #v4.10+ > Link: https://bugzilla.kernel.org/show_bug.cgi?id=208535 > Link: https://lkml.kernel.org/r/20201113015923.13960-1-yu.c.chen@intel.com > --- > arch/x86/kernel/cpu/microcode/intel.c | 63 +++++---------------------- > 1 file changed, 10 insertions(+), 53 deletions(-)