From patchwork Thu Aug 4 22:09:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 9264391 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4F1D60839 for ; Thu, 4 Aug 2016 22:09:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D639527E78 for ; Thu, 4 Aug 2016 22:09:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB04528395; Thu, 4 Aug 2016 22:09:31 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 453BB27E78 for ; Thu, 4 Aug 2016 22:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966150AbcHDWJ1 (ORCPT ); Thu, 4 Aug 2016 18:09:27 -0400 Received: from mga04.intel.com ([192.55.52.120]:52795 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966144AbcHDWJ1 (ORCPT ); Thu, 4 Aug 2016 18:09:27 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 04 Aug 2016 15:09:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,471,1464678000"; d="scan'208";a="150819874" Received: from dcgshare.lm.intel.com ([10.232.118.254]) by fmsmga004.fm.intel.com with ESMTP; 04 Aug 2016 15:09:26 -0700 Received: by dcgshare.lm.intel.com (Postfix, from userid 1017) id 55090E0C6D; Thu, 4 Aug 2016 16:09:25 -0600 (MDT) From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Jon Derrick , Keith Busch Subject: [PATCH 2/2] vmd: Synchronize with RCU freeing msi irq descs Date: Thu, 4 Aug 2016 16:09:09 -0600 Message-Id: <1470348549-10855-2-git-send-email-keith.busch@intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1470348549-10855-1-git-send-email-keith.busch@intel.com> References: <1470348549-10855-1-git-send-email-keith.busch@intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a potential race when disabling MSI/MSI-x on a VMD domain device. If the vmd interrupt service is running, it may see a disabled irq. We can synchronize rcu just before freeing the msi descriptor. This is safe since the irq_desc lock isn't held, and the descriptor is valid even though it is disabled. After vmd_msi_free, though, the handler is reinitialiazed to handle_bad_irq, so we can't let the vmd isr's list iteration see the disabled irq after this. Signed-off-by: Keith Busch --- arch/x86/pci/vmd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c index 2294907..e3c9b9e 100644 --- a/arch/x86/pci/vmd.c +++ b/arch/x86/pci/vmd.c @@ -213,6 +213,8 @@ static void vmd_msi_free(struct irq_domain *domain, struct vmd_irq *vmdirq = irq_get_chip_data(virq); unsigned long flags; + synchronize_rcu(); + /* XXX: Potential optimization to rebalance */ raw_spin_lock_irqsave(&list_lock, flags); vmdirq->irq->count--;