Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp459057pxf; Thu, 18 Mar 2021 04:55:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVy5jFyjhCXhKyUhZXldvOzwZ3zvnLDYoa38Cl4srugtmMcsF3eg1CLSn8t3KwXIgyCnxn X-Received: by 2002:a05:6402:354d:: with SMTP id f13mr3202029edd.228.1616068535698; Thu, 18 Mar 2021 04:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616068535; cv=none; d=google.com; s=arc-20160816; b=YR3Yny8QexpvGqBkkueDXO5W2BaqLF0vgXppfIlr0StNMvpA0Kf7OYw6dX0bvkn9T6 +PI3mqzgTtS/zP7uc1ozKFSb846rl7U0oKXpQyzHHgaIpOSjDCowSUJ8G8tH4ApCiGIN ihfNzwd9m8z0x4lTkuf1vkqP1thkfk2p1abwUujTIpFVRcH65BH4VkFesxMz4MnSo+3U rE9fRQpfG8EXLRruoIU3VopZyzbigNLwuPQl6AKlnclUkls7YkGrvqv0TtOnvcCB8MG1 EGBU4F4giRtSeUKyXuzjfRmhAl9sUZmf21X0BsBXbDo5MUDIAwzAjkqrTa91aD7+RTVS AxeQ== 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=6G1L6mH1jtIW8EV0TBXmfAWQN+GtFKefQOZApw8LQX0=; b=neHEfLZxFmA286/bsoveVvIPS5iAuONPX8GolXU+KgBPYHrNFpcYlhZN8in+2UeSA/ DCH9gPLTLWrnnOafayw2UU2wjS8EXmRh+sw5o6yUVKP3IJDXqn7nJ9LeECe86u7MrlLA PxZxCKqEH5dJ0aWTwNhzRhEhbYL9JYmu7qXWT78OYbGGjIAR3X41aN/ZxcPlILQIRMDK dN+c146vd2qWQREvEk1a0JZLRdGjG5HjUzm3VMDn9ZHfZQqG7GYC5/K5BF6rTmYrLzK1 PiEZg4JnLbqelIFz88HJUMb+klr7BKqnGYmRQFr8YhzLhfoF9j7vJkldKbftonvU3I7s 04sg== 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 y2si1454674edu.245.2021.03.18.04.55.13; Thu, 18 Mar 2021 04:55:35 -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 S229874AbhCRLyA (ORCPT + 99 others); Thu, 18 Mar 2021 07:54:00 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13982 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230041AbhCRLx7 (ORCPT ); Thu, 18 Mar 2021 07:53:59 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F1QNz086gzrYR1; Thu, 18 Mar 2021 19:52:03 +0800 (CST) Received: from [10.174.184.135] (10.174.184.135) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Thu, 18 Mar 2021 19:53:50 +0800 Subject: Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough To: "Tian, Kevin" , Alex Williamson CC: Cornelia Huck , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jean-Philippe Brucker , Eric Auger , Lu Baolu , "wanghaibin.wang@huawei.com" , "yuzenghui@huawei.com" , "Liu, Yi L" , "Pan, Jacob jun" References: <20210125090402.1429-1-lushenming@huawei.com> <20210129155730.3a1d49c5@omen.home.shazbot.org> <47bf7612-4fb0-c0bb-fa19-24c4e3d01d3f@huawei.com> <4f904b23-e434-d42b-15a9-a410f3b4edb9@huawei.com> From: Shenming Lu Message-ID: Date: Thu, 18 Mar 2021 19:53:39 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.135] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/18 17:07, Tian, Kevin wrote: >> From: Shenming Lu >> Sent: Thursday, March 18, 2021 3:53 PM >> >> On 2021/2/4 14:52, Tian, Kevin wrote:>>> In reality, many >>>>> devices allow I/O faulting only in selective contexts. However, there >>>>> is no standard way (e.g. PCISIG) for the device to report whether >>>>> arbitrary I/O fault is allowed. Then we may have to maintain device >>>>> specific knowledge in software, e.g. in an opt-in table to list devices >>>>> which allows arbitrary faults. For devices which only support selective >>>>> faulting, a mediator (either through vendor extensions on vfio-pci-core >>>>> or a mdev wrapper) might be necessary to help lock down non-faultable >>>>> mappings and then enable faulting on the rest mappings. >>>> >>>> For devices which only support selective faulting, they could tell it to the >>>> IOMMU driver and let it filter out non-faultable faults? Do I get it wrong? >>> >>> Not exactly to IOMMU driver. There is already a vfio_pin_pages() for >>> selectively page-pinning. The matter is that 'they' imply some device >>> specific logic to decide which pages must be pinned and such knowledge >>> is outside of VFIO. >>> >>> From enabling p.o.v we could possibly do it in phased approach. First >>> handles devices which tolerate arbitrary DMA faults, and then extends >>> to devices with selective-faulting. The former is simpler, but with one >>> main open whether we want to maintain such device IDs in a static >>> table in VFIO or rely on some hints from other components (e.g. PF >>> driver in VF assignment case). Let's see how Alex thinks about it. >> >> Hi Kevin, >> >> You mentioned selective-faulting some time ago. I still have some doubt >> about it: >> There is already a vfio_pin_pages() which is used for limiting the IOMMU >> group dirty scope to pinned pages, could it also be used for indicating >> the faultable scope is limited to the pinned pages and the rest mappings >> is non-faultable that should be pinned and mapped immediately? But it >> seems to be a little weird and not exactly to what you meant... I will >> be grateful if you can help to explain further. :-) >> > > The opposite, i.e. the vendor driver uses vfio_pin_pages to lock down > pages that are not faultable (based on its specific knowledge) and then > the rest memory becomes faultable. Ahh... Thus, from the perspective of VFIO IOMMU, if IOPF enabled for such device, only the page faults within the pinned range are valid in the registered iommu fault handler... I have another question here, for the IOMMU backed devices, they are already all pinned and mapped when attaching, is there a need to call vfio_pin_pages() to lock down pages for them? Did I miss something?... Thanks, Shenming > > Thanks > Kevin >