The patch is good to me.

Reviewed-by: Hao Wu <[email protected]>

Best Regards,
Hao Wu

> -----Original Message-----
> From: edk2-devel [mailto:[email protected]] On Behalf Of Feng
> Tian
> Sent: Wednesday, June 29, 2016 11:18 AM
> To: Wu, Hao A
> Cc: [email protected]
> Subject: [edk2] [patch] MdeModulePkg/EmmcDxe: Don't expose BlockIo
> interface for RPMB partition
> 
> This change is to avoid UEFI SCT failure as UEFI SCT has no knowledge
> about how to accessing a EMMC RPMB partition.
> 
> The user needs to access RPMB partition should get access through
> EFI_SD_MMC_PASS_THRU protocol with authentication key & mac.
> 
> Cc: Hao Wu <[email protected]>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Feng Tian <[email protected]>
> ---
>  MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c | 138 +++++++++++---------------
> --------
>  1 file changed, 45 insertions(+), 93 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
> b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
> index d3602a5..5040882 100644
> --- a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
> +++ b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
> @@ -443,77 +443,60 @@ InstallProtocolOnPartition (
>      //
>      // Install BlkIo/BlkIo2/Ssp for the specified partition
>      //
> -    Status = gBS->InstallMultipleProtocolInterfaces (
> -                    &Partition->Handle,
> -                    &gEfiDevicePathProtocolGuid,
> -                    Partition->DevicePath,
> -                    &gEfiBlockIoProtocolGuid,
> -                    &Partition->BlockIo,
> -                    &gEfiBlockIo2ProtocolGuid,
> -                    &Partition->BlockIo2,
> -                    NULL
> -                    );
> -    if (EFI_ERROR (Status)) {
> -      goto Error;
> -    }
> -
>      if (Partition->PartitionType != EmmcPartitionRPMB) {
> -      Status = gBS->InstallProtocolInterface (
> +      Status = gBS->InstallMultipleProtocolInterfaces (
>                        &Partition->Handle,
> +                      &gEfiDevicePathProtocolGuid,
> +                      Partition->DevicePath,
> +                      &gEfiBlockIoProtocolGuid,
> +                      &Partition->BlockIo,
> +                      &gEfiBlockIo2ProtocolGuid,
> +                      &Partition->BlockIo2,
>                        &gEfiEraseBlockProtocolGuid,
> -                      EFI_NATIVE_INTERFACE,
> -                      &Partition->EraseBlock
> +                      &Partition->EraseBlock,
> +                      NULL
>                        );
>        if (EFI_ERROR (Status)) {
> -        gBS->UninstallMultipleProtocolInterfaces (
> -               &Partition->Handle,
> -               &gEfiDevicePathProtocolGuid,
> -               Partition->DevicePath,
> -               &gEfiBlockIoProtocolGuid,
> -               &Partition->BlockIo,
> -               &gEfiBlockIo2ProtocolGuid,
> -               &Partition->BlockIo2,
> -               NULL
> -               );
>          goto Error;
>        }
> -    }
> 
> -    if (((Partition->PartitionType == EmmcPartitionUserData) ||
> -        (Partition->PartitionType == EmmcPartitionBoot1) ||
> -        (Partition->PartitionType == EmmcPartitionBoot2)) &&
> -        ((Device->Csd.Ccc & BIT10) != 0)) {
> -      Status = gBS->InstallProtocolInterface (
> -                      &Partition->Handle,
> -                      &gEfiStorageSecurityCommandProtocolGuid,
> -                      EFI_NATIVE_INTERFACE,
> -                      &Partition->StorageSecurity
> -                      );
> -      if (EFI_ERROR (Status)) {
> -        gBS->UninstallMultipleProtocolInterfaces (
> -               &Partition->Handle,
> -               &gEfiDevicePathProtocolGuid,
> -               Partition->DevicePath,
> -               &gEfiBlockIoProtocolGuid,
> -               &Partition->BlockIo,
> -               &gEfiBlockIo2ProtocolGuid,
> -               &Partition->BlockIo2,
> -               &gEfiEraseBlockProtocolGuid,
> -               &Partition->EraseBlock,
> -               NULL
> -               );
> -        goto Error;
> +      if (((Partition->PartitionType == EmmcPartitionUserData) ||
> +          (Partition->PartitionType == EmmcPartitionBoot1) ||
> +          (Partition->PartitionType == EmmcPartitionBoot2)) &&
> +          ((Device->Csd.Ccc & BIT10) != 0)) {
> +        Status = gBS->InstallProtocolInterface (
> +                        &Partition->Handle,
> +                        &gEfiStorageSecurityCommandProtocolGuid,
> +                        EFI_NATIVE_INTERFACE,
> +                        &Partition->StorageSecurity
> +                        );
> +        if (EFI_ERROR (Status)) {
> +          gBS->UninstallMultipleProtocolInterfaces (
> +                 &Partition->Handle,
> +                 &gEfiDevicePathProtocolGuid,
> +                 Partition->DevicePath,
> +                 &gEfiBlockIoProtocolGuid,
> +                 &Partition->BlockIo,
> +                 &gEfiBlockIo2ProtocolGuid,
> +                 &Partition->BlockIo2,
> +                 &gEfiEraseBlockProtocolGuid,
> +                 &Partition->EraseBlock,
> +                 NULL
> +                 );
> +          goto Error;
> +        }
>        }
> +
> +      gBS->OpenProtocol (
> +             Device->Private->Controller,
> +             &gEfiSdMmcPassThruProtocolGuid,
> +             (VOID **) &(Device->Private->PassThru),
> +             Device->Private->DriverBindingHandle,
> +             Partition->Handle,
> +             EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> +             );
>      }
> 
> -    gBS->OpenProtocol (
> -           Device->Private->Controller,
> -           &gEfiSdMmcPassThruProtocolGuid,
> -           (VOID **) &(Device->Private->PassThru),
> -           Device->Private->DriverBindingHandle,
> -           Partition->Handle,
> -           EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> -           );
>    } else {
>      Status = EFI_INVALID_PARAMETER;
>    }
> @@ -993,7 +976,6 @@ EmmcDxeDriverBindingStop (
>    EFI_BLOCK_IO_PROTOCOL                  *BlockIo;
>    EFI_BLOCK_IO2_PROTOCOL                 *BlockIo2;
>    EFI_STORAGE_SECURITY_COMMAND_PROTOCOL  *StorageSecurity;
> -  EFI_ERASE_BLOCK_PROTOCOL               *EraseBlock;
>    LIST_ENTRY                             *Link;
>    LIST_ENTRY                             *NextLink;
>    EMMC_REQUEST                           *Request;
> @@ -1120,6 +1102,8 @@ EmmcDxeDriverBindingStop (
>                      &Partition->BlockIo,
>                      &gEfiBlockIo2ProtocolGuid,
>                      &Partition->BlockIo2,
> +                    &gEfiEraseBlockProtocolGuid,
> +                    &Partition->EraseBlock,
>                      NULL
>                      );
>      if (EFI_ERROR (Status)) {
> @@ -1136,38 +1120,6 @@ EmmcDxeDriverBindingStop (
>      }
> 
>      //
> -    // If Erase Block Protocol is installed, then uninstall this protocol.
> -    //
> -    Status = gBS->OpenProtocol (
> -                    ChildHandleBuffer[Index],
> -                    &gEfiEraseBlockProtocolGuid,
> -                    (VOID **) &EraseBlock,
> -                    This->DriverBindingHandle,
> -                    Controller,
> -                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
> -                    );
> -
> -    if (!EFI_ERROR (Status)) {
> -      Status = gBS->UninstallProtocolInterface (
> -                      ChildHandleBuffer[Index],
> -                      &gEfiEraseBlockProtocolGuid,
> -                      &Partition->EraseBlock
> -                      );
> -      if (EFI_ERROR (Status)) {
> -        gBS->OpenProtocol (
> -          Controller,
> -          &gEfiSdMmcPassThruProtocolGuid,
> -          (VOID **) &Partition->Device->Private->PassThru,
> -          This->DriverBindingHandle,
> -          ChildHandleBuffer[Index],
> -          EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> -          );
> -        AllChildrenStopped = FALSE;
> -        continue;
> -      }
> -    }
> -
> -    //
>      // If Storage Security Command Protocol is installed, then uninstall this
> protocol.
>      //
>      Status = gBS->OpenProtocol (
> --
> 2.7.1.windows.2
> 
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to