From cae90a83907d5f9e10c45cd2985bab1fafc47f56 Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Wed, 31 Jul 2024 13:48:47 +0800 Subject: [PATCH] UefiCpuPkg: Remove duplicate code in SmiPfHandler In this commit, we remove duplicate CpuDeadLoop in SmiPfHandler where mCpuSmmRestrictedMemoryAccess is TRUE. With last commit, we always call CpuDeadLoop if SMM profile is disabled. Then the CpuDeadLoop calling for the condition (mCpuSmmRestrictedMemoryAccess && IsSmmCommBufferForbiddenAddress (PFAddress)) is not needed anymore. We also modify the IA32 related code to be aligned with X64. Signed-off-by: Dun Tan --- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c | 9 +++------ UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c index 5170be342f..a8f0b503c0 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c @@ -195,13 +195,7 @@ SmiPFHandler ( } if (IsSmmCommBufferForbiddenAddress (PFAddress)) { - DumpCpuContext (InterruptType, SystemContext); DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%x)!\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip); - ); - CpuDeadLoop (); - goto Exit; } } @@ -212,6 +206,9 @@ SmiPFHandler ( ); } else { DumpCpuContext (InterruptType, SystemContext); + DEBUG_CODE ( + DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip); + ); CpuDeadLoop (); } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c index 09a9c1c49f..a29bec55ea 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c @@ -966,13 +966,7 @@ SmiPFHandler ( } if (mCpuSmmRestrictedMemoryAccess && IsSmmCommBufferForbiddenAddress (PFAddress)) { - DumpCpuContext (InterruptType, SystemContext); DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%lx)!\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip); - ); - CpuDeadLoop (); - goto Exit; } } @@ -983,6 +977,9 @@ SmiPFHandler ( ); } else { DumpCpuContext (InterruptType, SystemContext); + DEBUG_CODE ( + DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip); + ); CpuDeadLoop (); }