]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg NvmExpressDxe: Add check on the attributes of NVME controller
authorHao Wu <hao.a.wu@intel.com>
Mon, 22 Aug 2016 06:11:23 +0000 (14:11 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 6 Sep 2016 07:31:31 +0000 (15:31 +0800)
According to UEFI spec, an EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL with neither
EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL nor
EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL set in the Attributes field
is an illegal configuration.

This commit adds this check in the PassThru API to follow the spec.

Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c

index 6b292608588a7d7727d69a16c2d36b60fb1217ea..c7ead2114f9d00ead075527aa5a0d9ca511307b4 100644 (file)
@@ -375,6 +375,7 @@ NvmExpressPassThru (
   UINT64                         *Prp;\r
   VOID                           *PrpListHost;\r
   UINTN                          PrpListNo;\r
+  UINT32                         Attributes;\r
   UINT32                         IoAlign;\r
   UINT32                         Data;\r
   NVME_PASS_THRU_ASYNC_REQ       *AsyncRequest;\r
@@ -395,10 +396,21 @@ NvmExpressPassThru (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  //\r
+  // 'Attributes' with neither EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL nor\r
+  // EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL set is an illegal\r
+  // configuration.\r
+  //\r
+  Attributes  = This->Mode->Attributes;\r
+  if ((Attributes & (EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL |\r
+    EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL)) == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   //\r
   // Buffer alignment check for TransferBuffer & MetadataBuffer.\r
   //\r
-  IoAlign = This->Mode->IoAlign;\r
+  IoAlign     = This->Mode->IoAlign;\r
   if (IoAlign > 0 && (((UINTN) Packet->TransferBuffer & (IoAlign - 1)) != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r