summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2024-06-26 16:04:50 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-28 15:25:27 +0000
commit3690d30a6e3cdc4f159bae74a88d6e201e3d69f6 (patch)
tree5fa38654f38120b29c4ec9ff175b6516f521fc96 /UefiCpuPkg
parent0593183d764e63ffd07807213300bbfe1702d079 (diff)
downloadedk2-3690d30a6e3cdc4f159bae74a88d6e201e3d69f6.tar.gz
edk2-3690d30a6e3cdc4f159bae74a88d6e201e3d69f6.tar.bz2
edk2-3690d30a6e3cdc4f159bae74a88d6e201e3d69f6.zip
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>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c18
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c32
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h13
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c7
4 files changed, 70 insertions, 0 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c
index 8dbcd8d950..27f159b98c 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c
@@ -461,6 +461,24 @@ GetSmmProfileData (
}
/**
+ 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.
@param[in] Address the address to be checked
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c
index 8c5286b744..70e94a6b76 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c
@@ -47,6 +47,38 @@ GetSmmProfileData (
}
/**
+ 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.
@param[in] Address the address to be checked
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h
index 44bf3f3aba..73ace4efa4 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h
@@ -980,6 +980,19 @@ GetSmmProfileData (
);
/**
+ 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.
@param[in] Address the address to be checked
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index a5253e8167..f56d2849de 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -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