UefiCpuPkg/PiSmmCpuDxeSmm: Check logging PF address for MM

This patch is to make sure only logging PF address for MM
can run into the SmmProfilePFHandler.

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-26 16:04:50 +08:00 committed by mergify[bot]
parent 0593183d76
commit 3690d30a6e
4 changed files with 70 additions and 0 deletions

View File

@ -460,6 +460,24 @@ GetSmmProfileData (
return Base;
}
/**
Return if the Address is the NonMmram logging Address.
@param[in] Address the address to be checked
@return TRUE The address is the NonMmram logging Address.
@return FALSE The address is not the NonMmram logging Address.
**/
BOOLEAN
IsNonMmramLoggingAddress (
IN UINT64 Address
)
{
ASSERT (FALSE);
return TRUE;
}
/**
Return if the Address is forbidden as SMM communication buffer.

View File

@ -46,6 +46,38 @@ GetSmmProfileData (
return SmmProfileDataHob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress;
}
/**
Return if the Address is the NonMmram logging Address.
@param[in] Address the address to be checked
@return TRUE The address is the NonMmram logging Address.
@return FALSE The address is not the NonMmram logging Address.
**/
BOOLEAN
IsNonMmramLoggingAddress (
IN UINT64 Address
)
{
EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
while (Hob.Raw != NULL) {
if ((Address >= Hob.ResourceDescriptor->PhysicalStart) && (Address < Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength)) {
if ((Hob.ResourceDescriptor->ResourceAttribute & MM_RESOURCE_ATTRIBUTE_LOGGING) != 0) {
return TRUE;
}
return FALSE;
}
Hob.Raw = GET_NEXT_HOB (Hob);
Hob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);
}
return FALSE;
}
/**
Return if the Address is forbidden as SMM communication buffer.

View File

@ -979,6 +979,19 @@ GetSmmProfileData (
IN OUT UINT64 *Size
);
/**
Return if the Address is the NonMmram logging Address.
@param[in] Address the address to be checked
@return TRUE The address is the NonMmram logging Address.
@return FALSE The address is not the NonMmram logging Address.
**/
BOOLEAN
IsNonMmramLoggingAddress (
IN UINT64 Address
);
/**
Return if the Address is forbidden as SMM communication buffer.

View File

@ -821,6 +821,13 @@ SmiPFHandler (
}
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
if (mIsStandaloneMm) {
//
// Only logging ranges shall run here in MM env.
//
ASSERT (IsNonMmramLoggingAddress (PFAddress));
}
SmmProfilePFHandler (
SystemContext.SystemContextX64->Rip,
SystemContext.SystemContextX64->ExceptionData