From nobody Mon Feb 9 13:59:04 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1566177764; cv=none; d=zoho.com; s=zohoarc; b=ki1uNDFB7jqmJhX9OhZZQu1ovSUUyt6r86ByPd6042Cp9cXb+qf1T/FyC4CexbJgEfgNPT4fXBtmgc0Zji0K28ZzRX+E9k7G0PEeV/Qss9w/hXUdsJm0GNAw9EHTs02DRje3StJy1TPS6VtPjknM+vv0H0xIMBtBrpBJ3RL+ZgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566177764; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XPVnPVwzqNZNFBLbajN1/dy27YIOXivCv+ExgUckJMc=; b=Xs+GThqgfTF7CUpJRiL+PPH96JNSZ3Hbk/4EbmfdNKkLkpOX49sXTS0n0TRg8WoMeIuVNlkKNnk7ZvPjCaBdXhI9NFRLpHKF1sES+KQYal0BQIFibdqJrXlMhfVyxkftXor7TFH+ulklbMyhDi0IODwOkfC1PE9wBivqvaZMAmw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1566177764644196.38746932529966; Sun, 18 Aug 2019 18:22:44 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzWMa-000145-Ef; Mon, 19 Aug 2019 01:21:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzWMY-00013u-P9 for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 01:21:34 +0000 Received: from mga03.intel.com (unknown [134.134.136.65]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id aeb07cac-c21f-11e9-8be3-12813bfff9fa; Mon, 19 Aug 2019 01:21:34 +0000 (UTC) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Aug 2019 18:21:34 -0700 Received: from gao-cwp.sh.intel.com ([10.239.159.26]) by orsmga001.jf.intel.com with ESMTP; 18 Aug 2019 18:21:32 -0700 X-Inumbo-ID: aeb07cac-c21f-11e9-8be3-12813bfff9fa X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,403,1559545200"; d="scan'208";a="261683854" From: Chao Gao To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 09:25:16 +0800 Message-Id: <1566177928-19114-4-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566177928-19114-1-git-send-email-chao.gao@intel.com> References: <1566177928-19114-1-git-send-email-chao.gao@intel.com> Subject: [Xen-devel] [PATCH v9 03/15] microcode/amd: distinguish old and mismatched ucode in microcode_fits() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ashok Raj , Wei Liu , Andrew Cooper , Jan Beulich , Chao Gao , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Sometimes, an ucode with a level lower than or equal to current CPU's patch level is useful. For example, to work around a broken bios which only loads ucode for BSP, when BSP parses an ucode blob during bootup, it is better to save an ucode with lower or equal level for APs No functional change is made in this patch. But following patch would handle "old ucode" and "mismatched ucode" separately. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v8: - new --- xen/arch/x86/microcode_amd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode_amd.c index 3069784..3db3555 100644 --- a/xen/arch/x86/microcode_amd.c +++ b/xen/arch/x86/microcode_amd.c @@ -152,8 +152,8 @@ static bool_t find_equiv_cpu_id(const struct equiv_cpu_= entry *equiv_cpu_table, return 0; } =20 -static bool_t microcode_fits(const struct microcode_amd *mc_amd, - unsigned int cpu) +static enum microcode_match_result microcode_fits( + const struct microcode_amd *mc_amd, unsigned int cpu) { struct ucode_cpu_info *uci =3D &per_cpu(ucode_cpu_info, cpu); const struct microcode_header_amd *mc_header =3D mc_amd->mpb; @@ -167,27 +167,27 @@ static bool_t microcode_fits(const struct microcode_a= md *mc_amd, current_cpu_id =3D cpuid_eax(0x00000001); =20 if ( !find_equiv_cpu_id(equiv_cpu_table, current_cpu_id, &equiv_cpu_id= ) ) - return 0; + return MIS_UCODE; =20 if ( (mc_header->processor_rev_id) !=3D equiv_cpu_id ) - return 0; + return MIS_UCODE; =20 if ( !verify_patch_size(mc_amd->mpb_size) ) { pr_debug("microcode: patch size mismatch\n"); - return 0; + return MIS_UCODE; } =20 if ( mc_header->patch_id <=3D uci->cpu_sig.rev ) { pr_debug("microcode: patch is already at required level or greater= .\n"); - return 0; + return OLD_UCODE; } =20 pr_debug("microcode: CPU%d found a matching microcode update with vers= ion %#x (current=3D%#x)\n", cpu, mc_header->patch_id, uci->cpu_sig.rev); =20 - return 1; + return NEW_UCODE; } =20 static int apply_microcode(unsigned int cpu) @@ -496,7 +496,7 @@ static int cpu_request_microcode(unsigned int cpu, cons= t void *buf, while ( (error =3D get_ucode_from_buffer_amd(mc_amd, buf, bufsize, &offset)) =3D=3D 0 ) { - if ( microcode_fits(mc_amd, cpu) ) + if ( microcode_fits(mc_amd, cpu) =3D=3D NEW_UCODE ) { error =3D apply_microcode(cpu); if ( error ) @@ -576,7 +576,7 @@ static int microcode_resume_match(unsigned int cpu, con= st void *mc) struct microcode_amd *mc_amd =3D uci->mc.mc_amd; const struct microcode_amd *src =3D mc; =20 - if ( !microcode_fits(src, cpu) ) + if ( microcode_fits(src, cpu) !=3D NEW_UCODE ) return 0; =20 if ( src !=3D mc_amd ) --=20 1.8.3.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel