Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3472919pxj; Tue, 1 Jun 2021 06:12:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9oKWs00rfz8v/iObApN8ECx/OjFTACtqadX6dgF+pcsV0t3wzvZ6prs77L0Lc6IoOPh9C X-Received: by 2002:a5d:9c9a:: with SMTP id p26mr21459046iop.94.1622553173282; Tue, 01 Jun 2021 06:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622553173; cv=none; d=google.com; s=arc-20160816; b=aTtnQUzq4beyLePEe2IOQKdFMxVems3+DShXYs/XnXWwkbIf7y0H+jRtWNyjsr0tBz J+mkIPQzAW0wvYEHQ0VKvx/OLchMsAJ6pGcIKn4FSe+x3AfxbtYGfXCOXASYwoLsx6UX lE5BglZqpofk+GqhGfbyGdHBUacjMeSkDIbqKDHmHWWimxryaDCIun3oP8n9V0OWFT/r /9N2RIYZlQZBH+vxc2SXWVgkxKaxRxjrGw4OzLA8MRUas/mzogytZittlJldAfm6IeFi YL4DZRWDXFmRC7JXgNe8kClRLp+c0EeQE4TLmStrGBZR1irXQblO4ItY0I9ambvfged0 HgxQ== 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=0BNPxRj4E2w65YpygGONdclerf0viAkm7IwuenHIqTU=; b=lq25tgEraNNwrUv2GXntPYsf9bovME8yOlVia99U04JVei2isLgyOuLshxNLpxJYVE Tkuo6soguzTfzt6251TJs3CUbygAxIHMUqtCn6wJTaF0wPOy63+bsOTgijqt3TLaL2DR jT5g8W+99OmV+csTmCjxv35A/3cwNUiTDAuNVjmlvLl1/U+tvRIjrxP9bVzE59/De0dM J4ScSNILZYy4mKahrHYUXFtDQ4VImo6f134haXOk9IDfIlTuDfRD9A1/5AlntplnIvNH ZForQlUVSRw3EpQ2M2aoxic/TkbrAHZm7/XpxKcwDmgoIOKTBlvarQZcnBJcQ/sv34KU pxlQ== 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 m2si2427097jaj.13.2021.06.01.06.12.40; Tue, 01 Jun 2021 06:12: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 S233992AbhFANMk (ORCPT + 99 others); Tue, 1 Jun 2021 09:12:40 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3367 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233768AbhFANMj (ORCPT ); Tue, 1 Jun 2021 09:12:39 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4FvXW34ZMTz67Pr; Tue, 1 Jun 2021 21:07:11 +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 21:10:55 +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 21:10:54 +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 , Jean-Philippe Brucker CC: Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jacob Pan , David Gibson , Kirti Wankhede , Robin Murphy , Zenghui Yu , "wanghaibin.wang@huawei.com" References: <01fe5034-42c8-6923-32f1-e287cc36bccc@linux.intel.com> From: Shenming Lu Message-ID: Date: Tue, 1 Jun 2021 21:10:42 +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: <01fe5034-42c8-6923-32f1-e287cc36bccc@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.185.220] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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 20:30, Lu Baolu wrote: > On 2021/6/1 15:15, Shenming Lu wrote: >> 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? > > The drivers register per page table fault handlers to /dev/ioasid which > will then register itself to iommu core to listen and route the per- > device I/O page faults. This is just a top level thought. Haven't gone > through the details yet. Need to wait and see what /dev/ioasid finally > looks like. OK. And it needs to be confirmed by Jean since we might migrate the code from io-pgfault.c to IOASID... Anyway, finalize /dev/ioasid first. Thanks, Shenming > > Best regards, > baolu > .