SecurityPkg/OpalPassword: Remove dependency on EFI_BLOCK_IO_PROTOCOL

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>
This commit is contained in:
Chu, Maggie 2019-11-04 12:04:28 +08:00 committed by Eric Dong
parent 78413dd4bc
commit 1a04951309
1 changed files with 27 additions and 43 deletions

View File

@ -2667,7 +2667,6 @@ OpalEfiDriverBindingSupported(
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL* SecurityCommand; EFI_STORAGE_SECURITY_COMMAND_PROTOCOL* SecurityCommand;
EFI_BLOCK_IO_PROTOCOL* BlkIo;
if (mOpalEndOfDxe) { if (mOpalEndOfDxe) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -2703,33 +2702,6 @@ OpalEfiDriverBindingSupported(
Controller 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; return EFI_SUCCESS;
} }
@ -2826,6 +2798,12 @@ OpalEfiDriverBindingStart(
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
//
// Block_IO not supported on handle
//
if(Status == EFI_UNSUPPORTED) {
BlkIo = NULL;
} else {
// //
// Close storage security that was opened // Close storage security that was opened
// //
@ -2839,10 +2817,15 @@ OpalEfiDriverBindingStart(
FreePool(Dev); FreePool(Dev);
return Status; return Status;
} }
}
// //
// Save mediaId // Save mediaId
// //
if(BlkIo == NULL) {
// If no Block IO present, use defined MediaId value.
Dev->MediaId = 0x0;
} else {
Dev->MediaId = BlkIo->Media->MediaId; Dev->MediaId = BlkIo->Media->MediaId;
gBS->CloseProtocol( gBS->CloseProtocol(
@ -2851,6 +2834,7 @@ OpalEfiDriverBindingStart(
This->DriverBindingHandle, This->DriverBindingHandle,
Controller Controller
); );
}
// //
// Acquire Ascii printable name of child, if not found, then ignore device // Acquire Ascii printable name of child, if not found, then ignore device