From nobody Sun Feb 8 18:41:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577801474; cv=none; d=zohomail.com; s=zohoarc; b=By5lmVP1dYEg4KjGodfEYWT0m3Qh5ASbXHG3m9GpEGchwOttnS5tuh9J6++qz7cKokNXWnwqmOmO1KvGrWlgjxDLbjtZYH7fRyInczwcxyWGhMTEF55PgYD4kG/NH9Wy3y0aj2PiAwHce7LNTWhyhbDf6rswlIVMXKTCKl+TbO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577801474; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fhwohmloHFNfz10OvQXD9ZYCYz5juJudQarfUI3byMA=; b=XFZC1n47e+uysngWXN9DJUX9nmy/zFd7VafSHuvzOqsXL2zJUtHkqltBcOxLLwktfmxiMYhpXEdgzsbfy2FC9HuJ+HU7MlaW7RGnJG4gTRwu5Qfrgf/quFX7F3mBODWxcT22XBzGOiNIsS0obdCxPQc1Maf6IPpcz6APp6/5UPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1577801474555175.32281066502128; Tue, 31 Dec 2019 06:11:14 -0800 (PST) Received: from localhost ([::1]:43124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imIEr-0006hb-14 for importer@patchew.org; Tue, 31 Dec 2019 09:11:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54907) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imHk3-0000Ny-OE for qemu-devel@nongnu.org; Tue, 31 Dec 2019 08:39:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1imHk0-0003gH-Cp for qemu-devel@nongnu.org; Tue, 31 Dec 2019 08:39:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42369 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1imHk0-0003b7-7Q for qemu-devel@nongnu.org; Tue, 31 Dec 2019 08:39:20 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-d_xs_FVqMTqRNgwBxbYQjg-1; Tue, 31 Dec 2019 08:39:18 -0500 Received: by mail-qt1-f197.google.com with SMTP id b14so24675130qtt.1 for ; Tue, 31 Dec 2019 05:39:18 -0800 (PST) Received: from xz-x1.hitronhub.home ([2607:9880:19c0:3f::2]) by smtp.gmail.com with ESMTPSA id x42sm15024955qtc.25.2019.12.31.05.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Dec 2019 05:39:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577799559; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fhwohmloHFNfz10OvQXD9ZYCYz5juJudQarfUI3byMA=; b=QOJ4jpOqmT7hiM3s/DIJG8X/Wqjz+U8PCtm4r2FB535di15Kra0DKChzFWrD/H2URBxyba pIbhYK/NrhZlc7kVoizDyItPnNBStI9ud2rReeAFO6CMeSITslt9sIw58Yw6m7vCCxmfsS VRsjI7qBkILrR25vWOqcezlUFRONZQs= 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:mime-version :content-transfer-encoding; bh=Av/SowyPZxgpgizfimyoTAfL5uv5aRNx7KfXWZx2BLY=; b=SeI9G2RCnebPTAeVFvd8nHAzUGtgAHi9iCuTj10+kB/HIu5wPSKEdj+hLBPE5bV/IY 2z93QoDWWt6br6Sy47PuWXRcU2T2ci9pMLW2AyrU0yAbSykHWB6ghX+jttS+ctr5XTmn nu/4FmbgEAZ+al+XphK03GYswj/nLI+UKCNFb6IqX21pzZcMAUD6MVGyvUomzokiGxwG MD3yoamdmHbaOEeBeXpuCPu4+Oql/6Vp0nLZt8WhjOX/qKy+U5N9Lc9Qf+LUDXpEcWJD 7iSjfzeJdQCyCB/Ogt/ZTGCX7Cy8AsFmKMvjzDOEggCsRquCOf9cGUFqOP5A+LGUo/E9 E8/A== X-Gm-Message-State: APjAAAVotcV213w3wTbPz/krJs0e3EOsFK9K5nCUO6I2jEErySwB3D5y faDd3fAFxk0prUoY6bYwf94z2/WkU1GfgOTta+JgnonxxPYK+gFKBujul6Uv8eEp9h+/c+KnCSC YeEoKYlIkNzhFMDM= X-Received: by 2002:a37:e505:: with SMTP id e5mr53066325qkg.324.1577799557258; Tue, 31 Dec 2019 05:39:17 -0800 (PST) X-Google-Smtp-Source: APXvYqz41MLFmeSA74k5Y7qvfCRlX0SDgenpWNUHCg2t0tzjYNyoSflguk74DgvDcTw9Pjbg+0q/gg== X-Received: by 2002:a37:e505:: with SMTP id e5mr53066311qkg.324.1577799557030; Tue, 31 Dec 2019 05:39:17 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH] vfio/pci: Don't remove irqchip notifier if not registered Date: Tue, 31 Dec 2019 08:39:15 -0500 Message-Id: <20191231133915.115363-1-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-MC-Unique: d_xs_FVqMTqRNgwBxbYQjg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: yanghliu@redhat.com, Alex Williamson , Eduardo Habkost , peterx@redhat.com, David Gibson 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" The kvm irqchip notifier is only registered if the device supports INTx, however it's unconditionally removed. If the assigned device does not support INTx, this will cause QEMU to crash when unplugging the device from the system. Change it to conditionally remove the notifier only if the notify hook is setup. CC: Eduardo Habkost CC: David Gibson CC: Alex Williamson Reported-by: yanghliu@redhat.com Fixes: c5478fea27 ("vfio/pci: Respond to KVM irqchip change notifier", 2019= -11-26) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=3D1782678 Signed-off-by: Peter Xu Reviewed-by: David Gibson Reviewed-by: Greg Kurz --- hw/vfio/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 2d40b396f2..337a173ce7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3076,7 +3076,9 @@ static void vfio_exitfn(PCIDevice *pdev) vfio_unregister_req_notifier(vdev); vfio_unregister_err_notifier(vdev); pci_device_set_intx_routing_notifier(&vdev->pdev, NULL); - kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier); + if (vdev->irqchip_change_notifier.notify) { + kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier); + } vfio_disable_interrupts(vdev); if (vdev->intx.mmap_timer) { timer_free(vdev->intx.mmap_timer); --=20 2.24.1