From nobody Mon May 6 09:57:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72521+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72521+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1615169818; cv=none; d=zohomail.com; s=zohoarc; b=iAbGodsL4EcdAW3hkTE/yPp+yag0/6siPKj/dVHnSBGOYSHDwJNHsF51ldfpqfwt/w7sbolmfPxiofLOxCRrT3T6DjEor6BgUmZHKDSTQ5bFC9B4iHt/1f/vF+kOAOw3Yoq7uJFcfi8IJ4BF2iI9MrKMNnb7CBYdG+8ogPyQtPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615169818; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Fpma1tSEx9zjX5qP7+4qdQvitlDdaOxVfNCXfObMSeI=; b=D10Uj8pu0igwHCLVSMRqRVBBQYATqHHflazHH9aNQk4IGrOiP46Mbgb3Ityjb8AO0QHi25Iaye3a7MMacUm6SBYHOymSlI3KYlc6ntopmer52LvwhJ0nT1q/onCic5DYnxVrJLZO/bEhRmcTsF2PvY0PK19OKyAokNhz4RwJZvY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72521+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1615169818133477.31760428841017; Sun, 7 Mar 2021 18:16:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id HK80YY1788612xirzg0M8kPE; Sun, 07 Mar 2021 18:16:57 -0800 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.30412.1615169817052534143 for ; Sun, 07 Mar 2021 18:16:57 -0800 IronPort-SDR: SPT5uFyg58+LAKbkskbik3e6WJmtjW0ic6Ru9ZnwJ7zD8qTdm4onEsSCXHBiSJztpsb8YAtiCK Wi9x9kkBmHrg== X-IronPort-AV: E=McAfee;i="6000,8403,9916"; a="207707885" X-IronPort-AV: E=Sophos;i="5.81,231,1610438400"; d="scan'208";a="207707885" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2021 18:16:55 -0800 IronPort-SDR: 5DKoLvNpnlSlOWIKGSFeAeLl3Mfe4zlXpF+ZaNPIIyBRTHCFP3wX57MBcGe97iJBE1I5jI0AVl veKor7tabn3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,231,1610438400"; d="scan'208";a="369273797" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.158.87]) by orsmga003.jf.intel.com with ESMTP; 07 Mar 2021 18:16:54 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpu: Don't allocate Token for SmmStartupThisAp Date: Mon, 8 Mar 2021 10:16:47 +0800 Message-Id: <20210308021647.528-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,ray.ni@intel.com X-Gm-Message-State: zVXa6EW01mzcWJQjatHvtgv8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615169817; bh=Hr0cFaInwtsXLuMN3N+P0Urt+NWwwtSt7G/5w4kL2EA=; h=Cc:Date:From:Reply-To:Subject:To; b=cACtOLqvalvV6rwvfx9oTmFqGAR8r0NOfLfdOiZxJOb4/TRhO7zYYBrBKQixUPchtWq U9LBC9MrSXQP9qlDvbVizZ7xKW4rqwEQvE1aEq7XmOq1fKja9l2w4ZgDh0UBaybcMrOvc Q3JWFRZVXDnOMvBHuLVOSWfNJfLoMokYZCk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 2 overheads can be avoided: 1. Call AllocateTokenBuffer() when there is no free token. 2. Get a free token from the token buffer. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Cc: Rahul Kumar Reviewed-by: Laszlo Ersek --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 6227b2428a..efb89832ca 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,23 @@ 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). + //=20 + // 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 implementation specific way to query the = completion status. + //=20 + // There is no need to allocate a token for such case so the overhea= d of SMRAM and + // the allocation operation can be avoided. + // + 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 +1489,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 +1499,7 @@ SmmStartupThisAp ( ProcedureWrapper, CpuIndex, &gSmmCpuPrivate->ApWrapperFunc[CpuIndex], - FeaturePcdGet (PcdCpuSmmBlockStartupThisAp) ? NULL : &Token, + FeaturePcdGet (PcdCpuSmmBlockStartupThisAp) ? NULL : &mSmmStartupThisA= pToken, 0, NULL ); --=20 2.27.0.windows.1 -=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 (#72521): https://edk2.groups.io/g/devel/message/72521 Mute This Topic: https://groups.io/mt/81165359/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-