* [Qemu-devel] [PATCH v2 0/3] nvme small fix @ 2019-01-11 2:08 Li Qiang 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 1/3] nvme: use TYPE_NVME instead of constant string Li Qiang ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Li Qiang @ 2019-01-11 2:08 UTC (permalink / raw) To: keith.busch, kwolf, mreitz; +Cc: qemu-block, qemu-devel, Li Qiang This patchset contains small fix. Change since v1: 1. drop the patch of checking return value of msix_init_exclusive_bar 2. return when nvme's num_queues configuration is 0 Li Qiang (3): nvme: use TYPE_NVME instead of constant string nvme: ensure the num_queues is not zero nvme: use pci_dev directly in nvme_realize hw/block/nvme.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] nvme: use TYPE_NVME instead of constant string 2019-01-11 2:08 [Qemu-devel] [PATCH v2 0/3] nvme small fix Li Qiang @ 2019-01-11 2:08 ` Li Qiang 2019-01-14 11:08 ` Philippe Mathieu-Daudé 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 2/3] nvme: ensure the num_queues is not zero Li Qiang 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 3/3] nvme: use pci_dev directly in nvme_realize Li Qiang 2 siblings, 1 reply; 7+ messages in thread From: Li Qiang @ 2019-01-11 2:08 UTC (permalink / raw) To: keith.busch, kwolf, mreitz; +Cc: qemu-block, qemu-devel, Li Qiang Signed-off-by: Li Qiang <liq3ea@gmail.com> Reviewed-by: Max Reitz <mreitz@redhat.com> --- hw/block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 7c8c63e8f5..f206391e8e 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1381,7 +1381,7 @@ static void nvme_instance_init(Object *obj) } static const TypeInfo nvme_info = { - .name = "nvme", + .name = TYPE_NVME, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(NvmeCtrl), .class_init = nvme_class_init, -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/3] nvme: use TYPE_NVME instead of constant string 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 1/3] nvme: use TYPE_NVME instead of constant string Li Qiang @ 2019-01-14 11:08 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 7+ messages in thread From: Philippe Mathieu-Daudé @ 2019-01-14 11:08 UTC (permalink / raw) To: Li Qiang, keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block On 1/11/19 3:08 AM, Li Qiang wrote: > Signed-off-by: Li Qiang <liq3ea@gmail.com> > Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > hw/block/nvme.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > index 7c8c63e8f5..f206391e8e 100644 > --- a/hw/block/nvme.c > +++ b/hw/block/nvme.c > @@ -1381,7 +1381,7 @@ static void nvme_instance_init(Object *obj) > } > > static const TypeInfo nvme_info = { > - .name = "nvme", > + .name = TYPE_NVME, > .parent = TYPE_PCI_DEVICE, > .instance_size = sizeof(NvmeCtrl), > .class_init = nvme_class_init, > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] nvme: ensure the num_queues is not zero 2019-01-11 2:08 [Qemu-devel] [PATCH v2 0/3] nvme small fix Li Qiang 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 1/3] nvme: use TYPE_NVME instead of constant string Li Qiang @ 2019-01-11 2:08 ` Li Qiang 2019-01-14 11:15 ` Philippe Mathieu-Daudé 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 3/3] nvme: use pci_dev directly in nvme_realize Li Qiang 2 siblings, 1 reply; 7+ messages in thread From: Li Qiang @ 2019-01-11 2:08 UTC (permalink / raw) To: keith.busch, kwolf, mreitz; +Cc: qemu-block, qemu-devel, Li Qiang When it is zero, it causes segv. Backtrack: Thread 5 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffc6c17700 (LWP 51808)] 0x0000555555acbd90 in nvme_start_ctrl (n=0x6240000c8100) at hw/block/nvme.c:820 warning: Source file is more recent than executable. 820 if (unlikely(n->cq[0])) { (gdb) bt 0 0x0000555555acbd90 in nvme_start_ctrl (n=0x6240000c8100) at hw/block/nvme.c:820 1 0x0000555555accdbc in nvme_write_bar (n=0x6240000c8100, offset=20, data=4587521, size=4) at hw/block/nvme.c:964 2 0x0000555555acdd2b in nvme_mmio_write (opaque=0x6240000c8100, addr=20, data=4587521, size=4) at hw/block/nvme.c:1158 3 0x00005555558973ed in memory_region_write_accessor (mr=0x6240000c89e0, addr=20, value=0x7fffc6c14428, size=4, shift=0, mask=4294967295, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:500 4 0x0000555555897600 in access_with_adjusted_size (addr=20, value=0x7fffc6c14428, size=4, access_size_min=2, access_size_max=8, access_fn=0x555555897304 <memory_region_write_accessor>, mr=0x6240000c89e0, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:566 5 0x000055555589a200 in memory_region_dispatch_write (mr=0x6240000c89e0, addr=20, data=4587521, size=4, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:1442 6 0x0000555555835151 in flatview_write_continue (fv=0x6060000e6fc0, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4, addr1=20, l=4, mr=0x6240000c89e0) at /home/liqiang02/qemu-upstream/qemu/exec.c:3233 7 0x000055555583529b in flatview_write (fv=0x6060000e6fc0, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4) at /home/liqiang02/qemu-upstream/qemu/exec.c:3272 8 0x00005555558355a1 in address_space_write (as=0x55555683ade0 <address_space_memory>, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4) at /home/liqiang02/qemu-upstream/qemu/exec.c:3362 9 0x00005555558355f2 in address_space_rw (as=0x55555683ade0 <address_space_memory>, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4, is_write=true) at /home/liqiang02/qemu-upstream/qemu/exec.c:3373 10 0x00005555558b66ac in kvm_cpu_exec (cpu=0x631000014800) at /home/liqiang02/qemu-upstream/qemu/accel/kvm/kvm-all.c:2031 11 0x000055555587c3ac in qemu_kvm_cpu_thread_fn (arg=0x631000014800) at /home/liqiang02/qemu-upstream/qemu/cpus.c:1277 12 0x0000555555e54ae6 in qemu_thread_start (args=0x60300002c170) at util/qemu-thread-posix.c:504 13 0x00007fffdadbd494 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 14 0x00007fffdaaffacf in clone () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) q Signed-off-by: Li Qiang <liq3ea@gmail.com> --- hw/block/nvme.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index f206391e8e..0ded74fa9a 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1223,6 +1223,11 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) error_setg(errp, "serial property not set"); return; } + + if (!n->num_queues) { + error_setg(errp, "num_queues can't be zero"); + return; + } blkconf_blocksizes(&n->conf); if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), false, errp)) { -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/3] nvme: ensure the num_queues is not zero 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 2/3] nvme: ensure the num_queues is not zero Li Qiang @ 2019-01-14 11:15 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 7+ messages in thread From: Philippe Mathieu-Daudé @ 2019-01-14 11:15 UTC (permalink / raw) To: Li Qiang, keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block Hi Li, On 1/11/19 3:08 AM, Li Qiang wrote: > When it is zero, it causes segv. Backtrack: > Thread 5 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. Can you add the relevant part of the command line you used here? > [Switching to Thread 0x7fffc6c17700 (LWP 51808)] > 0x0000555555acbd90 in nvme_start_ctrl (n=0x6240000c8100) at hw/block/nvme.c:820 > warning: Source file is more recent than executable. ^ drop this line > 820 if (unlikely(n->cq[0])) { > (gdb) bt > 0 0x0000555555acbd90 in nvme_start_ctrl (n=0x6240000c8100) at hw/block/nvme.c:820 > 1 0x0000555555accdbc in nvme_write_bar (n=0x6240000c8100, offset=20, data=4587521, size=4) at hw/block/nvme.c:964 > 2 0x0000555555acdd2b in nvme_mmio_write (opaque=0x6240000c8100, addr=20, data=4587521, size=4) at hw/block/nvme.c:1158 > 3 0x00005555558973ed in memory_region_write_accessor (mr=0x6240000c89e0, addr=20, value=0x7fffc6c14428, size=4, shift=0, mask=4294967295, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:500 > 4 0x0000555555897600 in access_with_adjusted_size (addr=20, value=0x7fffc6c14428, size=4, access_size_min=2, access_size_max=8, access_fn=0x555555897304 <memory_region_write_accessor>, mr=0x6240000c89e0, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:566 > 5 0x000055555589a200 in memory_region_dispatch_write (mr=0x6240000c89e0, addr=20, data=4587521, size=4, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:1442 > 6 0x0000555555835151 in flatview_write_continue (fv=0x6060000e6fc0, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4, addr1=20, l=4, mr=0x6240000c89e0) at /home/liqiang02/qemu-upstream/qemu/exec.c:3233 > 7 0x000055555583529b in flatview_write (fv=0x6060000e6fc0, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4) at /home/liqiang02/qemu-upstream/qemu/exec.c:3272 > 8 0x00005555558355a1 in address_space_write (as=0x55555683ade0 <address_space_memory>, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4) at /home/liqiang02/qemu-upstream/qemu/exec.c:3362 > 9 0x00005555558355f2 in address_space_rw (as=0x55555683ade0 <address_space_memory>, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4, is_write=true) at /home/liqiang02/qemu-upstream/qemu/exec.c:3373 > 10 0x00005555558b66ac in kvm_cpu_exec (cpu=0x631000014800) at /home/liqiang02/qemu-upstream/qemu/accel/kvm/kvm-all.c:2031 > 11 0x000055555587c3ac in qemu_kvm_cpu_thread_fn (arg=0x631000014800) at /home/liqiang02/qemu-upstream/qemu/cpus.c:1277 > 12 0x0000555555e54ae6 in qemu_thread_start (args=0x60300002c170) at util/qemu-thread-posix.c:504 > 13 0x00007fffdadbd494 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 > 14 0x00007fffdaaffacf in clone () from /lib/x86_64-linux-gnu/libc.so.6 > (gdb) q > > Signed-off-by: Li Qiang <liq3ea@gmail.com> > --- > hw/block/nvme.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > index f206391e8e..0ded74fa9a 100644 > --- a/hw/block/nvme.c > +++ b/hw/block/nvme.c > @@ -1223,6 +1223,11 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) > error_setg(errp, "serial property not set"); > return; > } > + > + if (!n->num_queues) { > + error_setg(errp, "num_queues can't be zero"); > + return; > + } I'd add this as the first check, to avoid the blk_getlength() call. > blkconf_blocksizes(&n->conf); > if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), > false, errp)) { > With command line comment: Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] nvme: use pci_dev directly in nvme_realize 2019-01-11 2:08 [Qemu-devel] [PATCH v2 0/3] nvme small fix Li Qiang 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 1/3] nvme: use TYPE_NVME instead of constant string Li Qiang 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 2/3] nvme: ensure the num_queues is not zero Li Qiang @ 2019-01-11 2:08 ` Li Qiang 2019-01-14 11:16 ` Philippe Mathieu-Daudé 2 siblings, 1 reply; 7+ messages in thread From: Li Qiang @ 2019-01-11 2:08 UTC (permalink / raw) To: keith.busch, kwolf, mreitz; +Cc: qemu-block, qemu-devel, Li Qiang There is no need to make another reference. Signed-off-by: Li Qiang <liq3ea@gmail.com> Reviewed-by: Max Reitz <mreitz@redhat.com> --- hw/block/nvme.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 0ded74fa9a..0a1da749fc 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1238,7 +1238,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) pci_conf[PCI_INTERRUPT_PIN] = 1; pci_config_set_prog_interface(pci_dev->config, 0x2); pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS); - pcie_endpoint_cap_init(&n->parent_obj, 0x80); + pcie_endpoint_cap_init(pci_dev, 0x80); n->num_namespaces = 1; n->reg_size = pow2ceil(0x1004 + 2 * (n->num_queues + 1) * 4); @@ -1250,10 +1250,10 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nvme", n->reg_size); - pci_register_bar(&n->parent_obj, 0, + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &n->iomem); - msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4, NULL); + msix_init_exclusive_bar(pci_dev, n->num_queues, 4, NULL); id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID)); id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID)); @@ -1308,7 +1308,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) n->cmbuf = g_malloc0(NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); memory_region_init_io(&n->ctrl_mem, OBJECT(n), &nvme_cmb_ops, n, "nvme-cmb", NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); - pci_register_bar(&n->parent_obj, NVME_CMBLOC_BIR(n->bar.cmbloc), + pci_register_bar(pci_dev, NVME_CMBLOC_BIR(n->bar.cmbloc), PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH, &n->ctrl_mem); -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] nvme: use pci_dev directly in nvme_realize 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 3/3] nvme: use pci_dev directly in nvme_realize Li Qiang @ 2019-01-14 11:16 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 7+ messages in thread From: Philippe Mathieu-Daudé @ 2019-01-14 11:16 UTC (permalink / raw) To: Li Qiang, keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block On 1/11/19 3:08 AM, Li Qiang wrote: > There is no need to make another reference. > > Signed-off-by: Li Qiang <liq3ea@gmail.com> > Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > hw/block/nvme.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > index 0ded74fa9a..0a1da749fc 100644 > --- a/hw/block/nvme.c > +++ b/hw/block/nvme.c > @@ -1238,7 +1238,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) > pci_conf[PCI_INTERRUPT_PIN] = 1; > pci_config_set_prog_interface(pci_dev->config, 0x2); > pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS); > - pcie_endpoint_cap_init(&n->parent_obj, 0x80); > + pcie_endpoint_cap_init(pci_dev, 0x80); > > n->num_namespaces = 1; > n->reg_size = pow2ceil(0x1004 + 2 * (n->num_queues + 1) * 4); > @@ -1250,10 +1250,10 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) > > memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, > "nvme", n->reg_size); > - pci_register_bar(&n->parent_obj, 0, > + pci_register_bar(pci_dev, 0, > PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, > &n->iomem); > - msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4, NULL); > + msix_init_exclusive_bar(pci_dev, n->num_queues, 4, NULL); > > id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID)); > id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID)); > @@ -1308,7 +1308,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) > n->cmbuf = g_malloc0(NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); > memory_region_init_io(&n->ctrl_mem, OBJECT(n), &nvme_cmb_ops, n, > "nvme-cmb", NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); > - pci_register_bar(&n->parent_obj, NVME_CMBLOC_BIR(n->bar.cmbloc), > + pci_register_bar(pci_dev, NVME_CMBLOC_BIR(n->bar.cmbloc), > PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64 | > PCI_BASE_ADDRESS_MEM_PREFETCH, &n->ctrl_mem); > > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-01-14 11:16 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-01-11 2:08 [Qemu-devel] [PATCH v2 0/3] nvme small fix Li Qiang 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 1/3] nvme: use TYPE_NVME instead of constant string Li Qiang 2019-01-14 11:08 ` Philippe Mathieu-Daudé 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 2/3] nvme: ensure the num_queues is not zero Li Qiang 2019-01-14 11:15 ` Philippe Mathieu-Daudé 2019-01-11 2:08 ` [Qemu-devel] [PATCH v2 3/3] nvme: use pci_dev directly in nvme_realize Li Qiang 2019-01-14 11:16 ` Philippe Mathieu-Daudé
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).