From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AAE5C433F5 for ; Fri, 18 Feb 2022 07:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231388AbiBRH4T (ORCPT ); Fri, 18 Feb 2022 02:56:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:39504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiBRH4T (ORCPT ); Fri, 18 Feb 2022 02:56:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A68C5597; Thu, 17 Feb 2022 23:56:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ADEB161149; Fri, 18 Feb 2022 07:56:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E961C340E9; Fri, 18 Feb 2022 07:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645170962; bh=JsBUt67lBl87g1fuiSB/RVaxBrwVBKkrB8bcypGwUbs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XjVsoi7Z/c+mYAKm2LjxR3hGvRBIU7XQJoO6tsa+cHUPWw30wEuaSNTYh+DEr7FHM ZWb6zwn2JYPBg2Kbu1EGRMM9F2KIASyi/prYKPfl9J3pOSF4OUgUNFm5B34LPjRztj +vyImsRb8HTKGQ5Nuj2bYg19qwl3sgp0q0WpEHlY= Date: Fri, 18 Feb 2022 08:55:59 +0100 From: Greg Kroah-Hartman To: Lu Baolu Cc: Joerg Roedel , Alex Williamson , Bjorn Helgaas , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Dan Williams , rafael@kernel.org, Diana Craciun , Cornelia Huck , Eric Auger , Liu Yi L , Jacob jun Pan , Chaitanya Kulkarni , Stuart Yoder , Laurentiu Tudor , Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , Li Yang , Dmitry Osipenko , iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 04/11] bus: platform,amba,fsl-mc,PCI: Add device DMA ownership management Message-ID: References: <20220218005521.172832-1-baolu.lu@linux.intel.com> <20220218005521.172832-5-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220218005521.172832-5-baolu.lu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Fri, Feb 18, 2022 at 08:55:14AM +0800, Lu Baolu wrote: > The devices on platform/amba/fsl-mc/PCI buses could be bound to drivers > with the device DMA managed by kernel drivers or user-space applications. > Unfortunately, multiple devices may be placed in the same IOMMU group > because they cannot be isolated from each other. The DMA on these devices > must either be entirely under kernel control or userspace control, never > a mixture. Otherwise the driver integrity is not guaranteed because they > could access each other through the peer-to-peer accesses which by-pass > the IOMMU protection. > > This checks and sets the default DMA mode during driver binding, and > cleanups during driver unbinding. In the default mode, the device DMA is > managed by the device driver which handles DMA operations through the > kernel DMA APIs (see Documentation/core-api/dma-api.rst). > > For cases where the devices are assigned for userspace control through the > userspace driver framework(i.e. VFIO), the drivers(for example, vfio_pci/ > vfio_platfrom etc.) may set a new flag (driver_managed_dma) to skip this > default setting in the assumption that the drivers know what they are > doing with the device DMA. > > With the IOMMU layer knowing DMA ownership of each device, above problem > can be solved. > > Cc: Greg Kroah-Hartman > Cc: Bjorn Helgaas > Cc: Stuart Yoder > Cc: Laurentiu Tudor > Signed-off-by: Lu Baolu > --- > include/linux/amba/bus.h | 8 ++++++++ > include/linux/fsl/mc.h | 8 ++++++++ > include/linux/pci.h | 8 ++++++++ > include/linux/platform_device.h | 8 ++++++++ > drivers/amba/bus.c | 20 ++++++++++++++++++++ > drivers/base/platform.c | 20 ++++++++++++++++++++ > drivers/bus/fsl-mc/fsl-mc-bus.c | 26 ++++++++++++++++++++++++-- > drivers/pci/pci-driver.c | 21 +++++++++++++++++++++ > 8 files changed, 117 insertions(+), 2 deletions(-) For the platform.c stuff: Reviewed-by: Greg Kroah-Hartman thanks for renaming this. greg k-h