From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F227BC433EF for ; Tue, 5 Apr 2022 19:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZXk5iarS1w4nZaBGI2/+DQBLDUsYoDSi1gnf4zgd8HA=; b=z+6x+iAjIBG0U3 XlpaiW6D1ClJI1ZdVmfkn1Cp5CLJL+T70Ho2gatWzXiKeoR86gzXbQUMrNi0SUdWK6nP9+SmBxRkx JvW2Z+clroat13on1x/Bs6fNeC/Hl751k/2QyXMJhDVHaiH/6Bbut52HfdGAYpwyPFVBPMGpQ+hhp kSTMmfMmmx2BY3TVQBZt+gmcDjqCHUsmPRbncP48DdpcZ91JlpED6QqVpCXp1BKtO0OkpYlet2Mwu tL+eGUtQ+ClPQxZra3fxgFg2e1THdgq3207VzcHUK3AeqvdK8ZkWfACQbxmgW2xQLRLIfj3ElSMya WtsNFN6W+kLRVz9Gheeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nboZu-002IjS-30; Tue, 05 Apr 2022 19:10:58 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nboZq-002Ii8-Tp for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2022 19:10:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649185848; 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=ufYYfNJ31ZxJiptHxZVI0cJDY245GxkfqBFvOLAxMek=; b=Z9xUuWIFR1s5Ev4w2nyOD2v0z3fHci6g13TOV980JOAop8ZJh1B/KGPbUnOLPzwiod2D5n zR9KVBTDx3Z1Fn096cuMlF3ritv9wL0sh6HY7KAWGny3m03LjZYEBUy5itgGqEsLKTFi79 JEkrQ5Axjt92XOV3XQSYNJdJKHT4Qkg= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-492-FP1O8nNgN8yMeFu4nfa66A-1; Tue, 05 Apr 2022 15:10:47 -0400 X-MC-Unique: FP1O8nNgN8yMeFu4nfa66A-1 Received: by mail-io1-f72.google.com with SMTP id h14-20020a05660208ce00b00645c339411bso136444ioz.8 for ; Tue, 05 Apr 2022 12:10:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=ufYYfNJ31ZxJiptHxZVI0cJDY245GxkfqBFvOLAxMek=; b=KJ68wUrtpl8dN+z+9cSKCp/Zz2nbyRXyr4Pfr2ScQBu/9yrLoO4MWlRgs7vHANF3Ml kq7/w3hKZDou94fa4wegYqgGFMQWu1szlj2xSPIVvlv1jfkdzqHXIQ7zpOGf+R046jHK pI5jGWdt+AuzHA5SejLtunrqH1N2FG5QdXyiemTqww1zpNVx5UEf8ekG17pJZwMAxyf2 7q/tSSeSj9SHl4+itRjqKmcJ0SwmRru4miPGvBNLYebhBuNfPZOn8HlZMzf5aQQ53zHy PBkB1K+G80qJBscLCrnJDO7WHQ2dDUWjbLzxX8uoBaPaXdhEIMD1pve7jSxPUxGwNriy cx5Q== X-Gm-Message-State: AOAM530m+/FG3Gr+6YYqfdr05+0fC0GlGCnPmINqszeCEbbjvMc2vUcO 8bPqsTIxGUbIt15acuZHe+xKMHarBouEoB13k7IR6RrgdIXmqBgw1PnD01bvhuesz2pqJRkXbMH riX6BcOA50cmPyIguthEcQxkatYmRS5oHagA= X-Received: by 2002:a92:cdad:0:b0:2c6:7b76:a086 with SMTP id g13-20020a92cdad000000b002c67b76a086mr2568128ild.5.1649185846540; Tue, 05 Apr 2022 12:10:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxocs2ZVaXF5YVJwjGBcLRqnK5UBIr3mQlWSQgNmkFdgGBC2rjlpWZLrLl9AI2wrgBUaUJw1w== X-Received: by 2002:a92:cdad:0:b0:2c6:7b76:a086 with SMTP id g13-20020a92cdad000000b002c67b76a086mr2568112ild.5.1649185846282; Tue, 05 Apr 2022 12:10:46 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id x2-20020a056602160200b006463c1977f9sm9314961iow.22.2022.04.05.12.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 12:10:45 -0700 (PDT) Date: Tue, 5 Apr 2022 13:10:44 -0600 From: Alex Williamson To: Jason Gunthorpe Cc: Lu Baolu , Christian Benvenuti , Cornelia Huck , David Woodhouse , Gerald Schaefer , iommu@lists.linux-foundation.org, Jason Wang , Joerg Roedel , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Matthew Rosato , "Michael S. Tsirkin" , Nelson Escobar , netdev@vger.kernel.org, Rob Clark , Robin Murphy , Suravee Suthikulpanit , virtualization@lists.linux-foundation.org, Will Deacon , Christoph Hellwig , "Tian, Kevin" Subject: Re: [PATCH 2/5] vfio: Require that devices support DMA cache coherence Message-ID: <20220405131044.23910b77.alex.williamson@redhat.com> In-Reply-To: <2-v1-ef02c60ddb76+12ca2-intel_no_snoop_jgg@nvidia.com> References: <0-v1-ef02c60ddb76+12ca2-intel_no_snoop_jgg@nvidia.com> <2-v1-ef02c60ddb76+12ca2-intel_no_snoop_jgg@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=alex.williamson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220405_121055_084614_D217326A X-CRM114-Status: GOOD ( 22.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 5 Apr 2022 13:16:01 -0300 Jason Gunthorpe wrote: > dev_is_dma_coherent() is the control to determine if IOMMU_CACHE can be > supported. > > IOMMU_CACHE means that normal DMAs do not require any additional coherency > mechanism and is the basic uAPI that VFIO exposes to userspace. For > instance VFIO applications like DPDK will not work if additional coherency > operations are required. > > Therefore check dev_is_dma_coherent() before allowing a device to join a > domain. This will block device/platform/iommu combinations from using VFIO > that do not support cache coherent DMA. > > Signed-off-by: Jason Gunthorpe > --- > drivers/vfio/vfio.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c > index a4555014bd1e72..2a3aa3e742d943 100644 > --- a/drivers/vfio/vfio.c > +++ b/drivers/vfio/vfio.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > #include "vfio.h" > > #define DRIVER_VERSION "0.3" > @@ -1348,6 +1349,11 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf) > if (IS_ERR(device)) > return PTR_ERR(device); > > + if (group->type == VFIO_IOMMU && !dev_is_dma_coherent(device->dev)) { > + ret = -ENODEV; > + goto err_device_put; > + } > + Failing at the point where the user is trying to gain access to the device seems a little late in the process and opaque, wouldn't we rather have vfio bus drivers fail to probe such devices? I'd expect this to occur in the vfio_register_group_dev() path. Thanks, Alex > if (!try_module_get(device->dev->driver->owner)) { > ret = -ENODEV; > goto err_device_put; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel