From nobody Mon Feb 9 15:10:53 2026 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-