⛏️ index : haiku.git

author Augustin Cavalier <waddlesplash@gmail.com> 2019-04-14 21:21:26.0 -04:00:00
committer Augustin Cavalier <waddlesplash@gmail.com> 2019-04-14 21:21:26.0 -04:00:00
commit
fa84c61a81a1bb13d8a7c62617694c1b9a4bd85a [patch]
tree
12ce7a296a5a54e4b490a17f4a4a6ad9b42cb0a2
parent
0c26c6f155cae53675203c712fce745db84ce544
download
hrev53070.tar.gz

nvme_disk: Round the length to the proper offset for partial reads.

Following this commit, Haiku boots successfully in VMware from a
NVMe device!

Diff

 src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 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 402c894..db4e386 100644
--- a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
+++ b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
@@ -288,8 +288,8 @@

	// libnvme does transfers in units of device sectors, so if we have to
	// round either the position or the length, we will need a bounce buffer.
	off_t rounded_pos = ROUNDDOWN(pos, block_size);
	size_t rounded_len = ROUNDUP(*length, block_size);
	const off_t rounded_pos = ROUNDDOWN(pos, block_size);
	size_t rounded_len = ROUNDUP((*length) + (pos - rounded_pos), block_size);
	if (rounded_pos != pos || rounded_len != *length
			|| IS_USER_ADDRESS(buffer)) {
		void* bounceBuffer = malloc(rounded_len);