From: qwang12 Date: Mon, 19 Mar 2007 09:05:41 +0000 (+0000) Subject: Change the EfiAquireLock with RaiseTPL as the call to Boot Service UnloadImage can... X-Git-Tag: edk2-stable201903~23409 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=b06af5d71ec9fc353b9433a26fc55d14077f7cde Change the EfiAquireLock with RaiseTPL as the call to Boot Service UnloadImage can be nested in another call to UnloadImage. So RaiseTPL is proper (EfiAcquireLock will ASSERT when these this API are nested in the call chain) in this situation to server the sychronization purposes. The same change has been done to Boot Service Exit with the same reason applied. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2486 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/EdkModulePkg/Core/Dxe/Image/Image.c b/EdkModulePkg/Core/Dxe/Image/Image.c index f1b2c7a105..3696400072 100644 --- a/EdkModulePkg/Core/Dxe/Image/Image.c +++ b/EdkModulePkg/Core/Dxe/Image/Image.c @@ -24,9 +24,6 @@ Abstract: // Module Globals // -EFI_LOCK mBsExitLock = EFI_INITIALIZE_LOCK_VARIABLE(EFI_TPL_NOTIFY); -EFI_LOCK mBsUnloadImageLock = EFI_INITIALIZE_LOCK_VARIABLE(EFI_TPL_NOTIFY); - LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL; LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = { @@ -1221,9 +1218,14 @@ Returns: --*/ { LOADED_IMAGE_PRIVATE_DATA *Image; + EFI_TPL OldTpl; - EfiAcquireLock (&mBsExitLock); - + // + // Prevent possible reentrance to this function + // for the same ImageHandle + // + OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY); + Image = CoreLoadedImageInfo (ImageHandle); if (Image == NULL_HANDLE) { Status = EFI_INVALID_PARAMETER; @@ -1266,7 +1268,7 @@ Returns: CopyMem (Image->ExitData, ExitData, Image->ExitDataSize); } - EfiReleaseLock (&mBsExitLock); + CoreRestoreTpl (OldTpl); // // return to StartImage // @@ -1278,7 +1280,7 @@ Returns: ASSERT (FALSE); Status = EFI_ACCESS_DENIED; Done: - EfiReleaseLock (&mBsExitLock); + CoreRestoreTpl (OldTpl); return Status; } @@ -1309,9 +1311,14 @@ Returns: { EFI_STATUS Status; LOADED_IMAGE_PRIVATE_DATA *Image; + EFI_TPL OldTpl; - EfiAcquireLock (&mBsUnloadImageLock); - + // + // Prevent possible reentrance to this function + // for the same ImageHandle + // + OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY); + Image = CoreLoadedImageInfo (ImageHandle); if (Image == NULL ) { // @@ -1346,7 +1353,7 @@ Returns: } Done: - EfiReleaseLock (&mBsUnloadImageLock); + CoreRestoreTpl (OldTpl); return Status; }