From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 07BC37803CE for ; Mon, 25 Dec 2023 16:20:44 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=f2eu9CYtS8VWhPgsnrTzIa3o2J9oxwm2S5Yd+AiNBng=; 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=a/lfJt7xfhL6J7DQB7m1xjh7sDQQDH/TTB0tRQhVGsOk1ZT1K7tiAJhxl+AYRJwY13fA+zjV XjEOIvHvieOrNwlSU+AET12MnZY0eeMEB1PYm8gSRkYQ1ahmXArKGYAcwMVy/6AAQYB4ayzGu43 rLqkO6DHXmHSgpRie38Xb5CM= X-Received: by 127.0.0.2 with SMTP id BiHNYY7687511xAQQqf55gDP; 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: p7vVnC5rAJOT3YdAmSsG1gMAx7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="a/lfJt7x"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 | 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); // // Initialize Debug Agent to support source level debug // - InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&Ia32Idtr, NULL); + if (mSmmDebugAgentSupport) { + InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&Ia32Idtr, NULL); + } } mBspApicId = GetApicId (); // // Skip AP initialization if mAcpiCpuData is not valid diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/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 = TRUE; - // - // 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); + } // // Mark this processor's presence // *(mSmmMpSyncData->CpuData[CpuIndex].Present) = TRUE; @@ -646,15 +648,17 @@ BSPHandler ( // Wait for all APs to complete MTRR programming // SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); } - // - // 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); + } // // Signal APs to Reset states/semaphore for this processor // ReleaseAllAPs (); diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 209a2e4810..9b230772cb 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -110,10 +110,15 @@ BOOLEAN mSmmReadyToLock = FALSE; // // Global used to cache PCD for SMM Code Access Check enable // BOOLEAN mSmmCodeAccessCheckEnable = FALSE; +// +// Global used to cache SMM Debug Agent Supported ot not +// +BOOLEAN mSmmDebugAgentSupport = FALSE; + // // Global copy of the PcdPteMemoryEncryptionAddressOrMask // UINT64 mAddressEncMask = 0; @@ -895,11 +900,11 @@ PiCpuSmmEntry ( PiSmmCpuSmiEntryFixupAddress (); // // 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); // // Report the start of CPU SMM initialization. // REPORT_STATUS_CODE ( diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/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; // // Copy of the PcdPteMemoryEncryptionAddressOrMask // extern UINT64 mAddressEncMask; -- 2.16.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-