Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp168304lqi; Wed, 6 Mar 2024 13:19:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUeymA21oNZmSI3NQWN2LmCs3FQH7bwVOdAJ20TkO/QaV/rmY6qHYxMe2N3Z8HkvgKDlCEg/P4WC3bmLrzRBa6okePa2Np7J3jUpRGZjg== X-Google-Smtp-Source: AGHT+IF7ZsZTkF2Wrb1rEHf/TQJIKic7wCe71/rwOOluVtQhPSzVB4boPdd0at28yKstF8QY6Z0a X-Received: by 2002:a17:902:ec8c:b0:1db:5213:222 with SMTP id x12-20020a170902ec8c00b001db52130222mr7451361plg.5.1709759964285; Wed, 06 Mar 2024 13:19:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709759964; cv=pass; d=google.com; s=arc-20160816; b=VgOglRiUobPma2qLfls0em/3vByGEwxEtLzHgD3YSz6ohhqTu7A7T6AorHYP3K7/gg 9dIjZ7S9pc2pyakHGp13ymcXM6ICirZgCS/fJ/GuxioA1iqtu1HxbrntyAu+O8Lnh/DD w+jTdx0ZMBZbEpX8IHItQ8lO8GBrBzoDceTcgTwl6HScUxRH/QRTZwqQmXW8WjED8jQv 9GUqFjCgtDeRHUMe0NWBUAnmW8O3H1XUVFh/qx1StvOdamPNJScCE3eOOdAnM0l84/1E LEkiEdFFtf46D3nZmZjq0rLPuBdfTZae9bLw72Mir0pk2LJFAQCyrJvUydShoRvepEWx YJfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uvV/nDuM+sweXjvIC5LuTFavoYDPU4njYTvMMtNtIIo=; fh=Oqa8QMyI07jjRzsBSvW3iPiN5pL80qVZ2qdPaQxMz9M=; b=MIA4ArpEX8o1ro6r4mVxSLzLp6+/HokobryQXyPEpP44fnHKNsVKcPTRnro+ZyCiSg X7mvKtDVLy1yxlbpuk2QYV4xX2y6DT/pe53Zz6C01TAXnZyCvJSMec+TYln7ZNL2w8pP /LX0WjxSPTqIGKjEaibK1E/uh2bDTpzUjSfPnRXVEbFvKS6ZNeDvjDk40rYFRyRbCzOE x3Fcb50zHj4lpFrwCtY7nCn3ZOL6v5J+aAzwHN6zSbNlCZFUIpudMkffpEqLL+Bhq7nZ LUU6MPfQP2x8eJ+gFcJEsQpXHda+OE1RjRo9RSm1WR3J5UZjuag06dJwAAH7qAp6B+2P rGhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TSAwVOCL; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-94585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l3-20020a170902f68300b001db81819d15si12906761plg.264.2024.03.06.13.19.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 13:19:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TSAwVOCL; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-94585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B08E1B21DEE for ; Wed, 6 Mar 2024 21:17:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F9161CAB0; Wed, 6 Mar 2024 21:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TSAwVOCL" 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 E1ECA1C6B8 for ; Wed, 6 Mar 2024 21:15:08 +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=1709759710; cv=none; b=JYO/a7qB5H4wrc3V8WbWDt507rP9qW77aHHqMt2qAeZbesSLTWPbi50nRKMrIZSore5VP76cwIZmtXXgkCn04jATdjk0tuPUoG2bHqkQXwm1yL4mX20/HI2Ywajgghot+Y06f/zqPNh//lVxU2j/t3COTKKy8/SAM+aGtb+tstU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709759710; c=relaxed/simple; bh=DcVKXTML5ywo+4G+K2NpqKcgjW37poRbZY0R6kODpyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sgJoKCOIwKa/PmAabCZOCXxbkc79JUm8FP+Or9d6MwrQvmM4R4Hzq/ue4nZrGhxk9YpKCkm/N0LJk9+OgmC03OWN+1kVCC/dQvctzF5z6poUkBFN0YNrpI+E2D8wQezyysBULObhM9gno06ft5K3ZnIKowHkEAOmDmQgXZ58gJY= 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=TSAwVOCL; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709759707; 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=uvV/nDuM+sweXjvIC5LuTFavoYDPU4njYTvMMtNtIIo=; b=TSAwVOCL7J3JIlOOuK/810LMfmssxzT1U6v3jZDaMt2+az2dlNmNZvNCnI0xuQsirYnlOR kZxoBgadm76jBR+BpaXZGw8hdeBvLfrj+9MuSBSrZxrGjTtuDi4se/BAAnJLQdqIVlweob L9ZfZ3JaocG4I18mZl+A6ThKWkscFW4= 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-499-Q7XHd1CCMGiyPq3ivckN0w-1; Wed, 06 Mar 2024 16:15:04 -0500 X-MC-Unique: Q7XHd1CCMGiyPq3ivckN0w-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 E6DCC1C05158; Wed, 6 Mar 2024 21:15:03 +0000 (UTC) Received: from omen.home.shazbot.org (unknown [10.22.33.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id E05B537F6; Wed, 6 Mar 2024 21:15:02 +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, diana.craciun@oss.nxp.com Subject: [PATCH 7/7] vfio/fsl-mc: Block calling interrupt handler without trigger Date: Wed, 6 Mar 2024 14:14:42 -0700 Message-ID: <20240306211445.1856768-8-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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 The eventfd_ctx trigger pointer of the vfio_fsl_mc_irq object is initially NULL and may become NULL if the user sets the trigger eventfd to -1. The interrupt handler itself is guaranteed that trigger is always valid between request_irq() and free_irq(), but the loopback testing mechanisms to invoke the handler function need to test the trigger. The triggering and setting ioctl paths both make use of igate and are therefore mutually exclusive. The vfio-fsl-mc driver does not make use of irqfds, nor does it support any sort of masking operations, therefore unlike vfio-pci and vfio-platform, the flow can remain essentially unchanged. Cc: Diana Craciun Fixes: cc0ee20bd969 ("vfio/fsl-mc: trigger an interrupt via eventfd") Signed-off-by: Alex Williamson --- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c b/drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c index d62fbfff20b8..82b2afa9b7e3 100644 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c @@ -141,13 +141,14 @@ static int vfio_fsl_mc_set_irq_trigger(struct vfio_fsl_mc_device *vdev, irq = &vdev->mc_irqs[index]; if (flags & VFIO_IRQ_SET_DATA_NONE) { - vfio_fsl_mc_irq_handler(hwirq, irq); + if (irq->trigger) + eventfd_signal(irq->trigger); } else if (flags & VFIO_IRQ_SET_DATA_BOOL) { u8 trigger = *(u8 *)data; - if (trigger) - vfio_fsl_mc_irq_handler(hwirq, irq); + if (trigger && irq->trigger) + eventfd_signal(irq->trigger); } return 0; -- 2.43.2