From nobody Mon May 13 20:46:22 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+112792+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+112792+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703125296; cv=none; d=zohomail.com; s=zohoarc; b=h+LG3ptgk3X9VNfmBbxNTRPya5q6YVNO4kbQkBdscturgkKzSWORfpgWW93Yzt2ro3uF23dUUv7cOBueNuKm6cOdkKWPDfDZjgxdkVBVbTuUd2p/S4fGVYC7AlbIhF4ThVBkS5A/AUDPH9UHxap5DYFk+S+kj+l9dYswXli4rPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703125296; 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=dcTx4D6YsiapQTGz9Gs377Ob281tMlV4udHmZMIhgs0=; b=MmT5VPKc7pITHuP9bfWUwBHdSqCL6unyjU6HHy4W72JxZykNgMzaMEnoq/TPx2jclDZ2KWEkcld195G+C5enjsFuWgHVDG8ZsHe+1jWggvDgKKg5jMXpHzMxP3BG1Xpzmw0ODRnT+nc7kuksWFINl/6lEtfmmRvtmgeR1QPG9Ng= 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+112792+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 1703125296546807.2531008135064; Wed, 20 Dec 2023 18:21:36 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=4t1N3VQ+CaBYkz47NjC9FF5CZKINShf3SMlaM0RlVzc=; 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=1703125296; v=1; b=R9XdYovPdhVmuJM4kRu6gXv00Y6SfU5sIUSSZv8EFECxfgq43/DFpEapgOAwd7xZEO0HgGNW lNngoku1QsAGrYC44tjs56hr3uBaLUqju0+94J3YQ7Zt0sTFrUCTzuhdxynN71Zm1hppenjrwd3 XTgRffkGA5+6rd8A+i591VDQ= X-Received: by 127.0.0.2 with SMTP id ugk3YY1788612xaU9cZhtXyF; Wed, 20 Dec 2023 18:21:36 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.43419.1703125294908514900 for ; Wed, 20 Dec 2023 18:21:35 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="14591361" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="14591361" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 18:21:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="920172797" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="920172797" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2023 18:21:25 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ray Ni Subject: [edk2-devel] [PATCH v1 1/6] SourceLevelDebugPkg/Library: Indicate SMM Debug Agent support or not Date: Thu, 21 Dec 2023 10:21:16 +0800 Message-Id: <20231221022121.12224-2-jiaxin.wu@intel.com> In-Reply-To: <20231221022121.12224-1-jiaxin.wu@intel.com> References: <20231221022121.12224-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: UPeo6jPo6DmZUWI5JAIBMnt0x1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703125297741100009 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch use the Context to indicate SMM Debug Agent support or not if InitFlag is DEBUG_AGENT_INIT_SMM. Context must be the pointer to the BOOLEAN value 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..1648c2b33e 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 be + the pointer to the BOOLEAN value if it's not NULL, which indicates SMM D= ebug + Agent supported 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 (#112792): https://edk2.groups.io/g/devel/message/112792 Mute This Topic: https://groups.io/mt/103293798/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 Mon May 13 20:46:22 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+112793+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+112793+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703125296; cv=none; d=zohomail.com; s=zohoarc; b=jf+VvDVkjE+EDUW94796YbgYuiZE0pyvELnDYZrTcJdsKkmCJFnkMz2yRAJJIm83knC+vP0Jkid+Co0fyb29ZbsHae07tQqMgDELoD7G7DcQp+gBWAiY+VjIgjh/Cy/J3dKlWJxk5Vxlf1DvHAYyNN41H+PVSOFtProQMvVjrqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703125296; 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=uP3i8XBYMitatLyG0wLdao0/7OtI0idQVVFzCv58E8c=; b=ZR/FZ9z0MB7wxUZXuM3pOF428HyGGCFV9Jt5gwKXHmrlSLq5Si9GDryXumFUzLeR36kXsfmIH5ENI/jv5XESNjAReeTlFiBmFJoQxClUXbTd0K9VQYgoNivAECE+OziHu3Em31F8a8vM93rWLZ1KFX5WrEivOppUpvK8ZagnuXs= 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+112793+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 1703125296526953.5814255018795; Wed, 20 Dec 2023 18:21:36 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=iYR8/2yz6ce2z7vAQlw7OcMbNEDs+fe+AlYNQ6Fe+3A=; 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=1703125296; v=1; b=dx4kyic1yYt1o9HWHINYH6P2ob7qDDlvB8g3c/g6B3Hl63mSrqKzDW8TeHpcH6v71Sxhv0M2 /rJTS5yby8n/Iyq8tzVtjZGG7STDWntUPtqbDv/hFSvT3U+I9JVP+uKedkmfYjByq/7CFLH+OBI 9e4oEyk1MTuwGYO2gl6PAam0= X-Received: by 127.0.0.2 with SMTP id wpC4YY1788612xHma5Ktnl3h; Wed, 20 Dec 2023 18:21:36 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web11.43008.1703125294459311440 for ; Wed, 20 Dec 2023 18:21:35 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="14591365" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="14591365" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 18:21:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="920172805" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="920172805" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2023 18:21:26 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ray Ni , Liming Gao Subject: [edk2-devel] [PATCH v1 2/6] MdeModulePkg/DebugAgentLibNull: Indicate SMM Debug Agent support or not Date: Thu, 21 Dec 2023 10:21:17 +0800 Message-Id: <20231221022121.12224-3-jiaxin.wu@intel.com> In-Reply-To: <20231221022121.12224-1-jiaxin.wu@intel.com> References: <20231221022121.12224-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: fpVbgmBhZpycXkNjQWXXZJqOx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703125297740100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch use the Context to indicate SMM Debug Agent support or not if InitFlag is DEBUG_AGENT_INIT_SMM. Context must be the pointer to the BOOLEAN value 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..a7f4945c03 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 be the pointer to the = BOOLEAN + value 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 (#112793): https://edk2.groups.io/g/devel/message/112793 Mute This Topic: https://groups.io/mt/103293799/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 Mon May 13 20:46:22 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+112794+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+112794+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703125297; cv=none; d=zohomail.com; s=zohoarc; b=PfM1iWO1Vn2Jb4YaVLI87RA/mp59V+IIUnEqPIqBLuDjGTmJjdq6AyPgG7MLSj4KWRYq30pmeVxTRU11FQK+Md5uvbCyCfznE3ZRTrMyrLrNdqiKGBjHCv1NIN2HfvpuTCEu9DZFMhUFSHh0kEcRIEQeINmph0EeKF/s9j7XqTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703125297; 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=56s3DCbrC4lQlHCG13F/g7yqQ5Gxy1oFK4q0I5QB5MY=; b=eEndWCyRyO1wTeMz/1jriM5Lk8+HBz4djCvXJ+zH+svhgiih1FCWbJRv2fSVdZK7ncZex+P3XPvZwquBoK2KIJOzZZHLGiSjytQBSTAvd2hBFQ6PzS/rUV6x7Gw6eA8h0p8KG1DaNFFaRp9UqS5rMnMWmxnIeecm7zspihqcOKQ= 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+112794+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 1703125297415835.9774610697367; Wed, 20 Dec 2023 18:21:37 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=mEdj3nxSbY1g/grc7jmQpdjPxUW6MgsbV9BCqxdz5OQ=; 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=1703125297; v=1; b=o9M2jfKj/O65mUzIvS2gGMMs8lf0ioe3SjDMugCnVlg671rT902P7mphYLNDtyho3zpgQpxz 2/odf94jBO+M3/ex8wHVo4agIPHfEMYLa08GMcT8aOlmmrfHOZs9xqB+bb6DMfBZJ7AIOIcRbSz rKwR9AUAqjCBatPIl5FY2pYU= X-Received: by 127.0.0.2 with SMTP id 0Z1QYY1788612xk0QKlTc0ql; Wed, 20 Dec 2023 18:21:37 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.43419.1703125294908514900 for ; Wed, 20 Dec 2023 18:21:35 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="14591370" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="14591370" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 18:21:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="920172810" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="920172810" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2023 18:21:27 -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 v1 3/6] UefiCpuPkg/PiSmmCpuDxeSmm: Check SMM Debug Agent support or not Date: Thu, 21 Dec 2023 10:21:18 +0800 Message-Id: <20231221022121.12224-4-jiaxin.wu@intel.com> In-Reply-To: <20231221022121.12224-1-jiaxin.wu@intel.com> References: <20231221022121.12224-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: 387ZVvAWGQ8vz5REKJBt6SaXx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703125297763100011 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 --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 4 +++- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 22 +++++++++++++--------- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 14 +++++++++++++- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 1 + 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/= CpuS3.c index 0bae0e33f1..13b5a302ee 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..408ee8a87d 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..006aa038bb 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 NULL; + // // Global copy of the PcdPteMemoryEncryptionAddressOrMask // UINT64 mAddressEncMask =3D 0; =20 @@ -894,12 +899,19 @@ PiCpuSmmEntry ( PiSmmCpuSmmInitFixupAddress (); PiSmmCpuSmiEntryFixupAddress (); =20 // // Initialize Debug Agent to support source level debug in SMM code + // Allocate the memory for SMM Debug Agent Support check, and to make su= re it + // survives from S3. // - InitializeDebugAgent (DEBUG_AGENT_INIT_SMM, NULL, NULL); + mSmmDebugAgentSupport =3D AllocatePool (sizeof (BOOLEAN)); + if (mSmmDebugAgentSupport =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + 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..cf452ea3c2 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 (#112794): https://edk2.groups.io/g/devel/message/112794 Mute This Topic: https://groups.io/mt/103293800/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 Mon May 13 20:46:22 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+112795+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+112795+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703125297; cv=none; d=zohomail.com; s=zohoarc; b=gcDNIU3XtvvHBq+/A6MMLTwFprruU5IBKFnUkRLo3yW/cOL2uQEZkD4b2f9J7HTEuDqTuawRPuIg2g6JqtPEcbALETs/PE7pEIB9i7kGqcW9WmWp1N4djJCH5KnQRfZDg3UOgRH9ducItV3wWx4JvsMuCVbDs/2Xp++ruOVYTw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703125297; 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=dMWLjXtn6lz0ny6bvN9lZjOR80PMIbqDNek+Q5dDwE4=; b=EkeBiVJumDhR9dGEgU01QD07xquM392B1YF+qZhol4wNIlhS58D4fUx/A0q4nbyaq9FNOiPj6Id5VJZSoMtz7gtC95e71E7VyL2vtN2OpMJbs39eJOLuaFOw2L4SyaoTcLDac++irqp29L+Qu3B68fbwABTAAqEz+A/yAU/jycA= 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+112795+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 1703125297387438.8138953842421; Wed, 20 Dec 2023 18:21:37 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=SJ/Cr1BF74SxyUFKg8wH3tyjAXBiLNa10iCTqaDeuWc=; 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=1703125297; v=1; b=Kk1EwDJiI5lfaL0GinHY5FiraCS0TPbyzgiz1J8PmQ35yHesWUTalw+BnTjFt2UYSFEtljy/ z6ic5grRnYKYe44yptJXn+roOi2TB4ttXbnD0jDZmqFYsi/cNr7DuJoZHEWHL0mV4elkk4r5FO1 dwGZPxu1KPFcAkKRLHcBny1o= X-Received: by 127.0.0.2 with SMTP id bCMTYY1788612xYHtkkUV3er; Wed, 20 Dec 2023 18:21:37 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web11.43008.1703125294459311440 for ; Wed, 20 Dec 2023 18:21:35 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="14591373" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="14591373" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 18:21:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="920172816" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="920172816" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2023 18:21:30 -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 v1 4/6] UefiCpuPkg/PiSmmCpuDxeSmm: Align MTRR sync logic between BSP and AP Date: Thu, 21 Dec 2023 10:21:19 +0800 Message-Id: <20231221022121.12224-5-jiaxin.wu@intel.com> In-Reply-To: <20231221022121.12224-1-jiaxin.wu@intel.com> References: <20231221022121.12224-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: vNGzVcyj17jlsSy0YBWqXpzpx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703125297741100008 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Below piece of code is to sync logic in AP for MTRR programming: if (SmmCpuFeaturesNeedConfigureMtrrs ()) { SmmCpuSyncReleaseBsp (); SmmCpuSyncWaitForBsp (); ... } SmmCpuSyncReleaseBsp (); SmmCpuSyncWaitForBsp (); This patch is to make BSP sync logic same as above coding style: if (SmmCpuFeaturesNeedConfigureMtrrs ()) { SmmCpuSyncWaitForAPs (); ReleaseAllAPs (); ... } SmmCpuSyncWaitForAPs (); ReleaseAllAPs (); With the changes, 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/PiSmmCpuDxe= Smm/MpService.c index 408ee8a87d..8e525ce3b3 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 (#112795): https://edk2.groups.io/g/devel/message/112795 Mute This Topic: https://groups.io/mt/103293801/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 Mon May 13 20:46:22 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+112796+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+112796+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703125297; cv=none; d=zohomail.com; s=zohoarc; b=W1wzDB2fAIE6AjmoeSmkuAeCT1ysadAGyNTZaMgWVU0me6tlVagfaWYpBWvbozFjyEDaKMsNic0PAHN95S/soFe0YAR5ntU4mfLB9O5wtnsw5wUFnx/5qMHcilZIWwh3Hc0+uH+HioeqJ/YHn90NfGqM2ulbvWNyh/gmpfb3RqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703125297; 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=Layl+inh2pIh0RwRsuYK/xjrhd2y+279ZFH8Yj165WQ=; b=KLOyTGxO1w5lRgUD+Eu6R0n6t46XpmfbNlv3IGignVIi4srE0qAODhJuObtFGNupDDwiF+CqXEEfIJUtHWRrRG3BM83GF0u3GDLpGVtefU1enx2powUKaIhA9ok0acEWH+v5dal/pc68a05FubC6Eah37pLK0it5hFKNLlZNbZw= 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+112796+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 1703125297827483.2537062491067; Wed, 20 Dec 2023 18:21:37 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=qNUuo53jdOqrgYPkDjHlXvt+fMm1Gex+A1GJYzdfi9U=; 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=1703125297; v=1; b=rOzbTU62oX+CzSmEjs8B2swDHkN/a8UVIM14EppRAoKbFgvL/uMAzNq/O8XYsGaROfrieUQP Adfr2cLMJgFrMplwv8S+PDlcPzYjbBhGlNnpDu+RBRarOKnurWQKLup/NeI3DM/6mScGAckwW4K 7oIt1jDTEtElZjY5GawyWyT8= X-Received: by 127.0.0.2 with SMTP id Blo3YY1788612xe9LCOFAer4; Wed, 20 Dec 2023 18:21:37 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.43419.1703125294908514900 for ; Wed, 20 Dec 2023 18:21:35 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="14591375" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="14591375" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 18:21:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="920172821" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="920172821" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2023 18:21:32 -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 v1 5/6] UefiCpuPkg/PiSmmCpuDxeSmm: Invert ReleaseAllAPs & InitializeDebugAgent Date: Thu, 21 Dec 2023 10:21:20 +0800 Message-Id: <20231221022121.12224-6-jiaxin.wu@intel.com> In-Reply-To: <20231221022121.12224-1-jiaxin.wu@intel.com> References: <20231221022121.12224-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: 15S67CO0oBaI2vw2yYfokXGMx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703125299760100023 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Below BSP & AP sync flow before exit SMI is to: 1. Make sure BSP and all APs finish the MTRR programming and start later executing the same start line. This is the MTRR programming requirement. 2. Make sure all APs finish the pending tasks, then BSP can stop source level debug. BSP: SmmCpuSyncWaitForAPs <-- AP: SmmCpuSyncReleaseBsp BSP: ReleaseAllAPs --> AP: SmmCpuSyncWaitForBsp For SMM source level debug, it doesn't depend on the AP Present flag set. So we can invert ReleaseAllAPs & InitializeDebugAgent. 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 8e525ce3b3..04622c66a2 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 (#112796): https://edk2.groups.io/g/devel/message/112796 Mute This Topic: https://groups.io/mt/103293802/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 Mon May 13 20:46:22 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+112797+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+112797+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703125298; cv=none; d=zohomail.com; s=zohoarc; b=RpuvMtbHb13TZkohDF823vf4Tc3j1FxEkqKKSpY4SoKPGwlg+jPTE5PAkupN/nXNawpOJOxRZglGM8bGQsqPPb3C+pqcE3xuuBlgugi6ZmrbJrucY7sxiEL1dBppV5IXileIGZzmMSwlwqlZgAPcbG5rwj3dAUypAYKBkl2vDwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703125298; 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=EGb88oeq/1Sc6RQV6YIfIR7VrZ/uhmfr3RWTJOW5qLk=; b=dSkmiscmIzYncRSgWYzvzQjrXGwQsttdKqZs+ZxMhUDH3gUigAD5taRaJxoXl0gvhlg6uOa3VmNLo/91x9AHLzeqvK8QLsXuw8HIVU8p6Vo4tnVqB11uNhdsIanQvsJknHe4yEffhGUt2K5nfz1MJmeTZg0sY1RLNZaANdl5CkQ= 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+112797+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 1703125298197489.9389706305218; Wed, 20 Dec 2023 18:21:38 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=pnJIoc2Ndp0o2C8gUUpdzV+aKbRLCtu07pPQpIjxvR8=; 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=1703125297; v=1; b=mkvgkfHhtNNB0MtdXuZjq0C3DbZ0APm3wkX6EeLV/2CNMQR4APh5DZhgQ5gBEwwej9riQ7C2 vo/TBm7+gWomeBf2pMDSdpjOMMXjkFJ8A6fwgLL9PrehLzcgMqUX6eJ2aJwoplacjsJIMnMIdZp hSNV1DMQHgRKtS79VU2c1xb4= X-Received: by 127.0.0.2 with SMTP id 4oyuYY1788612xaNOkTKKkWS; Wed, 20 Dec 2023 18:21:37 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web11.43009.1703125296922723837 for ; Wed, 20 Dec 2023 18:21:36 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="14591379" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="14591379" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 18:21:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="920172826" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="920172826" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2023 18:21:34 -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 v1 6/6] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce one round BSP & AP sync Date: Thu, 21 Dec 2023 10:21:21 +0800 Message-Id: <20231221022121.12224-7-jiaxin.wu@intel.com> In-Reply-To: <20231221022121.12224-1-jiaxin.wu@intel.com> References: <20231221022121.12224-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: q7G8wACs495hX9sEYI51dROfx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703125299764100024 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" One round BSP & AP sync for exit SMI is shown as below: BSP: SmmCpuSyncWaitForAPs <-- AP: SmmCpuSyncReleaseBsp BSP: ReleaseAllAPs --> AP: SmmCpuSyncWaitForBsp Above is only required if need configure MTRR and support SMM source level debug, So, reduce one round BSP & AP sync if both are unsupported. 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 | 36 +++++++++++++++++++------------= ---- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 04622c66a2..d0139228bb 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 (#112797): https://edk2.groups.io/g/devel/message/112797 Mute This Topic: https://groups.io/mt/103293803/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-