Block patch for 4.1.0-rc3:

- Fix CID 1403771 in block/nvme.c
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEkb62CjDbPohX0Rgp9AfbAGHVz0AFAl1APWgSHG1yZWl0ekBy
 ZWRoYXQuY29tAAoJEPQH2wBh1c9AeN0H/0DBLJz9Jcc679RCGg4JPCrOcfvusHzr
 rUd5lxx9al9c3VoSHqXFb0QIYNJnFP+ylLT/Pbt7KrXBimT2xpGEpsoSYv59OYA7
 qcOrHqVkUeIB8CWxA7qQxZC6ZHWvRApZqsIsNzcm/KBNd25gpmZO507ByEefZzYQ
 3RenEhpZQIfsbdgMgkXW/xh1o2JrCas4JbHrwJQKF0NfmLSOMvJx9lflOf7dEkQw
 nTa/UwfBiA2e5tzcnl89BS2/kZ6g4Ug1h1IYk7g63QTcYeb88jjxLQltmoSR+daG
 5hza5M5OJw98fFIOZOiYbwdPTaeHjcTTeuJXbb1Em8A1S95Pe2eTWg0=
 =oi2U
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-07-30' into staging

Block patch for 4.1.0-rc3:
- Fix CID 1403771 in block/nvme.c

# gpg: Signature made Tue 30 Jul 2019 13:51:52 BST
# gpg:                using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40
# gpg:                issuer "mreitz@redhat.com"
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2019-07-30:
  nvme: Limit blkshift to 12 (for 4 kB blocks)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-07-30 14:23:07 +01:00
commit 8517bf8405

View File

@ -105,7 +105,7 @@ typedef struct {
uint64_t nsze; /* Namespace size reported by identify command */
int nsid; /* The namespace id to read/write data. */
size_t blkshift;
int blkshift;
uint64_t max_transfer;
bool plugged;
@ -420,7 +420,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
NvmeIdNs *idns;
NvmeLBAF *lbaf;
uint8_t *resp;
int r, hwsect_size;
int r;
uint64_t iova;
NvmeCmd cmd = {
.opcode = NVME_ADM_CMD_IDENTIFY,
@ -474,11 +474,11 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
goto out;
}
hwsect_size = 1 << lbaf->ds;
if (hwsect_size < BDRV_SECTOR_SIZE || hwsect_size > s->page_size) {
error_setg(errp, "Namespace has unsupported block size (%d)",
hwsect_size);
if (lbaf->ds < BDRV_SECTOR_BITS || lbaf->ds > 12 ||
(1 << lbaf->ds) > s->page_size)
{
error_setg(errp, "Namespace has unsupported block size (2^%d)",
lbaf->ds);
goto out;
}
@ -804,16 +804,16 @@ static int64_t nvme_getlength(BlockDriverState *bs)
return s->nsze << s->blkshift;
}
static int64_t nvme_get_blocksize(BlockDriverState *bs)
static uint32_t nvme_get_blocksize(BlockDriverState *bs)
{
BDRVNVMeState *s = bs->opaque;
assert(s->blkshift >= BDRV_SECTOR_BITS);
return 1 << s->blkshift;
assert(s->blkshift >= BDRV_SECTOR_BITS && s->blkshift <= 12);
return UINT32_C(1) << s->blkshift;
}
static int nvme_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
{
int64_t blocksize = nvme_get_blocksize(bs);
uint32_t blocksize = nvme_get_blocksize(bs);
bsz->phys = blocksize;
bsz->log = blocksize;
return 0;