summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk
AgeCommit message (Collapse)AuthorFilesLines
2013-08-26MdeModulePkg/DiskIoDxe: fix source/destination pointer of overrun transferLaszlo Ersek1-1/+1
DiskIoCreateSubtaskList() may split the transfer into three segments: - a leading segment, called underrun, which is the fractional, trailing subset of the first underlying block, - a middle segment, which is an integral multiple of underlying blocks, - a trailing segment, called overrun, which is the fractional, leading subset of the last underlying block. This is an example read from the /EFI/BOOT/BOOTX64.EFI file, on the RHEL-6.4 installation ISO (debug log enabled with EFI_D_BLKIO). The underlying block size is 2048 bytes (IDE CD-ROM). DiskIo: Create subtasks for task: Offset/BufferSize/Buffer = 0000000000004600/00002000/BD890018 R:Lba/Offset/Length/WorkingBuffer/Buffer = 0000000000000008/00000600/00000200/BD90D000/BD890018 R:Lba/Offset/Length/WorkingBuffer/Buffer = 000000000000000C/00000000/00000600/BD90D000/BD890218 R:Lba/Offset/Length/WorkingBuffer/Buffer = 0000000000000009/00000000/00001800/00000000/BD890218 The first line corresponds to the underrun. The second line corresponds to the overrun. The third line corresponds to the middle segment. In decimal: - task: read 8192 bytes from offset 17920, storing it at BD890018 - underrun: - read block 8 [16384..18432) into the transfer area, - copy 512 bytes from offset 1536 of the transfer area to BD890018 (target buffer offset 0, running total: 512) - middle segment: - read blocks 9, 10, 11 [18432..24576) into the transfer area, - copy 6144 bytes from offset 0 of the transfer area to BD890218 (target buffer offset 512, running total: 6656) - overrun: - read block 12 [24576..26624) into the transfer area, - copy 1536 bytes from offset 0 of the transfer area to BD890218 (!!!) (target buffer offset 512 (!!!), running total 8192) The values marked with (!!!) constitute the bug -- DiskIoCreateSubtaskList() doesn't take the size of the middle segment into account when it calculates the destination (for reads) or source (for writes) pointer for the overrun. This leads to data corruption. When reading, data is copied form the transfer area to the target buffer with CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length); calls in DiskIo2OnReadWriteComplete() for nonblocking reads, and in DiskIo2ReadWriteDisk() for blocking reads. Therefore it's enough to adjust Subtask->Buffer when it is initialized. (See BD891A18 below.) DiskIo: Create subtasks for task: Offset/BufferSize/Buffer = 0000000000004600/00002000/BD890018 R:Lba/Offset/Length/WorkingBuffer/Buffer = 0000000000000008/00000600/00000200/BD90D000/BD890018 R:Lba/Offset/Length/WorkingBuffer/Buffer = 000000000000000C/00000000/00000600/BD90D000/BD891A18 R:Lba/Offset/Length/WorkingBuffer/Buffer = 0000000000000009/00000000/00001800/00000000/BD890218 The patched call to DiskIoCreateSubtask() is also executed for write requests. The changed Subtask->Buffer initialization fixes the "overrun half writes" in DiskIo2ReadWriteDisk() too: // // A sub task before this one should be a block read operation, causing // the WorkingBuffer filled with the entire one block data. // CopyMem (Subtask->WorkingBuffer + Subtask->Offset, Subtask->Buffer, Subtask->Length); This code doubles for underrun and overrun half-writes. The patch doesn't modify the underrun case. If we're storing the overrun at the beginning of the pre-read last block (which we're going to write out as a full block), then - Subtask->Offset == 0, - Subtask->Length == OverRun, - the first byte *not* accessed in the source area is ((Buffer + UnderRunLength) + BufferSize) + OverRun. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14602 6f19259b-4bc3-4df7-8a09-765794883524
2013-08-22Fix DDK3790 build failure.Ruiyu Ni1-1/+1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14587 6f19259b-4bc3-4df7-8a09-765794883524
2013-08-21Fix function header comments for DiskIoDestroySubtask.Ruiyu Ni1-0/+1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14577 6f19259b-4bc3-4df7-8a09-765794883524
2013-08-21MdeModulePkg/DiskIoDxe: Fixed GCC build errorOlivier Martin1-3/+0
Error: Variable "Media" was set but never used. Change-Id: I1297b3de797e436ed403375c801945b3202b532c Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14575 6f19259b-4bc3-4df7-8a09-765794883524
2013-08-20Add DiskIo2 protocol definition to MdePkg.Ruiyu Ni9-477/+1239
Change DiskIoDxe to produce DiskIo2 protocol when the BlockIo2 protocol is available. Change PartitionDxe to produce BlockIo2 protocol based on DiskIo2 protocol instead of BlockIo2 protocol. Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Kinney Michael <michael.d.kinney@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14570 6f19259b-4bc3-4df7-8a09-765794883524
2013-07-31MdeModulePkg PartitionDxe: Ensure the NumberOfPartitionEntries * ↵Star Zeng1-3/+12
SizeOfPartitionEntry doesn't overflow. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Chao Zhang <chao.b.zhang@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14520 6f19259b-4bc3-4df7-8a09-765794883524
2012-06-12Add comment for modules which have external input.jyao12-8/+43
signed-off-by: jiewen.yao@intel.com reviewed-by: guo.dong@intel.com reviewed-by: ting.ye@intel.com reviewed-by: liming.gao@intel.com reviewed-by: elvin.li@intel.com git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13446 6f19259b-4bc3-4df7-8a09-765794883524
2012-05-09Use PartitionHeader->SizeOfPartitionEntry instead of sizeof ↵niruiyu1-32/+32
(EFI_PARTITION_ENTRY). Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13296 6f19259b-4bc3-4df7-8a09-765794883524
2011-12-011. Remove the unnecessary check of the existing of BlockIo2 in ↵qianouyang1-29/+4
PartitionDriverBindingSupported(). 2. Remove the comments of the BlockIo2 check in PartitionDriverBindingStart(). Signed-off-by: qianouyang Reviewed-by: niruiyu git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12806 6f19259b-4bc3-4df7-8a09-765794883524
2011-10-12Grub4Dos copies the BPB of the first partition to the MBR. If the ↵niruiyu1-1/+9
DriverBindingStart() of the Fat driver gets run before that of Partition driver only the first partition can be recognized. Let the driver binding version of Partition driver be higher than that of Fat driver to make sure the DriverBindingStart() of the Partition driver gets run before that of Fat driver so that all the partitions can be recognized. Signed-off-by: niruiyu Reviewed-by: erictian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12528 6f19259b-4bc3-4df7-8a09-765794883524
2011-09-19The patch enhances the Partition driver to return the media status ↵niruiyu1-12/+53
(EFI_NO_MEDIA/EFI_MEDIA_CHANGED) even the other parameters are not valid for BlockIo2 interfaces. Signed-off-by: niruiyu Reviewed-by: erictian Reviewed-by: qianouyang git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12378 6f19259b-4bc3-4df7-8a09-765794883524
2011-07-12MdeModulePkg: Add CD Express PEIMjljusten3-0/+984
Signed-off-by: jljusten Reviewed-by: mdkinney git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12012 6f19259b-4bc3-4df7-8a09-765794883524
2011-07-06Fix the comments to follow UEFI Spec regarding how to check an EFI_HANDLE is ↵niruiyu3-6/+6
valid/invalid. Signed-off-by: niruiyu Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11987 6f19259b-4bc3-4df7-8a09-765794883524
2011-06-08String Reference Cleanup.lzeng142-46/+42
Signed-off-by: lzeng14 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11762 6f19259b-4bc3-4df7-8a09-765794883524
2011-05-27MdeModulePkg: Fixed memory corruption when BlockIo2 is not presentgeekboy15a1-6/+6
Fixed NULL pointer reference of BlockIo2.Media in partition code. This resulted in the interrupt vector table being corrupted in a legacy (CSM) based system. Signed-off-by: geekboy15a Reviewed-by: mdkinney Reviewed-by: niruiyu Reviewed-by: jljusten git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11711 6f19259b-4bc3-4df7-8a09-765794883524
2011-05-23Change Partition/ScsiDxe driver to produce Block IO revision 3.niruiyu1-3/+9
Signed-off-by: niruiyu Reviewed-by: erictian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11692 6f19259b-4bc3-4df7-8a09-765794883524
2011-05-19Update the function's descriptions (which is in AtaBus, AtaAtapiPassThru, ↵qianouyang2-2/+1
Partition drivers) to make them be consistent with the code. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11678 6f19259b-4bc3-4df7-8a09-765794883524
2011-05-06Add Pointer check for NULL before referring it and remove unnecessary ↵qianouyang1-48/+29
pointer check in AtaAtapiPassThru and Partition Drivers. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11627 6f19259b-4bc3-4df7-8a09-765794883524
2011-05-03Add BlockIO2 Protocol.qianouyang6-217/+646
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11606 6f19259b-4bc3-4df7-8a09-765794883524
2011-04-25Change BlockIo drivers to return EFI_NO_MEDIA or EFI_MEDIA_CHANGED even the ↵niruiyu1-4/+35
Buffer/BufferSize/Lba is invalid so that caller can probe the media status easier. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11584 6f19259b-4bc3-4df7-8a09-765794883524
2011-04-01Set the BlockIo.Media.IoAlign to 0 because the BlockIo produced by Partition ↵niruiyu1-2/+7
driver consumes DiskIo for read/write operation which doesn't have IO alignment requirement. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11493 6f19259b-4bc3-4df7-8a09-765794883524
2011-03-14Enhance inf and dec file to follow specs.ydong101-3/+3
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11392 6f19259b-4bc3-4df7-8a09-765794883524
2010-07-20Per UEFI Spec, LowestAlignedLba and LogicalBlocksPerPhysicalBlock must be 0 ↵niruiyu1-1/+10
for logical partitions. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10668 6f19259b-4bc3-4df7-8a09-765794883524
2010-05-05raise TPL to TPL_CALLBACK level at DriverBindingStart() for all usb-related ↵erictian2-5/+14
modules, which prevent DriverBindingStop() from being invoked when DriverBindingStart() runs. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10460 6f19259b-4bc3-4df7-8a09-765794883524
2010-04-24Update the copyright notice formathhtian14-28/+28
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10418 6f19259b-4bc3-4df7-8a09-765794883524
2010-02-241. Correct File header to ## @filelgao43-12/+12
2. Remove unnecessary .common] postfix on section. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10052 6f19259b-4bc3-4df7-8a09-765794883524
2009-09-21Update partition driver to not produce BlockIo if a GPT with OS-specific ↵qhuang82-3/+15
field (BIT1) set in its partition attributes. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9293 6f19259b-4bc3-4df7-8a09-765794883524
2009-09-161. updated "the Bus Driver that creates all of its child handles on the ↵vanjeff1-12/+39
first call to Start()" not to create any child handle if RemainingDeviepath is the End of Device Path Node, per UEFI 2.3. The others changes include: a. Check RemainingDevicePath at beginning of Supported(), make sure it has been verified before Start() is called. b. Check IO protocol firstly rather than EfiDevicePathProtocolGuid, reduce the times entering into Start() function because EfiDevicePathProtocolGuid existed on most of handle. 2. roll back serial drivers not to create child device, if the device speicifed by remainingdevicepath cannot find in the created devices list. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9267 6f19259b-4bc3-4df7-8a09-765794883524
2009-08-14Enhance Partition driver for EFI_NO_MEDIA caseqhuang81-6/+18
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9070 6f19259b-4bc3-4df7-8a09-765794883524
2009-08-14Enhance GPT to remove the assumption that GPT partition entry in PMBR must ↵qhuang81-5/+10
be the first partition entry. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9069 6f19259b-4bc3-4df7-8a09-765794883524
2009-08-14Fix a potential issue to use FreePool() with NULL pointer.qhuang81-2/+2
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9068 6f19259b-4bc3-4df7-8a09-765794883524
2009-07-24Roll back the change in Partition driver. currently we enhance the EHCI ↵eric_tian1-1/+1
driver to guarantee that the EHCI controller get attached to the EHCI controller before the UHCI driver attaches to the UHCI controller. This way can avoid the case happen that UHCI sees the disconnect and EHCI sees the connect event due to the control transfer in shared port. It may cause Partition.Start to be interrupted by Partition.Stop. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8991 6f19259b-4bc3-4df7-8a09-765794883524
2009-07-22if Usb mass storage interface returns EFI_DEVICE_ERROR, we should jump out ↵eric_tian1-1/+1
the loop which is used to determine if the current block device supports GPT/Torito/MBR in Partition driver. This way can avoid Partition.start is interrupted by itself Partition.stop(). git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8977 6f19259b-4bc3-4df7-8a09-765794883524
2009-06-02Use DiskIo->WriteDisk() API to avoid alignment issue.qhuang81-2/+8
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8445 6f19259b-4bc3-4df7-8a09-765794883524
2009-04-30Replace references to RFC 3066 with RFC 4646. gikidy5-9/+9
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8212 6f19259b-4bc3-4df7-8a09-765794883524
2009-04-27Fix the bug that the "Offset" parameter for DiskIo protocol should be ↵qhuang83-10/+10
byte-oriented. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8175 6f19259b-4bc3-4df7-8a09-765794883524
2009-04-22Use DiskIo->ReadDisk() API to avoid alignment issue.qhuang83-44/+43
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8144 6f19259b-4bc3-4df7-8a09-765794883524
2009-04-10Using sizeof(EFO_BLOCK_IO_MEDIA) replace Macro.gikidy2-4/+1
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8054 6f19259b-4bc3-4df7-8a09-765794883524
2009-04-02Modified for use reversion field and fix a typo. gikidy2-2/+5
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8006 6f19259b-4bc3-4df7-8a09-765794883524
2009-01-21Meta-data reviewed and verified.gikidy1-2/+2
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7326 6f19259b-4bc3-4df7-8a09-765794883524
2009-01-20Meta-data review.gikidy1-2/+2
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7319 6f19259b-4bc3-4df7-8a09-765794883524
2009-01-20Meta-data review.gikidy3-12/+12
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7313 6f19259b-4bc3-4df7-8a09-765794883524
2008-12-23Code scrub DxeIpl, Runtime, DevicePath, FvbServicesLib, DiskIo, Partition, ↵qhuang810-36/+54
English, EBC. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7105 6f19259b-4bc3-4df7-8a09-765794883524
2008-12-18check the usage of %d,%x,%ld,%lx and so on in debug print statement.jji41-1/+1
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7080 6f19259b-4bc3-4df7-8a09-765794883524
2008-12-16Clean up to update the reference of the these macros:qhuang82-2/+2
EFI_SIGNATURE_16 -> SIGNATURE_16 EFI_SIGNATURE_32 -> SIGNATURE_32 EFI_SIGNATURE_64 -> SIGNATURE_64 EFI_FIELD_OFFSET -> OFFSET_OF EFI_MAX_BIT -> MAX_BIT EFI_MAX_ADDRESS -> MAX_ADDRESS These macros are not defined in UEFI spec. It makes more sense to use the equivalent macros in Base.h to avoid alias. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7056 6f19259b-4bc3-4df7-8a09-765794883524
2008-12-041)Global variables have been moved backward ahead of functions.jji42-0/+2
2)INF comments have been reviewed. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6839 6f19259b-4bc3-4df7-8a09-765794883524
2008-12-03Remove some useless EDK_RELEASE_VERSION, EFI_SPECIFICATION_VERSION ,and ↵gikidy3-9/+0
review VALID_ARCHITECTURES in inf files with DSC file. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6818 6f19259b-4bc3-4df7-8a09-765794883524
2008-11-111, Add <Library/DevicePathLib.h> for all source that use device path utility ↵klu21-2/+2
macros 2, Add DevicePathLib library class to module's INF that use device path utility macros git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6456 6f19259b-4bc3-4df7-8a09-765794883524
2008-10-27re-defined CDROM_VOLUME_DESCRIPTOR to be a union including Boot Record ↵vanjeff1-6/+6
Volume Descriptor and Primary Volume Description. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6251 6f19259b-4bc3-4df7-8a09-765794883524
2008-10-20Move definition of EFI_PARTITION_ENTRY_STATUS from IndustryStandard in MDE ↵xli241-0/+9
Package to implementation of PartitionDxe module. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6156 6f19259b-4bc3-4df7-8a09-765794883524