History log of /haiku/src/add-ons/kernel/drivers/disk/virtual/virtio_block/virtio_block.cpp
Revision Date Author Comments
# 8a0910dd 29-Nov-2023 Murai Takashi <tmurai01@gmail.com>

disk/virtual: Fix use after free

Pointed out by cppcheck.

Change-Id: I785b7ee5623ac9fb37f2be0b9a75cdd82b5784fa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7257
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 8b567520 16-Oct-2023 Jérôme Duval <jerome.duval@gmail.com>

virtio_block: serialize requests, copy using user_memcpy

fix #18621 #18286

Change-Id: Ia1ecb1b3623b10b42bf6153bdbabb7053179ee3d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7048
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 6d42b430 03-Oct-2023 Jérôme Duval <jerome.duval@gmail.com>

virtio: support modern devices

fixes #17239 #17238

Change-Id: Ia5b6347110a60fab18852079b30dca6301010474
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6995
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 103c671e 27-Apr-2023 Augustin Cavalier <waddlesplash@gmail.com>

AbstractModuleDevice: Add generic read/write hooks via "io" hook.

This substitutes for the already-existing behavior of scsi_cd, scsi_disk,
and virtio_block, so we can delete their hooks and let them use
these new generic fallbacks.

Some other drivers perform clamping, and so using these fallbacks would
constitute a behavioral change.

Change-Id: I9a2e503f2e03abc276bdfc02d1cff1565a9742e9


# f64b0991 27-Apr-2023 Augustin Cavalier <waddlesplash@gmail.com>

scsi & virtio: Clean up IORequest usage.

* Use TransferredBytes() instead of assuming length.
* Consolidate checks and invoke io hook instead of scheduler directly.


# 59f8bbdd 12-Jan-2023 Alexander von Gluck IV <kallisti5@unixzen.com>

virtio_block: fix tracing on 64-bit platforms

Change-Id: I65738c17fc5ec923d47ef63832590ba3f6d28b6d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5993
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 215b685f 11-Dec-2022 X512 <danger_mail@list.ru>

kernel: Drop non-standard GNU inline assignment syntax

* We needed this previously due to our gcc2 compiled kernel.
* Now that our kernel is always latest gcc, we can move to the
c++20 syntax for inline assignment.
* Improves compatibility with clang, less GNU-specific stuff

Change-Id: Ib7272a0a52554a31e9a0e788fd3f031db9049795
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5898
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# ca6d474a 16-Sep-2022 Jérôme Duval <jerome.duval@gmail.com>

virtio_block: add support for the topology feature

gets the physical block size

Change-Id: I7b4d80874d1463a5122c34171956af2b267b1c69
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5669
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 688acf41 15-Sep-2022 Jérôme Duval <jerome.duval@gmail.com>

add physical_block_size field where applicable

only scsi_disk checks the actual value, other drivers take the logical block size.

This change reports the physical block size from the disk rather than the block
size used by IDE/SATA/SCSI commands. On typical modern SATA disks, the SATA
commands will use 512 byte blocks, but the disk will actually read and write
4K blocks internally. This is only of importance for partition alignment for DriveSetup,
and is independant of file systems or partitioning systems. This could also influence
the recommended block size for some file systems.

Change-Id: Id0f2e22659e89fcef64c1f8d04f81cd68995e01f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5667
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# dab646ac 26-Oct-2021 Augustin Cavalier <waddlesplash@gmail.com>

nvme_disk & virtio_block: Remove unneeded log2.

It was used, but then the result discarded. We have a log2()
in kernel/util/BitUtils.h anyway, so if it is really needed,
that should be used instead.


# 73445bc4 25-Jul-2021 X512 <danger_mail@list.ru>

virtio_block: set device name

Change-Id: Id96e0dd2247625b7b898316511da7f1d8d0e3ba0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4314
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# 9a2911ca 01-Sep-2019 Michael Lotz <mmlr@mlotz.ch>

virtio: Rework queue_dequeue to return a boolean.

It previously returned the cookie directly, which made it impossible
to distinguish between a NULL cookie and the function not having
anything to dequeue. This lead to some code setting a cookie that was
not actually used.

Return the dequeue status as a boolean and provide the cookie with an
optionally handed in pointer instead and adjust all users.

Change-Id: Iaac1726ac4bc7ae42bb96b8f0915852b6def5822
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1814
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 9216fc01 18-Jun-2018 Augustin Cavalier <waddlesplash@gmail.com>

More class/struct mixup fixes.

Spotted by Clang.


# 988f9998 26-Apr-2018 Jérôme Duval <jerome.duval@gmail.com>

virtio_block: fix build nach API change.


# 6e82e428 16-Apr-2018 Jérôme Duval <jerome.duval@gmail.com>

virtio: refactor to have a handler per queue.

* enable to iterate on available entries in one interrupt call.
* negociate -> negotiate, (void *) -> (void* ), thanks axel and philippe!

Change-Id: Ie2d290797abcbf4c0f3cb5bfff71d091bb800fa6


# 9e88776c 18-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

virtio_block: takes capacity change into account

* allows live resizing.


# 2f2f475b 18-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

virtio*: remove trailing spaces


# ed4a8e4d 17-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

virtio: changed a bit the driver API by adding a driverCookie.

* the processing of requests in drivers is eased a bit with this change, but
this could be improved for instance by enabling a driver to dequeue items
in a service thread instead of the interrupt handler.
* made a few methods const.


# e89d7992 16-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

virtio_block_callback(): prevent rescheduling

... since it can be called with interrupts disabled.


# 6bbf9c9d 26-May-2013 Jérôme Duval <jerome.duval@gmail.com>

Virtio: added drivers for PCI busses, bus manager and block device.

* the Virtio PCI bus driver exposes a Virtio controller to the Virtio bus manager,
which in turn exposes a Virtio device consumed by Virtio drivers. Drivers follow the
new driver model.
* virtio_block handles Virtio block devices under disk/virtual/virtio_block/x/raw.
* Here is the Qemu command line option for Virtio disk devices:
-drive file=haiku.image,if=virtio
* the PCI bus driver currently supports only legacy interrupts (no MSI(-X) yet).
* There is room for improvements in the bus manager:
- it notifies the host for each queued request, which isn't optimal.
- transfer descriptors should probably be simply preallocated (they are nicely
leaked at the moment).
- indirect descriptors are not supported yet.
and in the block driver:
- get the id of the disk.
- implements flushing the cache.
- improves dma restrictions.
- do_io() should use a page for header descriptors instead of malloc(), which
could cross boundaries.
* The device manager tries to guess the driver based on the PCI device type, this
implies having to declare the "busses/virtio" path for each possible type
provided by Virtio. Thus future driver additions might require patching the device
manager.
* virtio.h is still private, the API is subject to changes.
* virtio_pci.h, virtio_blk.h, virtio_ring.h are copied unchanged from FreeBSD.


# 9e88776c801a3a76f055ad935bd8ff1b0e48ce2e 18-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

virtio_block: takes capacity change into account

* allows live resizing.


# 2f2f475b1d35e32e2afdefe624686d8ab5936c35 18-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

virtio*: remove trailing spaces


# ed4a8e4d11d7972d6fb6f025c108915ad06c73af 17-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

virtio: changed a bit the driver API by adding a driverCookie.

* the processing of requests in drivers is eased a bit with this change, but
this could be improved for instance by enabling a driver to dequeue items
in a service thread instead of the interrupt handler.
* made a few methods const.


# e89d7992e5406444fb64cd4438c778982dd4604e 16-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

virtio_block_callback(): prevent rescheduling

... since it can be called with interrupts disabled.


# 6bbf9c9da977b2ea9d1caf36a867d320de81a836 26-May-2013 Jérôme Duval <jerome.duval@gmail.com>

Virtio: added drivers for PCI busses, bus manager and block device.

* the Virtio PCI bus driver exposes a Virtio controller to the Virtio bus manager,
which in turn exposes a Virtio device consumed by Virtio drivers. Drivers follow the
new driver model.
* virtio_block handles Virtio block devices under disk/virtual/virtio_block/x/raw.
* Here is the Qemu command line option for Virtio disk devices:
-drive file=haiku.image,if=virtio
* the PCI bus driver currently supports only legacy interrupts (no MSI(-X) yet).
* There is room for improvements in the bus manager:
- it notifies the host for each queued request, which isn't optimal.
- transfer descriptors should probably be simply preallocated (they are nicely
leaked at the moment).
- indirect descriptors are not supported yet.
and in the block driver:
- get the id of the disk.
- implements flushing the cache.
- improves dma restrictions.
- do_io() should use a page for header descriptors instead of malloc(), which
could cross boundaries.
* The device manager tries to guess the driver based on the PCI device type, this
implies having to declare the "busses/virtio" path for each possible type
provided by Virtio. Thus future driver additions might require patching the device
manager.
* virtio.h is still private, the API is subject to changes.
* virtio_pci.h, virtio_blk.h, virtio_ring.h are copied unchanged from FreeBSD.