From nobody Sat May 4 15:59:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1585822796; cv=none; d=zohomail.com; s=zohoarc; b=VpIUgMVrctriQ+Ax4B3HSc2PiMlR3LrQKwbLdYyVPskSVMFvxstw96sB4iAvJ/939qKtPRqpOwxiQ/0+EoRipqICWnBK2236+Z3W9C8st6dpqq9cDEky2rYF4sZBzQBSxB5sGkJuyh8tot+MDI6hL042S0/v0QOVoBQ8YUge39o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585822796; 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; bh=K8ti0r09GVSCKZFDZ/Ix37Rfj7fm15fSQMtHvyNNAXA=; b=ZROsW5TVW45GCO1nxtGCMcx4Tx3VDJKo+rMVl8crd1lelphV5m2Jj5dsnN9hDIg7SOty62I3FpTmfGAw0GjazWjcvQBRZ8KFsY6z2cohdUMz+wlnqI+YbhbKYVdDJqIEizNxt1l5gbxdqRI6IHDNVeFpgw0sBr+tSdleOzhRijY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 158582279633480.43920590124492; Thu, 2 Apr 2020 03:19:56 -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 1jJwwL-0000nh-2h; Thu, 02 Apr 2020 10:19:13 +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 1jJwwJ-0000nc-Ez for xen-devel@lists.xenproject.org; Thu, 02 Apr 2020 10:19:11 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 646c96db-74cb-11ea-bba1-12813bfff9fa; Thu, 02 Apr 2020 10:19:10 +0000 (UTC) X-Inumbo-ID: 646c96db-74cb-11ea-bba1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1585822750; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3/YZSxwxJdT+2zm3hr8RD7262jgsENAYDbS1h2PY7l0=; b=LTTM59bS/ZAVBJaqAjqKzT0aGstBFVXVbfOIjWgwgKrn/c3Q1ybNB6uM XnqxAcMiO+8mIPXWPktkg9muDqLwNjIivcpVXFneJFrvHVvOzFA5EQln5 9opwhr2oaH4uAp40kefI76QGTgVmacB1OWUOqnCZqiU5zSA/ilHb8CuQT w=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Be+7e6xH7LJDnmNx+3cTRqTen6+RPZZZf2wUTt6utz+BsHDh1oMTxEO6hzSNZzZvVLthMmJ30t o8+r8BMDuz7Z0Bb3VaiRIhUDOEP6aas/DkNnSNq8xsM7lrPzk4motAvN15jFopO4JusUc6nq1w uFCZPy3/cj0IQYGWIG+KlGIAkB7eGV9Dmx+MAzRLLhYRkxB487aSTF73fsMFqgx+6uO2RFSODE kXwBrDfw+v3sHnC9JQs6J/vwrrd6bLfjnJiytxEQFfcuGt+kun65X8FBoiJjHjX7GCt8lAD9pk gdM= X-SBRS: 2.7 X-MesageID: 15715926 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,335,1580792400"; d="scan'208";a="15715926" From: Andrew Cooper To: Xen-devel Subject: [PATCH 1/5] x86/ucode/intel: Remove CPUID from collect_cpu_info() Date: Thu, 2 Apr 2020 11:18:58 +0100 Message-ID: <20200402101902.28234-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200402101902.28234-1-andrew.cooper3@citrix.com> References: <20200402101902.28234-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The CPUID instruction is expensive. No point executing it twice when once will do fine. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/intel.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 72bd1ad0bc..f1e64e188b 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -121,14 +121,12 @@ static int collect_cpu_info(struct cpu_signature *csi= g) =20 memset(csig, 0, sizeof(*csig)); =20 - csig->sig =3D cpuid_eax(0x00000001); - rdmsrl(MSR_IA32_PLATFORM_ID, msr_content); csig->pf =3D 1 << ((msr_content >> 50) & 7); =20 wrmsrl(MSR_IA32_UCODE_REV, 0x0ULL); /* As documented in the SDM: Do a CPUID 1 here */ - cpuid_eax(1); + csig->sig =3D cpuid_eax(1); =20 /* get the current revision from MSR 0x8B */ rdmsrl(MSR_IA32_UCODE_REV, msr_content); --=20 2.11.0 From nobody Sat May 4 15:59:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1585822817; cv=none; d=zohomail.com; s=zohoarc; b=T7mKzYpyWN7QcnTUr2J/JN86ZS7j0fMd21Qi6iECa3rwznEd2txf/AJn0tlAMEVztOYoUjhJRn4kOP/qy9ZZdE79H1vtgt+grxOcMSQRGLBwwnP61gyEi1g0uK40VCmsKkBl1Z0rhVzSYBUC8g75GaYX/MdaBBaSPy0PspgqiKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585822817; 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; bh=5dtRGw3vTQsWXIAkI5VZpYae/MYY4tiLqRIbnQRDzko=; b=NpB54pT+uDpZ5k+8tPz90ezj20fh/TZCy8SUA1ep5bLH9esh05Y+TwKpIjxJULZzEBjpTHmK/Zws8vZ1GGG8BTv2rHtGCO6ioXbIgWtnQgm6R8BPTKlduNjIbjINXMq746PfEcIkCGjVOLzWg5VgZvXheFJixdaQxkFqdnR/w+k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 158582281746675.41854912307838; Thu, 2 Apr 2020 03:20:17 -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 1jJwwQ-0000oi-Bc; Thu, 02 Apr 2020 10:19:18 +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 1jJwwO-0000o3-DI for xen-devel@lists.xenproject.org; Thu, 02 Apr 2020 10:19:16 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 646c96dd-74cb-11ea-bba1-12813bfff9fa; Thu, 02 Apr 2020 10:19:11 +0000 (UTC) X-Inumbo-ID: 646c96dd-74cb-11ea-bba1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1585822751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Vam1QDmFn+vR0pBcHWu9YCMoeDedFnU5geNICv7MFCk=; b=fkiDtj+pCszF+ZpbwEYQkTSxTRBAyJo7vaGQQMLMKsabyvbIixL0ZuQ/ b7kSnYKODe5u7VZAkttV6CvMZUuPHT2OJD4sapK/godl6DAepHLXy20HP NTe8z2oy45ox9k50jmU/+LomTxGJ6XPh01VC+PPnS8ftYPqRfzI5Mftro 0=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 4PMnMFrvIGSYNQy/QsMzNhJ081TJtVr/ARxMVeRoI0wOaQknR8RRqnlfb3WSkXLIdVpDjPu6t9 M7a+d4Gf6UmXaCrSD1IcUV1qnIGANOsdxTHIjng8bhcDpJfw2ulRhg55bAUyL1Hvt1Vc7lFlIg 0IxciUbZV9fqx2LVBSKvjzfDAypY92Hqd1fFV54Hb7efOo1TQ/aDGKHQvPuQCXS1m2P+XFL7Oy vaLhBYI9jKAkEZTrJ9QI5tsIhlILE3gDcFpDELyc19QwrZIjBb8vpgeXY+eJQ3OK698HGe8R70 eNI= X-SBRS: 2.7 X-MesageID: 15380674 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,335,1580792400"; d="scan'208";a="15380674" From: Andrew Cooper To: Xen-devel Subject: [PATCH 2/5] x86/ucode: Drop ops->match_cpu() Date: Thu, 2 Apr 2020 11:18:59 +0100 Message-ID: <20200402101902.28234-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200402101902.28234-1-andrew.cooper3@citrix.com> References: <20200402101902.28234-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) It turns out there are no callers of the hook(). The only callers are the local, which can easily be rearranged to use the appropriate internal helpe= r. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 8 +------- xen/arch/x86/cpu/microcode/intel.c | 11 +---------- xen/arch/x86/cpu/microcode/private.h | 6 ------ 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index d4763ea776..c9656de55d 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -188,11 +188,6 @@ static enum microcode_match_result microcode_fits( return NEW_UCODE; } =20 -static bool match_cpu(const struct microcode_patch *patch) -{ - return patch && (microcode_fits(patch) =3D=3D NEW_UCODE); -} - static void free_patch(struct microcode_patch *patch) { xfree(patch); @@ -227,7 +222,7 @@ static int apply_microcode(const struct microcode_patch= *patch) if ( !patch ) return -ENOENT; =20 - if ( !match_cpu(patch) ) + if ( microcode_fits(patch) !=3D NEW_UCODE ) return -EINVAL; =20 if ( check_final_patch_levels(sig) ) @@ -428,5 +423,4 @@ const struct microcode_ops amd_ucode_ops =3D { #endif .free_patch =3D free_patch, .compare_patch =3D compare_patch, - .match_cpu =3D match_cpu, }; diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index f1e64e188b..315fca9ff2 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -245,14 +245,6 @@ static enum microcode_match_result microcode_update_ma= tch( return mc->rev > cpu_sig->rev ? NEW_UCODE : OLD_UCODE; } =20 -static bool match_cpu(const struct microcode_patch *patch) -{ - if ( !patch ) - return false; - - return microcode_update_match(patch) =3D=3D NEW_UCODE; -} - static void free_patch(struct microcode_patch *patch) { xfree(patch); @@ -281,7 +273,7 @@ static int apply_microcode(const struct microcode_patch= *patch) if ( !patch ) return -ENOENT; =20 - if ( !match_cpu(patch) ) + if ( microcode_update_match(patch) !=3D NEW_UCODE ) return -EINVAL; =20 /* write microcode via MSR 0x79 */ @@ -369,5 +361,4 @@ const struct microcode_ops intel_ucode_ops =3D { .apply_microcode =3D apply_microcode, .free_patch =3D free_patch, .compare_patch =3D compare_patch, - .match_cpu =3D match_cpu, }; diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index df0d0852cd..d31bcf14b1 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -60,12 +60,6 @@ struct microcode_ops { void (*free_patch)(struct microcode_patch *patch); =20 /* - * Is the microcode patch applicable for the current CPU, and newer th= an - * the currently running patch? - */ - bool (*match_cpu)(const struct microcode_patch *patch); - - /* * Given two patches, are they both applicable to the current CPU, and= is * new a higher revision than old? */ --=20 2.11.0 From nobody Sat May 4 15:59:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1585822814; cv=none; d=zohomail.com; s=zohoarc; b=lED6cy4EynQMvHJf/g3I+cnD9e/nUV/KT6Y3wq68CC6mtP6GnhZ42bRw/OM+cej0eH4JSVJlV3/VscDn6rTPIMm8IwbU9t+UVjeCBIAQoCWclNgF1jRbfaG+29QYHcXXg7GdtnT6H1DE5/PNv5MRJJ/VKMB6MXIGNrrLlQZG1OE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585822814; 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; bh=9UrlmpnfYoYv1PK1i/VHFTWY7W47uxgmKPGvTkFEyqk=; b=iL7Wwu+sNPovBQkSNH/x+Pa8pS5bcu7N6tEVrC86NwUpYvCVGFm5c71sy/PUKOXcYEQBxdQ9ogU6byTnx3Qx7NcYbID1HhZxosy3EQgWsqWOpLvj07GCCBoqdm7cKXOr39o/PXm5zPYOlBcvoZ6H1ldcStWC4IXKhq+yxEX8d9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 158582281463641.51576402242438; Thu, 2 Apr 2020 03:20:14 -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 1jJwwU-0000qG-Um; Thu, 02 Apr 2020 10:19:22 +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 1jJwwT-0000pm-DZ for xen-devel@lists.xenproject.org; Thu, 02 Apr 2020 10:19:21 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 65c20cf4-74cb-11ea-bba1-12813bfff9fa; Thu, 02 Apr 2020 10:19:12 +0000 (UTC) X-Inumbo-ID: 65c20cf4-74cb-11ea-bba1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1585822752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6rwZacdltItl9czt/IkZJAdDx3fDf89O2zoFUkCWxII=; b=DKuLQ31n4nvhglfk0XMdRtCLNKk0YguB2HElxGt3ggmJQeF9Odffh3v5 livHxNq7MkopCdbCaJMatxuD1iuM2OZTBkwUf8ifymEH5X7CNlEABylLu rowdankaB/H0GK/wqRsSeqoD0o5RNsiphDbjILXdBO/mb0xx0RtvvVFWC c=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 70Hu1c/V3Xo4KeglIpiHkC8ugzcgbwS4wwpPLpvGWqiMgO3cCdF5MPFMqKNra51MkBgKQaGzDE GQTm51Y1vqiZbkBhn92eiZ7f4Iq2lcbOSQKJz7219QNpMUpDbyfe8w8EzSvEc4kn6YrEMGmfDv miWv7fcjcBSnPsyQ+Q+iJVB32l2aIr3JGmuEmuBR6dJ0cCFoTZawP905WCU/MXqHaWll0tMvPw zAG1ZnhSfQShb9Qzfe0sX6IY73GaDLWdPyyRjYaOg7ee4+GNzEjb3Wo/T0lp7F5Pcfi0a7LqRh YCw= X-SBRS: 2.7 X-MesageID: 15380676 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,335,1580792400"; d="scan'208";a="15380676" From: Andrew Cooper To: Xen-devel Subject: [PATCH 3/5] x86/ucode: Don't try to cope with NULL pointers in apply_microcode() Date: Thu, 2 Apr 2020 11:19:00 +0100 Message-ID: <20200402101902.28234-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200402101902.28234-1-andrew.cooper3@citrix.com> References: <20200402101902.28234-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) No paths to apply_microcode() pass a NULL pointer, and other hooks don't tolerate one in the first place. We can expect the core logic not to pass = us junk, so drop the checks. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 3 --- xen/arch/x86/cpu/microcode/intel.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index c9656de55d..0ca0e9a038 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -219,9 +219,6 @@ static int apply_microcode(const struct microcode_patch= *patch) struct cpu_signature *sig =3D &per_cpu(cpu_sig, cpu); uint32_t rev, old_rev =3D sig->rev; =20 - if ( !patch ) - return -ENOENT; - if ( microcode_fits(patch) !=3D NEW_UCODE ) return -EINVAL; =20 diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 315fca9ff2..9cb077b583 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -270,9 +270,6 @@ static int apply_microcode(const struct microcode_patch= *patch) struct cpu_signature *sig =3D &this_cpu(cpu_sig); uint32_t rev, old_rev =3D sig->rev; =20 - if ( !patch ) - return -ENOENT; - if ( microcode_update_match(patch) !=3D NEW_UCODE ) return -EINVAL; =20 --=20 2.11.0 From nobody Sat May 4 15:59:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1585822818; cv=none; d=zohomail.com; s=zohoarc; b=FX1uliOdx+/DCh3yRgZzq5XtLKCiILt1xGfKuLSOaMr5e/c2u4fo1qNHGXYl6Crvy+qRbgmIUFd6bI8I+Frb963sQnuW7fiqGrjA6tQh86unH4xPoLUwdTnoc/uElZOo4wz2A7AN6TiCyV+Qx059QS8hWlV0WxUA6BAlhxCeK5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585822818; 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; bh=XkShl8fUn5oaYicFzv1UJpDjIpQbyMQ8GNtUyExxbpA=; b=nrwC69qKrKrbT9QglHXbwkUUG/A6g0qzpXIWqB8p34RGG/lT2ld1j++ApYcIDTMd0ne+7i72py5CvjbY0dvCQOPxIbFUy68g6158JPkbVtFouECTSzYcYxLld4y+bCaaH64PwgLxQ3aihYT7QLuZTN1ejenplyZMl7ODIyvzzYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 158582281897919.286158990091167; Thu, 2 Apr 2020 03:20:18 -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 1jJwwZ-0000sd-DC; Thu, 02 Apr 2020 10:19:27 +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 1jJwwY-0000sH-Dm for xen-devel@lists.xenproject.org; Thu, 02 Apr 2020 10:19:26 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 66a5fd6a-74cb-11ea-bba1-12813bfff9fa; Thu, 02 Apr 2020 10:19:14 +0000 (UTC) X-Inumbo-ID: 66a5fd6a-74cb-11ea-bba1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1585822754; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AD6n+KBMI4yDtXDNza0GnMzi5v0BBwM+iL+cgl/2+J8=; b=FPgqf9REoOlZW3iJfOwKvCf8O98HDotAbKo3JERkafijXPWJB58onOIq FN8MtG/5Mm+CzWpD740ZHRQTpWfnT7Fw7+jYTMZXWYUpHS2QK+2fGT30X hEQNYePvtDOeldDa/SeHTnZaiha/sKOtbYlY676D7HFMVHTGgv9hYZJWW c=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: LXGnhvtl0LbEKYegPnMWbxg6dYtw0N7TNPt4EZQAh/8iAKR2rFHd2I9HolsRhvtgw4fZiAlj8b G+RZmsKc+Ic7TlvjWBxq55+4YggPVrv/U2+XhlIXTELmyp3c5bXsT4wuAlD3OoiwK35PtK6ahy 2d7ln0lRIwKlYKpicb7jhKCk7DfID8rC1SzfAk6H9wBp85JFAARrqFOFw7epqEXx6brU4Ie2YS 6Q85Xy72RLcXbwOXjSm28V6rgf+L7F8UWQoJ+Ve7ZmO5NH1amoe3CRHUHfZLYPo+EmHyIP7cqh 4vQ= X-SBRS: 2.7 X-MesageID: 15068042 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,335,1580792400"; d="scan'208";a="15068042" From: Andrew Cooper To: Xen-devel Subject: [PATCH 4/5] x86/ucode: Drop ops->free_patch() Date: Thu, 2 Apr 2020 11:19:01 +0100 Message-ID: <20200402101902.28234-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200402101902.28234-1-andrew.cooper3@citrix.com> References: <20200402101902.28234-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) With the newly cleaned up vendor logic, each struct microcode_patch is a trivial object in memory with no dependent allocations. This is unlikely to change moving forwards, and function pointers are expensive in the days of retpoline. Move the responsibility to xfree() back to common code. If the need does arise in the future, we can consider reintroducing the hook. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 6 ------ xen/arch/x86/cpu/microcode/core.c | 4 ++-- xen/arch/x86/cpu/microcode/intel.c | 6 ------ xen/arch/x86/cpu/microcode/private.h | 5 +---- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index 0ca0e9a038..e23bdef6f2 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -188,11 +188,6 @@ static enum microcode_match_result microcode_fits( return NEW_UCODE; } =20 -static void free_patch(struct microcode_patch *patch) -{ - xfree(patch); -} - static enum microcode_match_result compare_header( const struct microcode_patch *new, const struct microcode_patch *old) { @@ -418,6 +413,5 @@ const struct microcode_ops amd_ucode_ops =3D { .start_update =3D start_update, .end_update_percpu =3D svm_host_osvw_init, #endif - .free_patch =3D free_patch, .compare_patch =3D compare_patch, }; diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index b3e5913d49..53e447ea9a 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -243,9 +243,9 @@ static struct microcode_patch *parse_blob(const char *b= uf, size_t len) return NULL; } =20 -static void microcode_free_patch(struct microcode_patch *microcode_patch) +static void microcode_free_patch(struct microcode_patch *patch) { - microcode_ops->free_patch(microcode_patch); + xfree(patch); } =20 /* Return true if cache gets updated. Otherwise, return false */ diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 9cb077b583..29745ed55f 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -245,11 +245,6 @@ static enum microcode_match_result microcode_update_ma= tch( return mc->rev > cpu_sig->rev ? NEW_UCODE : OLD_UCODE; } =20 -static void free_patch(struct microcode_patch *patch) -{ - xfree(patch); -} - static enum microcode_match_result compare_patch( const struct microcode_patch *new, const struct microcode_patch *old) { @@ -356,6 +351,5 @@ const struct microcode_ops intel_ucode_ops =3D { .cpu_request_microcode =3D cpu_request_microcode, .collect_cpu_info =3D collect_cpu_info, .apply_microcode =3D apply_microcode, - .free_patch =3D free_patch, .compare_patch =3D compare_patch, }; diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index d31bcf14b1..878f8d805f 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -25,7 +25,7 @@ struct microcode_ops { * * If one is found, allocate and return a struct microcode_patch * encapsulating the appropriate microcode patch. Does not alias the - * original buffer. + * original buffer. Must be suitable to be freed with a single xfree(= ). * * If one is not found, (nothing matches the current CPU), return NULL. * Also may return ERR_PTR(-err), e.g. bad container, out of memory. @@ -56,9 +56,6 @@ struct microcode_ops { */ void (*end_update_percpu)(void); =20 - /* Free a patch previously allocated by cpu_request_microcode(). */ - void (*free_patch)(struct microcode_patch *patch); - /* * Given two patches, are they both applicable to the current CPU, and= is * new a higher revision than old? --=20 2.11.0 From nobody Sat May 4 15:59:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1585822801; cv=none; d=zohomail.com; s=zohoarc; b=l68WYEtPmQ9ZKGXOpj2OuCbktuf7YS+ISf/DyQ3HvBrPhf1yZEdCsJceDUiTSB8G+Ot+DRcmKoNzlcQBeUjbXrm9ExtPZ6tzlv+6LeBEgzdo89+zcBNekWkaZ92g1YNnvSWF4qtl0k2zkwju0Rs/BnUreDpyCY6c5JrU74bFQPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585822801; 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; bh=5SZNEVWz8GODJp8DQ1xr64JVMPP1YSnVtru72IoQG/U=; b=GB0V68lxulK9tHoXE1NnbxKA+4wRVYEZztU+7/Eas9j98utUKMuBCwUJuV9rfuvPy063M5KtvQWVoORE8omKn+5Zoc/7PU+vzaj+/+NuW81AEnLetOMF54eMF4+PTn/GbFwln6Plv19cvuIDd2afe/pX/+t2lPFApWLJ6hBdYsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1585822801959869.5391034519156; Thu, 2 Apr 2020 03:20:01 -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 1jJwwU-0000px-LU; Thu, 02 Apr 2020 10:19:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jJwwS-0000pc-Vn for xen-devel@lists.xenproject.org; Thu, 02 Apr 2020 10:19:21 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6a0cec34-74cb-11ea-9e09-bc764e2007e4; Thu, 02 Apr 2020 10:19:20 +0000 (UTC) X-Inumbo-ID: 6a0cec34-74cb-11ea-9e09-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1585822761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eZcKbBNzadTU2s5TsuGgFszMTPPeWk2mohwFyrTvSJM=; b=GtZaplkanE0grmFBn+4xj8xzuYu9ogeyuiEQWTzOhGumB+EDeG6D4MZp N4466XoCzuIgTroJUQmZOAwgLjJKJKKu0DHiHBroRS1TfaL7TiMHvpofk SU+jlufOls2JYcExQZ6p1AcqYL+2NkBZijbBqkBfO3d70IViOXf3fl02y 4=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: mQ5ta3syU40qCuRiz25H7IFZHcb5LaPTsLyu+OecTg5uFvaosagAGd3/k9ggn2tYW8SZcAqiXm gzXSFg7f4/7NABosLqKGIVLBZbOxWWN4kuScVVVKwFszZymiE4btkFSZ+MOj3rcGYibhLI7PBm mvEeuEAF9ilrFMhh1zvmUOxFNA5E028/P7aAuyoU2NM10l03UfNbgtvqtgvERVFaxBUklPMzZe pYDhgJgdIiqEBnG0RHgmGFtGZu4EYTHQaNCcXTcxIPEySsuDichfhSfmnrTFWbGnLkU5qdWftF TiE= X-SBRS: 2.7 X-MesageID: 15041306 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,335,1580792400"; d="scan'208";a="15041306" From: Andrew Cooper To: Xen-devel Subject: [PATCH 5/5] x86/ucode: Simplify the ops->collect_cpu_info() API Date: Thu, 2 Apr 2020 11:19:02 +0100 Message-ID: <20200402101902.28234-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200402101902.28234-1-andrew.cooper3@citrix.com> References: <20200402101902.28234-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) All callers pass &this_cpu(cpu_sig) for the cpu_sig parameter, and all implementations unconditionally return 0. Simplify it to be void. Drop the long-stale comment on the AMD side, whose counterpart in start_update() used to be "collect_cpu_info() doesn't fail so we're fine". Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 7 +++---- xen/arch/x86/cpu/microcode/core.c | 14 ++++++-------- xen/arch/x86/cpu/microcode/intel.c | 5 ++--- xen/arch/x86/cpu/microcode/private.h | 7 +++++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index e23bdef6f2..13bf9f4dee 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -90,9 +90,10 @@ static struct { uint16_t id; } equiv __read_mostly; =20 -/* See comment in start_update() for cases when this routine fails */ -static int collect_cpu_info(struct cpu_signature *csig) +static void collect_cpu_info(void) { + struct cpu_signature *csig =3D &this_cpu(cpu_sig); + memset(csig, 0, sizeof(*csig)); =20 csig->sig =3D cpuid_eax(1); @@ -100,8 +101,6 @@ static int collect_cpu_info(struct cpu_signature *csig) =20 pr_debug("microcode: CPU%d collect_cpu_info: patch_id=3D%#x\n", smp_processor_id(), csig->rev); - - return 0; } =20 static bool_t verify_patch_size(uint32_t patch_size) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 53e447ea9a..a220f908b8 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -237,10 +237,9 @@ static const struct microcode_patch *nmi_patch =3D ZER= O_BLOCK_PTR; */ static struct microcode_patch *parse_blob(const char *buf, size_t len) { - if ( likely(!microcode_ops->collect_cpu_info(&this_cpu(cpu_sig))) ) - return microcode_ops->cpu_request_microcode(buf, len); + microcode_ops->collect_cpu_info(); =20 - return NULL; + return microcode_ops->cpu_request_microcode(buf, len); } =20 static void microcode_free_patch(struct microcode_patch *patch) @@ -306,10 +305,9 @@ static bool wait_cpu_callout(unsigned int nr) */ static int microcode_update_cpu(const struct microcode_patch *patch) { - int err =3D microcode_ops->collect_cpu_info(&this_cpu(cpu_sig)); + int err; =20 - if ( unlikely(err) ) - return err; + microcode_ops->collect_cpu_info(); =20 spin_lock(µcode_mutex); if ( patch ) @@ -737,7 +735,7 @@ int microcode_update_one(bool start_update) if ( !microcode_ops ) return -EOPNOTSUPP; =20 - microcode_ops->collect_cpu_info(&this_cpu(cpu_sig)); + microcode_ops->collect_cpu_info(); =20 if ( start_update && microcode_ops->start_update ) { @@ -819,7 +817,7 @@ int __init early_microcode_init(void) return -ENODEV; } =20 - microcode_ops->collect_cpu_info(&this_cpu(cpu_sig)); + microcode_ops->collect_cpu_info(); =20 if ( ucode_mod.mod_end || ucode_blob.size ) rc =3D early_microcode_update_cpu(); diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 29745ed55f..a9f4d6e829 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -115,8 +115,9 @@ static bool signature_matches(const struct cpu_signatur= e *cpu_sig, return cpu_sig->pf & ucode_pf; } =20 -static int collect_cpu_info(struct cpu_signature *csig) +static void collect_cpu_info(void) { + struct cpu_signature *csig =3D &this_cpu(cpu_sig); uint64_t msr_content; =20 memset(csig, 0, sizeof(*csig)); @@ -133,8 +134,6 @@ static int collect_cpu_info(struct cpu_signature *csig) csig->rev =3D (uint32_t)(msr_content >> 32); pr_debug("microcode: collect_cpu_info : sig=3D%#x, pf=3D%#x, rev=3D%#x= \n", csig->sig, csig->pf, csig->rev); - - return 0; } =20 /* diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index 878f8d805f..dc5c7a81ae 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -33,8 +33,11 @@ struct microcode_ops { struct microcode_patch *(*cpu_request_microcode)(const void *buf, size_t size); =20 - /* Obtain microcode-relevant details for the current CPU. */ - int (*collect_cpu_info)(struct cpu_signature *csig); + /* + * Obtain microcode-relevant details for the current CPU. Results in + * per_cpu(cpu_sig). + */ + void (*collect_cpu_info)(void); =20 /* * Attempt to load the provided patch into the CPU. Returns an error = if --=20 2.11.0