HomeFreeBSD

bhyve nvme: Fix LBA out-of-range calculation

Description

bhyve nvme: Fix LBA out-of-range calculation

The function which checks for a valid LBA range mistakenly named an
input value as NLB ("Number of Logical Blocks") instead of "number of
blocks". The NVMe specification defines NLB as a zero-based value (i.e.
NLB=0x0 represents 1 block, 0x1 is 2 blocks, etc.), but the passed
parameter is a 1's-based value.

Fix is to rename the variable to avoid future confusion.

While in the neighborhood, also check that the starting LBA is less than
the size of the backing storage to avoid an integer overflow.

Reviewed by: imp, allanjude, jhb
Tested by: jason@tubnor.net
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D33575

Details

Provenance
chuckAuthored on Jan 30 2022, 7:09 AM
Reviewer
imp
Differential Revision
D33575: bhyve nvme: Fix LBA out-of-range calculation
Parents
rG073f2076fea4: bhyve nvme: Add Select support to Get Features
Branches
Unknown
Tags
Unknown