Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1179174pxj; Fri, 18 Jun 2021 01:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynxwn3Y3GFAFHJ5nuJIGONLX2pb7q2DNsy8/lUew+R2fG6IzQnBtYFULE5MNzWT7cVzXjX X-Received: by 2002:a05:6402:1510:: with SMTP id f16mr3251709edw.377.1624003418047; Fri, 18 Jun 2021 01:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624003418; cv=none; d=google.com; s=arc-20160816; b=u8VBpWtVUEWFRqiCq3gv+JlWx2cvrd+hTzEMFwX2J451Im3mNObhvBrGWtEoY/fO51 0XYl48AMD6ZeL2+Dpa83pjnzUXIsNUG+/PPX+zEcfo+cs2kkt9iKz+d1LVnCjpOXZBoX uSp3wHIRNLfsNEzuEs1GWgj4GZSKB4GMtJ1dgLr6InJpNYK9d1mF7LDnJvo/oTMCwsgi OQO9Akl3eaKFY6xaIenJ/4gGKenabUFyPNvXHWfJaJidq3RPPlNy0M9wYgQy9BB4VLUJ FX8nqsvQDJXHFfW1RNRTo7LxrDJJBwMbUF07oBxRuV1kGzVNPAaLbuBj/CEqBwi4Pd7/ z3zg== 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=1gt+y077pC93xktcy7SWuL4OAekTofJEdCMc7IXEWe8=; b=iv/2ZRxxba48niZlCCBjzDJ1cbFOBgloB8TvJrefUtFaVVqJ1BXUOZKtLXqrJ9YK95 ltQmdZadl14/z4lcq70bhe4FvY03A5LLuRE0Bs3kEOrcB+uSkunaAms5NCTZ9IXpr9IZ ArfMbOGSgSUFCif1u3q/F1Qf6T5fEQzBj3SCFg9IGWG6LHVxslwpYs1nxMoKD6nG9BG6 2kn4FL0tgr1pPTqUqxquLDtU3GThtiRnVWdV9KtPNLV83XvOEWGcWoNcq3IAYCB3FPN5 GQZ+2q4jJY9mlHHoBwhd2kW+QTsVQd5jVEYAYxkfQIz9Y+NE7L8HxfXBZCgLpb326j9w 5VbQ== 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 cx14si8215451edb.356.2021.06.18.01.03.15; Fri, 18 Jun 2021 01:03:38 -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 S232458AbhFRFZf (ORCPT + 99 others); Fri, 18 Jun 2021 01:25:35 -0400 Received: from mga12.intel.com ([192.55.52.136]:45541 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbhFRFZb (ORCPT ); Fri, 18 Jun 2021 01:25:31 -0400 IronPort-SDR: b6Dn0RQZ0m6w/AcA8NgjB7mB4bDHPV8tntR4/T4NHh+qCmA5BelsV3deAH4VZsVd8emJ+AftWL TpfDqa+JtXKg== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="186190427" X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="186190427" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 22:23:21 -0700 IronPort-SDR: 4NGXo4KjN3kz+xI8wopVyXJfV6B9U5dgiyrFssRbBVsZnBC+5BLY00MKKQNFZOy06EeRcJ8FJr 9RnOGfuyridQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="555469079" Received: from allen-box.sh.intel.com (HELO [10.239.159.118]) ([10.239.159.118]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 22:23:16 -0700 Cc: baolu.lu@linux.intel.com, Jason Gunthorpe , Joerg Roedel , "Tian, Kevin" , "Alex Williamson (alex.williamson@redhat.com)" , Jean-Philippe Brucker , Jason Wang , "parav@mellanox.com" , "Enrico Weigelt, metux IT consult" , Paolo Bonzini , Shenming Lu , 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 Subject: Re: Plan for /dev/ioasid RFC v2 To: David Gibson References: <20210609123919.GA1002214@nvidia.com> <14d884a8-13bc-b2ba-7020-94b219e3e2d9@linux.intel.com> From: Lu Baolu Message-ID: Date: Fri, 18 Jun 2021 13:21:47 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, On 6/17/21 1:22 PM, David Gibson wrote: >> The iommu_group can guarantee the isolation among different physical >> devices (represented by RIDs). But when it comes to sub-devices (ex. mdev or >> vDPA devices represented by RID + SSID), we have to rely on the >> device driver for isolation. The devices which are able to generate sub- >> devices should either use their own on-device mechanisms or use the >> platform features like Intel Scalable IOV to isolate the sub-devices. > This seems like a misunderstanding of groups. Groups are not tied to > any PCI meaning. Groups are the smallest unit of isolation, no matter > what is providing that isolation. > > If mdevs are isolated from each other by clever software, even though > they're on the same PCI device they are in different groups from each > other*by definition*. They are also in a different group from their > parent device (however the mdevs only exist when mdev driver is > active, which implies that the parent device's group is owned by the > kernel). You are right. This is also my understanding of an "isolation group". But, as I understand it, iommu_group is only the isolation group visible to IOMMU. When we talk about sub-devices (sw-mdev or mdev w/ pasid), only the device and device driver knows the details of isolation, hence iommu_group could not be extended to cover them. The device drivers should define their own isolation groups. Otherwise, the device driver has to fake an iommu_group and add hacky code to link the related IOMMU elements (iommu device, domain, group etc.) together. Actually this is part of the problem that this proposal tries to solve. > >> Under above conditions, different sub-device from a same RID device >> could be able to use different IOASID. This seems to means that we can't >> support mixed mode where, for example, two RIDs share an iommu_group and >> one (or both) of them have sub-devices. > That doesn't necessarily follow. mdevs which can be successfully > isolated by their mdev driver are in a different group from their > parent device, and therefore need not be affected by whether the > parent device shares a group with some other physical device. They > *might* be, but that's up to the mdev driver to determine based on > what it can safely isolate. > If we understand it as multiple levels of isolation, can we classify the devices into the following categories? 1) Legacy devices - devices without device-level isolation - multiple devices could sit in a single iommu_group - only a single I/O address space could be bound to IOMMU 2) Modern devices - devices capable of device-level isolation - able to have subdevices - self-isolated, hence not share iommu_group with others - multiple I/O address spaces could be bound to IOMMU For 1), all devices in an iommu_group should be bound to a single IOASID; The isolation is guaranteed by an iommu_group. For 2) a single device could be bound to multiple IOASIDs with each sub- device corresponding to an IOASID. The isolation of each subdevice is guaranteed by the device driver. Best regards, baolu