hw/block/nvme: fix zone boundary check for append
commita679dc3efd580de67f30dcb8cb1a52a4bb559899
authorKlaus Jensen <k.jensen@samsung.com>
Tue, 19 Jan 2021 11:42:58 +0000 (19 12:42 +0100)
committerKlaus Jensen <k.jensen@samsung.com>
Mon, 8 Feb 2021 20:15:54 +0000 (8 21:15 +0100)
tree4bbc7daca1bdd55b9bf3dba4af8d423d19d63f7d
parent74cbbf3031e92c44bb138f16d3f0dc46ca2bc84c
hw/block/nvme: fix zone boundary check for append

When a zone append is processed the controller checks that validity of
the write before assigning the LBA to the append command. This causes
the boundary check to be wrong.

Fix this by checking the write *after* assigning the LBA. Remove the
append special case from the nvme_check_zone_write and open code it in
nvme_do_write, assigning the slba when basic sanity checks have been
performed. Then check the validity of the resulting write like any other
write command.

In the process, also fix a missing endianness conversion for the zone
append ALBA.

Reported-by: Niklas Cassel <Niklas.Cassel@wdc.com>
Cc: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Tested-by: Niklas Cassel <niklas.cassel@wdc.com>
Tested-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
hw/block/nvme.c