diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-12 06:26:10 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-12 06:26:10 +0000 |
commit | d126eaecb080a9e4d6fd697f1b6f5380a5248420 (patch) | |
tree | 8dd604277b2d63d3c61b5afb260d401af20c840b /EdkModulePkg/Core/Dxe | |
parent | 87c40bc89de1de4f8cf66341974a28bb84912896 (diff) | |
download | edk2-d126eaecb080a9e4d6fd697f1b6f5380a5248420.zip edk2-d126eaecb080a9e4d6fd697f1b6f5380a5248420.tar.gz edk2-d126eaecb080a9e4d6fd697f1b6f5380a5248420.tar.bz2 |
Add a lock to protect the critical region in UEFI Boot Service API: Exit() and UnloadImage from re-entrance from different TPL level.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2437 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Core/Dxe')
-rw-r--r-- | EdkModulePkg/Core/Dxe/Image/Image.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/EdkModulePkg/Core/Dxe/Image/Image.c b/EdkModulePkg/Core/Dxe/Image/Image.c index e9541f7..f1b2c7a 100644 --- a/EdkModulePkg/Core/Dxe/Image/Image.c +++ b/EdkModulePkg/Core/Dxe/Image/Image.c @@ -1,6 +1,6 @@ /*++
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -24,6 +24,9 @@ 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 = {
@@ -1219,9 +1222,12 @@ Returns: {
LOADED_IMAGE_PRIVATE_DATA *Image;
+ EfiAcquireLock (&mBsExitLock);
+
Image = CoreLoadedImageInfo (ImageHandle);
if (Image == NULL_HANDLE) {
- return EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
}
if (!Image->Started) {
@@ -1229,7 +1235,8 @@ Returns: // The image has not been started so just free its resources
//
CoreUnloadAndCloseImage (Image, TRUE);
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
+ goto Done;
}
//
@@ -1237,7 +1244,8 @@ Returns: //
if (Image != mCurrentImage) {
DEBUG ((EFI_D_LOAD|EFI_D_ERROR, "Exit: Image is not exitable image\n"));
- return EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
}
//
@@ -1252,11 +1260,13 @@ Returns: Image->ExitDataSize = ExitDataSize;
Image->ExitData = CoreAllocateBootServicesPool (Image->ExitDataSize);
if (Image->ExitData == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
}
CopyMem (Image->ExitData, ExitData, Image->ExitDataSize);
}
+ EfiReleaseLock (&mBsExitLock);
//
// return to StartImage
//
@@ -1266,7 +1276,10 @@ Returns: // If we return from LongJump, then it is an error
//
ASSERT (FALSE);
- return EFI_ACCESS_DENIED;
+ Status = EFI_ACCESS_DENIED;
+Done:
+ EfiReleaseLock (&mBsExitLock);
+ return Status;
}
@@ -1297,12 +1310,15 @@ Returns: EFI_STATUS Status;
LOADED_IMAGE_PRIVATE_DATA *Image;
+ EfiAcquireLock (&mBsUnloadImageLock);
+
Image = CoreLoadedImageInfo (ImageHandle);
if (Image == NULL ) {
//
// The image handle is not valid
//
- return EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
}
if (Image->Started) {
@@ -1329,6 +1345,8 @@ Returns: CoreUnloadAndCloseImage (Image, TRUE);
}
+Done:
+ EfiReleaseLock (&mBsUnloadImageLock);
return Status;
}
|