Re: [edk2] [patch] MdeModulePkg/EmmcDxe: Don't expose BlockIo interface for RPMB partition

2016-06-30 Thread Wu, Hao A
The patch is good to me.

Reviewed-by: Hao Wu <hao.a...@intel.com>

Best Regards,
Hao Wu

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Feng
> Tian
> Sent: Wednesday, June 29, 2016 11:18 AM
> To: Wu, Hao A
> Cc: edk2-devel@lists.01.org
> 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 <hao.a...@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Feng Tian <feng.t...@intel.com>
> ---
>  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 (
> ->Handle,
> -,
> -Partition->DevicePath,
> -,
> ->BlockIo,
> -,
> ->BlockIo2,
> -NULL
> -);
> -if (EFI_ERROR (Status)) {
> -  goto Error;
> -}
> -
>  if (Partition->PartitionType != EmmcPartitionRPMB) {
> -  Status = gBS->InstallProtocolInterface (
> +  Status = gBS->InstallMultipleProtocolInterfaces (
>>Handle,
> +  ,
> +  Partition->DevicePath,
> +  ,
> +  >BlockIo,
> +  ,
> +  >BlockIo2,
>,
> -  EFI_NATIVE_INTERFACE,
> -  >EraseBlock
> +  >EraseBlock,
> +  NULL
>);
>if (EFI_ERROR (Status)) {
> -gBS->UninstallMultipleProtocolInterfaces (
> -   >Handle,
> -   ,
> -   Partition->DevicePath,
> -   ,
> -   >BlockIo,
> -   ,
> -   >BlockIo2,
> -   NULL
> -   );
>  goto Error;
>}
> -}
> 
> -if (((Partition->PartitionType == EmmcPartitionUserData) ||
> -(Partition->PartitionType == EmmcPartitionBoot1) ||
> -(Partition->PartitionType == EmmcPartitionBoot2)) &&
> -((Device->Csd.Ccc & BIT10) != 0)) {
> -  Status = gBS->InstallProtocolInterface (
> -  >Handle,
> -  ,
> -  EFI_NATIVE_INTERFACE,
> -  >StorageSecurity
> -  );
> -  if (EFI_ERROR (Status)) {
> -gBS->UninstallMultipleProtocolInterfaces (
> -   >Handle,
> -   ,
> -   Partition->DevicePath,
> -   ,
> -   >BlockIo,
> -   ,
> -   >BlockIo2,
> -   ,
> -   >EraseBlock,
> -   NULL
> -   );
> -goto Error;
> +  if (((Partition->PartitionType == EmmcPartitionUserData) ||
> +  (Partition->PartitionType == EmmcPartitionBoot1) ||
> +  (Partition->PartitionType == EmmcPartitionBoot2)) &&
> +  ((Device->Csd.Ccc & BIT10) != 0)) {
> +Status = gBS->InstallProtocolInterface (
> +>Handle,
> +,
> +EFI_NATIVE_INTERFACE,
> +>StorageSecurity
> +);
> +if (EFI_ERROR (Status)) {
> +  gBS->UninstallMultipleProtocolInterfaces (
> + >Handle,
> + ,
> + Partition->DevicePath,
> + ,
> + >BlockIo,
> + ,
> + >BlockIo2,
> + ,
> + >EraseBlock,
> + NULL
> + );
> +  

[edk2] [patch] MdeModulePkg/EmmcDxe: Don't expose BlockIo interface for RPMB partition

2016-06-28 Thread Feng Tian
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 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian 
---
 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 (
->Handle,
-,
-Partition->DevicePath,
-,
->BlockIo,
-,
->BlockIo2,
-NULL
-);
-if (EFI_ERROR (Status)) {
-  goto Error;
-}
-
 if (Partition->PartitionType != EmmcPartitionRPMB) {
-  Status = gBS->InstallProtocolInterface (
+  Status = gBS->InstallMultipleProtocolInterfaces (
   >Handle,
+  ,
+  Partition->DevicePath,
+  ,
+  >BlockIo,
+  ,
+  >BlockIo2,
   ,
-  EFI_NATIVE_INTERFACE,
-  >EraseBlock
+  >EraseBlock,
+  NULL
   );
   if (EFI_ERROR (Status)) {
-gBS->UninstallMultipleProtocolInterfaces (
-   >Handle,
-   ,
-   Partition->DevicePath,
-   ,
-   >BlockIo,
-   ,
-   >BlockIo2,
-   NULL
-   );
 goto Error;
   }
-}
 
-if (((Partition->PartitionType == EmmcPartitionUserData) ||
-(Partition->PartitionType == EmmcPartitionBoot1) ||
-(Partition->PartitionType == EmmcPartitionBoot2)) &&
-((Device->Csd.Ccc & BIT10) != 0)) {
-  Status = gBS->InstallProtocolInterface (
-  >Handle,
-  ,
-  EFI_NATIVE_INTERFACE,
-  >StorageSecurity
-  );
-  if (EFI_ERROR (Status)) {
-gBS->UninstallMultipleProtocolInterfaces (
-   >Handle,
-   ,
-   Partition->DevicePath,
-   ,
-   >BlockIo,
-   ,
-   >BlockIo2,
-   ,
-   >EraseBlock,
-   NULL
-   );
-goto Error;
+  if (((Partition->PartitionType == EmmcPartitionUserData) ||
+  (Partition->PartitionType == EmmcPartitionBoot1) ||
+  (Partition->PartitionType == EmmcPartitionBoot2)) &&
+  ((Device->Csd.Ccc & BIT10) != 0)) {
+Status = gBS->InstallProtocolInterface (
+>Handle,
+,
+EFI_NATIVE_INTERFACE,
+>StorageSecurity
+);
+if (EFI_ERROR (Status)) {
+  gBS->UninstallMultipleProtocolInterfaces (
+ >Handle,
+ ,
+ Partition->DevicePath,
+ ,
+ >BlockIo,
+ ,
+ >BlockIo2,
+ ,
+ >EraseBlock,
+ NULL
+ );
+  goto Error;
+}
   }
+
+  gBS->OpenProtocol (
+ Device->Private->Controller,
+ ,
+ (VOID **) &(Device->Private->PassThru),
+ Device->Private->DriverBindingHandle,
+ Partition->Handle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
 }
 
-gBS->OpenProtocol (
-   Device->Private->Controller,
-   ,
-   (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 (
 >BlockIo,
 ,