Hi, Devkate

I agree the first one is a bug and need to be fixed like your proposal.

For the second one, sorry I couldn’t catch your point.

When the requested buffer size is larger than 2M, it means we need multiple PRP 
list pages.

For example, when block size is 4K, memory page size is 4K

1)      Offset = 0B, Transfer Length = 4K * 512 blocks = 2MB

Prp1 = 0 to 4KB

Prp2 = pointer to a Prp List which contains 511 entries to read data from 
offset 4KB to offset 2MB.

2)      Offset = 2KB, Transfer Length = 4K * 513 blocks = 2MB + 4K

Prp1 = 2K to 4KB

Prp2 = pointer to a Prp List which is followed by another Prp List.

The first Prp List contains 511 entries to read data from offset 4KB to offset 
2MB. the last one entry is a pointer to 2nd Prp List. The second Prp List 
contains 2 entries to read data from offset 2MB to offset 2MB +4k and from 
offset 2MB + 4K to offset 2MB + 6K.

So for the first sample, EFI_SIZE_TO_PAGES(Offset + Bytes) – 1 = 511. For the 
second sample, EFI_SIZE_TO_PAGES(Offset + Bytes) – 1 = 513. In 
NvmeCreatePrpList(), PrpListNo = 1 for first sample and PrpListNo = 2 for 
second sample.

So do I misunderstand something?

Thanks
Feng

From: Baban Devkate [mailto:baban.devk...@seagate.com]
Sent: Thursday, April 09, 2015 09:37
To: edk2-devel@lists.sourceforge.net
Cc: Tian, Feng
Subject: MdeModulePkg:Fix required in NvmExpressDxe driver

Hi,

Commit Message
============

MdeModulePkg: Fixed Pointer truncation and incorrect bytes passed for PRP list 
creation.

There were two issues in NvmExpressPassthru.c( 
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c)-
1.PRP list entries were zeroed out as "PrpListBase" was getting truncated to 
UINT8, changed to UINT64.

Old code- PrpListBase = *(UINT8*)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;

New code- PrpListBase = *(UINT64*)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;

2. Number of bytes passed to PRP list creation function corrected.

Actual payload length will not match requested whenever nested PRP list is 
required. With current 1024 max transfer size and 4K Blocksize if the
requested buffer is greater than 2MB then nested PRP list will be required and 
NvmeCreatePrpList (.., Pages-1 , ..) will result into above failure.

Old code-
Prp = NvmeCreatePrpList (PciIo, PhyAddr, EFI_SIZE_TO_PAGES(Offset + Bytes) - 1, 
&PrpListHost, &PrpListNo, &MapPrpList);

New code-
Prp = NvmeCreatePrpList (PciIo, PhyAddr, EFI_SIZE_TO_PAGES(Offset + Bytes), 
&PrpListHost, &PrpListNo, &MapPrpList);



Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: baban.devk...@seagate.com<mailto:baban.devk...@seagate.com>

Name-Baban Devkate
email-baban.devk...@seagate.com<mailto:email-baban.devk...@seagate.com>
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to