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 X-Spam-Level: X-Spam-Status: No, score=-5.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4661DC433E0 for ; Thu, 21 Jan 2021 18:30:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01BE923A40 for ; Thu, 21 Jan 2021 18:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728406AbhAUSad (ORCPT ); Thu, 21 Jan 2021 13:30:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42962 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732981AbhAUSPs (ORCPT ); Thu, 21 Jan 2021 13:15:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611252861; 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=lEgMkUTOCJsoedIDEpBA2hjPtpKSlnIAkYz8Z2MMNg0=; b=KxjYv2QaoHVMB4M1GTbQtoMfTUTowMlKbAfFVCSx/njpJ9xVXAy7v2U/h0tn2o+AMFkc3J FdbTkcHeeFjjvTvmORn+fgN7I9w79uUg+wz4BUVwTktWFpCn+lmE9Pz0C1i+6aQaOznPEp FRiVYI8SpWso0vNA+fzjepkZvVDT+0M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-4sowHxENOA-jNF3X_XPxfw-1; Thu, 21 Jan 2021 13:14:19 -0500 X-MC-Unique: 4sowHxENOA-jNF3X_XPxfw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87956107ACE3; Thu, 21 Jan 2021 18:14:16 +0000 (UTC) Received: from omen.home.shazbot.org (ovpn-112-255.phx2.redhat.com [10.3.112.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1251139A63; Thu, 21 Jan 2021 18:14:15 +0000 (UTC) Date: Thu, 21 Jan 2021 11:14:14 -0700 From: Alex Williamson To: Keqian Zhu Cc: , , , , , Kirti Wankhede , Cornelia Huck , Will Deacon , "Marc Zyngier" , Catalin Marinas , "Mark Rutland" , James Morse , "Robin Murphy" , Joerg Roedel , Daniel Lezcano , Thomas Gleixner , "Suzuki K Poulose" , Julien Thierry , Andrew Morton , Alexios Zavras , , Subject: Re: [PATCH v2 2/2] vfio/iommu_type1: Sanity check pfn_list when remove vfio_dma Message-ID: <20210121111414.143e3e4e@omen.home.shazbot.org> In-Reply-To: <32f8b347-587a-1a9a-bee8-569f09a03a15@huawei.com> References: <20210115092643.728-1-zhukeqian1@huawei.com> <20210115092643.728-3-zhukeqian1@huawei.com> <20210115121447.54c96857@omen.home.shazbot.org> <32f8b347-587a-1a9a-bee8-569f09a03a15@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Jan 2021 21:16:08 +0800 Keqian Zhu wrote: > On 2021/1/16 3:14, Alex Williamson wrote: > > On Fri, 15 Jan 2021 17:26:43 +0800 > > Keqian Zhu wrote: > > > >> vfio_sanity_check_pfn_list() is used to check whether pfn_list of > >> vfio_dma is empty when remove the external domain, so it makes a > >> wrong assumption that only external domain will add pfn to dma pfn_list. > >> > >> Now we apply this check when remove a specific vfio_dma and extract > >> the notifier check just for external domain. > > > > The page pinning interface is gated by having a notifier registered for > > unmaps, therefore non-external domains would also need to register a > > notifier. There's currently no other way to add entries to the > > pfn_list. So if we allow pinning for such domains, then it's wrong to > > WARN_ON() when the notifier list is not-empty when removing an external > > domain. Long term we should probably extend page {un}pinning for the > > caller to pass their notifier to be validated against the notifier list > > rather than just allowing page pinning if *any* notifier is registered. > > Thanks, > I was misled by the code comments. So when the commit a54eb55045ae is > added, the only user of pin interface is mdev vendor driver, but now > we also allow iommu backed group to use this interface to constraint > dirty scope. Is vfio_iommu_unmap_unpin_all() a proper place to put > this WARN()? vfio_iommu_unmap_unpin_all() deals with removing vfio_dmas, it's logically unrelated to whether any driver is registered to receive unmap notifications. Thanks, Alex