From patchwork Wed Mar 6 21:14:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 13584650 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5852C1BF31 for ; Wed, 6 Mar 2024 21:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709759707; cv=none; b=lg/tswWaljqI8T1OqyztpsRIX6UN+DhbY3TpyzpZ+5AG+4tmFJ429dwvVQbLsKVL1RVxaRV5WF9pGRovkK/riKbOA3oS3+mSTeXc44ZnF2leQdWo3FbUa1gFYCDiUeGSHYS6gpRt7jvJomVIYt3RixEwsCOb7HAi+TfJhh3VIlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709759707; c=relaxed/simple; bh=dSVU1B/QJjt/W88x1rG/V9ZIu+ncfuekn31A2r07ngg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n4X6MpKImylrn2Zfzpe23nBrJ4OmlG8NL56sMDBQ/OdDm4nHeeIcJFEdEyWtsHnQte6dwpThIdFoeVUc/BExp7g2wDnGVjbIE4GvRZ2VX5BJ3VDhAjiJxWNSn2l9NsFT/kzhqMeMK6CF4ZXakU39J7aNCaIAWumNnZBd3HYoM9w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NytzlbrR; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NytzlbrR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709759705; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WttmPitBsNM9Jh4S0C3++DVJj+i9Oa9tOATpD8c/j38=; b=NytzlbrRb8onN5B1BuoqcHKzSIMomLOQ1APJSTbYlCl3K1ZiUwTGdtMnXFIMvCWXeQaskf 4ZGFooAX6edEwSFA/pkargWn8gEvg4MoMlm9XHrk3WfWZpudZK04ax9UeAmuVAHMYBbdvT O5rhOF1vDJJ/lGZWNHas2LffNfHQWAY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-407-1koqFQVMN8-9YuTF3SVR4w-1; Wed, 06 Mar 2024 16:15:01 -0500 X-MC-Unique: 1koqFQVMN8-9YuTF3SVR4w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 436F228B6988; Wed, 6 Mar 2024 21:15:01 +0000 (UTC) Received: from omen.home.shazbot.org (unknown [10.22.33.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5268637FD; Wed, 6 Mar 2024 21:15:00 +0000 (UTC) From: Alex Williamson To: alex.williamson@redhat.com Cc: kvm@vger.kernel.org, eric.auger@redhat.com, clg@redhat.com, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, kevin.tian@intel.com Subject: [PATCH 5/7] vfio/platform: Disable virqfds on cleanup Date: Wed, 6 Mar 2024 14:14:40 -0700 Message-ID: <20240306211445.1856768-6-alex.williamson@redhat.com> In-Reply-To: <20240306211445.1856768-1-alex.williamson@redhat.com> References: <20240306211445.1856768-1-alex.williamson@redhat.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 irqfds for mask and unmask that are not specifically disabled by the user are leaked. Remove any irqfds during cleanup Cc: Eric Auger Fixes: a7fa7c77cf15 ("vfio/platform: implement IRQ masking/unmasking via an eventfd") Signed-off-by: Alex Williamson --- drivers/vfio/platform/vfio_platform_irq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index 61a1bfb68ac7..a311d70c695b 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -321,8 +321,13 @@ void vfio_platform_irq_cleanup(struct vfio_platform_device *vdev) { int i; - for (i = 0; i < vdev->num_irqs; i++) + for (i = 0; i < vdev->num_irqs; i++) { + int hwirq = vdev->get_irq(vdev, i); + + vfio_virqfd_disable(&vdev->irqs[i].mask); + vfio_virqfd_disable(&vdev->irqs[i].unmask); vfio_set_trigger(vdev, i, -1, NULL); + } vdev->num_irqs = 0; kfree(vdev->irqs);