Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2281482ybl; Thu, 19 Dec 2019 10:57:48 -0800 (PST) X-Google-Smtp-Source: APXvYqzKoJoifjUiBmATUTunvo0HrAgLEtUDqV7PDT1L89dIjxjPlM+DLIkk5/W7MXH/3YgHylXS X-Received: by 2002:aca:47d7:: with SMTP id u206mr2917746oia.79.1576781868856; Thu, 19 Dec 2019 10:57:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781868; cv=none; d=google.com; s=arc-20160816; b=jgO4Mjkkg+USwidGUJ/mUXLYZix0wdko+7jnjgJ4P9an0me4zdMAUljdl8+791UBiE plvFn3GNicT4Hoc77o+t8CwLYBZfvnLsaQxRXzu6uA6Yt9PZhdqYhGaF24pnV5Dt+PEk 1z1mJgaZkMwiQaGipFPA1edFVKJMD2oxRrZduO+1MfpzTFarxr0qtbu2CxA6poy7SUy3 abUdDEj3vvv1sG9FPejvolpl/FNK3G4ownZDA+IngxFiH1OaAsA+ezEcAJK6m3ORBZKA vb7uMANvE3Ww2ku2i/yRrQLY6uzlEJ3pzrc3V3SLgJkg2NMD6aAxea2ER5IPj+VgrHBn UfMQ== 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=LB8xxOA4JAll/Cc7z8QlgpDQfok+XX00P/CpNHvZREA=; b=ClONEjdhqJSqbqLfg3yV8m+AF1BkKq4Nj/xiuonnw3ZCBXWssKk+sWeOlbPa3NFBBp EGQExyOLqktH1L8wrZODG6/VoabUxqSCSwy4HNER4dkLPEpicbKMxoh74kCQBI1w7+Ob 0njskdPCpfHHAL438iTWHgstestHtKSyXXfayHmvpGu8bMMGsiSJT8JyffFVWtsQAboD I1qQRmvev0dXwAJFkw9xxswrahABSAXiXEMdKATatyAqCTPrST2ocOVgFQGX1f04086Q mmRrIULp+M7eIedPemohgeLy+xkfU9m4gnmd/YwpKizAGgrWtdg5SJxcFakq+JSancDO wMkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="VrRvLR4/"; 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 o129si3529517oib.236.2019.12.19.10.57.36; Thu, 19 Dec 2019 10:57:48 -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="VrRvLR4/"; 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 S1730825AbfLSS4e (ORCPT + 99 others); Thu, 19 Dec 2019 13:56:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:53022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730810AbfLSS40 (ORCPT ); Thu, 19 Dec 2019 13:56:26 -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 A5EC0206EC; Thu, 19 Dec 2019 18:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781786; bh=eCAN5lqFooG7iWXUlQB9I8xMUnIagZG7ajlX2uuPR/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VrRvLR4/C0E1HLhpe4FeYaQFYQ4FCmIFZaivb4DqtCcKlTlkHoB23Rdx/fDZfFsPx t+IigafS2SOXmcw69S45Wg5khl9PJekVBvoLj5wVaeLHZdjoYEik4hYaWnv8gHAxny uwbTseBLmfBDmcsO7qNILkdvDEhrhdQTfE7WYclk= 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 5.4 41/80] vfio/pci: call irq_bypass_unregister_producer() before freeing irq Date: Thu, 19 Dec 2019 19:34:33 +0100 Message-Id: <20191219183109.190703228@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@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 @@ -294,8 +294,8 @@ static int vfio_msi_set_vector_signal(st irq = pci_irq_vector(pdev, vector); 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;