From 52f94eb19e7e1fcb52d1a517070f5e2069c9b43c Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 27 Oct 2021 14:54:02 -0400 Subject: [PATCH] nvme_disk: Add missing checks in the case where there is only one iovec. May fix the remaining KDL in #16973. --- src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp index ef2366e735..0cd732ad8b 100644 --- a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp @@ -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.