Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp155077pxv; Thu, 15 Jul 2021 01:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVcjCXmgw59rgYG0SohZ4qsQ1OUbMY/SFloggvoiw30Y9hKMEyg340HP4Lfx3oVqK83OkT X-Received: by 2002:a17:906:aaca:: with SMTP id kt10mr4034370ejb.127.1626336195144; Thu, 15 Jul 2021 01:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626336195; cv=none; d=google.com; s=arc-20160816; b=u4e0wF/tmHedOspWyjdyDDC8RFggfN5uWGnMRJIT4mAp6vFn0MYI9b/bM1Wou6xuAa NpWTQxvaz0Ngv8MufQU0f9YG2LWIpnj7pWismVFUSRr+a8LejOScdFpa3kYoYKRv4VTe DkksbjGXeIh3KlH+pqn8TT/u5CCTduKZL8wRQBNHRCjuq41IukiekP4DBUPsLfBduaBe nTpYKmHEelJPMvyiIV8dr9Ncn9xW336JdBP0JfbYRs+K9METL76oO9c0hwLn8rjNXKjn qAqpyyofSgSV8QiG8JiJeDF2QF59DmN47FC/SWf7wAP/KEf3He3ZxJwXGDourdVv1vmR k/qw== 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=9y3a8ySv5DpSWjM2fAmgEvOWyeQFfh3JZTGvw3s3sL4=; b=h8MzRBT5gx8Us2nUn/XD8xRWilYjUN1RxIfqPYNpFQNhfmTGZVzSQji8LOBbQqUmN/ f/6fcAnoGbL1BjZW86zW9+KiQo4b6PWoItdhgkm7IXPWsVKLrxlOGj8Z0hRfJ4qgLddJ WNdhVDfTC/WKkH/1WUzTjpdM/s4QfHqhPFP/V0t72ZQ/8dqRFqIpROl1Dw6H8f/tyXKy DBNBifJpkFE3dK82O2zx5fpP7DdZiyqPsblWuBq/6i+fRXG/QgtsB1LZaDmKTBdb9jdM Rqlpl2/XcJMu2AF2MqK2xDz+zwQ8CVVjfMbpzzuWJeewWoRvKzhSDVeeXhM003/tzxLp YSLA== 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 y31si8580976edy.561.2021.07.15.01.02.52; Thu, 15 Jul 2021 01:03:15 -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 S240193AbhGOGcI (ORCPT + 99 others); Thu, 15 Jul 2021 02:32:08 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:7011 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbhGOGcH (ORCPT ); Thu, 15 Jul 2021 02:32:07 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GQPT04QJtzXtJ0; Thu, 15 Jul 2021 14:23:32 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 15 Jul 2021 14:29:11 +0800 Received: from [10.174.185.67] (10.174.185.67) 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; Thu, 15 Jul 2021 14:29:10 +0800 Subject: Re: [RFC v2] /dev/iommu uAPI proposal To: "Tian, Kevin" CC: Jason Gunthorpe , "Alex Williamson (alex.williamson@redhat.com)" , "Jean-Philippe Brucker" , David Gibson , Jason Wang , "parav@mellanox.com" , "Enrico Weigelt, metux IT consult" , Paolo Bonzini , Joerg Roedel , Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jacob Pan , "Kirti Wankhede" , Robin Murphy , "kvm@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "David Woodhouse" , LKML , "Lu Baolu" , "wanghaibin.wang@huawei.com" References: <7ea349f8-8c53-e240-fe80-382954ba7f28@huawei.com> From: Shenming Lu Message-ID: Date: Thu, 15 Jul 2021 14:29:00 +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.67] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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/7/15 11:55, Tian, Kevin wrote: >> From: Shenming Lu >> Sent: Thursday, July 15, 2021 11:21 AM >> >> On 2021/7/9 15:48, Tian, Kevin wrote: >>> 4.6. I/O page fault >>> +++++++++++++++++++ >>> >>> uAPI is TBD. Here is just about the high-level flow from host IOMMU driver >>> to guest IOMMU driver and backwards. This flow assumes that I/O page >> faults >>> are reported via IOMMU interrupts. Some devices report faults via device >>> specific way instead of going through the IOMMU. That usage is not >> covered >>> here: >>> >>> - Host IOMMU driver receives a I/O page fault with raw fault_data {rid, >>> pasid, addr}; >>> >>> - Host IOMMU driver identifies the faulting I/O page table according to >>> {rid, pasid} and calls the corresponding fault handler with an opaque >>> object (registered by the handler) and raw fault_data (rid, pasid, addr); >>> >>> - IOASID fault handler identifies the corresponding ioasid and device >>> cookie according to the opaque object, generates an user fault_data >>> (ioasid, cookie, addr) in the fault region, and triggers eventfd to >>> userspace; >>> >> >> Hi, I have some doubts here: >> >> For mdev, it seems that the rid in the raw fault_data is the parent device's, >> then in the vSVA scenario, how can we get to know the mdev(cookie) from >> the >> rid and pasid? >> >> And from this point of view,would it be better to register the mdev >> (iommu_register_device()) with the parent device info? >> > > This is what is proposed in this RFC. A successful binding generates a new > iommu_dev object for each vfio device. For mdev this object includes > its parent device, the defPASID marking this mdev, and the cookie > representing it in userspace. Later it is iommu_dev being recorded in > the attaching_data when the mdev is attached to an IOASID: > > struct iommu_attach_data *__iommu_device_attach( > struct iommu_dev *dev, u32 ioasid, u32 pasid, int flags); > > Then when a fault is reported, the fault handler just needs to figure out > iommu_dev according to {rid, pasid} in the raw fault data. > Yeah, we have the defPASID that marks the mdev and refers to the default I/O address space, but how about the non-default I/O address spaces? Is there a case that two different mdevs (on the same parent device) are used by the same process in the guest, thus have a same pasid route in the physical IOMMU? It seems that we can't figure out the mdev from the rid and pasid in this case... Did I misunderstand something?... :-) Thanks, Shenming