Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2268261ybl; Thu, 19 Dec 2019 10:43:43 -0800 (PST) X-Google-Smtp-Source: APXvYqz6Dfq03Hy5ZNL3qwiYw2n5VUtBfNLHvNV7CaBXPfGvGi+tituerfAcnxZ6d1FJFXS9DgIk X-Received: by 2002:a05:6830:1e37:: with SMTP id t23mr10380078otr.16.1576781023696; Thu, 19 Dec 2019 10:43:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781023; cv=none; d=google.com; s=arc-20160816; b=EJgUQB5T/Tfv1zYvUm/HLCPz0bjHAoVz4Kxs7I3OUiJcRkzR/IwQ2kIAxiQAzj/1au WF0AOKZAGaBGV+Rgz7FU7nqO7pE2cXYR+yiENDiU0DmClM7yLI7bjMKV7FMKSZJioT1Z 8dbjUdJVgR6nhzNsyoH8nyeXGnaK+HoT1AAAEjoKnOi0MJBlDzJ9g960ca5xXUy7Hks/ ZRpkxpWblE4/2Tk+sXSzEXqx/jae3Ju4/gp2J6E1oXSIKY7qXKLcoUHXnrvY4Zgxkmeq QLeqgwEScAWyXvJ08rUrVFD64CANsEfbhEDv85QiwzeBnqEYM+iwF1Mrv8s8PMYu/8lJ q8eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zF93RYlGXox7wf9s+pT1X6N6/7v2hDIHK4FX/gy5gRY=; b=oJ8shJcLb0lOd+QYRHK5wGM1vwZltJA168HXGApj1vDMXooXujiYpXa4wt55nJffzO L3Z2gch5TAsIvgPHUv7PFEXqzgcsdEM3TmocLC2tEo4BvUAUtLl1vODRjNwFLRw7nZQe sZduowDz1kTfwbc+Un1NkeAQJOSz+NSpbpFc/5zS+tUKFjpKZ9/Tb2t/+G+DDEeVDNAF LeMHpSmt0KQGOZLxHf/J6IcsYoi4X2FrFYzb7+9Vb+L2c8y1RgyIwmJudUA8ugNuM47v /8jpkMhObyGHTClbJdWsRza0VtTfWQ6VTKCXUzX19BWaRQXdPXaI7286Utt7jdyxbAr5 TSzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AJZzukD3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si3589003oic.119.2019.12.19.10.43.21; Thu, 19 Dec 2019 10:43:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AJZzukD3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727885AbfLSSlz (ORCPT + 99 others); Thu, 19 Dec 2019 13:41:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:60968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728587AbfLSSlr (ORCPT ); Thu, 19 Dec 2019 13:41:47 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B675F206D7; Thu, 19 Dec 2019 18:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576780907; bh=w3xchpWSaeEifrs1U1NvINkb8ay7YrSJsH15zMdBVQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AJZzukD3wDS/4Qdji8A3ZzqmW5ZGrmUZiOf9akHlBthRJPJbh39XGriNbg2tN9BI9 AkRGi7BpcOAhOLuYvY5JYf4NSWzRPCSWmbjqPNqKqnLKuZfSMqpG/GYPdzCyD7CCIR TcsL5tITg4KLoVzN9ZznFrZxzhYKrv50/BLNEXgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiang Yi , Marc Zyngier , Eric Auger , Alex Williamson Subject: [PATCH 4.4 157/162] vfio/pci: call irq_bypass_unregister_producer() before freeing irq Date: Thu, 19 Dec 2019 19:34:25 +0100 Message-Id: <20191219183217.321443381@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183150.477687052@linuxfoundation.org> References: <20191219183150.477687052@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiang Yi commit d567fb8819162099035e546b11a736e29c2af0ea upstream. Since irq_bypass_register_producer() is called after request_irq(), we should do tear-down in reverse order: irq_bypass_unregister_producer() then free_irq(). Specifically free_irq() may release resources required by the irqbypass del_producer() callback. Notably an example provided by Marc Zyngier on arm64 with GICv4 that he indicates has the potential to wedge the hardware: free_irq(irq) __free_irq(irq) irq_domain_deactivate_irq(irq) its_irq_domain_deactivate() [unmap the VLPI from the ITS] kvm_arch_irq_bypass_del_producer(cons, prod) kvm_vgic_v4_unset_forwarding(kvm, irq, ...) its_unmap_vlpi(irq) [Unmap the VLPI from the ITS (again), remap the original LPI] Signed-off-by: Jiang Yi Cc: stable@vger.kernel.org # v4.4+ Fixes: 6d7425f109d26 ("vfio: Register/unregister irq_bypass_producer") Link: https://lore.kernel.org/kvm/20191127164910.15888-1-giangyi@amazon.com Reviewed-by: Marc Zyngier Reviewed-by: Eric Auger [aw: commit log] Signed-off-by: Alex Williamson Signed-off-by: Greg Kroah-Hartman --- drivers/vfio/pci/vfio_pci_intrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -318,8 +318,8 @@ static int vfio_msi_set_vector_signal(st return -EINVAL; if (vdev->ctx[vector].trigger) { - free_irq(irq, vdev->ctx[vector].trigger); irq_bypass_unregister_producer(&vdev->ctx[vector].producer); + free_irq(irq, vdev->ctx[vector].trigger); kfree(vdev->ctx[vector].name); eventfd_ctx_put(vdev->ctx[vector].trigger); vdev->ctx[vector].trigger = NULL;