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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 AE980C47092 for ; Tue, 1 Jun 2021 07:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A02061396 for ; Tue, 1 Jun 2021 07:16:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233030AbhFAHRs (ORCPT ); Tue, 1 Jun 2021 03:17:48 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:2925 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbhFAHRp (ORCPT ); Tue, 1 Jun 2021 03:17:45 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4FvNfR6PWhz670K; Tue, 1 Jun 2021 15:13:03 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 1 Jun 2021 15:16:00 +0800 Received: from [10.174.185.220] (10.174.185.220) 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; Tue, 1 Jun 2021 15:15:59 +0800 Subject: Re: [RFC] /dev/ioasid uAPI proposal To: Lu Baolu , "Tian, Kevin" , LKML , Joerg Roedel , "Jason Gunthorpe" , David Woodhouse , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "Alex Williamson (alex.williamson@redhat.com)" , Jason Wang CC: Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jacob Pan , Jean-Philippe Brucker , David Gibson , "Kirti Wankhede" , Robin Murphy , "Zenghui Yu" , "wanghaibin.wang@huawei.com" References: From: Shenming Lu Message-ID: Date: Tue, 1 Jun 2021 15:15:59 +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: 8bit X-Originating-IP: [10.174.185.220] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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/6/1 13:10, Lu Baolu wrote: > Hi Shenming, > > On 6/1/21 12:31 PM, Shenming Lu wrote: >> On 2021/5/27 15:58, Tian, Kevin wrote: >>> /dev/ioasid provides an unified interface for managing I/O page tables for >>> devices assigned to userspace. Device passthrough frameworks (VFIO, vDPA, >>> etc.) are expected to use this interface instead of creating their own logic to >>> isolate untrusted device DMAs initiated by userspace. >>> >>> This proposal describes the uAPI of /dev/ioasid and also sample sequences >>> with VFIO as example in typical usages. The driver-facing kernel API provided >>> by the iommu layer is still TBD, which can be discussed after consensus is >>> made on this uAPI. >>> >>> It's based on a lengthy discussion starting from here: >>>     https://lore.kernel.org/linux-iommu/20210330132830.GO2356281@nvidia.com/ >>> >>> It ends up to be a long writing due to many things to be summarized and >>> non-trivial effort required to connect them into a complete proposal. >>> Hope it provides a clean base to converge. >>> >> >> [..] >> >>> >>> /* >>>    * Page fault report and response >>>    * >>>    * This is TBD. Can be added after other parts are cleared up. Likely it >>>    * will be a ring buffer shared between user/kernel, an eventfd to notify >>>    * the user and an ioctl to complete the fault. >>>    * >>>    * The fault data is per I/O address space, i.e.: IOASID + faulting_addr >>>    */ >> >> Hi, >> >> It seems that the ioasid has different usage in different situation, it could >> be directly used in the physical routing, or just a virtual handle that indicates >> a page table or a vPASID table (such as the GPA address space, in the simple >> passthrough case, the DMA input to IOMMU will just contain a Stream ID, no >> Substream ID), right? >> >> And Baolu suggested that since one device might consume multiple page tables, >> it's more reasonable to have one fault handler per page table. By this, do we >> have to maintain such an ioasid info list in the IOMMU layer? > > As discussed earlier, the I/O page fault and cache invalidation paths > will have "device labels" so that the information could be easily > translated and routed. > > So it's likely the per-device fault handler registering API in iommu > core can be kept, but /dev/ioasid will be grown with a layer to > translate and propagate I/O page fault information to the right > consumers. Yeah, having a general preprocessing of the faults in IOASID seems to be a doable direction. But since there may be more than one consumer at the same time, who is responsible for registering the per-device fault handler? Thanks, Shenming > > If things evolve in this way, probably the SVA I/O page fault also needs > to be ported to /dev/ioasid. > >> >> Then if we add host IOPF support (for the GPA address space) in the future >> (I have sent a series for this but it aimed for VFIO, I will convert it for >> IOASID later [1] :-)), how could we find the handler for the received fault >> event which only contains a Stream ID... Do we also have to maintain a >> dev(vPASID)->ioasid mapping in the IOMMU layer? >> >> [1] https://lore.kernel.org/patchwork/cover/1410223/ > > Best regards, > baolu > . 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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 46CBEC47080 for ; Tue, 1 Jun 2021 07:16:12 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D35F961396 for ; Tue, 1 Jun 2021 07:16:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D35F961396 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9B2F8607CB; Tue, 1 Jun 2021 07:16:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Mq1iC-LXsCN; Tue, 1 Jun 2021 07:16:10 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTP id D7A82605FA; Tue, 1 Jun 2021 07:16:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BBDA9C000E; Tue, 1 Jun 2021 07:16:09 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8398AC0001 for ; Tue, 1 Jun 2021 07:16:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 60CA083CD7 for ; Tue, 1 Jun 2021 07:16:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tOgP6c_TA6Ut for ; Tue, 1 Jun 2021 07:16:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by smtp1.osuosl.org (Postfix) with ESMTPS id D452683CD4 for ; Tue, 1 Jun 2021 07:16:06 +0000 (UTC) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4FvNfR6PWhz670K; Tue, 1 Jun 2021 15:13:03 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 1 Jun 2021 15:16:00 +0800 Received: from [10.174.185.220] (10.174.185.220) 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; Tue, 1 Jun 2021 15:15:59 +0800 Subject: Re: [RFC] /dev/ioasid uAPI proposal To: Lu Baolu , "Tian, Kevin" , LKML , Joerg Roedel , "Jason Gunthorpe" , David Woodhouse , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "Alex Williamson (alex.williamson@redhat.com)" , Jason Wang References: From: Shenming Lu Message-ID: Date: Tue, 1 Jun 2021 15:15:59 +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-Language: en-US X-Originating-IP: [10.174.185.220] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected Cc: Jean-Philippe Brucker , "Jiang, Dave" , "Raj, Ashok" , Jonathan Corbet , Kirti Wankhede , "wanghaibin.wang@huawei.com" , David Gibson , Robin Murphy X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" T24gMjAyMS82LzEgMTM6MTAsIEx1IEJhb2x1IHdyb3RlOgo+IEhpIFNoZW5taW5nLAo+IAo+IE9u IDYvMS8yMSAxMjozMSBQTSwgU2hlbm1pbmcgTHUgd3JvdGU6Cj4+IE9uIDIwMjEvNS8yNyAxNTo1 OCwgVGlhbiwgS2V2aW4gd3JvdGU6Cj4+PiAvZGV2L2lvYXNpZCBwcm92aWRlcyBhbiB1bmlmaWVk IGludGVyZmFjZSBmb3IgbWFuYWdpbmcgSS9PIHBhZ2UgdGFibGVzIGZvcgo+Pj4gZGV2aWNlcyBh c3NpZ25lZCB0byB1c2Vyc3BhY2UuIERldmljZSBwYXNzdGhyb3VnaCBmcmFtZXdvcmtzIChWRklP LCB2RFBBLAo+Pj4gZXRjLikgYXJlIGV4cGVjdGVkIHRvIHVzZSB0aGlzIGludGVyZmFjZSBpbnN0 ZWFkIG9mIGNyZWF0aW5nIHRoZWlyIG93biBsb2dpYyB0bwo+Pj4gaXNvbGF0ZSB1bnRydXN0ZWQg ZGV2aWNlIERNQXMgaW5pdGlhdGVkIGJ5IHVzZXJzcGFjZS4KPj4+Cj4+PiBUaGlzIHByb3Bvc2Fs IGRlc2NyaWJlcyB0aGUgdUFQSSBvZiAvZGV2L2lvYXNpZCBhbmQgYWxzbyBzYW1wbGUgc2VxdWVu Y2VzCj4+PiB3aXRoIFZGSU8gYXMgZXhhbXBsZSBpbiB0eXBpY2FsIHVzYWdlcy4gVGhlIGRyaXZl ci1mYWNpbmcga2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