public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: devel@edk2.groups.io
Cc: Ray Ni <ray.ni@intel.com>
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	[thread overview]
Message-ID: <20231225162034.2052-2-jiaxin.wu@intel.com> (raw)
In-Reply-To: <20231225162034.2052-1-jiaxin.wu@intel.com>

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 <ray.ni@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
---
 .../Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c    | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.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.
 
   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 HOB,
   it it exists, debug agent wiil copied it into the local Mailbox in SMM space.
-  it will override IDT table entries and initialize debug port. Context will be
-  NULL.
+  it will override IDT table entries and initialize debug port. Context must
+  point to a BOOLEAN if it's not NULL, which indicates SMM Debug 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.
 
@@ -203,29 +204,32 @@ InitializeDebugAgent (
                         (VOID *)&mVectorHandoffInfoDebugAgent[0],
                         sizeof (EFI_VECTOR_HANDOFF_INFO) * mVectorHandoffInfoCount
                         );
       if (EFI_ERROR (Status)) {
         DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
+        *(BOOLEAN *)Context = FALSE;
         CpuDeadLoop ();
       }
 
       //
       // Check if Debug Agent initialized in DXE phase
       //
       Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
       if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) {
         VerifyMailboxChecksum (Mailbox);
-        mMailboxPointer = Mailbox;
+        mMailboxPointer     = Mailbox;
+        *(BOOLEAN *)Context = TRUE;
         break;
       }
 
       //
       // Check if Debug Agent initialized in SEC/PEI phase
       //
       Mailbox = GetMailboxFromHob ();
       if (Mailbox != NULL) {
-        mMailboxPointer = Mailbox;
+        mMailboxPointer     = Mailbox;
+        *(BOOLEAN *)Context = TRUE;
         break;
       }
 
       //
       // 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_IDT_GATE_DESCRIPTOR));
 
+      *(BOOLEAN *)Context = TRUE;
+
       break;
 
     case DEBUG_AGENT_INIT_ENTER_SMI:
       SaveDebugRegister ();
       if (!mSmmDebugIdtInitFlag) {
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-12-25 16:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-25 16:20 [edk2-devel] [PATCH v2 0/6] Reduce one round BSP & AP sync Wu, Jiaxin
2023-12-25 16:20 ` Wu, Jiaxin [this message]
2023-12-26  2:17   ` [edk2-devel] [PATCH v2 1/6] SourceLevelDebugPkg/Library: Indicate SMM Debug Agent support or not Ni, Ray
2023-12-25 16:20 ` [edk2-devel] [PATCH v2 2/6] MdeModulePkg/DebugAgentLibNull: " Wu, Jiaxin
2023-12-26  2:18   ` Ni, Ray
2023-12-25 16:20 ` [edk2-devel] [PATCH v2 3/6] UefiCpuPkg/PiSmmCpuDxeSmm: Check " Wu, Jiaxin
2023-12-26  2:18   ` Ni, Ray
2023-12-25 16:20 ` [edk2-devel] [PATCH v2 4/6] UefiCpuPkg/PiSmmCpuDxeSmm: Align BSP and AP sync logic for SMI exit Wu, Jiaxin
2023-12-26  2:19   ` Ni, Ray
2023-12-25 16:20 ` [edk2-devel] [PATCH v2 5/6] UefiCpuPkg/PiSmmCpuDxeSmm: Invert ReleaseAllAPs & InitializeDebugAgent Wu, Jiaxin
2023-12-26  2:21   ` Ni, Ray
2023-12-25 16:20 ` [edk2-devel] [PATCH v2 6/6] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce one round BSP & AP sync Wu, Jiaxin
2023-12-26  5:02   ` Ni, Ray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231225162034.2052-2-jiaxin.wu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox