From nobody Tue May 7 13:42:07 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+72623+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+72623+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1615371155; cv=none; d=zohomail.com; s=zohoarc; b=NWKwo21BYoJGUAicavh0JEed5QXcqA4YFQ6f7beuNBghm/ofSSaF1CrOEB2wQrKPL+eXn9T6viHxyjfodhnQLCap7TVu8urtP1C9I5F/YaKOs2J3oZEtyyK7yUjSFdskZaqY5hFtfSt9Vfl9Ur5Y8/BEFUbTMP1hp/fv5irYvJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615371155; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=cG31kaTjpa7aX5/u65/iuUSZAiDJklJwq/DZ657NQFg=; b=eCSGfarhyndbikaBrqGagv3ulaXfXytKDq6S0gUqvXS7kGhIeXkJcpNlam/NMFMJOCVgPGXdFLIEQPKEj35rcT7LbzPJlFUw/9SKjr8b0WLJUymybRSPMyGar3P9Drx9k6SJqTHkmbV+F0zu7KjBxYKemM0hungtwKHSSkp1gjA= 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+72623+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 1615371155390318.335947363577; Wed, 10 Mar 2021 02:12:35 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id HmrIYY1788612xay6l3ECRtz; Wed, 10 Mar 2021 02:12:35 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.6939.1615371154571848581 for ; Wed, 10 Mar 2021 02:12:34 -0800 IronPort-SDR: IfL9Z2ttY6NDS8ZikIB5mdjdnXnrMW0S6sTNhCSkfHqa/5l+EIBsQh6NFd64LcQ7iGOgrweB+H gdwbMf0BqnYg== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="168348218" X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="168348218" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 02:12:33 -0800 IronPort-SDR: tT1TEVndVg/3sNqQlajEwKO4HDWIVqjdKZNWk0A+qUE6qMo4e1AxsLcI2rra5AZ/dzGjLZLVDl Q+ow7HL2n+4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="603024012" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.158.87]) by fmsmga005.fm.intel.com with ESMTP; 10 Mar 2021 02:12:31 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH v4] UefiCpuPkg/PiSmmCpu: Don't allocate Token for SmmStartupThisAp Date: Wed, 10 Mar 2021 18:12:17 +0800 Message-Id: <20210310101217.286-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: V5kkaSE9ojVXlbvOgT1QcGNrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615371155; bh=EimazWLmrdZiKI+A3xavE9+Z66Wg8sKS6MSvaVEi1SM=; h=Cc:Date:From:Reply-To:Subject:To; b=O8b7YxZ5gMZc+OwL0Dpwux+M+3Nzqs2uWR+nAfHwQlRzAxf2w9kjvxcW4Q9udS78vVT 8Vu/YoMWUpQhtGHuwkYcGmJ2Edsbruvioy56GRBjhkvUxVbD469viYD//Wh5A1ox2Dnf/ wZbztP1EvGI4AlZEPYYjbSflcAAKJKZRof4= 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 Reviewed-by: 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..fd6583f9d1 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-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 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 -=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 (#72623): https://edk2.groups.io/g/devel/message/72623 Mute This Topic: https://groups.io/mt/81223901/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-