Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3313553pxb; Wed, 14 Apr 2021 02:28:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydaxpz4NqKsQjYOVfV4Vb/oc8vo0Zjs+/milCdxpGdQCeZrhspmZUwkneWa4nleaOujOoL X-Received: by 2002:aa7:8a84:0:b029:231:ff56:2c7e with SMTP id a4-20020aa78a840000b0290231ff562c7emr34418762pfc.50.1618392500721; Wed, 14 Apr 2021 02:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618392500; cv=none; d=google.com; s=arc-20160816; b=hyMQ3GcH0Qu5FvhhQj8tjHicjUlsfY9I4nwRGqWg3mOOofJYXXnqzk0Sj0xi0kQ9N4 QZFKbogrms2sBPXflw/F8I1xNPVbhSOTCdV0qZXXDtZOdLaxwwOcrgEzykKQ2Qydjtp2 lDSA9EHIdoop10KOuzmu3n/obsSgooPCyNbbKDbEjQGEQclcw7q71DvDdGWmcLucxG3L 8W1/EE+5XO/NKw+6Mp7SKrLjwhWNqH+HCXFyG/0lomKKN57rKSo+MrJXiBbqt3SR98d5 wsaSo/vOj+kvn0iku4Xt75r8PpbkDjlj9qY6q4Os7JAyfI1WAtXVMNeyxQ2rHN87PQs2 P/sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:ironport-sdr:ironport-sdr; bh=BVwfDYyaA1hHizTgR791h9/EQJCyQv6Qzw9C/+XnHzE=; b=bbQ5U6fOcu5LL/nf9C7ofMrKBAhG9+6IyUxvcIqn/BeNEhT5duWz/SQFw5WcCxl1Ud iRyj6K4pSub2uXjxCRs9juEV6NmYhowZZaJx6Hx1XHbdjdonTAI51/1/3vff/UCmluJt 0+i3RP0bFze8zobylRz81nYORXHwKXN3yw/VHveWTmOUwy1wZidCiXBaXn+PntjqTXGk M0DywT0jBpmTDHOH0psf/UrnZv8Y6ZJgDLrlPrCX6SHLEWt6HLlXljSTEWf4m4zdU/As +lE4yiiIlWeU2hxwiSNu4dO7anrqlGGle43gbk+iYCdXzCzMf75LyC009G0bPXkDd6hq Hg0Q== 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 4si21241668pgt.230.2021.04.14.02.28.07; Wed, 14 Apr 2021 02:28:20 -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 S233002AbhDNAHc (ORCPT + 99 others); Tue, 13 Apr 2021 20:07:32 -0400 Received: from mga06.intel.com ([134.134.136.31]:42281 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbhDNAHb (ORCPT ); Tue, 13 Apr 2021 20:07:31 -0400 IronPort-SDR: AfFx6q/Te3qg7RmDF9I3bEAJ8zViktndb4XZlcLMzg32YC8tfYlY/UXdAjM59dMVbPAunhTDnR 3tMRh30fTqbQ== X-IronPort-AV: E=McAfee;i="6200,9189,9953"; a="255844718" X-IronPort-AV: E=Sophos;i="5.82,220,1613462400"; d="scan'208";a="255844718" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 17:07:10 -0700 IronPort-SDR: FW1+JDWFnnCJ0F8zcxYqh84SmkButXavMRcYvhG1wXMabDT20sJ6bofo8dJAA+BWwsfPAENdxM KRJBoeT0uySg== X-IronPort-AV: E=Sophos;i="5.82,220,1613462400"; d="scan'208";a="424475892" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 17:07:09 -0700 Date: Tue, 13 Apr 2021 17:09:47 -0700 From: Jacob Pan To: Jean-Philippe Brucker Cc: LKML , iommu@lists.linux-foundation.org, Joerg Roedel , Lu Baolu , Jean-Philippe Brucker , Yi Liu , Raj Ashok , "Tian, Kevin" , Jason Gunthorpe , Dave Jiang , wangzhou1@hisilicon.com, zhangfei.gao@linaro.org, vkoul@kernel.org, jacob.jun.pan@linux.intel.com Subject: Re: [PATCH 2/2] iommu/sva: Remove mm parameter from SVA bind API Message-ID: <20210413170947.35ba9267@jacob-builder> In-Reply-To: <20210409110305.6b0471d9@jacob-builder> References: <1617901736-24788-1-git-send-email-jacob.jun.pan@linux.intel.com> <1617901736-24788-2-git-send-email-jacob.jun.pan@linux.intel.com> <20210409110305.6b0471d9@jacob-builder> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jean, On Fri, 9 Apr 2021 11:03:05 -0700, Jacob Pan wrote: > > problems: > > > > * We don't have a use-case for binding the mm of a remote process (and > > it's supposedly difficult for device drivers to do it securely). So > > OK, we remove the mm argument from iommu_sva_bind_device() and use the > > current mm. But the IOMMU driver isn't going to do > > get_task_mm(current) every time it needs the mm being bound, it will > > take it from iommu_sva_bind_device(). Likewise iommu_sva_alloc_pasid() > > shouldn't need to bother with get_task_mm(). > > > > * cgroup accounting for IOASIDs needs to be on the current task. > > Removing the mm parameter from iommu_sva_alloc_pasid() doesn't help > > with that. Sure it indicates that iommu_sva_alloc_pasid() needs a > > specific task context but that's only for cgroup purpose, and I'd > > rather pass the cgroup down from iommu_sva_bind_device() anyway (but am > > fine with keeping it within ioasid_alloc() for now). Plus it's an > > internal helper, easy for us to check that the callers are doing the > > right thing. > With the above split, we really just have one allocation function: > ioasid_alloc(), so it can manage current cgroup accounting within. Would > this work? After a few attempts, I don't think the split can work better. I will restore the mm parameter and add a warning if mm != current->mm. Thanks, Jacob