Skip to content

Commit

Permalink
SecurityPkg/OpalPassword: Remove dependency on EFI_BLOCK_IO_PROTOCOL
Browse files Browse the repository at this point in the history
https://bugzilla.tianocore.org/show_bug.cgi?id=2327

RAID drivers abstract their physical drives that make up
the array into a single unit, and do not supply individual
EFI_BLOCK_IO_PROTOCOL instances for each physical drive in the array.
This breaks support for the Security Storage Command Protocol,
which currently requires an EFI_BLOCK_IO_PROTOCOL to be associated
with the same device the protocol is installed on and provide
all the same parameters.

This patch remove dependency on EFI_BLOCK_IO_PROTOCOL and
allows access to Opal drive members of a RAID array.

Signed-off-by: Maggie Chu <maggie.chu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
  • Loading branch information
Chu, Maggie authored and ydong10 committed Nov 6, 2019
1 parent 78413dd commit 1a04951
Showing 1 changed file with 27 additions and 43 deletions.
70 changes: 27 additions & 43 deletions SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2667,7 +2667,6 @@ OpalEfiDriverBindingSupported(
{
EFI_STATUS Status;
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL* SecurityCommand;
EFI_BLOCK_IO_PROTOCOL* BlkIo;

if (mOpalEndOfDxe) {
return EFI_UNSUPPORTED;
Expand Down Expand Up @@ -2703,33 +2702,6 @@ OpalEfiDriverBindingSupported(
Controller
);

//
// Test EFI_BLOCK_IO_PROTOCOL on controller Handle, required by EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
// function APIs
//
Status = gBS->OpenProtocol(
Controller,
&gEfiBlockIoProtocolGuid,
(VOID **)&BlkIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);

if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "No EFI_BLOCK_IO_PROTOCOL on controller\n"));
return Status;
}

//
// Close protocol and reopen in Start call
//
gBS->CloseProtocol(
Controller,
&gEfiBlockIoProtocolGuid,
This->DriverBindingHandle,
Controller
);

return EFI_SUCCESS;
}
Expand Down Expand Up @@ -2827,30 +2799,42 @@ OpalEfiDriverBindingStart(
);
if (EFI_ERROR(Status)) {
//
// Close storage security that was opened
// Block_IO not supported on handle
//
gBS->CloseProtocol(
Controller,
&gEfiStorageSecurityCommandProtocolGuid,
This->DriverBindingHandle,
Controller
);
if(Status == EFI_UNSUPPORTED) {
BlkIo = NULL;
} else {
//
// Close storage security that was opened
//
gBS->CloseProtocol(
Controller,
&gEfiStorageSecurityCommandProtocolGuid,
This->DriverBindingHandle,
Controller
);

FreePool(Dev);
return Status;
FreePool(Dev);
return Status;
}
}

//
// Save mediaId
//
Dev->MediaId = BlkIo->Media->MediaId;
if(BlkIo == NULL) {
// If no Block IO present, use defined MediaId value.
Dev->MediaId = 0x0;
} else {
Dev->MediaId = BlkIo->Media->MediaId;

gBS->CloseProtocol(
Controller,
&gEfiBlockIoProtocolGuid,
This->DriverBindingHandle,
Controller
gBS->CloseProtocol(
Controller,
&gEfiBlockIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
}

//
// Acquire Ascii printable name of child, if not found, then ignore device
Expand Down

0 comments on commit 1a04951

Please sign in to comment.