Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp177797pxb; Wed, 14 Apr 2021 12:21:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkjNcq79zaXjERPIBMxnKi+xc51iz5u72/LZabonCKWS32rv5yCVBQD0hGlB2wEOzuKz60 X-Received: by 2002:a05:6402:5146:: with SMTP id n6mr458728edd.299.1618428068817; Wed, 14 Apr 2021 12:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618428068; cv=none; d=google.com; s=arc-20160816; b=BJ2YY0/Z43JBhyQs4zn8e57G9BaHt22MkyDCoWBLQzxzI/j1v6M0BgH5GT9Pmt74OJ QVoC0fZYl6Oen7/5zGpTJi3X6DMounJjkMz7VZnab4yDi8AEqzcpUynjKGTpLIGVaYck vjdwMbivL6rWT6u8LupoN7d2Ww21j6FZKgAALovNNZZXuw2YEGtoxPHrJB2u6STrMgY+ 9vWjeMX5As58dQrya6m29gbq2t6jqM5rJS5d4z9rLZfHOPUr/YwWZZZBq3C23B+4Zl6i EwqLqL7DztYqe0FcBcFE0LsiZrWQgvKhRZCBjee2MZ57T7icwtsG6TR51iq804b23s0I NHlw== 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=iaNy5jgiij2Nkl4ZSj4tNX3ctbba+2m57GezTCyzPsQ=; b=YRIUKnTcF4cqpakqZ5er4YlteM+aKZTG94SQycPNMyYVEEKwXqa0VtMGFoKpqvFlTC jafFUJsCaAU+9HJ8wBW5qEdJhcbIe7Fq3o2Tb8QWzvcrvrvU76z4hWKh2lFPI233Kkwk AJViCepTfQYCtYx7Uc2Hd692MoC3ipLqRjmpsZgCfZSoBUDBKNHsnDDbiEGI3RWMNV6k S8GYSaSm4UNyClMW6vUqgwPrV+mCYEpXqVxM9WcK3nkgDIUPa4XVtbjWpaVd4xjTfQeP vc8Fmlhl53ERIjzvcLGbJ1XvNLGsxFLhWQ4a03JpKJcTPt5aKsRTw0eRwSxShv7WSBuy W/HQ== 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 p4si371588edq.332.2021.04.14.12.20.46; Wed, 14 Apr 2021 12:21:08 -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 S245412AbhDNGcf (ORCPT + 99 others); Wed, 14 Apr 2021 02:32:35 -0400 Received: from mga03.intel.com ([134.134.136.65]:25036 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231831AbhDNGc0 (ORCPT ); Wed, 14 Apr 2021 02:32:26 -0400 IronPort-SDR: XhwycpHN6oHcXIMOs2W5zE7xuKkVZyVdu2kwZ3FMGG+QdG3vNijWAP8+gQa/T80Afb30sKKzh5 KoPxaFjncsIg== X-IronPort-AV: E=McAfee;i="6200,9189,9953"; a="194603677" X-IronPort-AV: E=Sophos;i="5.82,221,1613462400"; d="scan'208";a="194603677" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 23:31:49 -0700 IronPort-SDR: jtTk4WrJ1bqaHDp2OMiOJLdZVz7CpNjV6TV1Sg570t5Pli+ReRHeJNydL3jvtdloMOYZwH7tn6 r2LcAEzJYvOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,221,1613462400"; d="scan'208";a="443703998" Received: from allen-box.sh.intel.com (HELO [10.239.159.128]) ([10.239.159.128]) by fmsmga004.fm.intel.com with ESMTP; 13 Apr 2021 23:31:45 -0700 Cc: baolu.lu@linux.intel.com, LKML , iommu@lists.linux-foundation.org, Joerg Roedel , Jean-Philippe Brucker , Yi Liu , Raj Ashok , "Tian, Kevin" , Jason Gunthorpe , Dave Jiang , wangzhou1@hisilicon.com, zhangfei.gao@linaro.org, vkoul@kernel.org Subject: Re: [PATCH 2/2] iommu/sva: Remove mm parameter from SVA bind API To: Jacob Pan , Jean-Philippe Brucker 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> <20210413170947.35ba9267@jacob-builder> From: Lu Baolu Message-ID: <41433d99-e413-f5bf-5279-695dae6c58ba@linux.intel.com> Date: Wed, 14 Apr 2021 14:22:09 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210413170947.35ba9267@jacob-builder> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, On 4/14/21 8:09 AM, Jacob Pan wrote: > 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. I still worry about supervisor pasid allocation. If we use iommu_sva_alloc_pasid() to allocate a supervisor pasid, which mm should the pasid be set? I've ever thought about passing &init_mm to iommu_sva_alloc_pasid(). But if you add "mm != current->mm", this seems not to work. Or do you prefer a separated interface for supervisor pasid allocation/free? Best regards, baolu > > Thanks, > > Jacob >