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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67276C07E95 for ; Tue, 20 Jul 2021 09:27:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FB9661209 for ; Tue, 20 Jul 2021 09:27:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234923AbhGTIqq (ORCPT ); Tue, 20 Jul 2021 04:46:46 -0400 Received: from foss.arm.com ([217.140.110.172]:54430 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbhGTIqp (ORCPT ); Tue, 20 Jul 2021 04:46:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4BD656D; Tue, 20 Jul 2021 02:27:23 -0700 (PDT) Received: from [10.57.36.146] (unknown [10.57.36.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C684C3F73D; Tue, 20 Jul 2021 02:27:21 -0700 (PDT) Subject: Re: [PATCH 4/5] iommu/vt-d: Disallow SVA if devices don't support 64-bit address To: Lu Baolu , Joerg Roedel , Sanjay Kumar , Kevin Tian , Ashok Raj , Jacob Pan , Dave Jiang , Liu Yi L Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20210720013856.4143880-1-baolu.lu@linux.intel.com> <20210720013856.4143880-5-baolu.lu@linux.intel.com> From: Robin Murphy Message-ID: <22302277-0470-db41-7a19-41b5f73bd2c5@arm.com> Date: Tue, 20 Jul 2021 10:27:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210720013856.4143880-5-baolu.lu@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-07-20 02:38, Lu Baolu wrote: > When the device and CPU share an address space (such as SVA), the device > must support the same addressing capability as the CPU. The CPU does not > consider the addressing ability of any device when managing the page table > of a process, so the device must have enough addressing ability to bind > the page table of the process. > > Signed-off-by: Lu Baolu > --- > drivers/iommu/intel/iommu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index f45c80ce2381..f3cca1dd384d 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -5372,6 +5372,9 @@ static int intel_iommu_enable_sva(struct device *dev) > if (!(iommu->flags & VTD_FLAG_SVM_CAPABLE)) > return -ENODEV; > > + if (!dev->dma_mask || *dev->dma_mask != DMA_BIT_MASK(64)) Careful - VFIO doesn't set DMA masks (since it doesn't use the DMA API), so this appears to be relying on another driver having bound previously, otherwise the mask would still be the default 32-bit one from pci_setup_device(). I'm not sure that's an entirely robust assumption. Robin. > + return -ENODEV; > + > if (intel_iommu_enable_pasid(iommu, dev)) > return -ENODEV; > > 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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A6CFC07E95 for ; Tue, 20 Jul 2021 09:27:29 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 11EE461209 for ; Tue, 20 Jul 2021 09:27:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11EE461209 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BB287404C3; Tue, 20 Jul 2021 09:27:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uitdiFX2Yvxd; Tue, 20 Jul 2021 09:27:27 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 57474404A4; Tue, 20 Jul 2021 09:27:27 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 12A83C0010; Tue, 20 Jul 2021 09:27:27 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 83905C000E for ; Tue, 20 Jul 2021 09:27:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 602CF4049D for ; Tue, 20 Jul 2021 09:27:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8yNi12EPhDQP for ; Tue, 20 Jul 2021 09:27:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp4.osuosl.org (Postfix) with ESMTP id 4BDDC404A4 for ; Tue, 20 Jul 2021 09:27:24 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4BD656D; Tue, 20 Jul 2021 02:27:23 -0700 (PDT) Received: from [10.57.36.146] (unknown [10.57.36.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C684C3F73D; Tue, 20 Jul 2021 02:27:21 -0700 (PDT) Subject: Re: [PATCH 4/5] iommu/vt-d: Disallow SVA if devices don't support 64-bit address To: Lu Baolu , Joerg Roedel , Sanjay Kumar , Kevin Tian , Ashok Raj , Jacob Pan , Dave Jiang , Liu Yi L References: <20210720013856.4143880-1-baolu.lu@linux.intel.com> <20210720013856.4143880-5-baolu.lu@linux.intel.com> From: Robin Murphy Message-ID: <22302277-0470-db41-7a19-41b5f73bd2c5@arm.com> Date: Tue, 20 Jul 2021 10:27:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210720013856.4143880-5-baolu.lu@linux.intel.com> Content-Language: en-GB Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 2021-07-20 02:38, Lu Baolu wrote: > When the device and CPU share an address space (such as SVA), the device > must support the same addressing capability as the CPU. The CPU does not > consider the addressing ability of any device when managing the page table > of a process, so the device must have enough addressing ability to bind > the page table of the process. > > Signed-off-by: Lu Baolu > --- > drivers/iommu/intel/iommu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index f45c80ce2381..f3cca1dd384d 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -5372,6 +5372,9 @@ static int intel_iommu_enable_sva(struct device *dev) > if (!(iommu->flags & VTD_FLAG_SVM_CAPABLE)) > return -ENODEV; > > + if (!dev->dma_mask || *dev->dma_mask != DMA_BIT_MASK(64)) Careful - VFIO doesn't set DMA masks (since it doesn't use the DMA API), so this appears to be relying on another driver having bound previously, otherwise the mask would still be the default 32-bit one from pci_setup_device(). I'm not sure that's an entirely robust assumption. Robin. > + return -ENODEV; > + > if (intel_iommu_enable_pasid(iommu, dev)) > return -ENODEV; > > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu