UefiCpuPkg/PiSmmCpuDxeSmm: Move GetSmiCommandPort into DxeSmm Code

MM can not call the EfiLocateFirstAcpiTable(), so, move the
function into DxeSmm Code. This will make InitSmmProfileCallBack()
to be common function for both SMM and MM.

Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
This commit is contained in:
Jiaxin Wu 2024-06-25 01:00:26 +08:00 committed by mergify[bot]
parent abc2f59523
commit 9d9bbb6f5f
5 changed files with 35 additions and 29 deletions

View File

@ -40,8 +40,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/SmmCpuPlatformHookLib.h>
#include <Library/MmServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/DebugAgentLib.h>
#include <Library/UefiLib.h>
#include <Library/HobLib.h>

View File

@ -10,6 +10,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "PiSmmCpuCommon.h"
#include <Library/UefiBootServicesTableLib.h>
/**
To get system port address of the SMI Command Port in FADT table.
**/
VOID
GetSmiCommandPort (
VOID
)
{
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)EfiLocateFirstAcpiTable (
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
);
ASSERT (Fadt != NULL);
mSmiCommandPort = Fadt->SmiCmd;
DEBUG ((DEBUG_INFO, "mSmiCommandPort = %x\n", mSmiCommandPort));
}
/**
SMM Ready To Lock event notification handler.
@ -36,6 +57,16 @@ SmmReadyToLockEventNotify (
//
GetUefiMemoryMap ();
//
// Skip SMM profile initialization if feature is disabled
//
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
//
// Get Software SMI from FADT
//
GetSmiCommandPort ();
}
//
// Set SMM ready to lock flag and return
//

View File

@ -678,26 +678,6 @@ InitPaging (
PERF_FUNCTION_END ();
}
/**
To get system port address of the SMI Command Port in FADT table.
**/
VOID
GetSmiCommandPort (
VOID
)
{
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)EfiLocateFirstAcpiTable (
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
);
ASSERT (Fadt != NULL);
mSmiCommandPort = Fadt->SmiCmd;
DEBUG ((DEBUG_INFO, "mSmiCommandPort = %x\n", mSmiCommandPort));
}
/**
Updates page table to make some memory ranges (like system memory) absent
and make some memory ranges (like MMIO) present and execute disable. It also
@ -757,11 +737,6 @@ InitSmmProfileCallBack (
&mSmmProfileBase
);
//
// Get Software SMI from FADT
//
GetSmiCommandPort ();
//
// Initialize protected memory range for patching page table later.
//

View File

@ -130,5 +130,9 @@ extern BOOLEAN mXdEnabled;
// The flag indicates if #DB will be setup in #PF handler.
//
extern BOOLEAN mSetupDebugTrap;
//
// SMI command port.
//
extern UINT32 mSmiCommandPort;
#endif // _SMM_PROFILE_H_

View File

@ -11,8 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define _SMM_PROFILE_INTERNAL_H_
#include <Protocol/SmmReadyToLock.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/CpuLib.h>
#include <IndustryStandard/Acpi.h>