From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 79405D80419 for ; Mon, 5 Feb 2024 16:59:46 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=jGpfvNICW967czuHO6vqzHG5ew7rzVBkb07QuTOHKNI=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Message-ID:Date:User-Agent:Subject:To:CC:References:From:Organization:In-Reply-To:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707152385; v=1; b=G72Abg/+0NZXJ53IIewGixrzTJiqyYrNDY8feIDFeqeFymnEYRzTyKKsp6GnmCxR+R7IDrxj liGn24uddPZl22YfTcKyD7aZ87ORGMQsiKR6fywGkeEsqZsGzGmQszVu9uYjmY8HYsuN9Qn8ySi DIkNSBM8KXtASxu9bl7bK3ac= X-Received: by 127.0.0.2 with SMTP id q3RhYY7687511xeUBg5sTcHE; Mon, 05 Feb 2024 08:59:45 -0800 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.68019.1707152383955533871 for ; Mon, 05 Feb 2024 08:59:44 -0800 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 415CQg2T001118; Mon, 5 Feb 2024 16:59:43 GMT X-Received: from p1lg14879.it.hpe.com ([16.230.97.200]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3w2yp7jakw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 16:59:43 +0000 X-Received: from p1wg14926.americas.hpqcorp.net (unknown [10.119.18.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id 43489130E2; Mon, 5 Feb 2024 16:59:42 +0000 (UTC) X-Received: from p1wg14925.americas.hpqcorp.net (10.119.18.114) by p1wg14926.americas.hpqcorp.net (10.119.18.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Mon, 5 Feb 2024 04:59:41 -1200 X-Received: from p1wg14919.americas.hpqcorp.net (16.230.19.122) by p1wg14925.americas.hpqcorp.net (10.119.18.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42 via Frontend Transport; Mon, 5 Feb 2024 04:59:41 -1200 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (192.58.206.38) by edge.it.hpe.com (16.230.19.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Mon, 5 Feb 2024 04:59:36 -1200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f0M/JzZK0KAbRyiEliq9mMbsi/B1Lznyi4QzpTxEcws6xE7hNoVC9Ms32ZB8dd04qa+LSYWYsbK7wlfycIsFb8CGWxQTsDOLt6QklyzQ6uhyA26llMvFSeorZu/6/QTAy+9J1vCHfOD6n8NE/AO6Y6jf28tmyIJ/PBhMkw43zBCypKe4QfccvyoJRiEQpsRwn0TCC1wjR1Ld6kTjPW5kles2x1tu7+pQJXZ5GGUqXxRhwy1ZiJBtAfOr/gRVCTjZv+IBL/P1rZs/T2nAES8D9pE0vb5Orw2sF2TveJ9XKVcHvMEmQCqsDW5IqGrds87KBdqy5QWsJYmERgngUUJ+sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7Oa0ayNkmyis0UJmORulftd7FwQh9MIPqUeHglu0tNI=; b=mE0k/XspKuNTbSITPmR3Ndo/+lJpgGRge4tL/ZmnMDgaGBQBG3XpPTd3uke8ejM3slc4hnRuy4mfUbeh3wQ8UBexdfUbVO/BckWaI910j/E1DNW0dm11zHW8f7K+kFgj4UH1TZyX90qkwCtJQMnmPwngj6vh2QIIiY7+fmSVdDFpboNM7EURmu6cgizH8jh2FGuI+CndiTsHph+Je3F06+osIedUvJaiiV9CMuR2XEcEz4vi7wLTemf3xl3V2ZIWFo9gJpmaHI/N1a0fEr8oyyNW/mZGVr1+kULoghm7ledr1Ivw+U2Nsf4n3fMwnqTy7K+gHTc3W4wOzwq0Fbcqpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none X-Received: from MW5PR84MB1354.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:303:1c0::21) by PH7PR84MB1765.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:153::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.34; Mon, 5 Feb 2024 16:59:34 +0000 X-Received: from MW5PR84MB1354.NAMPRD84.PROD.OUTLOOK.COM ([fe80::550f:288e:75c9:9083]) by MW5PR84MB1354.NAMPRD84.PROD.OUTLOOK.COM ([fe80::550f:288e:75c9:9083%4]) with mapi id 15.20.7249.032; Mon, 5 Feb 2024 16:59:34 +0000 Message-ID: <1ed25187-0700-4ac3-b3cd-792d7b6de7f5@hpe.com> Date: Mon, 5 Feb 2024 10:59:31 -0600 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Execute CET and XD check only on BSP To: , CC: Ray Ni , Laszlo Ersek , Eric Dong , Zeng Star , Gerd Hoffmann , Rahul Kumar References: <20240204084744.16464-1-jiaxin.wu@intel.com> <20240204084744.16464-2-jiaxin.wu@intel.com> From: "Brian J. Johnson" Organization: HPE In-Reply-To: <20240204084744.16464-2-jiaxin.wu@intel.com> X-ClientProxiedBy: CH2PR18CA0039.namprd18.prod.outlook.com (2603:10b6:610:55::19) To MW5PR84MB1354.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:303:1c0::21) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW5PR84MB1354:EE_|PH7PR84MB1765:EE_ X-MS-Office365-Filtering-Correlation-Id: 57d2a3ea-e4c0-4a94-b2ea-08dc266bd436 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: Fo91gjD1PhJjsngZP8I2o9bR/cC6PEgfdati7DCQ+JisrrDIMHFV5+IqlU2RmLXtb6u25fvn+WryPsO0UudZ0pKt3YTKpxz9xJI6SnlNGBxBzXvGCjMlhm3H/2pQns6rMlcJFEfonjOATMEyy+t3tbSKLpqzFF08H6kWPhA6vEgRDb+0amPhWBOsN1F0bJQ5zDl5+YJ2AKDhoUi2THToDD3OTouq2igtUxYabVnhLe+pyQ7s2NgyTqtZu3UBFg6VHhfR4T8EO1x0mx78i27ylFbqFYNFJnvxHB2LgUkuloeqvyAQlHQ1/ytlyvspr55pVIoVDYfUwpyu1XXpxyfOUyv/2Py7dZCUigT+bXGbmI5M43XQgFjxlWEBO3tvdZp8tzBPHnUYOYfionISVNuWbPwug9VsFX5ITYBMhmZOd53Gaxvy6iAeiEeUhExXdcelynfvCXUULQkc5rAHzteCSyvcedHLxTWZjfPaOXwQ83PaCDjgSqDBxhn3D7caKBd2uDVI1Ef4UaduBupnhrXHnSO7I0T7oe+kVkbX91nsuK1QL6wwf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2cFFYVW5aWkxCeEVGQUlHcGIvdkZRQlhGb3p4RlB4?= =?utf-8?B?Z3F3VVI3bmJjdVZZMjJNQXh0WFpSR2JtV0psbE1OdFp2YlFpa3FxSFAwN25l?= =?utf-8?B?UzFsRXFydmZQNmNJWHdST096Z1VTQ241OElXbjBudnJZV1N2UTc2eDZsdzZC?= =?utf-8?B?UG1NVnN5VkNMNXlPQ1BWMWtNRmJvZkkrWTM2djNnSy9MVmZ0MUhjei95VGxH?= =?utf-8?B?dEdzTFNKVVB1SFRmeXN5ZTNLdjhZTDBwMk84RmtOOFVvVkVNMXBvZUIyMXZK?= =?utf-8?B?MVJ5QkVQaE9DamVlSVNBU1VpOVJhVTNwL082b1VPK1MvU095WjdSVG8rWS9q?= =?utf-8?B?MWtzSmU4cHM0T09JVVJlMC92T1RFOEdUTlRzT2lRUThNK0VZeFFxWlloZ2tD?= =?utf-8?B?ZEZrNFZXVTlNS2xaQis3RUhHaVhCU0g3bFJ0THF5cEIyT2doS1hNcVQ2TUlT?= =?utf-8?Q?NnpTyt5VPI34HaxEkofUq9HrM?= X-MS-Exchange-CrossTenant-Network-Message-Id: 57d2a3ea-e4c0-4a94-b2ea-08dc266bd436 X-MS-Exchange-CrossTenant-AuthSource: MW5PR84MB1354.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2024 16:59:34.4614 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: agFW/sjspe15qhwVCbsmYHASIinNS7MT/cmHEtXvELEnogFTFTu5xMYGVx9dPYpZFDdW1vS3F42Z90IddyDgMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR84MB1765 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: olt80EUA6MQ0gJzCMOgy4h9HHxVLoJpg X-Proofpoint-ORIG-GUID: olt80EUA6MQ0gJzCMOgy4h9HHxVLoJpg X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,brian.johnson@hpe.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: XEW7TV2HFpElyuPisNy32AgSx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="G72Abg/+"; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=hpe.com (policy=none); arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") As others have pointed out, setting BOOLEAN values from TRUE to FALSE on=20 multiple CPUs at once "should" be safe, in that the final values of the=20 variables are the same no matter what order the CPUs write the data. Now that only the BSP is writing these values, what guarantees that they=20 are written before the APs need to read them? The commit message didn't=20 mention it, and I haven't traced through the SMM initialization flow. Brian J. Johnson -------- Original Message -------- From: Wu, Jiaxin [mailto:jiaxin.wu@intel.com] Sent: Sunday, February 4, 2024 at 2:47 AM To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Eric=20 Dong , Zeng Star , Gerd=20 Hoffmann , Rahul Kumar Subject: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Execute=20 CET and XD check only on BSP Existing CheckFeatureSupported function will check CET & XD features on each processor. The CPUIDs for CET & XD features are software visible domain, which means a properly configured platform will have consistent values for these CPUID Leafs/SubLeafs/Fields on each logical processor. So, execute Execute CET and XD check only on BSP.This belongs to the optimization, which can avoid unnecessary and duplicate check on multiple processors. Note 1: we don't split those functionality check out of the SmmInitHandler. Because the CET & XD & BTS features might be different in non-smm & smm environment. Keep in SMM is more safer. As for MSR_IA32_MISC_ENABLE.BTS, it's core scope according SDM. So, still keep it check on each processor. Note 2: For BTS, using global variable to indicate feature supported or not (mBtsSupported), the function only performs variable modification from TRUE to FALSE. So even the code runs in parallel, it's safe. Cc: Ray Ni Cc: Laszlo Ersek Cc: Eric Dong Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 6 +-- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 78=20 +++++++++++++++++------------- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h | 6 ++- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c=20 b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index cd394826ff..15d26dd88f 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1,9 +1,9 @@ /** @file Agent Module to load other modules to deploy SMM Entry Vector for X86=20 CPU. -Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -375,13 +375,13 @@ SmmInitHandler ( &mCpuHotPlugData ); if (!mSmmS3Flag) { // - // Check XD and BTS features on each processor on normal boot + // Check CET & XD & BTS features on each processor on normal boot // - CheckFeatureSupported (); + CheckFeatureSupported (IsBsp); } else if (IsBsp) { // // BSP rebase is already done above. // Initialize private data during S3 resume // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c=20 b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c index 8142d3ceac..44c352ad98 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c @@ -1,9 +1,9 @@ /** @file Enable SMM profile. -Copyright (c) 2012 - 2023, Intel Corporation. All rights reserved.
+Copyright (c) 2012 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2017 - 2020, AMD Incorporated. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -892,62 +892,74 @@ InitSmmProfileInternal ( } /** Check if feature is supported by a processor. + @param[in] IsBsp Indicate it's called by BSP or not. + **/ VOID CheckFeatureSupported ( - VOID + IN BOOLEAN IsBsp ) { UINT32 RegEax; UINT32 RegEcx; UINT32 RegEdx; MSR_IA32_MISC_ENABLE_REGISTER MiscEnableMsr; - if ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) !=3D 0) &&=20 mCetSupported) { - AsmCpuid (CPUID_SIGNATURE, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS) { - AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,=20 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, NULL, NULL,=20 &RegEcx, NULL); - if ((RegEcx & CPUID_CET_SS) =3D=3D 0) { + // + // The feature scope is software visible domain. + // Only need check on BSP. + // + if (IsBsp) { + if ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) !=3D 0) &&=20 mCetSupported) { + AsmCpuid (CPUID_SIGNATURE, &RegEax, NULL, NULL, NULL); + if (RegEax >=3D CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS) { + AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,=20 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, NULL, NULL,=20 &RegEcx, NULL); + if ((RegEcx & CPUID_CET_SS) =3D=3D 0) { + mCetSupported =3D FALSE; + PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1); + } + } else { mCetSupported =3D FALSE; PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1); } - } else { - mCetSupported =3D FALSE; - PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1); } - } - if (mXdSupported) { - AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); - if (RegEax <=3D CPUID_EXTENDED_FUNCTION) { - // - // Extended CPUID functions are not supported on this processor. - // - mXdSupported =3D FALSE; - PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); - } + if (mXdSupported) { + AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); + if (RegEax <=3D CPUID_EXTENDED_FUNCTION) { + // + // Extended CPUID functions are not supported on this processor. + // + mXdSupported =3D FALSE; + PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); + } - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & CPUID1_EDX_XD_SUPPORT) =3D=3D 0) { - // - // Execute Disable Bit feature is not supported on this processor. - // - mXdSupported =3D FALSE; - PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); - } + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & CPUID1_EDX_XD_SUPPORT) =3D=3D 0) { + // + // Execute Disable Bit feature is not supported on this processor. + // + mXdSupported =3D FALSE; + PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); + } - if (StandardSignatureIsAuthenticAMD ()) { - // - // AMD processors do not support MSR_IA32_MISC_ENABLE - // - PatchInstructionX86 (gPatchMsrIa32MiscEnableSupported, FALSE, 1); + if (StandardSignatureIsAuthenticAMD ()) { + // + // AMD processors do not support MSR_IA32_MISC_ENABLE + // + PatchInstructionX86 (gPatchMsrIa32MiscEnableSupported, FALSE, 1); + } } } + // + // The feature scope is core. + // Need check on each processor. + // if (mBtsSupported) { AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &RegEdx); if ((RegEdx & CPUID1_EDX_BTS_AVAILABLE) !=3D 0) { // // Per IA32 manuals: diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h=20 b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h index 1a82ac05ce..02554a9983 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h @@ -1,9 +1,9 @@ /** @file SMM profile header file. -Copyright (c) 2012 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2012 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _SMM_PROFILE_H_ @@ -81,14 +81,16 @@ PageFaultIdtHandlerSmmProfile ( ); /** Check if feature is supported by a processor. + @param[in] IsBsp Indicate it's called by BSP or not. + **/ VOID CheckFeatureSupported ( - VOID + IN BOOLEAN IsBsp ); /** Update page table according to protected memory ranges and the=20 4KB-page mapped memory ranges. --=20 Brian J. Johnson Enterprise X86 Lab Hewlett Packard Enterprise -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115122): https://edk2.groups.io/g/devel/message/115122 Mute This Topic: https://groups.io/mt/104153488/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-