nvme_disk: Add missing checks in the case where there is only one iovec.

May fix the remaining KDL in #16973.
This commit is contained in:
Augustin Cavalier 2021-10-27 14:54:02 -04:00
parent 535b7dc9d3
commit 52f94eb19e

View File

@ -701,10 +701,11 @@ nvme_disk_io(void* cookie, io_request* request)
bounceAll = true;
}
// See if we need to bounce due to the first or last vec (which, unlike middle vecs,
// need only be a multiple of the block size, and must end and start on a page boundary,
// respectively, though the start address must always be 32-bit-aligned.)
// See if we need to bounce due to the first or last vecs.
if (nvme_request.iovec_count > 1) {
// There are middle vecs, so the first and last vecs have different restrictions: they
// need only be a multiple of the block size, and must end and start on a page boundary,
// respectively, though the start address must always be 32-bit-aligned.
physical_entry* entry = &nvme_request.iovecs[0];
if (!bounceAll && (((entry->address + entry->size) % B_PAGE_SIZE) != 0
|| (entry->address & 0x3) != 0 || (entry->size % block_size) != 0))
@ -714,6 +715,12 @@ nvme_disk_io(void* cookie, io_request* request)
if (!bounceAll && ((entry->address % B_PAGE_SIZE) != 0
|| (entry->size % block_size) != 0))
bounceAll = true;
} else {
// There is only one vec. Check that it is a multiple of the block size,
// and that its address is 32-bit-aligned.
physical_entry* entry = &nvme_request.iovecs[0];
if (!bounceAll && ((entry->address & 0x3) != 0 || (entry->size % block_size) != 0))
bounceAll = true;
}
// See if we need to bounce due to rounding.