From nobody Sat Apr 27 06:30:11 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+72579+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+72579+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1615280262; cv=none; d=zohomail.com; s=zohoarc; b=mTYWmkR+HFt/6SKVuCL27AIMl4Az6F2aepFOK0tm/eR55eoFdFDnq+1ywzt0i4UQ2ce1aCl2k1Z9sOtLMUcvkdS47NJWHZGtYjry+FAnjrAJwgL/CGzQPgjcz4rJNxRjpaTZ40vpr35X9i0Jyr88ui5iK/euM/4hmukbVGlakxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615280262; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=8ELg1RYHu+PnyzAklr35d43Hp203zioCDv/73+lslEI=; b=UsrXvIFjSKf4lOmVqTULUtSzzw55vMLnHATn2bKyz+px18DeeR1UJY87Lpb1cKoAS7BiVIsVaNU6/zQcjSbSMQKjbLMpdrid2lObeHlYmtC2qJ+ze3QCdvKfKIRFRsaDcmZezLZ9BHQbpgVW4gHI8EdPlXWKdWDgMkreGyfZoJs= 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+72579+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 1615280262608245.28145793565716; Tue, 9 Mar 2021 00:57:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id AMPDYY1788612xx5DiTZubrW; Tue, 09 Mar 2021 00:57:42 -0800 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.6092.1615280261753160583 for ; Tue, 09 Mar 2021 00:57:41 -0800 IronPort-SDR: RrpXQl1AtOiBkQOefAeNOKMWgckz2WrEDf4AIqpUVKKMKxWjiPj65yCsDGSqvDJSCCEqljI+iH xJPuq7Vj8WFg== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="187554980" X-IronPort-AV: E=Sophos;i="5.81,234,1610438400"; d="scan'208";a="187554980" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2021 00:57:40 -0800 IronPort-SDR: 6KC/0zrLUoyUKVlTd9Xigh09pqc/8n6uRcuxyF8IYXSF6RM5WxdvTG3bCN+4gIcXz8dRrPQwDc UjtbBXByISEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,234,1610438400"; d="scan'208";a="599233619" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.158.87]) by fmsmga006.fm.intel.com with ESMTP; 09 Mar 2021 00:57:39 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH v2] UefiCpuPkg/PiSmmCpu: Don't allocate Token for SmmStartupThisAp Date: Tue, 9 Mar 2021 16:57:30 +0800 Message-Id: <20210309085730.1720-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: nmeeBpIizT2TZ2AfhR5cAqGAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615280262; bh=ntE3ASSb+q8HLb0L8I2RWAe7jxbsP9M+1xtHFnRfQ60=; h=Cc:Date:From:Reply-To:Subject:To; b=D4PM4vvFSyteKM44F3OYROcKurvod8FRows/Esam1X+GQzJkkiE4MOeFvnhpt4pXzpR cTd8+bKOLPJ0lJmLjvtHDqMgyJLauYHm/LaUKaOuEF8Mj5y1+ouDDG8Iyw08u+DxK0fhe fg+2zROElLD3JRf9DbmeSGe/SeqpDHFcq9k= 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 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 | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 6227b2428a..91452ec398 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). + // + // 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. + // + // 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 (#72579): https://edk2.groups.io/g/devel/message/72579 Mute This Topic: https://groups.io/mt/81197093/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-