From patchwork Tue Oct 30 05:18:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10660461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A923413A4 for ; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96EED29A86 for ; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87B8729AAF; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2383429A86 for ; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) Received: from localhost ([::1]:50834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMSF-00072a-Bf for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 01:20:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMQi-0005lz-UV for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHMQi-0005V8-3q for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:04 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42898) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHMQb-0005Rm-VV; Tue, 30 Oct 2018 01:18:58 -0400 Received: by mail-pf1-x444.google.com with SMTP id f26-v6so5191983pfn.9; Mon, 29 Oct 2018 22:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q5ERHq/GYs6jQbpyqrBOwyNWI53cjm9LZQoHpww6Txw=; b=qnO8Y/d0SJVwVLYnflkv8fUeWnSzBKV7osgAyq6HNnxE6BX5nlYKdPP2fYpnerZFkT QVuMP4ALrnsEMjj9KAuAotURifYW3bEWegS4jIzSDzWKXqYYI6Nc0Zf9QNyKgZ691bC4 pzWvgbgpqGNNgVvHCn0vAvV+0v+d6PnCHGaXK0WWsR3/7my1+oknef9zCFE3HBswqtPq LXCIRfIvphAxfKGso1dyR4mipQxJhNqFblHKKRgRSUH+/UgzI9eqFYdRmdmRmhkl2InR 0igCzGvU2lRtiI/jTGExPzmfUoZoKWg5axZYL2Us/kmCIbv2dGgPkAxa1OhuA0K5t8ct ao3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q5ERHq/GYs6jQbpyqrBOwyNWI53cjm9LZQoHpww6Txw=; b=DqV1gIwswFQj0o8SRUhQx0/NBX6ZRPO+R5UXz6XMj2/6JZmUsM8b27CZrDx31y6/dX J2JBtu/6C599h00BJIP0dfQOw7s5fV+ZmCsUhNEjsrr0KIoTcgf1SSIVgcdCisk3ulqb m23pJI+2ifFXHEX1X27CMmIiX0f92Q/PYG2V3UU142rqpifuKOEyEb/T7eo57jrvp1g+ ViJjTLRZTZ3T7l75GvFik1R3c1WDPRyaK6c9MCnBQxRYlE5xM4LIxqVUOrsbYuRSP/An p6HchURZhkUEMhy+wWo26L1QTK04vbRdKfx0BytKutb2yg4fabAOeFA04mOUMOhknK7j aYvQ== X-Gm-Message-State: AGRZ1gJ91ktZiW+CbAb3upYXpQIvzszIPAhQAaTN2NpvJKSJ20c3tV1a OYMk2vsMmPx3IU7lUceoWoY= X-Google-Smtp-Source: AJdET5fzcyAHaq6eMYbR2v+YUicJEdn7/dBy8fRbzaFiT0EQ6woOPKu+umP1YM+Ul8nhBCEdzKwltw== X-Received: by 2002:a62:388b:: with SMTP id f133-v6mr1484333pfa.48.1540876737081; Mon, 29 Oct 2018 22:18:57 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id p129-v6sm11463729pgp.92.2018.10.29.22.18.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 22:18:56 -0700 (PDT) From: Li Qiang To: keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com Date: Mon, 29 Oct 2018 22:18:38 -0700 Message-Id: <1540876720-9574-3-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> References: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH 2/4] nvme: ensure the num_queues is not zero X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 , 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 , 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 , 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 --- hw/block/nvme.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 676cc48..72c9644 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1221,6 +1221,10 @@ 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"); + } blkconf_blocksizes(&n->conf); if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), false, errp)) {