Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3442281pxj; Tue, 1 Jun 2021 05:32:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjryniNGa6n1wAEcf/03gjTkQCDED7sQ1ns38D8inLf9TgMkk3T0Rg9cw/qw4RfmIw2gkc X-Received: by 2002:a17:907:2bf4:: with SMTP id gv52mr28628244ejc.271.1622550728835; Tue, 01 Jun 2021 05:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622550728; cv=none; d=google.com; s=arc-20160816; b=vaC1GsRV81vFbojRx7WT+jt5i+40G4UYRNtY6BOiMnvNvG7ZW5PPpIZi0ZYlJR+jYb hRUGCj5og+PIxtZaqEhi7H2vjuOT1UOcrHoHfjOikZSQBREacrC5dF2Yij8OKj0CbIjw jCw6Zl0eZMYy7ehaM46usanw9wLK1/QpQwWMOCgs+8rKaejuGChs4nxC1Lk84EL0Niq8 ytsBSciQc0kJUO+HP1fQq0bTu/HT7LKn16BA24/OSY8B6mzrmxgnbyW7Yqtcg91uUyae ZAWwfm/QemwYBnTb7tUYMGHJEOrBtDwV7slLwfpU253pCDL7lNninsWAjKerKmtvMLF1 Y1NQ== 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 :to:subject:cc:ironport-sdr:ironport-sdr; bh=Sxf6O4ceOP65nKNzFDDjOQ1CBycmxpb3j3fMCQhfzCs=; b=GTOndgbdy87CmeNCgYpMichRerpxtcGO49HrEzeFpBnFtzvTs5jlHADajhTEykYYf4 htdzqoKkuymCBPVFWRwlk08umAwM2ho3nowft5uH8Byw//LgZli6eIILeayjMQ9AOwJ/ fliRNlFrac0EHESlD/k28IFoM6h5nZ9sq3Cn3MHsTYrkUG9TeKpfam9V6lk6J4RH6VQu aRsM4X7FmygQoHWIyG+ZvF1+taajqQpziY6xT4Rnx8UGzKgu6mEb2jyI5dWyuNJNRy5r bgUXPi09fKdiQwbunceMGtMLCURfw+aMxt0xwA8Uabije6LLcG6OmU0zrVbvft/PEAxB FCAw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si12340163ejz.696.2021.06.01.05.31.42; Tue, 01 Jun 2021 05:32:08 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233409AbhFAMc3 (ORCPT + 99 others); Tue, 1 Jun 2021 08:32:29 -0400 Received: from mga17.intel.com ([192.55.52.151]:60719 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbhFAMc2 (ORCPT ); Tue, 1 Jun 2021 08:32:28 -0400 IronPort-SDR: aVjDwVqi+d3RUg37IKw3LHd0pWMA70a4JVQMTICrzeeGrSx95i71zhNlezAAyEM6tFGO72EOGQ SNoEFnxJ+/OA== X-IronPort-AV: E=McAfee;i="6200,9189,10001"; a="183897135" X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="183897135" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 05:30:44 -0700 IronPort-SDR: pmRj6eQl7X0Fy7iIH1MbbbVkU0DGVu7qw6nbeDY/T4pbyT5C2VCpozjuvAh/HOtbhAPZWRXLJ7 5LEqbVipItug== X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="479260607" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.213.9]) ([10.254.213.9]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 05:30:37 -0700 Cc: baolu.lu@linux.intel.com, 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" Subject: Re: [RFC] /dev/ioasid uAPI proposal To: Shenming Lu , "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: Lu Baolu Message-ID: <01fe5034-42c8-6923-32f1-e287cc36bccc@linux.intel.com> Date: Tue, 1 Jun 2021 20:30:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Best regards, baolu