From nobody Tue May 21 11:25:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1563812265; cv=none; d=zoho.com; s=zohoarc; b=WyjNM8TWXp6/TdWAHh2KzOYSUytEp1mvLtNdCBnCXsKLNxY/Yt5noynk45mwit7kIW2dD8+g46fsiCp4pjXd5kvf8gg8dqhLWveyMQj1MAQ2cfqSFqUEFbt4mqazYiUuWdh8JByup7ScL3O+1wd8pmi496PgO7YQCxh04JjXJvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563812265; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sfTY8XQYwydUBik6pz+sOsPpf+J/3/G7lA07pOd4fqU=; b=Fj/L17L5ljjpfReUYsEM02DhPr3NlshijboTFTLtywR6Rf4FZ1crX6bQSVIxVRi3evTIH3RTPAi0dEZYhV9ebTXkzr5Vr08PioEMc2jdjIZsnu43mfadwBkGsNqughLS817mYTmNh8iHKSufTOF15pR2EpMKX1RminGwdou7uWI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563812265981695.445493907027; Mon, 22 Jul 2019 09:17:45 -0700 (PDT) Received: from localhost ([::1]:35700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpb0S-0006xQ-VO for importer@patchew.org; Mon, 22 Jul 2019 12:17:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33496) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpazl-0004di-7u for qemu-devel@nongnu.org; Mon, 22 Jul 2019 12:17:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpazj-0006P6-TY for qemu-devel@nongnu.org; Mon, 22 Jul 2019 12:17:01 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:40104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hpazj-0006Ni-MH for qemu-devel@nongnu.org; Mon, 22 Jul 2019 12:16:59 -0400 Received: by mail-wr1-x432.google.com with SMTP id r1so40042676wrl.7 for ; Mon, 22 Jul 2019 09:16:59 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:10f7:67c8:abb4:8512]) by smtp.gmail.com with ESMTPSA id o6sm77717501wra.27.2019.07.22.09.16.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 09:16:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sfTY8XQYwydUBik6pz+sOsPpf+J/3/G7lA07pOd4fqU=; b=fUfFs+wfU88pwlAac2ZSQcbJ3+3yBnxY16nFTAO3XTNH/xfKDc4/wqFu1XIkl4ZdJT 3y/Ms1kPohW2l+zHIeyhppAUHGzXmFNJBv02YnEB0PysD/cSF+BLENO1mt/B7VEBGr8J vmAIMuu2HlWvMI8WmjdZFN3YYwGgw/d5M8wXLzsITv5ef4lG3s7dFfA52JhgOPskytF1 I2YShBIBjKi9yapeu3x2DSeqFvEUpJSA/Y/YKAaVF3P0RVDWpcl2aNKk6dSdnl6dzFNO TxNQmKugZor/VDegrZe2WRNYZW/RRn4rHlkdQTASW0QcuQ559oECfJ//jyKaLm/qLGHf BZ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=sfTY8XQYwydUBik6pz+sOsPpf+J/3/G7lA07pOd4fqU=; b=Igy5NjBysmuMp4XJtp23twB+GprghJ67EYr7Yyk4Jd8wTtqYT/E4RhSqwFICcfm8bW 84PaSBEiOJRzBAEesTWJQKcrNEM3D/wTwLcz+iYzXMq60ev0C75u7015syRvWSL2Kjwi NA3VzJvoIP4g6urUqXxqA8mwh/tfY3v0k0fQKb+9ijmjWoXejb5GBKxj+1v+P1ZlljYO lIBYLnZUM9XxBxLp0iDvZpvKrmhuXaBjya3plIBfHs2XPnNTXmC8wBaVPKbjwwBRidEZ o1Wo/B8GRcBMK/nycrwzYrlsMoxT4NmqQfFY2jruEZAvwMwv6PXEqz2xgZ786BoDU2+P vkQQ== X-Gm-Message-State: APjAAAX0C2QZ9xvofNNCZHa/LDu9rWqsLGQXi1CBZY4kWXTXbi2Khw8v CTP08NJxlS71Udgfmh34/z+aA+FBZBg= X-Google-Smtp-Source: APXvYqyoJqCDcBN+GuXPu4/ITHhUNzEq3QjbfVuZ5aYlXp+RxkAhxR1MXz4Dtx8DGY7Hnv6IDeUV+w== X-Received: by 2002:a05:6000:11c6:: with SMTP id i6mr69385575wrx.193.1563812218361; Mon, 22 Jul 2019 09:16:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 22 Jul 2019 18:16:56 +0200 Message-Id: <20190722161657.8188-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190722161657.8188-1-pbonzini@redhat.com> References: <20190722161657.8188-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [PULL 1/2] virtio-scsi: fixed virtio_scsi_ctx_check failed when detaching scsi disk X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhengui li Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Zhengui li commit a6f230c move blockbackend back to main AioContext on unplug. It set = the AioContext of SCSIDevice to the main AioContex, but s->ctx is still the iothread AioConte= x=C3=AF=C2=BC=CB=86if the scsi controller is configure with iothread=C3=AF=C2=BC=E2=80=B0. So if there are having in-= flight requests during unplug, a failing assertion happend. The bt is below: (gdb) bt #0 0x0000ffff86aacbd0 in raise () from /lib64/libc.so.6 #1 0x0000ffff86aadf7c in abort () from /lib64/libc.so.6 #2 0x0000ffff86aa6124 in __assert_fail_base () from /lib64/libc.so.6 #3 0x0000ffff86aa61a4 in __assert_fail () from /lib64/libc.so.6 #4 0x0000000000529118 in virtio_scsi_ctx_check (d=3D, s=3D<= optimized out>, s=3D) at /home/qemu-4.0.0/hw/scsi/virtio-scs= i.c:246 #5 0x0000000000529ec4 in virtio_scsi_handle_cmd_req_prepare (s=3D0x2779ec0= 0, req=3D0xffff740397d0) at /home/qemu-4.0.0/hw/scsi/virtio-scsi.c:559 #6 0x000000000052a228 in virtio_scsi_handle_cmd_vq (s=3D0x2779ec00, vq=3D0= xffff7c6d7110) at /home/qemu-4.0.0/hw/scsi/virtio-scsi.c:603 #7 0x000000000052afa8 in virtio_scsi_data_plane_handle_cmd (vdev=3D, vq=3D0xffff7c6d7110) at /home/qemu-4.0.0/hw/scsi/virtio-scsi-data= plane.c:59 #8 0x000000000054d94c in virtio_queue_host_notifier_aio_poll (opaque=3D) at /home/qemu-4.0.0/hw/virtio/virtio.c:2452 assert(blk_get_aio_context(d->conf.blk) =3D=3D s->ctx) failed. To avoid assertion failed, moving the "if" after qdev_simple_device_unplug= _cb. In addition, to avoid another qemu crash below, add aio_disable_external be= fore qdev_simple_device_unplug_cb, which disable the further processing of exter= nal clients when doing qdev_simple_device_unplug_cb. (gdb) bt #0 scsi_req_unref (req=3D0xffff6802c6f0) at hw/scsi/scsi-bus.c:1283 #1 0x00000000005294a4 in virtio_scsi_handle_cmd_req_submit (req=3D, s=3D) at /home/qemu-4.0.0/hw/scsi/virtio-scsi.c:589 #2 0x000000000052a2a8 in virtio_scsi_handle_cmd_vq (s=3Ds@entry=3D0x9c90e9= 0, vq=3Dvq@entry=3D0xffff7c05f110) at /home/qemu-4.0.0/hw/scsi/virtio-scsi= .c:625 #3 0x000000000052afd8 in virtio_scsi_data_plane_handle_cmd (vdev=3D, vq=3D0xffff7c05f110) at /home/qemu-4.0.0/hw/scsi/virtio-scsi-dataplane.= c:60 #4 0x000000000054d97c in virtio_queue_host_notifier_aio_poll (opaque=3D) at /home/qemu-4.0.0/hw/virtio/virtio.c:2447 #5 0x00000000009b204c in run_poll_handlers_once (ctx=3Dctx@entry=3D0x6efea= 40, timeout=3Dtimeout@entry=3D0xffff7d7f7308) at util/aio-posix.c:521 #6 0x00000000009b2b64 in run_poll_handlers (ctx=3Dctx@entry=3D0x6efea40, max_ns=3Dmax_ns@entry=3D4000, timeout=3Dtimeout@entry=3D0xffff7d7f7308)= at util/aio-posix.c:559 #7 0x00000000009b2ca0 in try_poll_mode (ctx=3Dctx@entry=3D0x6efea40, timeo= ut=3D0xffff7d7f7308, timeout@entry=3D0xffff7d7f7348) at util/aio-posix.c:594 #8 0x00000000009b31b8 in aio_poll (ctx=3D0x6efea40, blocking=3Dblocking@en= try=3Dtrue) at util/aio-posix.c:636 #9 0x00000000006973cc in iothread_run (opaque=3D0x6ebd800) at iothread.c:75 #10 0x00000000009b592c in qemu_thread_start (args=3D0x6efef60) at util/qemu= -thread-posix.c:502 #11 0x0000ffff8057f8bc in start_thread () from /lib64/libpthread.so.0 #12 0x0000ffff804e5f8c in thread_start () from /lib64/libc.so.6 (gdb) p bus $1 =3D (SCSIBus *) 0x0 Signed-off-by: Zhengui li Message-Id: <1563696502-7972-1-git-send-email-lizhengui@huawei.com> Signed-off-by: Paolo Bonzini --- hw/scsi/virtio-scsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index d0bdbff090..aa33819d59 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -841,14 +841,16 @@ static void virtio_scsi_hotunplug(HotplugHandler *hot= plug_dev, DeviceState *dev, virtio_scsi_release(s); } =20 + aio_disable_external(s->ctx); + qdev_simple_device_unplug_cb(hotplug_dev, dev, errp); + aio_enable_external(s->ctx); + if (s->ctx) { virtio_scsi_acquire(s); /* If other users keep the BlockBackend in the iothread, that's ok= */ blk_set_aio_context(sd->conf.blk, qemu_get_aio_context(), NULL); virtio_scsi_release(s); } - - qdev_simple_device_unplug_cb(hotplug_dev, dev, errp); } =20 static struct SCSIBusInfo virtio_scsi_scsi_info =3D { --=20 2.21.0 From nobody Tue May 21 11:25:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1563812250; cv=none; d=zoho.com; s=zohoarc; b=U61k0/Etx3Gs3+hJL3wJ4SlEccB3yKZsZD4tAMzajl5GjXJrnDuRNzMqLwQA+Cn+99MXRlR7m+ggx2JAzS98aFBeo0jlSDbZ2ws9nR7l5TdlBPFKIoRpCe8z2bH+XJ4MGmzCLV0eJH0Ta0rg2GoMEua642hWTj9T0TwBGeKL0aA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563812250; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=AdVUU+R8Ux7jmIt6GoFxhTDhy7zQnJVp6dVmD0rp2YU=; b=LqNFdYGe1GnLsqtpbpQnwA/Dd9cSMFhXcTobnI/QdVpqa7tN04aWCApHHugXUMX2/m4TBkE+FLJEkJ2r0jrAW0JCOk2VEbWDlKeung5g/Et04tvdRyLByVxJd3Kxdxe8raSgFljX5mTOy3ZqPrgC0gIOgdx0Ran/3QcusQgndbQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563812250265520.7931010625367; Mon, 22 Jul 2019 09:17:30 -0700 (PDT) Received: from localhost ([::1]:35688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpb0D-0005uC-1C for importer@patchew.org; Mon, 22 Jul 2019 12:17:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33520) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpazm-0004dv-4W for qemu-devel@nongnu.org; Mon, 22 Jul 2019 12:17:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpazk-0006RA-VV for qemu-devel@nongnu.org; Mon, 22 Jul 2019 12:17:02 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:34649) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hpazk-0006PL-O6 for qemu-devel@nongnu.org; Mon, 22 Jul 2019 12:17:00 -0400 Received: by mail-wm1-x331.google.com with SMTP id w9so29130390wmd.1 for ; Mon, 22 Jul 2019 09:17:00 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:10f7:67c8:abb4:8512]) by smtp.gmail.com with ESMTPSA id o6sm77717501wra.27.2019.07.22.09.16.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 09:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AdVUU+R8Ux7jmIt6GoFxhTDhy7zQnJVp6dVmD0rp2YU=; b=fKbsioali0XnQrJd9t8tVedx3xe8rCU7kp0nWaH3Qe9PD8WK+ntsc2jOkYyb8N9N1N mj6Wmh4zor5b6bdLxDHut5YhTyxpaMXzaCholy4OFxvfCL8ehUhaqX3jzCNO3u42GWiM fHOnW1rGAwyROL1MOyejV5QlYFL1Vc46KBb3Nnhtncdy82YaH5Wsv3zjJO+VK4Mq74Gk W8PtVmz1Kp0viX6x6s5BlxnC797spfzqJStXEwHrHjWPRGW6iL5oL57HRlCHyJma8WCE wx36ztIunIi2JintIkyq55Bcg4iomldYnBQ1rIfbaJo67SbULo9D097oFXLc4QMcsJeK cmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=AdVUU+R8Ux7jmIt6GoFxhTDhy7zQnJVp6dVmD0rp2YU=; b=S0UbsE3WsubpYQ6NiT27scJ44rj6AI2Cx5yeRc4xkJFB3M5c/nVeFE11nctSXbERIa 06MmiQBfqedRR1CYpSeDzp1sINLAxibca7fNG+ULYtebrP9bXjTGITGEIZn9dxEIAq8b IXispyNPColrPya9WpoipXXrK3T1pJkRMWLKfTZVLjcklZuuzT+VsO1f+a7FNA6HGNXf BVHxJ9OtFtYXA+ETTSHPHRTENQzAHPbfj35uh6frMzYwxbVBfkE38sZjA2fW+C003Of/ eWTkzA2tSityRJdKgapGFl2ykTCqWavhEXjO/CeZiGkfqY+wXl9Ksf2d9t5kvHMf7+Lk HBXQ== X-Gm-Message-State: APjAAAU9Erm8lwN+4cUnj0z7bZcctvDVCIImXDwE8iB3vWjGNrGyuSxV eU4ljmR6kxNMTF5/9kw+Ll3OzNPQBPs= X-Google-Smtp-Source: APXvYqyTmqxZbsjocdoMcwCqim69VqmiT6iiRxoUS2pnEfsbBcdr6UEFX8kkbvRKLzR4Lx9CHd5+uA== X-Received: by 2002:a7b:ce18:: with SMTP id m24mr62460427wmc.126.1563812219411; Mon, 22 Jul 2019 09:16:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 22 Jul 2019 18:16:57 +0200 Message-Id: <20190722161657.8188-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190722161657.8188-1-pbonzini@redhat.com> References: <20190722161657.8188-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 2/2] i386/kvm: Do not sync nested state during runtime X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kiszka Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jan Kiszka Writing the nested state e.g. after a vmport access can invalidate important parts of the kernel-internal state, and it is not needed as well. So leave this out from KVM_PUT_RUNTIME_STATE. Suggested-by: Paolo Bonzini Signed-off-by: Jan Kiszka Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index ada89d27cc..dbbb13772a 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -3563,12 +3563,12 @@ int kvm_arch_put_registers(CPUState *cpu, int level) =20 assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); =20 - ret =3D kvm_put_nested_state(x86_cpu); - if (ret < 0) { - return ret; - } - if (level >=3D KVM_PUT_RESET_STATE) { + ret =3D kvm_put_nested_state(x86_cpu); + if (ret < 0) { + return ret; + } + ret =3D kvm_put_msr_feature_control(x86_cpu); if (ret < 0) { return ret; --=20 2.21.0