Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3547541pxb; Mon, 16 Nov 2020 18:43:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdMwSMN0fHVaRE19iSm1FcgURrgeykb8GTguHXKm2jbEM1jLJCSdsJI41T3/Yum4RU/DVt X-Received: by 2002:a17:906:7f10:: with SMTP id d16mr17127701ejr.104.1605580983862; Mon, 16 Nov 2020 18:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605580983; cv=none; d=google.com; s=arc-20160816; b=nn+xGVqsgdJDVlSQze7E7v0w5BsufY577vzzouX7M6LgZOq+cs0pXkiGsDDaT1zGdA lgpEfIJdR8EmJZqNIsp/4zoanvfW2WuEZSSlKWlZKlnbMlD+0UJg0NQzo+NtuPa5+BWL FDL6SJ5nPG6b19tC1PVNArvKRj1Jxs+1Rdbr5GxcMooF5W5LTF7wk9EphgGjT3Ge4P6s 3qnjozRdA5Cccm7BiKOSwSqin9/DFHcBCQI47Ht1U6vRAwYIJRCj+dqODVlE4zneuhdo HZZ6tKluK6ok59mhmCCTcv1Qf5iaxbLgI+gFTlN92HmQoEoG2DM7alodyGmJhwNENj/b A6hw== 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=ZP1J5bEaFXoXYrDOD52I2MjktIkrP3YEQZHwsLuGsnk=; b=RpZ86lZ5CfCVLEF6c0K283QhDwaUooGNqG+mPzGexmwO43Oc6r/cf/ZoPxA5+xp+9L XDZiHbF6Fq7Pe+Llv/NaHY0TOWGowCS6RkRaebjQFi8l72n+ZNLl9Y3CMra379ov0iRF I1aK6/rqFBqhOR3LMkD5lSPPBMWSNqCl3tor2KSxGSspdIbpwnULaJvCX00+q53hRaBZ UitvyxI72X04Pjc8LlXim0w7xFcmQfu5GUGV7a+C69HoKhOLqwhfkPLXNYLGYsb80cmN letKYrDC1bfA1WjwHgOX6WElvksCbZEGcsf+OjNQSs3E1Zhc6oCL4hsYNFsTs7SkL2pj EnwQ== 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 be17si8852829edb.595.2020.11.16.18.42.41; Mon, 16 Nov 2020 18:43:03 -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 S1726739AbgKQCWp (ORCPT + 99 others); Mon, 16 Nov 2020 21:22:45 -0500 Received: from mga09.intel.com ([134.134.136.24]:44728 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbgKQCWo (ORCPT ); Mon, 16 Nov 2020 21:22:44 -0500 IronPort-SDR: aMYa4t9TkdTWbGXd7AvgbW/mwohYUSBYurSRzx5g/a6dkKEyBrgp0LCRmeaNwjUaA1qz0128qC cBRI0RBfWWBg== X-IronPort-AV: E=McAfee;i="6000,8403,9807"; a="171019823" X-IronPort-AV: E=Sophos;i="5.77,484,1596524400"; d="scan'208";a="171019823" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2020 18:22:43 -0800 IronPort-SDR: rnWeFILlHT4o7cLSEHwmEZ151Cp1cb+Rfxgi1BQV1L8Jh5xPl9zo//ipZYt4ZOLU4lj2EgZFBp uc6YBs9TDGLQ== X-IronPort-AV: E=Sophos;i="5.77,484,1596524400"; d="scan'208";a="543844106" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2020 18:22:40 -0800 Date: Tue, 17 Nov 2020 10:25:18 +0800 From: Chen Yu To: Borislav Petkov Cc: Andy Lutomirski , Ashok Raj , "Hansen, Dave" , Len Brown , "Rafael J. Wysocki" , Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][v2] x86/microcode/intel: check cpu stepping and processor flag before saving microcode Message-ID: <20201117022518.GA17555@chenyu-office.sh.intel.com> 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.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris, thanks for taking a look, 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@ ) > > 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. > This patch works for me. Besides I have one question about adding the signature check in save_mc_for_early(): > --- > 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. > If I understand correctly, the only place that invokes save_mc_for_early() is in generic_load_microcode(). While in generic_load_microcode() only microcode has a newer version will be saved by checking has_newer_microcode(), and this function leverages find_matching_signature() to check if the candidate is of the same signature. So when it comes to save_microcode_patch(), the signature already matches. In case save_mc_for_early() will be invoked by other function in the future, it is okay to add this check too. thanks, Chenyu > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette