Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3351346rdb; Tue, 6 Feb 2024 15:19:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWRBsks7adpyaoo/WVfTnxfqYdJgHt+xj4v9/dR0T4wDa2Z5jkgJOBNT7NHlCbStbPumF4UgNkqyLcGgELo1lEWlK6/Q1DSoOGvuyNmOA== X-Google-Smtp-Source: AGHT+IEL9lpMaE4DbkAg3+Cn4jvwS3MaNKqgYSvzJvFDDm5xwEQz9EahxXCgYDm/ViLKGVY3t+x6 X-Received: by 2002:a05:622a:11d6:b0:42c:514:7fa2 with SMTP id n22-20020a05622a11d600b0042c05147fa2mr4816606qtk.7.1707261596434; Tue, 06 Feb 2024 15:19:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707261596; cv=pass; d=google.com; s=arc-20160816; b=nrjuXz5bA4PLy1zyMvmR2+shaJ8N/U8oKcnPWiAr3YdNVwGEuwzckQmS16OMRcqumn 5GTlCfjyZQMes2ABnHF56n5LfFgusUG8PQ449EHJXKdwTM6VeqzlWGcK6ls3UVSM3ICz Ran5CXy5B+ddJPQXbdYvCTsHuPPukqGV3KMIsuko1DMthEsaWjNOvt6ZpXNfft2GS5kr zyinODMCzFiWeWKgzj1k5R3ljOBadkv6CoO2n7kLKvUpfaSw/kpGwK4/btxv+JCqAioy yVxMF2N9u4ZXRky8Mv4yZAzCqtUhGW8TRWu1pKcxSSvaO3A/ayk+ZBmCYmqSSv6cVKu+ cExA== 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 :subject:cc:to:from:date:dkim-signature; bh=/9lQWrs1kWLDUb9rNRJMZocZRASv82NRrn4c/SQZik0=; fh=F9rlo0MQDaj+s6pC6rBcOyTsOyFrqsopQtFczBKm39A=; b=B4UwOU/jAsQhSQkXxBSHBEi7M0vOJjSJczPLRbaOtXG/GYW8SJ5bjCWQZb0MPIVIOo 6eHxpTb/0gRYpB44BKE1o+B/TZdSc8jjODrfqoc5CErGAJuP/pOTRW1lfQkkCXvNu/9t MzyFy/2Xy4H23NFVlTaSUm0uRvryLQ14uKl/MHKIvx2RLEsJP7hkSbUJiyOva+N+4jko B6tmHb+0Nvc6GjioPy5RC9jUVYp/G+3wXCAaLMDYOb+DsN8VJ8BvpFia0PHnsW3Y27S5 LzEBTK1LCmCfjO4qinye6MEScVQXOJD58FnzNZUGqLtEINglB1VmS2bxtGRjfTMjMjmk FlWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XPNLdvn5; 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-55720-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55720-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVM2Vf8NDr1ylwFdO55RLCIgdSkne1EIE4H3Ke5u9IypAvmDu6paH8xqDwPWBw/GaNTd5FWwJEeJM1q4s44CT1zDlGykaGQZ0nRilF6oA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o14-20020ac85a4e000000b0042c07a7bfefsi3515209qta.110.2024.02.06.15.19.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 15:19:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55720-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XPNLdvn5; 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-55720-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55720-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 982541C247F8 for ; Tue, 6 Feb 2024 23:19:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDC541CD21; Tue, 6 Feb 2024 23:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XPNLdvn5" 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 6AF6B1CD19 for ; Tue, 6 Feb 2024 23:19:40 +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=1707261582; cv=none; b=B9FKlnz/GFu40//F6p6VtG2x8pQcfCz7tvSQyuziHwJPh/w8DJIaGOY2VMawkUDbouSAquSSHhek4W8AzOZBImMbxL/YxlixMdRbs76tM5N9DXQ7EUyus/bcX5AnKzY1WKVsxXo2/EbL4/Q2XSqxVxfltLkePEzhQ/7gim+mHlc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707261582; c=relaxed/simple; bh=mSp1+JYDb7NdH17RZ+qMLPdVmrJ42e3fPvlEjXiGpZc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ou+DBM4KhntyAnBArlOydmJ4tSzTLstlIrX+j64SZvK4ORCcHG9tw6QGqtnsVgA7qW6bcjw9NUZD9WZ/UF3gKIKevoXZ6QFjucnrGYyQ7wWWRPReL44sudFHaRV84W/nn/+qeDk85yFogyxmXovsaCNpPDK6GJ51ZFMdtnhBEJA= 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=XPNLdvn5; 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=1707261579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9lQWrs1kWLDUb9rNRJMZocZRASv82NRrn4c/SQZik0=; b=XPNLdvn5V6bTVv/AXIx/40HLOU3SbTPJ8u609S6aAjQFMJ4I+PVOmI75YZRMH/X0Ne5/xU lkEe57jZ+0cWUv9vlW/EhTMuGTurTeZpmFPwHXFsuQMzDSg6CTxnVPBNXO3C1wbGp0sLVg kaeK+n2JdexH1DNU/4eXgiWGw/St1PE= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-RiCdQmKUNUOF9k_qgt9ZeA-1; Tue, 06 Feb 2024 18:19:37 -0500 X-MC-Unique: RiCdQmKUNUOF9k_qgt9ZeA-1 Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-7bfe777fe22so2914239f.3 for ; Tue, 06 Feb 2024 15:19:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707261577; x=1707866377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/9lQWrs1kWLDUb9rNRJMZocZRASv82NRrn4c/SQZik0=; b=OmIhBS2O+pxUljmLkAVKYfC6MpzhAn/EcA2c4xd1lkyhcepQZjcD4Lpn8McA3/f3V/ PckfXHXvs0Rn9V1ZJ6q6+8LYsWdZB3u321budQ/KJB1yFDWvoL6/CJQ6MgxfoM6pL7Hi ruSVJ/y9cRXOdKepSH5D7X2zR8Jeb7RKmfABF/QMXxiS+2eBfF0Ekr3gchmtVcwIlKla hfv3/NNzNDRbHQa3LZuTh4R/Aq0u4rB17qPiFMYwwYxJnNOMXmkLJA/GS+UCV8ASC1BK DGx+POZnk0xB5Vy9DFgkvx3N5WiwB/B64IsCBPqnwI9zcuZ1zbzyG2ViPQ4b1PUkGyzM fMjg== X-Forwarded-Encrypted: i=1; AJvYcCWkP5z2Ftj4lRoS1kTG9J6J8tCPOqG8/0nJOOWml6o0n2jtwj0PpsyOvXtfh8I27QAd4fQ6AFgCNBs7n7vhduOHKLMN80L4HmQ5nvh6 X-Gm-Message-State: AOJu0YxIJXl+46b2+iwc9hf/xxNicOZIUsFtiFroUrhQcj3r5FOd49Ux Utg/8OZKF/zyVIY+Jg0mVi40GSqebW9WtEHEg/yCTjEjHwaGKFOPgn6SxN0epX+eqvdmo4KuJvy iMgy9LEUifZgjgsgmlmpBcqVzKFIyVeALg37kXyXT0js1Q49zTvQLCZ1pFLr14A== X-Received: by 2002:a6b:d90c:0:b0:7c3:eda4:ea11 with SMTP id r12-20020a6bd90c000000b007c3eda4ea11mr3842369ioc.16.1707261577162; Tue, 06 Feb 2024 15:19:37 -0800 (PST) X-Received: by 2002:a6b:d90c:0:b0:7c3:eda4:ea11 with SMTP id r12-20020a6bd90c000000b007c3eda4ea11mr3842343ioc.16.1707261576688; Tue, 06 Feb 2024 15:19:36 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVxQNy7WM81D1KyTsj5b6dysZmQ7irl+mHz/wXIJCehZJzT0rzy+38bzv2vK3ShDIBzaGnFianyWRV+Hdsia6yEsRrKo2XUlAzSu2R7lPibY72NFRgkL6J1H4gguFl0tSVtOPFdoSDj6gOxqFGFXrShMogteJqdI2GP0UhDD2LGRyM9B5Wc+7HDrTXKN44RMTBUNTuq7aMfFxLTXCzPdV4FZ1UgM7UOCYN7m5m0EnQ23l/aEj0OzE8fhqLrcF+Mya/rFzyaRajzcLY69xrxYnzGhpt+N80pc4GtLcrRAz51m/QHUQtyk020l/znzMSPys9qDlGZ3Q== Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id s24-20020a6bdc18000000b007c3f616986csm369762ioc.40.2024.02.06.15.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 15:19:36 -0800 (PST) Date: Tue, 6 Feb 2024 16:19:34 -0700 From: Alex Williamson To: Reinette Chatre Cc: , , , , , , , , Subject: Re: [PATCH 15/17] vfio/pci: Let enable and disable of interrupt types use same signature Message-ID: <20240206161934.684237d3.alex.williamson@redhat.com> In-Reply-To: References: <20240205153542.0883e2ff.alex.williamson@redhat.com> <5784cc9b-697a-40fa-99b0-b75530f51214@intel.com> <20240206150341.798bb9fe.alex.williamson@redhat.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 6 Feb 2024 14:22:04 -0800 Reinette Chatre wrote: > Hi Alex, > > On 2/6/2024 2:03 PM, Alex Williamson wrote: > > On Tue, 6 Feb 2024 13:46:37 -0800 > > Reinette Chatre wrote: > > > >> Hi Alex, > >> > >> On 2/5/2024 2:35 PM, Alex Williamson wrote: > >>> On Thu, 1 Feb 2024 20:57:09 -0800 > >>> Reinette Chatre wrote: > >> > >> .. > >> > >>>> @@ -715,13 +724,13 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev, > >>>> if (is_intx(vdev)) > >>>> return vfio_irq_set_block(vdev, start, count, fds, index); > >>>> > >>>> - ret = vfio_intx_enable(vdev); > >>>> + ret = vfio_intx_enable(vdev, start, count, index); > >>> > >>> Please trace what happens when a user calls SET_IRQS to setup a trigger > >>> eventfd with start = 0, count = 1, followed by any other combination of > >>> start and count values once is_intx() is true. vfio_intx_enable() > >>> cannot be the only place we bounds check the user, all of the INTx > >>> callbacks should be an error or nop if vector != 0. Thanks, > >>> > >> > >> Thank you very much for catching this. I plan to add the vector > >> check to the device_name() and request_interrupt() callbacks. I do > >> not think it is necessary to add the vector check to disable() since > >> it does not operate on a range and from what I can tell it depends on > >> a successful enable() that already contains the vector check. Similar, > >> free_interrupt() requires a successful request_interrupt() (that will > >> have vector check in next version). > >> send_eventfd() requires a valid interrupt context that is only > >> possible if enable() or request_interrupt() succeeded. > > > > Sounds reasonable. > > > >> If user space creates an eventfd with start = 0 and count = 1 > >> and then attempts to trigger the eventfd using another combination then > >> the changes in this series will result in a nop while the current > >> implementation will result in -EINVAL. Is this acceptable? > > > > I think by nop, you mean the ioctl returns success. Was the call a > > success? Thanks, > > Yes, I mean the ioctl returns success without taking any > action (nop). > > It is not obvious to me how to interpret "success" because from what I > understand current INTx and MSI/MSI-x are behaving differently when > considering this flow. If I understand correctly, INTx will return > an error if user space attempts to trigger an eventfd that has not > been set up while MSI and MSI-x will return 0. > > I can restore existing INTx behavior by adding more logic and a return > code to the send_eventfd() callback so that the different interrupt types > can maintain their existing behavior. Ah yes, I see the dilemma now. INTx always checked start/count were valid but MSI/X plowed through regardless, and with this series we've standardized the loop around the MSI/X flow. Tricky, but probably doesn't really matter. Unless we break someone. I can ignore that INTx can be masked and signaling a masked vector doesn't do anything, but signaling an unconfigured vector feels like an error condition and trying to create verbiage in the uAPI header to weasel out of that error and unconditionally return success makes me cringe. What if we did this: uint8_t *bools = data; ... for (i = start; i < start + count; i++) { if ((flags & VFIO_IRQ_SET_DATA_NONE) || ((flags & VFIO_IRQ_SET_DATA_BOOL) && bools[i - start])) { ctx = vfio_irq_ctx_get(vdev, i); if (!ctx || !ctx->trigger) return -EINVAL; intr_ops[index].send_eventfd(vdev, ctx); } } And we note the behavior change for MSI/X in the commit log and if someone shouts that we broke them, we can make that an -errno or continue based on is_intx(). Sound ok? Thanks, Alex