From nobody Mon Feb 9 17:37:36 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+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-