From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yigit, Ferruh" Subject: Re: VFIO no-iommu Date: Mon, 21 Dec 2015 11:46:43 +0000 Message-ID: <20151221114643.GA30129@sivlogin002.ir.intel.com> References: <1450198398.6042.32.camel@redhat.com> <20151216040408.GA18363@sivlogin002.ir.intel.com> <1450240711.2674.11.camel@redhat.com> <1450285912.2674.22.camel@redhat.com> <1450370639.2674.93.camel@redhat.com> <20151218104310.GA11371@sivlogin002.ir.intel.com> <1450449520.2674.162.camel@redhat.com> <1450475417.2674.167.camel@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" To: Alex Williamson Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id D8EA2F72 for ; Mon, 21 Dec 2015 12:47:06 +0100 (CET) Content-Disposition: inline In-Reply-To: <1450475417.2674.167.camel@redhat.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Dec 18, 2015 at 02:50:17PM -0700, Alex Williamson wrote: > On Fri, 2015-12-18 at 07:38 -0700, Alex Williamson wrote: > > On Fri, 2015-12-18 at 10:43 +0000, Yigit, Ferruh wrote: > > > On Thu, Dec 17, 2015 at 09:43:59AM -0700, Alex Williamson wrote: > > > <...> > > > > > > > > >=20 > > > > > > > > > Also I need to disable VFIO_CHECK_EXTENSION ioctl, > > > > > > > > > because in > > > > > > > > > vfio > > > > > > > > > module, > > > > > > > > > container->noiommu is not set before doing a > > > > > > > > > vfio_group_set_container() > > > > > > > > > and vfio_for_each_iommu_driver selects wrong driver. > > > > > > > >=20 > > > > > > > > Running CHECK_EXTENSION on a container without the group > > > > > > > > attached is > > > > > > > > only going to tell you what extensions vfio is capable > > > > > > > > of, > > > > > > > > not > > > > > > > > necessarily what extensions are available to you with > > > > > > > > that > > > > > > > > group. > > > > > > > > Is this just a general dpdk- vfio ordering bug? > > > > > > >=20 > > > > > > > Yes, that is how VFIO was implemented in DPDK. I was under > > > > > > > the > > > > > > > impression that checking extension before assigning devices > > > > > > > was > > > > > > > the > > > > > > > correct way to do things, so as to not to try anything we > > > > > > > know > > > > > > > would > > > > > > > fail anyway. Does this imply that CHECK_EXTENSION needs to > > > > > > > be > > > > > > > called > > > > > > > on both container and groups (or just on groups)? > > > > > >=20 > > > > > > Hmm, in Documentation/vfio.txt we do give the following > > > > > > algorithm: > > > > > >=20 > > > > > > =A0=A0=A0=A0=A0=A0=A0=A0if (ioctl(container, VFIO_GET_API_VER= SION) !=3D > > > > > > VFIO_API_VERSION) > > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Unknown AP= I version */ > > > > > >=20 > > > > > > =A0=A0=A0=A0=A0=A0=A0=A0if (!ioctl(container, VFIO_CHECK_EXTE= NSION, > > > > > > VFIO_TYPE1_IOMMU)) > > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Doesn't su= pport the IOMMU driver we want. > > > > > > */ > > > > > > =A0=A0=A0=A0=A0=A0=A0=A0... > > > > > >=20 > > > > > > That's just going to query each iommu driver and we can't yet > > > > > > say > > > > > > whether > > > > > > the group the user attaches to the container later will > > > > > > actually > > > > > > support that > > > > > > extension until we try to do it, that would come at > > > > > > VFIO_SET_IOMMU. > > > > > > =A0So is > > > > > > it perhaps a vfio bug that we're not advertising no-iommu > > > > > > until > > > > > > the > > > > > > group is > > > > > > attached? =A0After all, we are capable of it with just an emp= ty > > > > > > container, just > > > > > > like we are with type1, but we're going to fail SET_IOMMU for > > > > > > the > > > > > > wrong > > > > > > combination. > > > > > > =A0This is exactly the sort of thing that makes me glad we > > > > > > reverted > > > > > > it without > > > > > > feedback from a working user driver. =A0Thanks, > > > > >=20 > > > > > Whether it should be considered a "bug" in VFIO or "by design" > > > > > is > > > > > up > > > > > to you, of course, but at least according to the VFIO > > > > > documentation, > > > > > we are meant to check for type 1 extension and then attach > > > > > devices, > > > > > so it would be expected to get VFIO_NOIOMMU_IOMMU marked as > > > > > supported > > > > > even without any devices attached to the container (just like > > > > > we > > > > > get > > > > > type 1 as supported without any devices attached). Having said > > > > > that, > > > > > if it was meant to attach devices first and then check the > > > > > extensions, then perhaps the documentation should also point > > > > > out > > > > > that > > > > > fact (or perhaps I missed that detail in my readings of the > > > > > docs, > > > > > in > > > > > which case my apologies). > > > >=20 > > > > Hi Anatoly, > > > >=20 > > > > Does the below patch make it behave more like you'd expect. =A0Th= is > > > > applies to v4.4-rc4, I'd fold this into the base patch if we > > > > reincorporate it to a future kernel. =A0Thanks, > > > >=20 > > > > Alex > > > >=20 > > > > commit 88d4dcb6b77624965f0b45b5cd305a2b4a105c94 > > > > Author: Alex Williamson > > > > Date:=A0=A0=A0Wed Dec 16 19:02:01 2015 -0700 > > > >=20 > > > > =A0=A0=A0=A0vfio: Fix no-iommu CHECK_EXTENSION > > > > =A0=A0=A0=A0 > > > > =A0=A0=A0=A0Previously the no-iommu iommu driver was only visible= when > > > > the > > > > =A0=A0=A0=A0container had an attached no-iommu group.=A0=A0This m= eans that > > > > =A0=A0=A0=A0CHECK_EXTENSION on and empty container couldn't repor= t the > > > > possibility > > > > =A0=A0=A0=A0of using VFIO_NOIOMMU_IOMMU.=A0=A0We report TYPE1 whe= ther or not > > > > the user > > > > =A0=A0=A0=A0can make use of it with the group, so this is > > > > inconsistent.=A0=A0Add the > > > > =A0=A0=A0=A0no-iommu iommu to the list of iommu drivers when enab= led via > > > > module > > > > =A0=A0=A0=A0option, but skip all the others if the container is a= ttached > > > > to > > > > a > > > > =A0=A0=A0=A0no-iommu groups.=A0=A0Note that tainting is now done = with the > > > > "unsafe" > > > > =A0=A0=A0=A0module callback rather than explictly within vfio. > > > > =A0=A0=A0=A0 > > > > =A0=A0=A0=A0Also fixes module option and module description name > > > > inconsistency. > > > > =A0=A0=A0=A0 > > > > =A0=A0=A0=A0Also make vfio_noiommu_ops const. > > > > =A0=A0=A0=A0 > > > > =A0=A0=A0=A0Signed-off-by: Alex Williamson > > >=20 > > > Hi Alex, > > >=20 > > > I got following crash with this update: >=20 > Let's try this one: >=20 > commit 8ff839c6ffe9f3b50b50f1cc87e7afbf23171f05 > Author: Alex Williamson > Date:=A0=A0=A0Fri Dec 18 14:45:55 2015 -0700 >=20 > =A0=A0=A0=A0v2 vfio fix no-iommu CHECK_EXTENSION > =A0=A0=A0=A0 > =A0=A0=A0=A0Register and unregister the no-iommu iommu backend at modul= e > =A0=A0=A0=A0initialization and exit, but disable it unless enabled via = module > =A0=A0=A0=A0option.=A0=A0Rather than modify the iommu driver walk, sele= ctively skip > =A0=A0=A0=A0combinations that aren't supported.=A0=A0CHECK_EXTENSION on= a container > =A0=A0=A0=A0without any groups attached exposes all possible extensions= .=A0=A0Once a > =A0=A0=A0=A0group is attached, the no-iommu backend is skipped for regu= lar groups > =A0=A0=A0=A0and regular iommu backends are skipped for no-iommu groups. > =A0=A0=A0=A0 > =A0=A0=A0=A0This would be folded into a single patch to re-propose vfio= no-iommu > =A0=A0=A0=A0mode upstream. > =A0=A0=A0=A0 > =A0=A0=A0=A0Signed-off-by: Alex Williamson >=20 Hi Alex, Thank you for the update. I have tested this on both no-iommu and iommu e= nvironment and worked successfully. I believe this approach is better because it is = simpler. >>From DPDK point of view, only update to support vfio no-iommu is: to use = new group names and disable DMA mapping. If VFIO module compiled with "CONFIG_VFIO_NOIOMMU=3Dy" by default, that m= akes things easier for DPDK, in no-iommu environment inserting vfio module with proper param= eter makes it available for DPDK. Thanks, ferruh