Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp946905pxj; Fri, 21 May 2021 02:56:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9b7CYkQ5aYKeIWu/nQHiUW4ijElvGAUV5l+eXKFTzSwUl3nRIG4a/lcm7VyEWjY/YDlgx X-Received: by 2002:aa7:cd77:: with SMTP id ca23mr10276689edb.378.1621591013734; Fri, 21 May 2021 02:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621591013; cv=none; d=google.com; s=arc-20160816; b=n9w80yyGuuUN6u1Qqc4hotxmczBEs2TKf3kAdGTVajAjwK+C3w3UGo2ppx5FXrMmVr 1Sl0KGXVZe3c+OQozY8Aod2d0PdLptGTTRkeTi7ztcQMEKD0OyJKp7SKlUqdS6dqZm6X S40Za8jvLBgUtHqmdzgSp+q3mGG0jersacVEwd2a3bzMVQer+1JiOioQCi1cuTHGP/pI pIBqJcaGMxI5xELqUGsP2akCDck3NCxjDHgZmPbI3fWbcK7e+6paNcdEIQu9GyJxoNNU aIACYefxJLGWKQN1yeAaTgCRsZlezGgtZ7fEVvtK2qwaNjShQ6h+LraiRT7elVzPg9OK NL8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=3hnwkC2Umqn1hB8gjRKn7Ysy5pY0sl+3pT9WIBvYXFc=; b=VSFa8XeB1Z6irVaLu5VORlnPNxRTCicUt/1rIS23i8Clras6TK6XrZ7+tKAkvfMxGS XjXGWnPj0e/cecefmExrSg7dl+mJWm3ugg4/uDCnih9vXQ247gdB+kV0cU9v81d8HlnS BMqs81ov84OPPLqUi/xe10t/2LSuLVouaxhrGBcpcXewYlgkCQdlxrnFdOpno5u5JTG6 50pwjKq4w1B66In8XnBHjb9aXXl7TcV4HKhyaMtHiexavgpJuRUa9ccNLgoEnlf8JpwW TWyjJcyyaTLH0xQgrMjk/cIqKayBbTMkVI0GXobdNO02r02TgIvlOP/TNfQhjMDXQMeS jImA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gh7si5309296ejb.387.2021.05.21.02.56.30; Fri, 21 May 2021 02:56:53 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233424AbhEUGnI (ORCPT + 99 others); Fri, 21 May 2021 02:43:08 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3609 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232355AbhEUGlI (ORCPT ); Fri, 21 May 2021 02:41:08 -0400 Received: from dggems706-chm.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FmcLQ2VNVzQpjW; Fri, 21 May 2021 14:35:42 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 21 May 2021 14:39:14 +0800 Received: from [10.174.187.155] (10.174.187.155) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 21 May 2021 14:39:13 +0800 Subject: Re: [RFC PATCH v3 7/8] vfio/type1: Add selective DMA faulting support To: Alex Williamson , Kevin Tian CC: Cornelia Huck , Will Deacon , "Robin Murphy" , Joerg Roedel , "Jean-Philippe Brucker" , Eric Auger , , , , , , Lu Baolu , , Christoph Hellwig , Jonathan Cameron , Barry Song , , References: <20210409034420.1799-1-lushenming@huawei.com> <20210409034420.1799-8-lushenming@huawei.com> <20210518125813.7b8a78f1.alex.williamson@redhat.com> From: Shenming Lu Message-ID: Date: Fri, 21 May 2021 14:39:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <20210518125813.7b8a78f1.alex.williamson@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.155] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/19 2:58, Alex Williamson wrote: > On Fri, 9 Apr 2021 11:44:19 +0800 > Shenming Lu wrote: > >> Some devices only allow selective DMA faulting. Similar to the selective >> dirty page tracking, the vendor driver can call vfio_pin_pages() to >> indicate the non-faultable scope, we add a new struct vfio_range to >> record it, then when the IOPF handler receives any page request out >> of the scope, we can directly return with an invalid response. > > Seems like this highlights a deficiency in the design, that the user > can't specify mappings as iopf enabled or disabled. Also, if the > vendor driver has pinned pages within the range, shouldn't that prevent > them from faulting in the first place? Why do we need yet more > tracking structures? Pages pinned by the vendor driver need to count > against the user's locked memory limits regardless of iopf. Thanks, Currently we only have a vfio_pfn struct to track the external pinned pages (single page granularity), so I add a vfio_range struct for efficient lookup. Yeah, by this patch, for the non-pinned scope, we can directly return INVALID, but for the pinned(non-faultable) scope, tracking the pinned range doesn't seem to help more... Thanks, Shenming > > Alex > > . >