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.

(cherry picked from commit 9d8cd04694d47d48cc4003f8322739ba10fa8108)

Details

Provenance
chuckAuthored on Jan 30 2022, 7:09 AM
Parents
rG3444d620b2a4: bhyve nvme: Add Select support to Get Features
Branches
Unknown
Tags
Unknown