From nobody Sat May 4 21:19:48 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495516791952140.62865138877294; Mon, 22 May 2017 22:19:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 04C8F21A134B8; Mon, 22 May 2017 22:19:50 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3BA0721A16E47 for ; Mon, 22 May 2017 22:19:48 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2017 22:19:47 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.20]) by FMSMGA003.fm.intel.com with ESMTP; 22 May 2017 22:19:46 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,380,1491289200"; d="scan'208";a="860246380" From: Star Zeng To: edk2-devel@lists.01.org Date: Tue, 23 May 2017 13:19:43 +0800 Message-Id: <1495516783-73172-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [PATCH] MdeModulePkg SmiHandlerProfile: Use fixed data type in data structure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D568 Use fixed data type in data structure and make the structure be natural aligned. Without this update, the code must assume DXE and SMM are using same data type (same size of UINTN), but it may be not true at some case, for example, after standalone SMM feature is enabled. With this update, the data structure will be phase independent and convenient for consumer to parse the data. Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng --- .../SmiHandlerProfileInfo/SmiHandlerProfileInfo.c | 14 +-- MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c | 115 ++++++++++++++---= ---- MdeModulePkg/Include/Guid/SmiHandlerProfile.h | 41 ++++---- 3 files changed, 104 insertions(+), 66 deletions(-) diff --git a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfi= leInfo.c b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfile= Info.c index 338671374c72..96e9977aad0c 100644 --- a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c +++ b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c @@ -348,9 +348,9 @@ DumpSmmLoadedImage( if (ImageStruct->Header.Signature =3D=3D SMM_CORE_IMAGE_DATABASE_SIGNA= TURE) { NameString =3D GetDriverNameString (ImageStruct); Print(L" ImageBase, I= mageStruct->ImageSize); + Print(L" Base=3D\"0x%lx\" Size=3D\"0x%lx\"", ImageStruct->ImageBase,= ImageStruct->ImageSize); if (ImageStruct->EntryPoint !=3D 0) { - Print(L" EntryPoint=3D\"0x%x\"", ImageStruct->EntryPoint); + Print(L" EntryPoint=3D\"0x%lx\"", ImageStruct->EntryPoint); } Print(L" FvFile=3D\"%g\"", &ImageStruct->FileGuid); Print(L" RefId=3D\"0x%x\"", ImageStruct->ImageRef); @@ -540,7 +540,7 @@ DumpSmiChildContext ( CHAR16 *Str; =20 if (CompareGuid (HandlerType, &gEfiSmmSwDispatch2ProtocolGuid)) { - Print(L" SwSmi=3D\"0x%x\"", ((EFI_SMM_SW_REGISTER_CONTEXT *)Context)->= SwSmiInputValue); + Print(L" SwSmi=3D\"0x%lx\"", ((SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT= *)Context)->SwSmiInputValue); } else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid)) { Print(L" SxType=3D\"%a\"", SxTypeToString(((EFI_SMM_SX_REGISTER_CONTEX= T *)Context)->Type)); Print(L" SxPhase=3D\"%a\"", SxPhaseToString(((EFI_SMM_SX_REGISTER_CONT= EXT *)Context)->Phase)); @@ -609,14 +609,14 @@ DumpSmiHandler( Print(L" %a\n", (UINT8 *)ImageStruct + ImageStru= ct->PdbStringOffset); } Print(L" \n"); - Print(L" \n", SmiHandlerStruct->H= andler); + Print(L" \n", SmiHandlerStruct->= Handler); if (ImageStruct !=3D NULL) { - Print(L" 0x%x\n", SmiHandlerStruct->Handler -= ImageStruct->ImageBase); + Print(L" 0x%x\n", (UINTN) (SmiHandlerStruct->= Handler - ImageStruct->ImageBase)); } Print(L" \n", SmiHandlerStruct->Handler); - Print(L" \n", SmiHandlerStruct->Ca= llerAddr); + Print(L" \n", SmiHandlerStruct->C= allerAddr); if (ImageStruct !=3D NULL) { - Print(L" 0x%x\n", SmiHandlerStruct->CallerAdd= r - ImageStruct->ImageBase); + Print(L" 0x%x\n", (UINTN) (SmiHandlerStruct->= CallerAddr - ImageStruct->ImageBase)); } Print(L" \n", SmiHandlerStruct->Handler); SmiHandlerStruct =3D (VOID *)((UINTN)SmiHandlerStruct + SmiHandler= Struct->Length); diff --git a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c b/MdeModulePkg= /Core/PiSmmCore/SmiHandlerProfile.c index 49eba945fd9a..3a031183b81f 100644 --- a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c +++ b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c @@ -33,14 +33,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 #include "PiSmmCore.h" =20 +#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \ + ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((= Alignment) - 1))) + typedef struct { - EFI_GUID FileGuid; - UINTN ImageRef; - UINTN EntryPoint; - UINTN ImageBase; - UINTN ImageSize; - UINTN PdbStringSize; - CHAR8 *PdbString; + EFI_GUID FileGuid; + PHYSICAL_ADDRESS EntryPoint; + PHYSICAL_ADDRESS ImageBase; + UINT64 ImageSize; + UINT32 ImageRef; + UINT16 PdbStringSize; + CHAR8 *PdbString; } IMAGE_STRUCT; =20 /** @@ -89,8 +92,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED LIST_ENTRY *mSmmCoreSm= iEntryList =3D &mSmiEntry GLOBAL_REMOVE_IF_UNREFERENCED LIST_ENTRY *mSmmCoreHardwareSmiEntryLis= t =3D &mHardwareSmiEntryList; =20 GLOBAL_REMOVE_IF_UNREFERENCED IMAGE_STRUCT *mImageStruct; -GLOBAL_REMOVE_IF_UNREFERENCED UINTN mImageStructCountMax; -GLOBAL_REMOVE_IF_UNREFERENCED UINTN mImageStructCount; +GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mImageStructCountMax; +GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mImageStructCount; =20 GLOBAL_REMOVE_IF_UNREFERENCED VOID *mSmiHandlerProfileDatabase; GLOBAL_REMOVE_IF_UNREFERENCED UINTN mSmiHandlerProfileDatabaseSize; @@ -162,11 +165,11 @@ GetDriverGuid ( **/ VOID AddImageStruct( - IN UINTN ImageBase, - IN UINTN ImageSize, - IN UINTN EntryPoint, - IN EFI_GUID *Guid, - IN CHAR8 *PdbString + IN PHYSICAL_ADDRESS ImageBase, + IN UINT64 ImageSize, + IN PHYSICAL_ADDRESS EntryPoint, + IN EFI_GUID *Guid, + IN CHAR8 *PdbString ) { UINTN PdbStringSize; @@ -185,7 +188,7 @@ AddImageStruct( PdbStringSize =3D AsciiStrSize(PdbString); mImageStruct[mImageStructCount].PdbString =3D AllocateCopyPool (PdbStr= ingSize, PdbString); if (mImageStruct[mImageStructCount].PdbString !=3D NULL) { - mImageStruct[mImageStructCount].PdbStringSize =3D PdbStringSize; + mImageStruct[mImageStructCount].PdbStringSize =3D (UINT16) PdbString= Size; } } =20 @@ -222,7 +225,7 @@ AddressToImageStruct( =20 @return image reference index **/ -UINTN +UINT32 AddressToImageRef( IN UINTN Address ) @@ -252,11 +255,11 @@ GetSmmLoadedImage( EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; CHAR16 *PathStr; EFI_SMM_DRIVER_ENTRY *LoadedImagePrivate; - UINTN EntryPoint; + PHYSICAL_ADDRESS EntryPoint; VOID *EntryPointInImage; EFI_GUID Guid; CHAR8 *PdbString; - UINTN RealImageBase; + PHYSICAL_ADDRESS RealImageBase; =20 HandleBufferSize =3D 0; HandleBuffer =3D NULL; @@ -286,7 +289,7 @@ GetSmmLoadedImage( } =20 NoHandles =3D HandleBufferSize/sizeof(EFI_HANDLE); - mImageStructCountMax =3D NoHandles; + mImageStructCountMax =3D (UINT32) NoHandles; mImageStruct =3D AllocateZeroPool(mImageStructCountMax * sizeof(IMAGE_ST= RUCT)); if (mImageStruct =3D=3D NULL) { goto Done; @@ -309,8 +312,8 @@ GetSmmLoadedImage( LoadedImagePrivate =3D BASE_CR(LoadedImage, EFI_SMM_DRIVER_ENTRY, SmmL= oadedImage); RealImageBase =3D (UINTN)LoadedImage->ImageBase; if (LoadedImagePrivate->Signature =3D=3D EFI_SMM_DRIVER_ENTRY_SIGNATUR= E) { - EntryPoint =3D (UINTN)LoadedImagePrivate->ImageEntryPoint; - if ((EntryPoint !=3D 0) && ((EntryPoint < (UINTN)LoadedImage->ImageB= ase) || (EntryPoint >=3D ((UINTN)LoadedImage->ImageBase + (UINTN)LoadedImag= e->ImageSize)))) { + EntryPoint =3D LoadedImagePrivate->ImageEntryPoint; + if ((EntryPoint !=3D 0) && ((EntryPoint < (UINTN)LoadedImage->ImageB= ase) || (EntryPoint >=3D ((UINTN)LoadedImage->ImageBase + LoadedImage->Imag= eSize)))) { // // If the EntryPoint is not in the range of image buffer, it shoul= d come from emulation environment. // So patch ImageBuffer here to align the EntryPoint. @@ -320,9 +323,9 @@ GetSmmLoadedImage( RealImageBase =3D (UINTN)LoadedImage->ImageBase + EntryPoint - (UI= NTN)EntryPointInImage; } } - DEBUG ((DEBUG_INFO, "(0x%x - 0x%x", RealImageBase, (UINTN)LoadedImage-= >ImageSize)); + DEBUG ((DEBUG_INFO, "(0x%lx - 0x%lx", RealImageBase, LoadedImage->Imag= eSize)); if (EntryPoint !=3D 0) { - DEBUG ((DEBUG_INFO, ", EntryPoint:0x%x", EntryPoint)); + DEBUG ((DEBUG_INFO, ", EntryPoint:0x%lx", EntryPoint)); } DEBUG ((DEBUG_INFO, ")\n")); =20 @@ -334,7 +337,7 @@ GetSmmLoadedImage( } DEBUG ((DEBUG_INFO, " (%s)\n", PathStr)); =20 - AddImageStruct((UINTN)RealImageBase, (UINTN)LoadedImage->ImageSize, En= tryPoint, &Guid, PdbString); + AddImageStruct(RealImageBase, LoadedImage->ImageSize, EntryPoint, &Gui= d, PdbString); } =20 Done: @@ -359,7 +362,7 @@ DumpSmiChildContext ( CHAR16 *Str; =20 if (CompareGuid (HandlerType, &gEfiSmmSwDispatch2ProtocolGuid)) { - DEBUG ((DEBUG_INFO, " SwSmi - 0x%x\n", ((EFI_SMM_SW_REGISTER_CONTEXT = *)Context)->SwSmiInputValue)); + DEBUG ((DEBUG_INFO, " SwSmi - 0x%lx\n", ((SMI_HANDLER_PROFILE_SW_REGI= STER_CONTEXT *)Context)->SwSmiInputValue)); } else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid)) { DEBUG ((DEBUG_INFO, " SxType - 0x%x\n", ((EFI_SMM_SX_REGISTER_CONTEXT= *)Context)->Type)); DEBUG ((DEBUG_INFO, " SxPhase - 0x%x\n", ((EFI_SMM_SX_REGISTER_CONTEX= T *)Context)->Phase)); @@ -422,12 +425,12 @@ DumpSmiHandlerOnSmiEntry( } DEBUG ((DEBUG_INFO, " Handler - 0x%x", SmiHandler->Handler)); if (ImageStruct !=3D NULL) { - DEBUG ((DEBUG_INFO, " <=3D=3D RVA - 0x%x", (UINTN)SmiHandler->Handle= r - ImageStruct->ImageBase)); + DEBUG ((DEBUG_INFO, " <=3D=3D RVA - 0x%x", (UINTN)SmiHandler->Handle= r - (UINTN) ImageStruct->ImageBase)); } DEBUG ((DEBUG_INFO, "\n")); DEBUG ((DEBUG_INFO, " CallerAddr - 0x%x", SmiHandler->CallerAddr)); if (ImageStruct !=3D NULL) { - DEBUG ((DEBUG_INFO, " <=3D=3D RVA - 0x%x", SmiHandler->CallerAddr - = ImageStruct->ImageBase)); + DEBUG ((DEBUG_INFO, " <=3D=3D RVA - 0x%x", SmiHandler->CallerAddr - = (UINTN) ImageStruct->ImageBase)); } DEBUG ((DEBUG_INFO, "\n")); } @@ -533,11 +536,11 @@ GetSmmImageDatabaseSize( ) { UINTN Size; - UINTN Index; + UINT32 Index; =20 - Size =3D (sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE)) * mImageStructCount; + Size =3D 0; for (Index =3D 0; Index < mImageStructCount; Index++) { - Size +=3D mImageStruct[Index].PdbStringSize; + Size +=3D sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE) + GET_OCCUPIED_SIZ= E (mImageStruct[Index].PdbStringSize, sizeof (UINT64)); } return Size; } @@ -564,7 +567,7 @@ GetSmmSmiHandlerSizeOnSmiEntry( ListEntry !=3D &SmiEntry->SmiHandlers; ListEntry =3D ListEntry->ForwardLink) { SmiHandler =3D CR(ListEntry, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE); - Size +=3D sizeof(SMM_CORE_SMI_HANDLER_STRUCTURE) + SmiHandler->Context= Size; + Size +=3D sizeof(SMM_CORE_SMI_HANDLER_STRUCTURE) + GET_OCCUPIED_SIZE (= SmiHandler->ContextSize, sizeof (UINT64)); } =20 return Size; @@ -640,11 +643,11 @@ GetSmmImageDatabaseData ( if (Size >=3D ExpectedSize) { return 0; } - if (sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE) + mImageStruct[Index].Pd= bStringSize > ExpectedSize - Size) { + if (sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE) + GET_OCCUPIED_SIZE (mIm= ageStruct[Index].PdbStringSize, sizeof (UINT64)) > ExpectedSize - Size) { return 0; } ImageStruct->Header.Signature =3D SMM_CORE_IMAGE_DATABASE_SIGNATURE; - ImageStruct->Header.Length =3D (UINT32)(sizeof(SMM_CORE_IMAGE_DATABASE= _STRUCTURE) + mImageStruct[Index].PdbStringSize); + ImageStruct->Header.Length =3D (UINT32)(sizeof(SMM_CORE_IMAGE_DATABASE= _STRUCTURE) + GET_OCCUPIED_SIZE (mImageStruct[Index].PdbStringSize, sizeof = (UINT64))); ImageStruct->Header.Revision =3D SMM_CORE_IMAGE_DATABASE_REVISION; CopyGuid(&ImageStruct->FileGuid, &mImageStruct[Index].FileGuid); ImageStruct->ImageRef =3D mImageStruct[Index].ImageRef; @@ -658,7 +661,7 @@ GetSmmImageDatabaseData ( ImageStruct->PdbStringOffset =3D 0; } ImageStruct =3D (SMM_CORE_IMAGE_DATABASE_STRUCTURE *)((UINTN)ImageStru= ct + ImageStruct->Header.Length); - Size +=3D sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE) + mImageStruct[Ind= ex].PdbStringSize; + Size +=3D sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE) + GET_OCCUPIED_SIZ= E (mImageStruct[Index].PdbStringSize, sizeof (UINT64)); } =20 if (ExpectedSize !=3D Size) { @@ -682,7 +685,7 @@ GetSmmSmiHandlerDataOnSmiEntry( IN SMI_ENTRY *SmiEntry, IN OUT VOID *Data, IN UINTN MaxSize, - OUT UINTN *Count + OUT UINT32 *Count ) { SMM_CORE_SMI_HANDLER_STRUCTURE *SmiHandlerStruct; @@ -702,11 +705,11 @@ GetSmmSmiHandlerDataOnSmiEntry( *Count =3D 0; return 0; } - if (sizeof(SMM_CORE_SMI_HANDLER_STRUCTURE) + SmiHandler->ContextSize >= MaxSize - Size) { + if (sizeof(SMM_CORE_SMI_HANDLER_STRUCTURE) + GET_OCCUPIED_SIZE (SmiHan= dler->ContextSize, sizeof (UINT64)) > MaxSize - Size) { *Count =3D 0; return 0; } - SmiHandlerStruct->Length =3D (UINT32)(sizeof(SMM_CORE_SMI_HANDLER_STRU= CTURE) + SmiHandler->ContextSize); + SmiHandlerStruct->Length =3D (UINT32)(sizeof(SMM_CORE_SMI_HANDLER_STRU= CTURE) + GET_OCCUPIED_SIZE (SmiHandler->ContextSize, sizeof (UINT64))); SmiHandlerStruct->CallerAddr =3D (UINTN)SmiHandler->CallerAddr; SmiHandlerStruct->Handler =3D (UINTN)SmiHandler->Handler; SmiHandlerStruct->ImageRef =3D AddressToImageRef((UINTN)SmiHandler->Ha= ndler); @@ -717,7 +720,7 @@ GetSmmSmiHandlerDataOnSmiEntry( } else { SmiHandlerStruct->ContextBufferOffset =3D 0; } - Size +=3D sizeof(SMM_CORE_SMI_HANDLER_STRUCTURE) + SmiHandler->Context= Size; + Size +=3D sizeof(SMM_CORE_SMI_HANDLER_STRUCTURE) + GET_OCCUPIED_SIZE (= SmiHandler->ContextSize, sizeof (UINT64)); SmiHandlerStruct =3D (SMM_CORE_SMI_HANDLER_STRUCTURE *)((UINTN)SmiHand= lerStruct + SmiHandlerStruct->Length); *Count =3D *Count + 1; } @@ -748,7 +751,7 @@ GetSmmSmiDatabaseData( SMI_ENTRY *SmiEntry; UINTN Size; UINTN SmiHandlerSize; - UINTN SmiHandlerCount; + UINT32 SmiHandlerCount; =20 SmiStruct =3D Data; Size =3D 0; @@ -1133,6 +1136,36 @@ ConvertSmiHandlerUsbContext ( } =20 /** + Convert EFI_SMM_SW_REGISTER_CONTEXT to SMI_HANDLER_PROFILE_SW_REGISTER_C= ONTEXT. + + @param SwContext A pointer to EFI_SMM_SW_REGISTER_CON= TEXT + @param SwContextSize The size of EFI_SMM_SW_REGISTER_CONT= EXT in bytes + @param SmiHandlerSwContextSize The size of SMI_HANDLER_PROFILE_SW_R= EGISTER_CONTEXT in bytes + + @return SmiHandlerSwContext A pointer to SMI_HANDLER_PROFILE_SW_REGIST= ER_CONTEXT +**/ +SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT * +ConvertSmiHandlerSwContext ( + IN EFI_SMM_SW_REGISTER_CONTEXT *SwContext, + IN UINTN SwContextSize, + OUT UINTN *SmiHandlerSwContextSize + ) +{ + SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT *SmiHandlerSwContext; + + ASSERT (SwContextSize =3D=3D sizeof(EFI_SMM_SW_REGISTER_CONTEXT)); + + SmiHandlerSwContext =3D AllocatePool (sizeof (SMI_HANDLER_PROFILE_SW_REG= ISTER_CONTEXT)); + if (SmiHandlerSwContext =3D=3D NULL) { + *SmiHandlerSwContextSize =3D 0; + return NULL; + } + SmiHandlerSwContext->SwSmiInputValue =3D SwContext->SwSmiInputValue; + *SmiHandlerSwContextSize =3D sizeof (SMI_HANDLER_PROFILE_SW_REGISTER_CON= TEXT); + return SmiHandlerSwContext; +} + +/** This function is called by SmmChildDispatcher module to report a new SMI handler is registered, to SmmCore. =20 @@ -1186,6 +1219,8 @@ SmiHandlerProfileRegisterHandler ( if (Context !=3D NULL) { if (CompareGuid (HandlerGuid, &gEfiSmmUsbDispatch2ProtocolGuid)) { SmiHandler->Context =3D ConvertSmiHandlerUsbContext (Context, Contex= tSize, &SmiHandler->ContextSize); + } else if (CompareGuid (HandlerGuid, &gEfiSmmSwDispatch2ProtocolGuid))= { + SmiHandler->Context =3D ConvertSmiHandlerSwContext (Context, Context= Size, &SmiHandler->ContextSize); } else { SmiHandler->Context =3D AllocateCopyPool (ContextSize, Context); } @@ -1261,6 +1296,8 @@ SmiHandlerProfileUnregisterHandler ( if (Context !=3D NULL) { if (CompareGuid (HandlerGuid, &gEfiSmmUsbDispatch2ProtocolGuid)) { SearchContext =3D ConvertSmiHandlerUsbContext (Context, ContextSize,= &SearchContextSize); + } else if (CompareGuid (HandlerGuid, &gEfiSmmSwDispatch2ProtocolGuid))= { + SearchContext =3D ConvertSmiHandlerSwContext (Context, ContextSize, = &SearchContextSize); } } =20 diff --git a/MdeModulePkg/Include/Guid/SmiHandlerProfile.h b/MdeModulePkg/I= nclude/Guid/SmiHandlerProfile.h index c5d29e889234..ba41393cf2e2 100644 --- a/MdeModulePkg/Include/Guid/SmiHandlerProfile.h +++ b/MdeModulePkg/Include/Guid/SmiHandlerProfile.h @@ -25,12 +25,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include =20 -#pragma pack(1) - typedef struct { UINT32 Signature; UINT32 Length; UINT32 Revision; + UINT8 Reserved[4]; } SMM_CORE_DATABASE_COMMON_HEADER; =20 #define SMM_CORE_IMAGE_DATABASE_SIGNATURE SIGNATURE_32 ('S','C','I','D') @@ -39,12 +38,12 @@ typedef struct { typedef struct { SMM_CORE_DATABASE_COMMON_HEADER Header; EFI_GUID FileGuid; - UINTN ImageRef; - UINTN EntryPoint; - UINTN ImageBase; - UINTN ImageSize; + PHYSICAL_ADDRESS EntryPoint; + PHYSICAL_ADDRESS ImageBase; + UINT64 ImageSize; + UINT32 ImageRef; UINT16 PdbStringOffset; - UINT8 Reserved2[6]; + UINT8 Reserved[2]; //CHAR8 PdbString[]; } SMM_CORE_IMAGE_DATABASE_STRUCTURE; =20 @@ -64,7 +63,7 @@ typedef enum { // NULL // Context for SmmCoreSmiHandlerCategoryHardwareHandler: // (NOTE: The context field should NOT include any data pointer.) -// gEfiSmmSwDispatch2ProtocolGuid: EFI_SMM_SW_REGISTER_CONTEXT +// gEfiSmmSwDispatch2ProtocolGuid: (EFI_SMM_SW_REGISTER_CONTE= XT =3D> SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT) // gEfiSmmSxDispatch2ProtocolGuid: EFI_SMM_SX_REGISTER_CONTEXT // gEfiSmmPowerButtonDispatch2ProtocolGuid: EFI_SMM_POWER_BUTTON_REGIS= TER_CONTEXT // gEfiSmmStandbyButtonDispatch2ProtocolGuid: EFI_SMM_STANDBY_BUTTON_REG= ISTER_CONTEXT @@ -81,21 +80,25 @@ typedef struct { } SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT; =20 typedef struct { - UINT32 Length; - UINTN CallerAddr; - UINTN Handler; - UINTN ImageRef; - UINT16 ContextBufferOffset; - UINT8 Reserved2[2]; - UINT32 ContextBufferSize; -//UINT8 ContextBuffer[]; + UINT64 SwSmiInputValue; +} SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT; + +typedef struct { + UINT32 Length; + UINT32 ImageRef; + PHYSICAL_ADDRESS CallerAddr; + PHYSICAL_ADDRESS Handler; + UINT16 ContextBufferOffset; + UINT8 Reserved[2]; + UINT32 ContextBufferSize; +//UINT8 ContextBuffer[]; } SMM_CORE_SMI_HANDLER_STRUCTURE; =20 typedef struct { SMM_CORE_DATABASE_COMMON_HEADER Header; - UINT32 HandlerCategory; EFI_GUID HandlerType; - UINTN HandlerCount; + UINT32 HandlerCategory; + UINT32 HandlerCount; //SMM_CORE_SMI_HANDLER_STRUCTURE Handler[HandlerCount]; } SMM_CORE_SMI_DATABASE_STRUCTURE; =20 @@ -144,8 +147,6 @@ typedef struct { =20 #define SMI_HANDLER_PROFILE_GUID {0x49174342, 0x7108, 0x409b, {0x8b, 0xbe,= 0x65, 0xfd, 0xa8, 0x53, 0x89, 0xf5}} =20 -#pragma pack() - extern EFI_GUID gSmiHandlerProfileGuid; =20 typedef struct _SMI_HANDLER_PROFILE_PROTOCOL SMI_HANDLER_PROFILE_PROTOCOL; --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel