* [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 @ 2019-07-30 12:59 Max Reitz 2019-07-30 12:59 ` [Qemu-devel] [PULL 1/1] nvme: Limit blkshift to 12 (for 4 kB blocks) Max Reitz 2019-07-30 16:00 ` [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 Peter Maydell 0 siblings, 2 replies; 3+ messages in thread From: Max Reitz @ 2019-07-30 12:59 UTC (permalink / raw) To: qemu-block; +Cc: Kevin Wolf, Peter Maydell, qemu-devel, Max Reitz The following changes since commit 6e9a6cbe7d56107f5e0d7711905dc19bb4d7e3f0: Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-07-30 12:25:35 +0100) are available in the Git repository at: https://github.com/XanClic/qemu.git tags/pull-block-2019-07-30 for you to fetch changes up to 1120407bdf70a2c4681464ae08bdb7c615566200: nvme: Limit blkshift to 12 (for 4 kB blocks) (2019-07-30 14:49:24 +0200) ---------------------------------------------------------------- Block patch for 4.1.0-rc3: - Fix CID 1403771 in block/nvme.c ---------------------------------------------------------------- Max Reitz (1): nvme: Limit blkshift to 12 (for 4 kB blocks) block/nvme.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) -- 2.21.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PULL 1/1] nvme: Limit blkshift to 12 (for 4 kB blocks) 2019-07-30 12:59 [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 Max Reitz @ 2019-07-30 12:59 ` Max Reitz 2019-07-30 16:00 ` [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 Peter Maydell 1 sibling, 0 replies; 3+ messages in thread From: Max Reitz @ 2019-07-30 12:59 UTC (permalink / raw) To: qemu-block; +Cc: Kevin Wolf, Peter Maydell, qemu-devel, Max Reitz Linux does not support blocks greater than 4 kB anyway, so we might as well limit blkshift to 12 and thus save us from some potential trouble. Reported-by: Peter Maydell <peter.maydell@linaro.org> Suggested-by: Maxim Levitsky <mlevitsk@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Message-id: 20190730114812.10493-1-mreitz@redhat.com Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Coverity: CID 1403771 Signed-off-by: Max Reitz <mreitz@redhat.com> --- block/nvme.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index c28755cc31..2c85713519 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -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; -- 2.21.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 2019-07-30 12:59 [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 Max Reitz 2019-07-30 12:59 ` [Qemu-devel] [PULL 1/1] nvme: Limit blkshift to 12 (for 4 kB blocks) Max Reitz @ 2019-07-30 16:00 ` Peter Maydell 1 sibling, 0 replies; 3+ messages in thread From: Peter Maydell @ 2019-07-30 16:00 UTC (permalink / raw) To: Max Reitz; +Cc: Kevin Wolf, QEMU Developers, Qemu-block On Tue, 30 Jul 2019 at 13:59, Max Reitz <mreitz@redhat.com> wrote: > > The following changes since commit 6e9a6cbe7d56107f5e0d7711905dc19bb4d7e3f0: > > Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-07-30 12:25:35 +0100) > > are available in the Git repository at: > > https://github.com/XanClic/qemu.git tags/pull-block-2019-07-30 > > for you to fetch changes up to 1120407bdf70a2c4681464ae08bdb7c615566200: > > nvme: Limit blkshift to 12 (for 4 kB blocks) (2019-07-30 14:49:24 +0200) > > ---------------------------------------------------------------- > Block patch for 4.1.0-rc3: > - Fix CID 1403771 in block/nvme.c > > ---------------------------------------------------------------- > Max Reitz (1): > nvme: Limit blkshift to 12 (for 4 kB blocks) > > block/nvme.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) > Applied, thanks. Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1 for any user-visible changes. -- PMM ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-30 16:03 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-07-30 12:59 [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 Max Reitz 2019-07-30 12:59 ` [Qemu-devel] [PULL 1/1] nvme: Limit blkshift to 12 (for 4 kB blocks) Max Reitz 2019-07-30 16:00 ` [Qemu-devel] [PULL 0/1] Block patches for 4.1.0-rc3 Peter Maydell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).