From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=binx.song@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 02E6F21CB87AC for ; Sun, 24 Dec 2017 19:06:37 -0800 (PST) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Dec 2017 19:11:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,453,1508828400"; d="dat'59?scan'59,208,59";a="4640928" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 24 Dec 2017 19:11:30 -0800 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 24 Dec 2017 19:11:29 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 24 Dec 2017 19:11:23 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.159]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Mon, 25 Dec 2017 11:11:21 +0800 From: "Song, BinX" To: "edk2-devel@lists.01.org" CC: "Dong, Eric" , "lersek@redhat.com" Thread-Topic: [PATCH] UefiCpuPkg: Update AESNI support checking logic Thread-Index: AdN9LgmUQcPTPg4QQy6jpRa0es7k1A== Date: Mon, 25 Dec 2017 03:11:21 +0000 Message-ID: <559D2DF22BC9A3468B4FA1AA547F0EF1025C9A07@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: <559D2DF22BC9A3468B4FA1AA547F0EF1025C9A07@SHSMSX101.ccr.corp.intel.com> dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 Subject: [PATCH] UefiCpuPkg: Update AESNI support checking logic X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Dec 2017 03:06:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable With correct model CPU, current checking logic will always execute AsmReadMsr64 operation and then check ECX.AESNI[bit 25] =3D 1. Update checking logic to check ECX.AESNI[bit 25] =3D 1 first and then do AsmReadMsr64 operation. Cc: Eric Dong Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bell Song --- UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c b/UefiCpuPkg/L= ibrary/CpuCommonFeaturesLib/Aesni.c index 880f092..56b1b55 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c @@ -62,15 +62,17 @@ AesniSupport ( { MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig; =20 - if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayM= odel) || - IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMod= el) || - IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMode= l) || - IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)= || - IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel= )) { - MsrFeatureConfig =3D (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) Conf= igData; - ASSERT (MsrFeatureConfig !=3D NULL); - MsrFeatureConfig[ProcessorNumber].Uint64 =3D AsmReadMsr64 (MSR_SANDY_B= RIDGE_FEATURE_CONFIG); - return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI =3D=3D 1); + if (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI =3D=3D 1) { + if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->Displa= yModel) || + IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayM= odel) || + IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMo= del) || + IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMode= l) || + IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMod= el)) { + MsrFeatureConfig =3D (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) Co= nfigData; + ASSERT (MsrFeatureConfig !=3D NULL); + MsrFeatureConfig[ProcessorNumber].Uint64 =3D AsmReadMsr64 (MSR_SANDY= _BRIDGE_FEATURE_CONFIG); + } + return TRUE; } return FALSE; } --=20 2.10.2.windows.1