Add a lock to protect the critical region in Service APIs for gEfiBlockIoProtocolGuid and gEfiSimpleFileSystemProtocolGuid Protocol to prevent re-entrance of the same API from from different TPL level. In UEFI 2.1 spec, it is state that the service API for this Protocol is callable at EFI_TPL_CALLBACK level.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2449 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2005, Intel Corporation
|
||||
Copyright (c) 2004 - 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
|
||||
@ -1064,25 +1064,32 @@ UnixBlockIoReadBlocks (
|
||||
UNIX_BLOCK_IO_PRIVATE *Private;
|
||||
ssize_t len;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||
|
||||
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
Status = UnixBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "UnixReadBlocks");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
len = Private->UnixThunk->Read (Private->fd, Buffer, BufferSize);
|
||||
if (len != BufferSize) {
|
||||
DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n"));
|
||||
return UnixBlockIoError (Private);
|
||||
Status = UnixBlockIoError (Private);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// If we wrote then media is present.
|
||||
//
|
||||
This->Media->MediaPresent = TRUE;
|
||||
return EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
STATIC
|
||||
@ -1123,18 +1130,22 @@ UnixBlockIoWriteBlocks (
|
||||
UNIX_BLOCK_IO_PRIVATE *Private;
|
||||
ssize_t len;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||
|
||||
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
Status = UnixBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "UnixWriteBlocks");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
len = Private->UnixThunk->Write (Private->fd, Buffer, BufferSize);
|
||||
if (len != BufferSize) {
|
||||
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n"));
|
||||
return UnixBlockIoError (Private);
|
||||
Status = UnixBlockIoError (Private);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
@ -1142,7 +1153,11 @@ UnixBlockIoWriteBlocks (
|
||||
//
|
||||
This->Media->MediaPresent = TRUE;
|
||||
This->Media->ReadOnly = FALSE;
|
||||
return EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
Done:
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
STATIC
|
||||
@ -1193,7 +1208,10 @@ UnixBlockIoResetBlock (
|
||||
--*/
|
||||
{
|
||||
UNIX_BLOCK_IO_PRIVATE *Private;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||
|
||||
Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
if (Private->fd >= 0) {
|
||||
@ -1201,6 +1219,8 @@ UnixBlockIoResetBlock (
|
||||
Private->fd = -1;
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user