Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp435804pxb; Thu, 21 Jan 2021 10:31:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJysrPofxWXWKiKmec6ycZS8JnriojdqzwKOB632f9gOjUIu67aYCjVJPxfZaokyFO5F4S5T X-Received: by 2002:a05:6402:1c0b:: with SMTP id ck11mr364256edb.35.1611253885876; Thu, 21 Jan 2021 10:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611253885; cv=none; d=google.com; s=arc-20160816; b=GGksrggYC+hg1CWrZTkJF7jSON9O/ebxQpm2xBYp30t9/tBYmRv41iM/EVDRur3yBi HU7GobccCKPm65ACU/Zx77WymLN1/zeoGM24omLC0BJRA4cnwBUK3O5K6lD06ZNrt0// R8y5DCMkeop/x9n2WguDJetSf1Wr7RsnDwijYGW8/wnY4ZqdROD5CwP8N8ahPZ+B0rv/ HIxVdQpM50kOOIpSlMWp6Lt7indwxmVFoySR4w4+uH+v8eUdjebNXYCmggC04Bfd63Gd FORSftAkL0/PsZwqY17ZIjuuvAcodENx7MEAY0zs9X7twRACh2P6x61kfCOM8QU1IrOb qThw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=lEgMkUTOCJsoedIDEpBA2hjPtpKSlnIAkYz8Z2MMNg0=; b=hv/TAtaEeNgM6AEJTmfBOGUCX2oXa4C7JNzBd7ahJ19eXlbOAXuTQcvNBEEKxlZf7O Q9KSIwCARSN47cJAyQRhOAdOTR0uoIdtjsTiw4tmp+x24uDlXikmxyeS+y/e8A1C81hG 7LZJdE/M+UHTo3V3hsGJ0sVma+g0MwLnW1/KG4ICIspXHsx+kvPExhF7Tf+/z15hYYxO 12IBbzyIaycQvp8caO/UOmVJ/mfPZC33usrc7GGco2ALsKOWHQ+uQLQ/URHqWs6VDAfU gkF/6e2302dUv8ZactjOYDxNdIA59RQ6uq0R1r/BPGe9uPHGHQWgN2Uf8wZgVDQ8E/5J m1sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KxjYv2Qa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cd24si2030960ejb.666.2021.01.21.10.31.00; Thu, 21 Jan 2021 10:31:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KxjYv2Qa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726261AbhAUSa1 (ORCPT + 99 others); Thu, 21 Jan 2021 13:30:27 -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