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 3B122780091 for ; Mon, 25 Dec 2023 16:20:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=O/thXAl/qJBm9BGB3KGHJwlDgXpQzlSTYtpRpwhpZSE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20140610; t=1703521245; v=1; b=K5SaObTfmJxEffayWy+i9pnbALrPN41qUa1NuUPqtnVkdcw5E5TrSXGLUm5I7qzJlafGthiC 93TOIZzZkChPOLTADZRuCdDLHqhtHFOSQP40RexsDZROjcecD3yEJ/jgDLjZjWHZYjSAzEwvw87 2Zmq/wQ4tN12gJEqi6R5tH9E= X-Received: by 127.0.0.2 with SMTP id mhJ4YY7687511xCBxQE3R5be; Mon, 25 Dec 2023 08:20:45 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.61867.1703521238683254667 for ; Mon, 25 Dec 2023 08:20:45 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="375789616" X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="375789616" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2023 08:20:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="26085432" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa001.jf.intel.com with ESMTP; 25 Dec 2023 08:20:43 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Laszlo Ersek , Eric Dong , Ray Ni , Zeng Star , Gerd Hoffmann , Rahul Kumar Subject: [edk2-devel] [PATCH v2 4/6] UefiCpuPkg/PiSmmCpuDxeSmm: Align BSP and AP sync logic for SMI exit Date: Tue, 26 Dec 2023 00:20:32 +0800 Message-Id: <20231225162034.2052-5-jiaxin.wu@intel.com> In-Reply-To: <20231225162034.2052-1-jiaxin.wu@intel.com> References: <20231225162034.2052-1-jiaxin.wu@intel.com> 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,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: HxopUK2SY6nccm2YuPTXbEyNx7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=K5SaObTf; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Below piece of code is the BSP and AP sync logic for SMI exit. 1. AP after finish the scheduled procedure: if (SmmCpuFeaturesNeedConfigureMtrrs ()) { SmmCpuSyncReleaseBsp (); SmmCpuSyncWaitForBsp (); ... } SmmCpuSyncReleaseBsp (); SmmCpuSyncWaitForBsp (); SmmCpuSyncReleaseBsp (); 2. BSP after return from SmmCoreEntry: SmmCpuSyncWaitForAPs (); if (SmmCpuFeaturesNeedConfigureMtrrs ()) { ReleaseAllAPs (); ... SmmCpuSyncWaitForAPs (); } ReleaseAllAPs (); SmmCpuSyncWaitForAPs(); This patch is to make BSP same as AP sync logic: if (SmmCpuFeaturesNeedConfigureMtrrs ()) { SmmCpuSyncWaitForAPs (); ReleaseAllAPs (); ... } SmmCpuSyncWaitForAPs (); ReleaseAllAPs (); SmmCpuSyncWaitForAPs(); With the change, it will be easy to understand the sync flow as below: BSP: SmmCpuSyncWaitForAPs <-- AP: SmmCpuSyncReleaseBsp BSP: ReleaseAllAPs --> AP: SmmCpuSyncWaitForBsp This patch doesn't have function impact. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c index 324e85d6b5..bd2c9f841b 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -625,33 +625,33 @@ BSPHandler ( // Notify all APs to exit // *mSmmMpSyncData->InsideSmm = FALSE; ReleaseAllAPs (); - // - // Wait for all APs to complete their pending tasks - // - SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); - if (SmmCpuFeaturesNeedConfigureMtrrs ()) { + // + // Wait for all APs the readiness to program MTRRs + // + SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); + // // Signal APs to restore MTRRs // ReleaseAllAPs (); // // Restore OS MTRRs // SmmCpuFeaturesReenableSmrr (); MtrrSetAllMtrrs (&Mtrrs); - - // - // Wait for all APs to complete MTRR programming - // - SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); } + // + // Wait for all APs to complete their pending tasks including MTRR programming if needed. + // + SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); + if (mSmmDebugAgentSupport) { // // Stop source level debug in BSP handler, the code below will not be // debugged. // -- 2.16.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112889): https://edk2.groups.io/g/devel/message/112889 Mute This Topic: https://groups.io/mt/103360805/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-