This series lets a ufs-lu be a host-managed zoned block device (ZBC) with zoned=on, so that the zoned storage stack, for example f2fs on host-managed zones, can be tested on UFS without zoned UFS hardware. Patches 1-3 fix the command path that the zoned code relies on and can be merged first; patch 4 documents zoned logical units, patch 5 adds them and patch 6 the tests.
Not modelled: persistent zone state, conventional and gap zones, and the zoned UFS descriptor bits. Tested with the UFS qtests (also under ASan and UBSan) and with Linux 7.3-rc7 and android17-6.18 guests, legacy doorbell and MCQ: fio --zonemode=zbd with verification, blkzone, and f2fs on android17-6.18. Changes in v2: - Drop the hw/scsi patch: scsi-hd stays TYPE_DISK and ufs-lu reports TYPE_ZBC itself. With v1's TYPE_ZBC scsi-hd, MODE SENSE failed and the guest never sent a flush. - New patches 1-3: a crash on commands without a PRDT, SYNCHRONIZE CACHE(16), and PRDTs longer than the CDB transfer length. - Fix v1's REPORT ZONES buffer overflow, NULL zone dereference past the last zone, division by zero with zoned.zone_size=0, and its zone state handling. - Move the write pointer back when a write fails or is aborted, reject UNMAP, drop zoned.zone_capacity. - Add trace events, tests and documentation. - Jeuk's Reviewed-by on v1 is not carried over, since both patches changed substantially. - Link to v1: https://lore.kernel.org/qemu-devel/20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3 --- Daejun Park (6): hw/ufs: Fail SCSI commands that move data without a PRDT hw/ufs: Pass SYNCHRONIZE CACHE(16) to scsi-hd as SYNCHRONIZE CACHE(10) hw/ufs: Limit data transfers to the transfer length of the CDB docs/system: Document zoned UFS logical units hw/ufs: Support for Zoned UFS tests/qtest: Add tests for Zoned UFS docs/system/devices/ufs.rst | 55 +++ hw/ufs/lu.c | 886 ++++++++++++++++++++++++++++++++- hw/ufs/trace-events | 6 + hw/ufs/ufs.h | 36 ++ include/block/ufs.h | 27 + tests/qtest/ufs-test.c | 1146 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 2151 insertions(+), 5 deletions(-) --- base-commit: 7e8d3c7fc460fe7cd28a3e423d7466fa292bc269 change-id: 20261016-zoned-ufs-0a6c741446a9 Best regards, -- Daejun Park <[email protected]>
