Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp766804pxb; Thu, 15 Apr 2021 06:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypYfDKNBzshfR04HlZkE9VlqtINRa6yjXpcMGD2KoqeMNBd4woJe5dKgIDz/b6bY4XCZT7 X-Received: by 2002:a17:906:f1cf:: with SMTP id gx15mr3470859ejb.143.1618492390510; Thu, 15 Apr 2021 06:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618492390; cv=none; d=google.com; s=arc-20160816; b=uMDskgaac23pSp7tNK+jX45Rsu8Hppj3EsyyxSsr9Oe+9Z3VOtNfdwwaKrgIRKGn9e y2DK/l+AG+SkHUKRgQ3owi9mxzBELuJMJWy29ZSzEqd8wOF15yn0ybUJOEnY7bZutyPV NZ4iWDj+cSS2gAqPXL7PdZiBa7l8Ny5WWO2i2uTxXF9CclVh79jp3kEkc4fa6MF6snVG PU/b104fFzIg4KGdzPYReWzP3uKkLzXDApbQk1/Sfxqt3xa/qPrB+DTLhDoJhGEV6am5 0ZiOH6lF6qWmxOYs2raqj4t8brGmF1O3A9cjiT/vmNbyA9/e/VQkVyOWSnsZd7rnJxUS DUmA== 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:dkim-signature; bh=uJFJJborCVJEMqUuUmQ0ihhHIFtN58LgRcEx9fJY0yk=; b=USs3oGLDBc6HOZ2udJG5Gy3+QRyY/ZbmXlmXT7cTuxUt2PsJNyBnD1jAZ6SRQ1E0gA fPZVt6994EOc51+vopAWEvfuwsh6rjZJw4E/oYtsH/GuBZuuna1XP9gKBTWGGyQG0Wml GWoDDRYRBOmd4jN3/wK1kyffXdsyUX8gL2cnuvErrcCrvggt+HUGB1hwxKCXL+kkBX+F hPs440UwHdM9659Oo0LdyWoLALbhdpvsdefyuDuCYt7l83NUZ0wezAX/pPAq1ACc63As bA1PluXxvA1coyJIrc5vJD4BcDOvUdvAbZBv8pcWGEq6MA/LWjgwjvhsoloxrCMWJ+da pTog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YfdYhD1K; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si2239304ede.264.2021.04.15.06.12.47; Thu, 15 Apr 2021 06:13:10 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YfdYhD1K; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbhDONME (ORCPT + 99 others); Thu, 15 Apr 2021 09:12:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36824 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbhDONMD (ORCPT ); Thu, 15 Apr 2021 09:12:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618492300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uJFJJborCVJEMqUuUmQ0ihhHIFtN58LgRcEx9fJY0yk=; b=YfdYhD1KXOQofVDi6ddoyfUiLfmOSpXtVQo48PGgsItO1LiUx5Bi46thUvFlk12UnUU5rl Cjjp7LYpRteqZB7Wtz1KvjifuKM/0sZQQ9SA5V1Q9mEUmsuW+csMfblwdqfiW8Fl7JO0I1 B2Zwi1X8/2q0XKteF2uCgdI0xB/S12A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-8zek38_XN6qIhkiadECvyA-1; Thu, 15 Apr 2021 09:11:36 -0400 X-MC-Unique: 8zek38_XN6qIhkiadECvyA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 279A710054F6; Thu, 15 Apr 2021 13:11:33 +0000 (UTC) Received: from [10.36.114.81] (ovpn-114-81.ams2.redhat.com [10.36.114.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0911660C22; Thu, 15 Apr 2021 13:11:21 +0000 (UTC) Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs To: Jason Gunthorpe , "Liu, Yi L" Cc: Jean-Philippe Brucker , "Tian, Kevin" , Jacob Pan , LKML , Joerg Roedel , Lu Baolu , David Woodhouse , "iommu@lists.linux-foundation.org" , "cgroups@vger.kernel.org" , Tejun Heo , Li Zefan , Johannes Weiner , Jean-Philippe Brucker , Alex Williamson , Jonathan Corbet , "Raj, Ashok" , "Wu, Hao" , "Jiang, Dave" References: <20210330132830.GO2356281@nvidia.com> <20210331124038.GE1463678@nvidia.com> <20210401134236.GF1463678@nvidia.com> <20210401160337.GJ1463678@nvidia.com> From: Auger Eric Message-ID: <4bea6eb9-08ad-4b6b-1e0f-c97ece58a078@redhat.com> Date: Thu, 15 Apr 2021 15:11:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210401160337.GJ1463678@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, On 4/1/21 6:03 PM, Jason Gunthorpe wrote: > On Thu, Apr 01, 2021 at 02:08:17PM +0000, Liu, Yi L wrote: > >> DMA page faults are delivered to root-complex via page request message and >> it is per-device according to PCIe spec. Page request handling flow is: >> >> 1) iommu driver receives a page request from device >> 2) iommu driver parses the page request message. Get the RID,PASID, faulted >> page and requested permissions etc. >> 3) iommu driver triggers fault handler registered by device driver with >> iommu_report_device_fault() > > This seems confused. > > The PASID should define how to handle the page fault, not the driver. In my series I don't use PASID at all. I am just enabling nested stage and the guest uses a single context. I don't allocate any user PASID at any point. When there is a fault at physical level (a stage 1 fault that concerns the guest), this latter needs to be reported and injected into the guest. The vfio pci driver registers a fault handler to the iommu layer and in that fault handler it fills a circ bugger and triggers an eventfd that is listened to by the VFIO-PCI QEMU device. this latter retrives the faault from the mmapped circ buffer, it knowns which vIOMMU it is attached to, and passes the fault to the vIOMMU. Then the vIOMMU triggers and IRQ in the guest. We are reusing the existing concepts from VFIO, region, IRQ to do that. For that use case, would you also use /dev/ioasid? Thanks Eric > > I don't remember any device specific actions in ATS, so what is the > driver supposed to do? > >> 4) device driver's fault handler signals an event FD to notify userspace to >> fetch the information about the page fault. If it's VM case, inject the >> page fault to VM and let guest to solve it. > > If the PASID is set to 'report page fault to userspace' then some > event should come out of /dev/ioasid, or be reported to a linked > eventfd, or whatever. > > If the PASID is set to 'SVM' then the fault should be passed to > handle_mm_fault > > And so on. > > Userspace chooses what happens based on how they configure the PASID > through /dev/ioasid. > > Why would a device driver get involved here? > >> Eric has sent below series for the page fault reporting for VM with passthru >> device. >> https://lore.kernel.org/kvm/20210223210625.604517-5-eric.auger@redhat.com/ > > It certainly should not be in vfio pci. Everything using a PASID needs > this infrastructure, VDPA, mdev, PCI, CXL, etc. > > Jason >