Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14837424rwb; Mon, 28 Nov 2022 05:33:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf51mL7U2v0GRgolorRjuIKsxr7BBweZY7VuautRnUhK04OtCu3XHLC6YuG/Ade/bUW9PzYQ X-Received: by 2002:a63:d601:0:b0:442:eb8e:910 with SMTP id q1-20020a63d601000000b00442eb8e0910mr28295504pgg.97.1669642414068; Mon, 28 Nov 2022 05:33:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669642414; cv=none; d=google.com; s=arc-20160816; b=M6ozwnxCnmCn7Cc8aytFQYGWvHGjkvXtkUjYkLGYDSK9Y2bdE3AnwGVgqxebrBgeDI AJU7HVZxQZZVZxUrlIzltFzxfgP0k4iuSUvnJg4VyNzgNihVmwuIb7j6K5luFHl4qCIx WQeX5g2kt9Lcc5VLCIM0DoSs592poQcMea46YTx6njKRUdTNlROrZGp65t9zFTstFP+w W5KmUrwG8/16JXhTUK3GbbfqjM4tsG/6hBURNbQUBU3vI+KO870TzzvmGlxypcKvGPek CnpmrMn9Lv3BT1V9oVw/pZQ2EiTB7xa7N/+KMaUSpA0EROxkV4Bx93MC5FbNV5evzpo0 LVFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:content-language:references:to:cc:user-agent:mime-version:date :message-id:dkim-signature; bh=h4m7CrrB64NJkGTolJa0DE08eZqV+pDfPz8VYK0PN7c=; b=1HZZdoitytSrpIOkvTb4mlC+Omabl7e0SKvp91gu2av1KAo5U/d+64CU5xM2gDkeOL 1wGfRnekHu0/o+IeGLtppTCbdnA1AGqENu2MYSR/84X8syfya1603y0rDqfawZCRRqnx 4tF2m/lWHWMw4zYbgchvthrdkX/JSgbNl+F7kRpDzrtgA40EKXQQzDwVXNg/iK6+nI2M 4twy3ijaoXQnuu8pqdAxxT7Q2u4FYPmbdjK55gH7vwoGKF9XBSvWRZwLGDTnpeJFePQo PMNz97BAf9+qR1XAqHufwDUtOtAvOyyOULZ8T6c3/4vad3WVK0PPr8wokvJxWGioMIM7 5f0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LFZxKupJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a056a0021c800b00574b46d3b26si10624342pfj.334.2022.11.28.05.33.21; Mon, 28 Nov 2022 05:33:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LFZxKupJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231445AbiK1NAn (ORCPT + 85 others); Mon, 28 Nov 2022 08:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiK1NAl (ORCPT ); Mon, 28 Nov 2022 08:00:41 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00E211156; Mon, 28 Nov 2022 05:00:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669640440; x=1701176440; h=message-id:date:mime-version:cc:to:references:from: subject:in-reply-to:content-transfer-encoding; bh=CuUxM0z/3KSQu9y5awXbBEiVKQT5wLrzlc0qrTwSUdc=; b=LFZxKupJ8DM44fqYIEVgGtuu+gFpT1hTj3ROdToKYDgoq4zc+uF1Uv4Z 3WSoBrrCTIdcmSS46Y+EdVqqm7447XTId+NNkwaRhh/siit0WmTeQF4m6 5YRT97WiYnqitA19IgzP0HXDDYohNwXv69Eg57LGG4LqSbSZakZKVS47L I/2465eT/pqoPJyCIJyXIACZgBUk5DtmOB6Q2EwkdZ4b1R/lSKQxaz8SC zCHD9W9IBf8gydhRjT2Y2tWIfe2cSiJkb2IId67Ax8fmrI8M3NvdNsQ51 RC2tlgrGCbIQEmqnAJaFkJA/u7ZzJccNOoniwSEmefIKTAyiCWm1WAViS A==; X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="316652634" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="316652634" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 05:00:39 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="785620261" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="785620261" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.213.244]) ([10.254.213.244]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 05:00:35 -0800 Message-ID: <2fde49a1-a1df-d78a-dd38-2322a760513b@linux.intel.com> Date: Mon, 28 Nov 2022 21:00:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Cc: baolu.lu@linux.intel.com, Pierre Morel , linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, linux-kernel@vger.kernel.org, Julian Ruess To: Niklas Schnelle , Matthew Rosato , Gerd Bayer , iommu@lists.linux.dev, Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Wenjia Zhang References: <20221116171656.4128212-1-schnelle@linux.ibm.com> <20221116171656.4128212-5-schnelle@linux.ibm.com> <33eea9bd-e101-4836-19e8-d4b191b78b00@linux.intel.com> <9163440eb6a47fe02730638bbdf72fda5ee5ad2c.camel@linux.ibm.com> Content-Language: en-US From: Baolu Lu Subject: Re: [PATCH v2 4/7] iommu: Let iommu.strict override ops->def_domain_type In-Reply-To: <9163440eb6a47fe02730638bbdf72fda5ee5ad2c.camel@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/11/28 19:10, Niklas Schnelle wrote: > On Thu, 2022-11-17 at 09:55 +0800, Baolu Lu wrote: >> On 2022/11/17 1:16, Niklas Schnelle wrote: >>> When iommu.strict=1 is set or iommu_set_dma_strict() was called we >>> should use IOMMU_DOMAIN_DMA irrespective of ops->def_domain_type. >>> >>> Signed-off-by: Niklas Schnelle >>> --- >>> drivers/iommu/iommu.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c >>> index 65a3b3d886dc..d9bf94d198df 100644 >>> --- a/drivers/iommu/iommu.c >>> +++ b/drivers/iommu/iommu.c >>> @@ -1562,6 +1562,9 @@ static int iommu_get_def_domain_type(struct device *dev) >>> { >>> const struct iommu_ops *ops = dev_iommu_ops(dev); >>> >>> + if (iommu_dma_strict) >>> + return IOMMU_DOMAIN_DMA; >> If any quirky device must work in IOMMU identity mapping mode, this >> might introduce functional regression. At least for VT-d platforms, some >> devices do require IOMMU identity mapping mode for functionality. > That's a good point. How about instead of unconditionally returning > IOMMU_DOMAIN_DMA we just do so if the domain type returned by ops- >> def_domain_type uses a flush queue (i.e. the __IOMMU_DOMAIN_DMA_FQ bit > is set). That way a device that only supports identity mapping gets to > set that but iommu_dma_strict at least always prevents use of an IOVA > flush queue. def_domain_type returns IOMMU_DOMAIN_DMA, IOMMU_DOMAIN_IDENTIRY or 0 (don't care). From a code perspective, you can force IOMMU_DOMAIN_DMA if def_domain_type() returns 0. *But* you need to document the relationship between strict mode and default domain type somewhere and get that agreed with Robin. Best regards, baolu