Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 7b3b39a2e4bdb0f216d539fa1271c49063c49df2
      
https://github.com/tianocore/edk2/commit/7b3b39a2e4bdb0f216d539fa1271c49063c49df2
  Author: Jiaxin Wu <[email protected]>
  Date:   2023-12-26 (Tue, 26 Dec 2023)

  Changed paths:
    M SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c

  Log Message:
  -----------
  SourceLevelDebugPkg/Library: Indicate SMM Debug Agent support or not

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 <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: c7c2de798a50acf796ad36f7e99cc548a743368c
      
https://github.com/tianocore/edk2/commit/c7c2de798a50acf796ad36f7e99cc548a743368c
  Author: Jiaxin Wu <[email protected]>
  Date:   2023-12-26 (Tue, 26 Dec 2023)

  Changed paths:
    M MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c

  Log Message:
  -----------
  MdeModulePkg/DebugAgentLibNull: Indicate SMM Debug Agent support or not

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 <[email protected]>
Cc: Liming Gao <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: e1b62f3e28a95847c6ab23ae3a07a640d7e300cf
      
https://github.com/tianocore/edk2/commit/e1b62f3e28a95847c6ab23ae3a07a640d7e300cf
  Author: Jiaxin Wu <[email protected]>
  Date:   2023-12-26 (Tue, 26 Dec 2023)

  Changed paths:
    M UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
    M UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
    M UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
    M UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h

  Log Message:
  -----------
  UefiCpuPkg/PiSmmCpuDxeSmm: Check SMM Debug Agent support or not

This patch is to check SMM Debug Agent support or not before
InitializeDebugAgent.

Cc: Laszlo Ersek <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 3a4ec6de01209a0310a6e4c63d6941e7a592a457
      
https://github.com/tianocore/edk2/commit/3a4ec6de01209a0310a6e4c63d6941e7a592a457
  Author: Jiaxin Wu <[email protected]>
  Date:   2023-12-26 (Tue, 26 Dec 2023)

  Changed paths:
    M UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

  Log Message:
  -----------
  UefiCpuPkg/PiSmmCpuDxeSmm: Align BSP and AP sync logic for SMI exit

Below piece of code is the BSP and AP sync logic for SMI exit.
1. AP after finish the scheduled procedure:
  if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
    SmmCpuSyncReleaseBsp ();
    SmmCpuSyncWaitForBsp ();
    ...
  }
  SmmCpuSyncReleaseBsp ();
  SmmCpuSyncWaitForBsp ();
  SmmCpuSyncReleaseBsp ();

2. BSP after return from SmmCoreEntry:
  SmmCpuSyncWaitForAPs ();
  if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
    ReleaseAllAPs ();
    ...
    SmmCpuSyncWaitForAPs ();
  }
  ReleaseAllAPs ();
  SmmCpuSyncWaitForAPs();

This patch is to make BSP same as AP sync logic:
  if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
    SmmCpuSyncWaitForAPs ();
    ReleaseAllAPs ();
    ...
  }
  SmmCpuSyncWaitForAPs ();
  ReleaseAllAPs ();
  SmmCpuSyncWaitForAPs();

With the change, 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 <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 41d1c4475b91760982c48403047adeb0a3cb1141
      
https://github.com/tianocore/edk2/commit/41d1c4475b91760982c48403047adeb0a3cb1141
  Author: Jiaxin Wu <[email protected]>
  Date:   2023-12-26 (Tue, 26 Dec 2023)

  Changed paths:
    M UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

  Log Message:
  -----------
  UefiCpuPkg/PiSmmCpuDxeSmm: Invert ReleaseAllAPs & InitializeDebugAgent

Existing BSP handler stops source level debug, then call ReleaseAllAPs
to tell all APs can reset the Present flag to FALSE:
  InitializeDebugAgent (); /// Stop source level debug
  ReleaseAllAPs ();        /// Tell APs can reset "Present" flag.

This patch is to invert ReleaseAllAPs & InitializeDebugAgent:
  ReleaseAllAPs ();        /// Tell APs can reset "Present" flag.
  InitializeDebugAgent (); /// Stop source level debug

After this change, there is no negative impact since SMM source level
debug feature doesn't depend on AP's "Present" flag, no impact to the
SMM source level debug capability.

Instead, the change will benefit the AP source level debug capability
to trace its "Present" flag change for SMI exit since the source
level debug feature will be stopped after each AP has the chance to
reset the state.

Cc: Laszlo Ersek <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 58d94639390803e375a7d16c94a5a527ec158474
      
https://github.com/tianocore/edk2/commit/58d94639390803e375a7d16c94a5a527ec158474
  Author: Jiaxin Wu <[email protected]>
  Date:   2023-12-26 (Tue, 26 Dec 2023)

  Changed paths:
    M UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

  Log Message:
  -----------
  UefiCpuPkg/PiSmmCpuDxeSmm: Reduce one round BSP & AP sync

After BSP returned from SmmCoreEntry, there are several rounds BSP
and AP sync in BSP handler:

1 .ReleaseAllAPs();  /// Notify all APs to exit.
if (SmmCpuFeaturesNeedConfigureMtrrs()) {
  2. SmmCpuSyncWaitForAPs(); /// Wait for all APs to program MTRRs.
  3. ReleaseAllAPs(); /// Signal APs to restore MTRRs.
}

4. SmmCpuSyncWaitForAPs(); /// Wait for all APs to complete pending
                               tasks including MTRR.
5. ReleaseAllAPs(); /// Signal APs to Reset states.

6. SmmCpuSyncWaitForAPs(); /// Gather APs to exit SMM synchronously.

Before step 6 and after step 5, BSP performs below items:
A. InitializeDebugAgent() /// Stop source level debug.
B. SmmCpuUpdate() /// Perform pending operations for hot-plug.
C. Present = FALSE; /// Clear the Present flag of BSP.

For InitializeDebugAgent(), BSP needs to wait all APs complete
pending tasks and then notify all APs to stop source level debug.
So, above step 4 & step 5 are required for InitializeDebugAgent().

For SmmCpuUpdate(), it's to perform pending operations for
hot-plug CPUs take effect in next SMI. Existing APs in SMI do not
reply on the CPU switch & hot-add & hot-remove operations. So, no
need step 4 and step 5 for additional one round BSP & AP sync.
Step 6 can make sure all APs are ready to exit SMM, then hot-plug
operation can take effect in next SMI.

For BSP "Present" flag, AP does not reply on it. No need step 4
and step 5 for additional one round BSP & AP sync.

Based on above analysis, step 4 and step 5 are only required if
need configure MTRR and support SMM source level debug. So, we can
reduce one round BSP and AP sync if both are unsupported. With
this change, SMI performance can be improved.

Cc: Laszlo Ersek <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


Compare: https://github.com/tianocore/edk2/compare/54c662845f5d...58d946393908


_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to