summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2016-08-22 14:11:23 +0800
committerHao Wu <hao.a.wu@intel.com>2016-09-06 15:31:31 +0800
commit491f6026293bef88ea31b3d1848300708253f68b (patch)
treece5e024b5408af322033e3fbb5be146507791997 /MdeModulePkg
parent3c52deafda51b16f665c44eec967ed03689932f9 (diff)
downloadedk2-491f6026293bef88ea31b3d1848300708253f68b.tar.gz
edk2-491f6026293bef88ea31b3d1848300708253f68b.tar.bz2
edk2-491f6026293bef88ea31b3d1848300708253f68b.zip
MdeModulePkg NvmExpressDxe: Add check on the attributes of NVME controller
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
index 6b29260858..c7ead2114f 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
@@ -375,6 +375,7 @@ NvmExpressPassThru (
UINT64 *Prp;
VOID *PrpListHost;
UINTN PrpListNo;
+ UINT32 Attributes;
UINT32 IoAlign;
UINT32 Data;
NVME_PASS_THRU_ASYNC_REQ *AsyncRequest;
@@ -396,9 +397,20 @@ NvmExpressPassThru (
}
//
+ // 'Attributes' with neither EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL nor
+ // EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL set is an illegal
+ // configuration.
+ //
+ Attributes = This->Mode->Attributes;
+ if ((Attributes & (EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL |
+ EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL)) == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
// Buffer alignment check for TransferBuffer & MetadataBuffer.
//
- IoAlign = This->Mode->IoAlign;
+ IoAlign = This->Mode->IoAlign;
if (IoAlign > 0 && (((UINTN) Packet->TransferBuffer & (IoAlign - 1)) != 0)) {
return EFI_INVALID_PARAMETER;
}