From 9f8b5f3427be732357513d2784d17ae4e376401c Mon Sep 17 00:00:00 2001 From: Kun Qin Date: Wed, 6 Dec 2023 14:37:22 -0800 Subject: [PATCH 1/2] Fixing up a few prints --- .../UEFI/Dxe/App/DxePagingAuditTestApp.c | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c index bbfce0cf06..340e55edcf 100644 --- a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c +++ b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c @@ -1211,6 +1211,7 @@ ImageCodeSectionsRoDataSectionsXp ( BOOLEAN TestFailure; UINT64 SectionStart; UINT64 SectionEnd; + CHAR8 *PdbFileName; DEBUG ((DEBUG_INFO, "%a Enter...\n", __FUNCTION__)); @@ -1243,6 +1244,15 @@ ImageCodeSectionsRoDataSectionsXp ( } // Check PE/COFF image + PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase); + if (PdbFileName == NULL) { + DEBUG ((DEBUG_WARN, "%a Could not get name of image loaded at 0x%llx - 0x%llx...\n", + __func__, + (UINTN)LoadedImage->ImageBase, + (UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize + )); + } + DosHdr = (EFI_IMAGE_DOS_HEADER *)(UINTN)LoadedImage->ImageBase; PeCoffHeaderOffset = 0; if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { @@ -1260,7 +1270,8 @@ ImageCodeSectionsRoDataSectionsXp ( if (!IsLoadedImageSectionAligned (SectionAlignment, LoadedImage->ImageCodeType)) { UT_LOG_ERROR ( - "Image 0x%llx - 0x%llx is not aligned\n", + "Image %a: 0x%llx - 0x%llx is not aligned\n", + PdbFileName, (UINTN)LoadedImage->ImageBase, (UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize ); @@ -1287,7 +1298,8 @@ ImageCodeSectionsRoDataSectionsXp ( (EFI_IMAGE_SCN_CNT_INITIALIZED_DATA || EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA)) != 0)) { UT_LOG_ERROR ( - "Image Section 0x%llx-0x%llx contains code and data\n", + "Image %a: Section 0x%llx-0x%llx contains code and data\n", + PdbFileName, SectionStart, SectionEnd ); @@ -1313,7 +1325,8 @@ ImageCodeSectionsRoDataSectionsXp ( { if ((Attributes & EFI_MEMORY_RO) == 0) { UT_LOG_ERROR ( - "Image Section 0x%llx-0x%llx is not EFI_MEMORY_RO\n", + "Image %a: Section 0x%llx-0x%llx is not EFI_MEMORY_RO\n", + PdbFileName, SectionStart, SectionEnd ); @@ -1322,7 +1335,8 @@ ImageCodeSectionsRoDataSectionsXp ( } else { if ((Attributes & EFI_MEMORY_XP) == 0) { UT_LOG_ERROR ( - "Image Section 0x%llx-0x%llx is not EFI_MEMORY_XP\n", + "Image %a: Section 0x%llx-0x%llx is not EFI_MEMORY_XP\n", + PdbFileName, SectionStart, SectionEnd ); @@ -1377,7 +1391,7 @@ BspStackIsXpAndHasGuardPage ( StackBase = (EFI_PHYSICAL_ADDRESS)((MemoryHob->AllocDescriptor.MemoryBaseAddress / EFI_PAGE_SIZE) * EFI_PAGE_SIZE); StackLength = (EFI_PHYSICAL_ADDRESS)(EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (MemoryHob->AllocDescriptor.MemoryLength))); - UT_LOG_INFO ("BSP stack located at 0x%llx - 0x%llx", StackBase, StackBase + StackLength); + UT_LOG_INFO ("BSP stack located at 0x%llx - 0x%llx\n", StackBase, StackBase + StackLength); Attributes = 0; Status = GetRegionCommonAccessAttributes ( @@ -1545,7 +1559,7 @@ DxePagingAuditTestAppEntryPoint ( ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a Could not retrieve command line args!\n", __FUNCTION__)); + DEBUG ((DEBUG_ERROR, "%a Could not retrieve command line args!\n", __FUNCTION__)); return EFI_PROTOCOL_ERROR; } @@ -1563,13 +1577,13 @@ DxePagingAuditTestAppEntryPoint ( } } else { if (StrnCmp (ShellParams->Argv[1], L"-h", MAX_CHARS_TO_READ) != 0) { - DEBUG ((DEBUG_INFO, "Invalid argument!\n")); + DEBUG ((DEBUG_ERROR, "Invalid argument!\n")); } - DEBUG ((DEBUG_INFO, "-h : Print available flags\n")); - DEBUG ((DEBUG_INFO, "-d : Dump the page table files\n")); - DEBUG ((DEBUG_INFO, "-r : Run the application tests\n")); - DEBUG ((DEBUG_INFO, "NOTE: Combined flags (i.e. -rd) is not supported\n")); + Print (L"-h : Print available flags\n"); + Print (L"-d : Dump the page table files\n"); + Print (L"-r : Run the application tests\n"); + Print (L"NOTE: Combined flags (i.e. -rd) is not supported\n"); } } From 6f0b4d8edb2e2a6543eba86d24e5f1bf69684b29 Mon Sep 17 00:00:00 2001 From: Kun Qin Date: Fri, 8 Dec 2023 12:19:54 -0800 Subject: [PATCH 2/2] Fixing uncrustify --- .../PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c index 340e55edcf..5be101ff0d 100644 --- a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c +++ b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c @@ -1246,11 +1246,13 @@ ImageCodeSectionsRoDataSectionsXp ( // Check PE/COFF image PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase); if (PdbFileName == NULL) { - DEBUG ((DEBUG_WARN, "%a Could not get name of image loaded at 0x%llx - 0x%llx...\n", - __func__, - (UINTN)LoadedImage->ImageBase, - (UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize - )); + DEBUG (( + DEBUG_WARN, + "%a Could not get name of image loaded at 0x%llx - 0x%llx...\n", + __func__, + (UINTN)LoadedImage->ImageBase, + (UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize + )); } DosHdr = (EFI_IMAGE_DOS_HEADER *)(UINTN)LoadedImage->ImageBase;