Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp738923pxj; Thu, 3 Jun 2021 19:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJiNhQToUFgXcaS4rm7ir2FWUifzXGhRw4DJFn6vTX476Qe1BXtspd4Kh9hsmm8CsNwAn7 X-Received: by 2002:a50:d589:: with SMTP id v9mr2365974edi.126.1622772319357; Thu, 03 Jun 2021 19:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622772319; cv=none; d=google.com; s=arc-20160816; b=qoCNESRQRr1kJ+oRW5RYcQwoInWjuJUzk+e4F46lOrgemW3l8aOzDp/yLrSuej+ITz ew53LTbojKGS7/XC/2AwDi7qjTYodlPYQz8oFT95NnZQ4zmocGr7OtOyGXavwSGMLgcb 1XMf/EnO/D2mKrBd3HXCYSNbPT3r9W0BUxG2Hqyk76DXxhDKE0ohlKs7AI7SgkDn3jsZ GpVfwSiUNtN8SSJWYDTnuPazUEBsRMNfLEK1IT6gin4mIV4QAshfv+xv3vZe2KGU9/54 lPVvpdluOmQT4pCe0QraY8B2WVgam3gXGxMDI/5t15aN15l/mr31F0Q2od3qHymiLBZ9 vJnw== 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=Js2zVgUTEfMznT9kfQiPyrkrcvExmZcHMroE7UbQxVo=; b=pJ3yyxrAHG31eeXH7JLULjNBMdS2546klmO/NQ7zLXscM2PpdbUGayKlcykYaBL69l EoCe3kgsnCsi49i2hV8xSwiEMMPo+ebBnfr+/5TExtsRyFTCTRnuzdGKUXibH7NelqGq 30yN2Z93DYJQZKyKD+bdI06qBvJ8Z9T62hvbHz5KQ4HiGVxw1sN+pjyaNlL0AgiDSibT 9jaB3g2BElZMKMaQqtJFYW+z/JvQkbYL1I0b6HOp7QTTvoYHpYsdzl6DOlcYsAcKZ2XC x5Y0gPRIAfwnNoP78EwC5GRibExB8LGzoSddaVXeNKDwG8K9rOaWGqqdR2dnEkZZxTTv kTgw== 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 hh16si3616402ejb.532.2021.06.03.19.04.55; Thu, 03 Jun 2021 19:05:19 -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 S229916AbhFDCE7 (ORCPT + 99 others); Thu, 3 Jun 2021 22:04:59 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:4466 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFDCE6 (ORCPT ); Thu, 3 Jun 2021 22:04:58 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Fx5ZJ2cJgzYqJ4; Fri, 4 Jun 2021 10:00:24 +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; Fri, 4 Jun 2021 10:03:09 +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; Fri, 4 Jun 2021 10:03:08 +0800 Subject: Re: [RFC] /dev/ioasid uAPI proposal To: Jacob Pan CC: Jason Gunthorpe , Lu Baolu , "Tian, Kevin" , LKML , Joerg Roedel , David Woodhouse , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "Alex Williamson (alex.williamson@redhat.com)" , Jason Wang , Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jean-Philippe Brucker , David Gibson , Kirti Wankhede , Robin Murphy , Zenghui Yu , "wanghaibin.wang@huawei.com" References: <01fe5034-42c8-6923-32f1-e287cc36bccc@linux.intel.com> <20210601173323.GN1002214@nvidia.com> <23a482f9-b88a-da98-3800-f3fd9ea85fbd@huawei.com> <20210603111914.653c4f61@jacob-builder> From: Shenming Lu Message-ID: Date: Fri, 4 Jun 2021 10:03:08 +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: <20210603111914.653c4f61@jacob-builder> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.185.220] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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/4 2:19, Jacob Pan wrote: > Hi Shenming, > > On Wed, 2 Jun 2021 12:50:26 +0800, Shenming Lu > wrote: > >> On 2021/6/2 1:33, Jason Gunthorpe wrote: >>> On Tue, Jun 01, 2021 at 08:30:35PM +0800, Lu Baolu wrote: >>> >>>> 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. >>> >>> I'm still confused why drivers need fault handlers at all? >> >> Essentially it is the userspace that needs the fault handlers, >> one case is to deliver the faults to the vIOMMU, and another >> case is to enable IOPF on the GPA address space for on-demand >> paging, it seems that both could be specified in/through the >> IOASID_ALLOC ioctl? >> > I would think IOASID_BIND_PGTABLE is where fault handler should be > registered. There wouldn't be any IO page fault without the binding anyway. Yeah, I also proposed this before, registering the handler in the BIND_PGTABLE ioctl does make sense for the guest page faults. :-) But how about the page faults from the GPA address space (it's page table is mapped through the MAP_DMA ioctl)? From your point of view, it seems that we should register the handler for the GPA address space in the (first) MAP_DMA ioctl. > > I also don't understand why device drivers should register the fault > handler, the fault is detected by the pIOMMU and injected to the vIOMMU. So > I think it should be the IOASID itself register the handler. Yeah, and it can also be said that the provider of the page table registers the handler (Baolu). Thanks, Shenming