From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.9298.1615298931731232557 for ; Tue, 09 Mar 2021 06:08:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=YgwN2xVa; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: eric.dong@intel.com) IronPort-SDR: xZyWUL4an5zEDVrpf+aTYiYTT2mb5/sOkgHJnZrcSldSRWbahS8n1/2GWVIoMwKMLIqL0eP37g VIiKQ81V8BZw== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="175847017" X-IronPort-AV: E=Sophos;i="5.81,234,1610438400"; d="scan'208";a="175847017" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2021 06:08:46 -0800 IronPort-SDR: pzAmeAb/CvEEaibS+2SZraXQl6FA75t8NUvuhjXhhf6/OO7Tqnuoq0EdXml4LhNcstxA193fzr GcgG3zTh1ONA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,234,1610438400"; d="scan'208";a="602632119" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga005.fm.intel.com with ESMTP; 09 Mar 2021 06:08:46 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 9 Mar 2021 06:08:46 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 9 Mar 2021 06:08:45 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Tue, 9 Mar 2021 06:08:45 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.104) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Tue, 9 Mar 2021 06:08:45 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MHEkSQFuH5S1vYc+CjHUH0L3xIaXk6Fop7JIrxzOXcfAdX5WclD/2AQjr9p7+0LoV806GKMHaPN6urrO6WhJdRUR2oMbudID6MGZl7kg6XgpZsR4kJUL/cxFHTpA96EkEA8vDXKwIwM0zQLQ5ZXso5m27NDwz5Oet2hLAisrg+wEqnATKM/sRBSuG3uyvumJ/NZOU8E1SNRoz0XKGggg9nzmQly/9VGJ58aK9nq4t4sS31gE/OqDd7RhS1f1FnoxLFUi+aUrxZyE2ex6LQh4B+CZaat1emlPwcnSOrBGersGwfNiwxNkdJ0DlY4hBxWmEsSdsSh8/wEDYjVPZxeCqA== 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-SenderADCheck; bh=ndwuXOBI4Ie42ZK8JXIwAIO7Qv1rynHX39kFjX5oGTA=; b=Y0BXxJFeGbdiBseu1PRVhgJ5qZU6aManBfxb2wTdyAFxupfUVoB/5Z1D6xfzHp64pF81xOD6keGEzOPeaFNX18i0Me2ee9MH86BFxQBe5xCApN0A3kF0g7JjVwOEU8FbdPKkqzgMdJx5xNbE5s7W1laaNmIrd1T/M5Xiytr3gJlF+mP/hHRrjOx/eV8r8jrbOpR2iJysXHz7z9JYJZBcKAWM6tlNHc8CT8y6SMKyUtiCZjjNqnPee9DeaCgvND6mOenzcP+K9n3G8Rv5i1OrBi0kLih2ODJn2t0T0X8Am05JltmFznMLSt8KkVjYwpAgnO+OpGRlrvmrREo32A9hKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ndwuXOBI4Ie42ZK8JXIwAIO7Qv1rynHX39kFjX5oGTA=; b=YgwN2xVa8JgRa9uT0XSQwAgf9ZejxEibP+bch0nqBmu4Zu561ikTcpeEmVxTFJPJYGioemXMbgcSUQyfBr1H70VZJw9dnteMDVTXpIB44B7ivcqdMd3Hiinyz8+yNo1VRSssdegZROMm/HdZYNhA4e8F+os71AjgOA5z+93CIOc= Received: from DM5PR11MB1274.namprd11.prod.outlook.com (2603:10b6:3:12::8) by DM6PR11MB4137.namprd11.prod.outlook.com (2603:10b6:5:199::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Tue, 9 Mar 2021 14:08:44 +0000 Received: from DM5PR11MB1274.namprd11.prod.outlook.com ([fe80::952:4a92:d71:8cb]) by DM5PR11MB1274.namprd11.prod.outlook.com ([fe80::952:4a92:d71:8cb%5]) with mapi id 15.20.3912.028; Tue, 9 Mar 2021 14:08:44 +0000 From: "Dong, Eric" To: "Ni, Ray" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul1" Subject: Re: [PATCH v3] UefiCpuPkg/PiSmmCpu: Don't allocate Token for SmmStartupThisAp Thread-Topic: [PATCH v3] UefiCpuPkg/PiSmmCpu: Don't allocate Token for SmmStartupThisAp Thread-Index: AQHXFMPwgCar3If9X0mAL7Ixo4Us/ap7sc6A Date: Tue, 9 Mar 2021 14:08:44 +0000 Message-ID: References: <20210309090916.1815-1-ray.ni@intel.com> In-Reply-To: <20210309090916.1815-1-ray.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.196] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bf202883-5f1b-4213-dfae-08d8e304d9aa x-ms-traffictypediagnostic: DM6PR11MB4137: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3631; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: spOR6hMh0fVx6ecnInF/4IlwEOxhx3xp+iuwmsNu/BZ+J8NX2bQ4kcUGq6ZzMUTIzUUfiTXtz7Bc14M4FMz+m1o7t/nza25ymwJJK2aUbL20NLyZbcLFhJebCN9pih+XhH3Dvlyv3QZ9VYP8ehJ3bdUfSBJC4zq0TAI5GmG6PoehXEwhf2BI9MEn0/9fUYysqjn/ojly+el/iSmyE5JVxXKWpWY3ISZ4dDMQaFmKj4PSKNSwuaBrq5qtrt3FX4H/bfmxgQtO8ij0HcV+iXl/KdA4u/XUP7/caDRs3CVghFQBSqQP7mA2Qm8vKOhWIDdjjxPizlvVY2DLHaj9c0umPKZC/41alCfjSiUl3x//dzwnP3bY6M6RHRhvXBFoS8uRabW4UMzuDtNyFKlHtH1x2GldFHs6VW4zO13i//gQmnLMHg5vKY75SBy/j0bPRBIZpH6nEE99uxQAcDHpWBIGg+CkBHsT32DTzgLzpiVe1/W+VeGQoMgHIoHKuKBFqPbmOLIsUX+PWK4AANHgDdX5NavK4GeNlXGh5zckGIurd1WgGf0qxRF4NxnhentfjH/C7CYpepm1Q8vHHYb0idaMBFa1UlUYoNf4nVrAwv/GjrE= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR11MB1274.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(136003)(376002)(366004)(346002)(39860400002)(396003)(66946007)(64756008)(66446008)(86362001)(8936002)(33656002)(83380400001)(54906003)(66556008)(107886003)(76116006)(66476007)(4326008)(110136005)(5660300002)(478600001)(316002)(7696005)(71200400001)(8676002)(26005)(966005)(53546011)(6506007)(52536014)(55016002)(2906002)(9686003)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?0emgf3zpDtyp8QlDokTr+QNcRCHuwYK+RPBIHg4tWfVDy6FBrraKuPrfFyn9?= =?us-ascii?Q?s1IfFq0zkiIe6CLlZNspX/gUgJNGx/bKBqYT+uN7x70OXXeI8b/Nphq/Zq7q?= =?us-ascii?Q?24/20kxYzZcLbjkynzasi0jWg392ynviq536kao10e7dUBznXVi+GLt6B8bf?= =?us-ascii?Q?hwyb9tRQtzlVBB+7ltiEE+MI5gqUQ1Kkq0qEupZxwU070GXEXMEssJo8LnUJ?= =?us-ascii?Q?8Ghmuu3mpz9f9i7xYvGcCKvwdOmuMNPDEpJY9VnSqRd5/oXOPbXLyTYt7LSw?= =?us-ascii?Q?SuuWJqFwdq/Mg2ESBSmPxSKcPOD0XDVt2SRhjV03Pg6pvfpqMjRO18YJOu0e?= =?us-ascii?Q?KAugNYig7vhu7OSqG7H5PyOCewEROBADJaC7EJELRLAu7El4gJS1hTnqZ5DX?= =?us-ascii?Q?eVEEb3foFSzjmV+mb+CMaouvsFN07Disqy3YS8CXYVH2FWXCp0u5A8bqJ7ud?= =?us-ascii?Q?drGRgE2pwHYE+Ny0nswND+LNqQLx5cW7/ZxwuZ0Yb2VtGjl7ReDf2IMjLjMR?= =?us-ascii?Q?FJRGTvWWiz+qb8thQFbn5GbVRLPtaKmyaJxMGnEl+vrYOO09GHe0I/Bd8YKw?= =?us-ascii?Q?8YreJmNIJwvCR9JMeQaSrDL9zGwiS0JPa/+dUjoWWoZao6/XJ6t4QOpy9je+?= =?us-ascii?Q?uKoeOCQqDzwcDqk6Hczd+e8MHEiXXWKHCJ6wqF+9tHYODxlLK7PBdmyWJFSE?= =?us-ascii?Q?rdxm37HQqw3wS70VfzSRrimdRvO3DTaYorUzWoi4jWg4ANxfokizkaYrDUZY?= =?us-ascii?Q?UqRffojHZiyARj2NFz7UJX+L5o6ZbA1cQoivvoeQe3PTn+0WSo8sHuFkiioy?= =?us-ascii?Q?tbeICSu2PF3VngqmzB+8Mt4Wb/K/7MxhaGnxSV6I/zi4EKYp6t52EywNmXEh?= =?us-ascii?Q?7yX2M7/5EM6pwatXmNglh4Itf/v+r3UL4eX2ZHz/XM3+dsytCV7YSIIHMmRB?= =?us-ascii?Q?4nb969DEnzpvpsWMXO2JU6cmTcPKFTyyAGQC52YWObuHk4YIhjDwYS5BRW7e?= =?us-ascii?Q?zk13yUvRX6JJJymynEPn1jhtEDFPkz3OEjCuLxypI9LuGAeyP6d26NKZIjqm?= =?us-ascii?Q?zZrGe61VdDBhu/g+9UvLCZqfZun7jJe369nn6SimhSy9MikxV9D9mCYTqpJa?= =?us-ascii?Q?IcCOy0AFCVhQoE+eVkeS9AQMN0eFC1HbwgRR6/zeH/CxN2P7QMxF8JhR8JOP?= =?us-ascii?Q?Kqt2VUNqHNww9HOrzJcOzibtvV2zm5YnCGjcnNadP4sDBr9YCh7pfTtiV68J?= =?us-ascii?Q?KnGtNNH3/w6rLnF9PdEdLA/maOtawoQigx4AXcLJriQ6TeuUbXxCt1qmmyk9?= =?us-ascii?Q?WlIz6V2nBfkiWfCg+90KiyuM?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM5PR11MB1274.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf202883-5f1b-4213-dfae-08d8e304d9aa X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Mar 2021 14:08:44.1495 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: d6D2wE4IEAc9hvQvmO6dEF8F3Ej+j9p88pbINvz/i5/vcOBozjAhpxQY+k5fhSf9Ji/hhP5HlPC5gCZs+sibug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4137 Return-Path: eric.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: Ni, Ray =20 Sent: Tuesday, March 9, 2021 5:09 PM To: devel@edk2.groups.io Cc: Dong, Eric ; Laszlo Ersek ; Kum= ar, Rahul1 Subject: [PATCH v3] UefiCpuPkg/PiSmmCpu: Don't allocate Token for SmmStartu= pThisAp REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3199 When Token points to mSmmStartupThisApToken, this routine is called from SmmStartupThisAp() in non-blocking mode due to PcdCpuSmmBlockStartupThisAp =3D=3D FALSE. In this case, caller wants to startup AP procedure in non-blocking mode and cannot get the completion status from the Token because there is no way to return the Token to caller from SmmStartupThisAp(). Caller needs to use its specific way to query the completion status. There is no need to allocate a token for such case so the 3 overheads can be avoided: 1. Call AllocateTokenBuffer() when there is no free token. 2. Get a free token from the token buffer. 3. Call ReleaseToken() in APHandler(). Signed-off-by: Ray Ni Cc: Eric Dong Reviewed-by: Laszlo Ersek Cc: Rahul Kumar --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 30 ++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 6227b2428a..4f3c5f60a1 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -1,7 +1,7 @@ /** @file SMM MP service implementation =20 -Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -22,6 +22,7 @@ UINTN mSemaphoreSiz= e; SPIN_LOCK *mPFLock =3D NULL; SMM_CPU_SYNC_MODE mCpuSmmSyncMode; BOOLEAN mMachineCheckSupported =3D FAL= SE; +MM_COMPLETION mSmmStartupThisApToken; =20 extern UINTN mSmmShadowStackSize; =20 @@ -1240,9 +1241,26 @@ InternalSmmStartupThisAp ( mSmmMpSyncData->CpuData[CpuIndex].Procedure =3D Procedure; mSmmMpSyncData->CpuData[CpuIndex].Parameter =3D ProcArguments; if (Token !=3D NULL) { - ProcToken=3D GetFreeToken (1); - mSmmMpSyncData->CpuData[CpuIndex].Token =3D ProcToken; - *Token =3D (MM_COMPLETION)ProcToken->SpinLock; + if (Token !=3D &mSmmStartupThisApToken) { + // + // When Token points to mSmmStartupThisApToken, this routine is call= ed + // from SmmStartupThisAp() in non-blocking mode (PcdCpuSmmBlockStart= upThisAp =3D=3D FALSE). + // + // In this case, caller wants to startup AP procedure in non-blockin= g + // mode and cannot get the completion status from the Token because = there + // is no way to return the Token to caller from SmmStartupThisAp(). + // Caller needs to use its implementation specific way to query the = completion status. + // + // There is no need to allocate a token for such case so the 3 overh= eads + // can be avoided: + // 1. Call AllocateTokenBuffer() when there is no free token. + // 2. Get a free token from the token buffer. + // 3. Call ReleaseToken() in APHandler(). + // + ProcToken=3D GetFreeToken (1); + mSmmMpSyncData->CpuData[CpuIndex].Token =3D ProcToken; + *Token =3D (MM_COMPLETION)ProcToken->SpinLock; + } } mSmmMpSyncData->CpuData[CpuIndex].Status =3D CpuStatus; if (mSmmMpSyncData->CpuData[CpuIndex].Status !=3D NULL) { @@ -1474,8 +1492,6 @@ SmmStartupThisAp ( IN OUT VOID *ProcArguments OPTIONAL ) { - MM_COMPLETION Token; - gSmmCpuPrivate->ApWrapperFunc[CpuIndex].Procedure =3D Procedure; gSmmCpuPrivate->ApWrapperFunc[CpuIndex].ProcedureArgument =3D ProcArgume= nts; =20 @@ -1486,7 +1502,7 @@ SmmStartupThisAp ( ProcedureWrapper, CpuIndex, &gSmmCpuPrivate->ApWrapperFunc[CpuIndex], - FeaturePcdGet (PcdCpuSmmBlockStartupThisAp) ? NULL : &Token, + FeaturePcdGet (PcdCpuSmmBlockStartupThisAp) ? NULL : &mSmmStartupThisA= pToken, 0, NULL ); --=20 2.27.0.windows.1