From nobody Wed May 15 13:36:19 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+112886+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+112886+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703521240; cv=none; d=zohomail.com; s=zohoarc; b=cony+Km+JHvR2mfD7rivk7VuKZ2HycAEaUBN5o5wkLh2pZqqBTVgMLwnk3QgK3mXxH8M9smA+63q8769CSnrDWpeffzODcNhv/dyDMv5ZFP73WQ7sHSVAj1CU/hC9b7gmBy+b+G9qQPWizd3n8CwupRIk7nnjnmZupT1vu8gOk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703521240; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=AR63L+xSXnYiv9oT5C2u3ehvalMa1PqP54LoFsyw66U=; b=l1l5ic26d2a48BcfY81Ukp3a9prAHMNj8iGdShxH2FOUNWStkfDnk01OEP/eTyTp3bnfEs80fn2HCJfrLVF1jbw60fG8mpdp6msxZriD7IUEBO1kOvyy3wf8A9pk5uySBySbysNssOALqtLhKuF+ofzlCelmaKtcK/Vy0g5N5RE= 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+112886+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 170352124065183.60341422184206; Mon, 25 Dec 2023 08:20:40 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=BGG5JbZu32FnB2A8hpeq1jJyF7h7bTM56lPMFHWKDzA=; 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=1703521240; v=1; b=td2uvUnXAs8fP+T21gysvRWALNc4M9Jds7CggT0UOp/Z5hKglzAw4MACVttoZfBAd+kF1ur0 e25CbX4f0FQxTpRGqp5hXMb3Lwb91R1V+Bnss0/tpqSYv89S8gN3vKFhXg0Xp+PyJCxx6vsubFN M0v5Sx+9cAoDk9BVxIxy/tRo= X-Received: by 127.0.0.2 with SMTP id v7kTYY1788612xWWxLaGbOYw; Mon, 25 Dec 2023 08:20:40 -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:39 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="375789608" X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="375789608" 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:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="26085421" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa001.jf.intel.com with ESMTP; 25 Dec 2023 08:20:38 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ray Ni Subject: [edk2-devel] [PATCH v2 1/6] SourceLevelDebugPkg/Library: Indicate SMM Debug Agent support or not Date: Tue, 26 Dec 2023 00:20:29 +0800 Message-Id: <20231225162034.2052-2-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: NLR9eTNx5E6AmaA1qcswlNUKx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703521242540100006 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is to use the Context to indicate SMM Debug Agent support or not if InitFlag is DEBUG_AGENT_INIT_SMM. Context must point to a BOOLEAN if it's not NULL. Cc: Ray Ni Signed-off-by: Jiaxin Wu --- .../Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c | 14 ++++++++++= ---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugA= gentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAg= entLib.c index f49a592d27..1f34a0edc8 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib= .c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib= .c @@ -157,12 +157,13 @@ RestoreDebugRegister ( in SMM code. =20 If InitFlag is DEBUG_AGENT_INIT_SMM, it will override IDT table entries and initialize debug port. It will get debug agent Mailbox from GUIDed H= OB, it it exists, debug agent wiil copied it into the local Mailbox in SMM s= pace. - it will override IDT table entries and initialize debug port. Context wi= ll be - NULL. + it will override IDT table entries and initialize debug port. Context mu= st + point to a BOOLEAN if it's not NULL, which indicates SMM Debug Agent sup= ported + or not. If InitFlag is DEBUG_AGENT_INIT_ENTER_SMI, debug agent will save Debug Registers and get local Mailbox in SMM space. Context will be NULL. If InitFlag is DEBUG_AGENT_INIT_EXIT_SMI, debug agent will restore Debug Registers. Context will be NULL. =20 @@ -203,29 +204,32 @@ InitializeDebugAgent ( (VOID *)&mVectorHandoffInfoDebugAgent[0], sizeof (EFI_VECTOR_HANDOFF_INFO) * mVectorHandoffI= nfoCount ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration tab= le for persisted vector handoff info!\n")); + *(BOOLEAN *)Context =3D FALSE; CpuDeadLoop (); } =20 // // Check if Debug Agent initialized in DXE phase // Status =3D EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOI= D **)&Mailbox); if ((Status =3D=3D EFI_SUCCESS) && (Mailbox !=3D NULL)) { VerifyMailboxChecksum (Mailbox); - mMailboxPointer =3D Mailbox; + mMailboxPointer =3D Mailbox; + *(BOOLEAN *)Context =3D TRUE; break; } =20 // // Check if Debug Agent initialized in SEC/PEI phase // Mailbox =3D GetMailboxFromHob (); if (Mailbox !=3D NULL) { - mMailboxPointer =3D Mailbox; + mMailboxPointer =3D Mailbox; + *(BOOLEAN *)Context =3D TRUE; break; } =20 // // Debug Agent was not initialized before, use the local mailbox. @@ -273,10 +277,12 @@ InitializeDebugAgent ( // // Restore saved IDT entries // CopyMem ((VOID *)IdtDescriptor.Base, &IdtEntry, 33 * sizeof (IA32_ID= T_GATE_DESCRIPTOR)); =20 + *(BOOLEAN *)Context =3D TRUE; + break; =20 case DEBUG_AGENT_INIT_ENTER_SMI: SaveDebugRegister (); if (!mSmmDebugIdtInitFlag) { --=20 2.16.2.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 (#112886): https://edk2.groups.io/g/devel/message/112886 Mute This Topic: https://groups.io/mt/103360802/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- From nobody Wed May 15 13:36:19 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+112887+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+112887+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703521241; cv=none; d=zohomail.com; s=zohoarc; b=RPpa+IdVOiRtk/7K7W7RzPxsmddFJ9RecUY3V4qSpQ5SvqzRWKVHOJ0q6IEBqGAHyB50BK9iqfbbPO0MAq4wQPZPvmMRWXaSw44qDgmZcizxSBILKS7XX5HTzgaCsl7Ajl2puaSly29JMlq9k2ZiOaFGKIxXZLBZKg/O2EmGkYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703521241; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=2nlS6JyI4boXhsw3Cl1IRFgmTM78XwRhi2JgY6wH3ck=; b=Wvatjsp7jYMYQ1iFTf1bRhHXFI2gXTq+DBAIJGwXlhyEXOZ7SPufdXKlD1YiA0EqJL6Lezcoh6H7pvykC7w+58pkeDtcMC3saEeCcOnJ91Xmo8UDOzZ9bvAiJJQu1fINnwmudWbomJl2jd0Z6r2MuOMTjanrTJ1lftqcfiKjW6s= 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+112887+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1703521241766609.5059412909889; Mon, 25 Dec 2023 08:20:41 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=CDTPMXcq1Y4wxwnM3VSdaznG22jL+cJE42Lno+QXYRY=; 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=1703521241; v=1; b=lInc3PoApzgVmcysJd9gUcOvjTLcN2HoeGibTjwroTYdhE6L6nU7BiVHSC/rVB40HpEmvyKW lpwTrG+RpPcTbydI4tsjPW+BamxBOTHvwit4mqrsb7QTAS62PgzuG9Sw7i6EW7kCFFeB9IEYdwf P9DRIrMSmsCrhcT0+Jp6rmEY= X-Received: by 127.0.0.2 with SMTP id gq98YY1788612xHs6SnLfuiK; Mon, 25 Dec 2023 08:20:41 -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:41 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="375789611" X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="375789611" 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:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="26085425" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa001.jf.intel.com with ESMTP; 25 Dec 2023 08:20:40 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ray Ni , Liming Gao Subject: [edk2-devel] [PATCH v2 2/6] MdeModulePkg/DebugAgentLibNull: Indicate SMM Debug Agent support or not Date: Tue, 26 Dec 2023 00:20:30 +0800 Message-Id: <20231225162034.2052-3-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: dNktgTs7X9EP9d761ytYLya9x1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703521242535100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is to use the Context to indicate SMM Debug Agent support or not if InitFlag is DEBUG_AGENT_INIT_SMM. Context must point to a BOOLEAN if it's not NULL. Cc: Ray Ni Cc: Liming Gao Signed-off-by: Jiaxin Wu --- MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c b/M= deModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c index 8e70705eb6..5596ee3bf9 100644 --- a/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c +++ b/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c @@ -22,10 +22,13 @@ passing in the Context to be its parameter. =20 If Function() is NULL, Debug Agent Library instance will return after se= tup debug environment. =20 + If InitFlag is DEBUG_AGENT_INIT_SMM, Context must point to a BOOLEAN if = it's not + NULL, which indicates SMM Debug Agent supported or not. + @param[in] InitFlag Init flag is used to decide the initialize proce= ss. @param[in] Context Context needed according to InitFlag; it was opt= ional. @param[in] Function Continue function called by debug agent library;= it was optional. =20 @@ -36,10 +39,16 @@ InitializeDebugAgent ( IN UINT32 InitFlag, IN VOID *Context OPTIONAL, IN DEBUG_AGENT_CONTINUE Function OPTIONAL ) { + switch (InitFlag) { + case DEBUG_AGENT_INIT_SMM: + *(BOOLEAN *)Context =3D FALSE; + return; + } + if (Function !=3D NULL) { Function (Context); } } =20 --=20 2.16.2.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 (#112887): https://edk2.groups.io/g/devel/message/112887 Mute This Topic: https://groups.io/mt/103360803/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- From nobody Wed May 15 13:36:19 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+112888+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+112888+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703521244; cv=none; d=zohomail.com; s=zohoarc; b=bRvnqrV9+aMWDMSXClhNL22p2DsrY5Gi50SWEqN+TKMp0nufKXs912i3EzVrWOZLCIFC9gYhyN2ZIwHm87rqCDePDW/Hfci4OjoGyW94zgzlnBhAMIH1wdywgmUKNRorXI0Mz6ADYxv/t1yQN7AzTsROckkTtDwzdo/IMvQOc20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703521244; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=vQCMpjZY1AQaj1d+gQdqXARuWNxcSp/SbY5pXlWxhCg=; b=A1V+UYsv8Cm204T1wz0skc1GhGrQ27/EAqqR/9WTePkKi5Zclj3bSo2OO/O+ln+0OY2VI0fJ9fhQRPWjEJonGKNBtmTkVeOynIeNGQUfzX8M7j30KGxTh8gHnlMpm0L4Yu/9iVftmuyTJkVBFiL+MtosfCJ24JB9ZOTdZxhvrCc= 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+112888+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1703521244072834.2084977365337; Mon, 25 Dec 2023 08:20:44 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=jkZnJ/8T/Z4PI3ZNyvD0/+qZ7HeB8h2vQ2TuQxo80Qk=; 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=1703521243; v=1; b=gpSk8oeL2sXWW4OgziLaJvldngcUNNcjIQZOCZU3J5s3C5uGTnL+rqIVdAlnifpk+6dEdcCd UHkz8aD/tJWQwCzhMfvYywhbBTuiAjCnHWWtwqVEvuYUmOTqvQ1XGXXJXlA617Zoy6zZYafstOG 4NVgok45yB/mCUXg6NmnygIU= X-Received: by 127.0.0.2 with SMTP id eXJ3YY1788612xJHlbZuA081; Mon, 25 Dec 2023 08:20:43 -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:43 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="375789614" X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="375789614" 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:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="26085428" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa001.jf.intel.com with ESMTP; 25 Dec 2023 08:20:41 -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 3/6] UefiCpuPkg/PiSmmCpuDxeSmm: Check SMM Debug Agent support or not Date: Tue, 26 Dec 2023 00:20:31 +0800 Message-Id: <20231225162034.2052-4-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: CSdHS2bTs37nXf7hMBWls80Hx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703521244530100013 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is to check SMM Debug Agent support or not before InitializeDebugAgent. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 4 +++- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 22 +++++++++++++--------- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 7 ++++++- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 1 + 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/= CpuS3.c index 0bae0e33f1..b14c289a27 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -835,11 +835,13 @@ SmmRestoreCpu ( ASSERT_EFI_ERROR (Status); =20 // // Initialize Debug Agent to support source level debug // - InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&I= a32Idtr, NULL); + if (mSmmDebugAgentSupport) { + InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)= &Ia32Idtr, NULL); + } } =20 mBspApicId =3D GetApicId (); // // Skip AP initialization if mAcpiCpuData is not valid diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 4fbb0bba87..324e85d6b5 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -474,14 +474,16 @@ BSPHandler ( // // Flag BSP's presence // *mSmmMpSyncData->InsideSmm =3D TRUE; =20 - // - // Initialize Debug Agent to start source level debug in BSP handler - // - InitializeDebugAgent (DEBUG_AGENT_INIT_ENTER_SMI, NULL, NULL); + if (mSmmDebugAgentSupport) { + // + // Initialize Debug Agent to start source level debug in BSP handler + // + InitializeDebugAgent (DEBUG_AGENT_INIT_ENTER_SMI, NULL, NULL); + } =20 // // Mark this processor's presence // *(mSmmMpSyncData->CpuData[CpuIndex].Present) =3D TRUE; @@ -646,15 +648,17 @@ BSPHandler ( // Wait for all APs to complete MTRR programming // SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); } =20 - // - // Stop source level debug in BSP handler, the code below will not be - // debugged. - // - InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL); + if (mSmmDebugAgentSupport) { + // + // Stop source level debug in BSP handler, the code below will not be + // debugged. + // + InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL); + } =20 // // Signal APs to Reset states/semaphore for this processor // ReleaseAllAPs (); diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.c index 209a2e4810..9b230772cb 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -110,10 +110,15 @@ BOOLEAN mSmmReadyToLock =3D FALSE; // // Global used to cache PCD for SMM Code Access Check enable // BOOLEAN mSmmCodeAccessCheckEnable =3D FALSE; =20 +// +// Global used to cache SMM Debug Agent Supported ot not +// +BOOLEAN mSmmDebugAgentSupport =3D FALSE; + // // Global copy of the PcdPteMemoryEncryptionAddressOrMask // UINT64 mAddressEncMask =3D 0; =20 @@ -895,11 +900,11 @@ PiCpuSmmEntry ( PiSmmCpuSmiEntryFixupAddress (); =20 // // Initialize Debug Agent to support source level debug in SMM code // - InitializeDebugAgent (DEBUG_AGENT_INIT_SMM, NULL, NULL); + InitializeDebugAgent (DEBUG_AGENT_INIT_SMM, &mSmmDebugAgentSupport, NULL= ); =20 // // Report the start of CPU SMM initialization. // REPORT_STATUS_CODE ( diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.h index a2fa4f6734..7f244ea803 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -481,10 +481,11 @@ extern UINTN mSemaphoreSize; extern SPIN_LOCK *mPFLock; extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock; extern EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges; extern UINTN mSmmCpuSmramRangeCount; extern UINT8 mPhysicalAddressBits; +extern BOOLEAN mSmmDebugAgentSupport; =20 // // Copy of the PcdPteMemoryEncryptionAddressOrMask // extern UINT64 mAddressEncMask; --=20 2.16.2.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 (#112888): https://edk2.groups.io/g/devel/message/112888 Mute This Topic: https://groups.io/mt/103360804/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- From nobody Wed May 15 13:36:19 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+112889+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+112889+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703521246; cv=none; d=zohomail.com; s=zohoarc; b=Ge1X+09d6z1FFaf/1GOREqpyibApv9fiiDaSbQ3SO3Rx3Sei4+Ul/LQMaalyze/3REhl4xbvCNDYIr7hPUCG9jQ63BiJe5s0D0Badk0+o7oYt9zH2LwZ7YGPxQAf5WDIqDAZ/KAdv3QLXzKrSLfPzXczemp6AbQ/Y1FtQl4KfvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703521246; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=xh7BfDZrEqQ0giKfitrU3Ubrux0cwFx3dv1uetqM6is=; b=AKhi/6oB4BlV/uGmWL6iS4PPbB/wV8C4bPfp4DHLl2GqSHG5Qo58qYErIAMtu9dzB7YOEfxe8W8O5WQpyigPCoBRYNFGv5ss3avk+jY2K87gGZU3r4p/6HXWRDR/d5KS3J1f/5rrU6U8AqjFzLvKRNWbLvoFK9lBtR6ZSswQXGg= 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+112889+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 170352124627355.21253433080972; Mon, 25 Dec 2023 08:20:46 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=xVvLXBsmqssDWijLq5fKxaYrCuE7hilRQ7WHTdS1yXg=; 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=Jf+k+gRIITjyLQkKSKW+q1TjwK1MNjgupV4lE9JwSD3Iq/f5TetdCa63YTY7sLNo9L+Qhe2H kTqQxao9wxnDKaOJLaC78ixcRhRLJC4minBQUD3G94W5bfTV27ldMN3WBjxoKZ+liMuuWKIV/30 UCbN7u5eYJJInP22CIKLbLSg= X-Received: by 127.0.0.2 with SMTP id j7aMYY1788612xXvN3Rmh4R2; 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: PkcNPp0ESLoQxt07RxUt6h0Kx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703521246590100017 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/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 =3D FALSE; ReleaseAllAPs (); =20 - // - // 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 (); =20 // // Restore OS MTRRs // SmmCpuFeaturesReenableSmrr (); MtrrSetAllMtrrs (&Mtrrs); - - // - // Wait for all APs to complete MTRR programming - // - SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); } =20 + // + // Wait for all APs to complete their pending tasks including MTRR progr= amming if needed. + // + SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); + if (mSmmDebugAgentSupport) { // // Stop source level debug in BSP handler, the code below will not be // debugged. // --=20 2.16.2.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 (#112889): https://edk2.groups.io/g/devel/message/112889 Mute This Topic: https://groups.io/mt/103360805/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- From nobody Wed May 15 13:36:19 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+112890+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+112890+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703521248; cv=none; d=zohomail.com; s=zohoarc; b=hniLT0ycxpimsvdms7N2plQZZgUhI7i2FZEiyuDyCpRM5PURh+tVzgQ8ilTwXm0ne0Q4VQKRj0KChlXF2biKJdGpWXMbjlvTSWPTd4CJP8vJQt0E3j2ddzs74sKI9E2++14fSQ2HredrhPV4zjTfsN5O5jfZZdK67q5J4RTqoKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703521248; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=IIc+d4c10JlRX/KAnP3tnF070XqLsXrZVtoZOzPaRhc=; b=fAHpktM7IAspoog0r2I1fJIcnCsoHHggYxEBryheNOoiNxR+vZVccXUNSAgo2JG/Y2vLqd0hJ/eaoI6BDBM0qs+A9RiKGovYk89e8Dsw/lypVF/Od1vISYBQN8fK+CO8I4pvUbBj4VuLY61BMF//J15BLcOWYoDhARamVIPyajk= 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+112890+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1703521248586914.3961237524204; Mon, 25 Dec 2023 08:20:48 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=n1pUjZj/dG9fnau6dFkXNAQrlE8lpgFJpcBMlTzLGvQ=; 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=1703521248; v=1; b=Xi6tIWCLqMfDSL/g7GIwsogr7K/IugafEFFkOHhYaipFq2xJGZJwbkJl9kkzEDJ6c7+8XODy wHBIgY3UZBPIldMIuHrCz8yjdU94hCbqcZlugsXEnARH0Vc5cfUA244qCfYWrcnt+5ILYQbW0bM Ed++Q0zNxH4FTT5/dD8qfMTE= X-Received: by 127.0.0.2 with SMTP id yLtTYY1788612xzPfHt6jk9s; Mon, 25 Dec 2023 08:20:48 -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:47 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="375789618" X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="375789618" 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:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="26085438" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa001.jf.intel.com with ESMTP; 25 Dec 2023 08:20:46 -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 5/6] UefiCpuPkg/PiSmmCpuDxeSmm: Invert ReleaseAllAPs & InitializeDebugAgent Date: Tue, 26 Dec 2023 00:20:33 +0800 Message-Id: <20231225162034.2052-6-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: 8IAz8GHzVpwGJp8ts7omyxqqx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703521250723100023 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Existing BSP handler stops source level debug, then call ReleaseAllAPs to tell all APs can reset the Present flag to FALSE: InitializeDebugAgent (); /// Stop source level debug ReleaseAllAPs (); /// Tell APs can reset "Present" flag. This patch is to invert ReleaseAllAPs & InitializeDebugAgent: ReleaseAllAPs (); /// Tell APs can reset "Present" flag. InitializeDebugAgent (); /// Stop source level debug After this change, there is no negative impact since SMM source level debug feature doesn't depend on AP's "Present" flag, no impact to the SMM source level debug capability. Instead, the change will benefit the AP source level debug capability to trace its "Present" flag change for SMI exit since the source level debug feature will be stopped after each AP has the chance to reset the state. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index bd2c9f841b..9aa9908863 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -648,23 +648,23 @@ BSPHandler ( // // Wait for all APs to complete their pending tasks including MTRR progr= amming if needed. // SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); =20 + // + // Signal APs to Reset states/semaphore for this processor + // + ReleaseAllAPs (); + if (mSmmDebugAgentSupport) { // // Stop source level debug in BSP handler, the code below will not be // debugged. // InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL); } =20 - // - // Signal APs to Reset states/semaphore for this processor - // - ReleaseAllAPs (); - // // Perform pending operations for hot-plug // SmmCpuUpdate (); =20 --=20 2.16.2.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 (#112890): https://edk2.groups.io/g/devel/message/112890 Mute This Topic: https://groups.io/mt/103360806/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- From nobody Wed May 15 13:36:19 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+112891+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+112891+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703521250; cv=none; d=zohomail.com; s=zohoarc; b=Pt4MI8epr4prjumz0Z9d8Ov79NVkww2I0BcgRtNKPWkIzAFe5FEwQQTZfb6xRXb9DCqLuhuKGkgMXv/L4Hx9HrcBRV4uqSP3Rh5OI6PL/LZOqtkDC4LwdFo4iGJzhfBEYxkWQxT9caN/a4Ha5klxGgIt4+q/81E3lo2ImJY+K+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703521250; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=4Je7KwDG9HK8Wu+JxWlYtxfYzEcv2WeZGfooXudVqyQ=; b=cK1vyEfQC4YpCc/Xo+KA5tzHSk5y4Tq3Fw6ra0UUpj6mWktZSkExDe9dTzATtNY+jXlJtyc2CQLKZP4W3Kk3iGATk55AvAcPtZ3bpBvRM0bbTUoeUln1cK19k+U6ROUT2xKPh10knu6FoqT3dr9+InxuGH104/ZBeXWEN7HKNW0= 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+112891+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1703521250888940.1500975486183; Mon, 25 Dec 2023 08:20:50 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=ZK1Ll6jT/WP7xnXIIADJCpLEypuIt9M56ozzmhPheCQ=; 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=1703521250; v=1; b=PLlCCq2fSRCUDoa15lndAg02JD0cFZuvdT5+H7wA5uZNR8VfrokfoUm4g4qlAPFFw3kLhn2t 7GmBYxgOAObb9ieOeEwFfbgWmRDog2GSPEjXlffiQhcrYU1A6Z2yEsJNki3r8/OO3igp3hfEM7t PnD5n7KShuxLPjyXpCzmJCyw= X-Received: by 127.0.0.2 with SMTP id qk3mYY1788612xs5K4zv8rGk; Mon, 25 Dec 2023 08:20:50 -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:50 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="375789620" X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="375789620" 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:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,303,1695711600"; d="scan'208";a="26085443" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa001.jf.intel.com with ESMTP; 25 Dec 2023 08:20:48 -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 6/6] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce one round BSP & AP sync Date: Tue, 26 Dec 2023 00:20:34 +0800 Message-Id: <20231225162034.2052-7-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: tlXKml2zB03dXErHAGcnQAH5x1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703521252804100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After BSP returned from SmmCoreEntry, there are several rounds BSP and AP sync in BSP handler: 1 .ReleaseAllAPs(); /// Notify all APs to exit. if (SmmCpuFeaturesNeedConfigureMtrrs()) { 2. SmmCpuSyncWaitForAPs(); /// Wait for all APs to program MTRRs. 3. ReleaseAllAPs(); /// Signal APs to restore MTRRs. } 4. SmmCpuSyncWaitForAPs(); /// Wait for all APs to complete pending tasks including MTRR. 5. ReleaseAllAPs(); /// Signal APs to Reset states. 6. SmmCpuSyncWaitForAPs(); /// Gather APs to exit SMM synchronously. Before step 6 and after step 5, BSP performs below items: A. InitializeDebugAgent() /// Stop source level debug. B. SmmCpuUpdate() /// Perform pending operations for hot-plug. C. Present =3D FALSE; /// Clear the Present flag of BSP. For InitializeDebugAgent(), BSP needs to wait all APs complete pending tasks and then notify all APs to stop source level debug. So, above step 4 & step 5 are required for InitializeDebugAgent(). For SmmCpuUpdate(), it's to perform pending operations for hot-plug CPUs take effect in next SMI. Existing APs in SMI do not reply on the CPU switch & hot-add & hot-remove operations. So, no need step 4 and step 5 for additional one round BSP & AP sync. Step 6 can make sure all APs are ready to exit SMM, then hot-plug operation can take effect in next SMI. For BSP "Present" flag, AP does not reply on it. No need step 4 and step 5 for additional one round BSP & AP sync. Based on above analysis, step 4 and step 5 are only required if need configure MTRR and support SMM source level debug. So, we can reduce one round BSP and AP sync if both are unsupported. With this change, SMI performance can be improved. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 36 +++++++++++++++++++------------= ---- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 9aa9908863..e988ce0542 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -643,19 +643,21 @@ BSPHandler ( // SmmCpuFeaturesReenableSmrr (); MtrrSetAllMtrrs (&Mtrrs); } =20 - // - // Wait for all APs to complete their pending tasks including MTRR progr= amming if needed. - // - SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); + if (SmmCpuFeaturesNeedConfigureMtrrs () || mSmmDebugAgentSupport) { + // + // Wait for all APs to complete their pending tasks including MTRR pro= gramming if needed. + // + SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); =20 - // - // Signal APs to Reset states/semaphore for this processor - // - ReleaseAllAPs (); + // + // Signal APs to Reset states/semaphore for this processor + // + ReleaseAllAPs (); + } =20 if (mSmmDebugAgentSupport) { // // Stop source level debug in BSP handler, the code below will not be // debugged. @@ -894,19 +896,21 @@ APHandler ( // SmmCpuFeaturesReenableSmrr (); MtrrSetAllMtrrs (&Mtrrs); } =20 - // - // Notify BSP the readiness of this AP to Reset states/semaphore for thi= s processor - // - SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); + if (SmmCpuFeaturesNeedConfigureMtrrs () || mSmmDebugAgentSupport) { + // + // Notify BSP the readiness of this AP to Reset states/semaphore for t= his processor + // + SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); =20 - // - // Wait for the signal from BSP to Reset states/semaphore for this proce= ssor - // - SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); + // + // Wait for the signal from BSP to Reset states/semaphore for this pro= cessor + // + SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); + } =20 // // Reset states/semaphore for this processor // *(mSmmMpSyncData->CpuData[CpuIndex].Present) =3D FALSE; --=20 2.16.2.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 (#112891): https://edk2.groups.io/g/devel/message/112891 Mute This Topic: https://groups.io/mt/103360807/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-