Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp327463rwe; Fri, 26 Aug 2022 05:57:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Vnor3Q5tS0bphTP+ySzHWGYeBaJZaYVmCg8pYPixx7G8vD0UjorGYfVH/qvrp0mksJ3YH X-Received: by 2002:a17:907:c0e:b0:731:614:e507 with SMTP id ga14-20020a1709070c0e00b007310614e507mr5515704ejc.529.1661518626458; Fri, 26 Aug 2022 05:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661518626; cv=none; d=google.com; s=arc-20160816; b=YXVu+zMvR29WdxGJzdPqCGWbAhbKBhUp79l3NGWoUCIV2C6N72Uv2+tDraywfMc7N7 UW5n6oMybi7wcIGfIFuJfrF4gk5PNOSvxaxtFUapYG6JRHHfiHaKMzwEhBV+vkjz5K4b c5O4xJtCvBSG/DjcXgZYPfg/GlsFsMf7vDx8m9l5/cuGJuKRzUqzKh5prdNpjZeK4aXi kTrHay4H4ZnBJqwwezak/D14naVfeljmGgYBeL6q+uYXq5LZp0KRAIzKwZNNH3i7IAM7 WqbC2XtQjAJ4TZwg6Dtd0qgag75tqDhRGP/Ls/Jzd3iBu4v5gy6xAiEA7p5Sx9/RpuN6 inow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N+EzK7Pif/SwmuuW/kkNhGX0xD824hWexpAOn/mlOF4=; b=HOaG86Pu0c0ytqbdSeQWD93Ei/Srq9h8wPc9YqJYLS7hja9le/3qr2JUg0z9EDB3qR +C+FleBb/XWkyD0mSN1X/1eikr4BqJYuP5CfDkoz5vLuxphpKr9aUPCI9Vq9bl6crjNH 1baycpgKMGgZIyrBz5F0idu3F4eKqS/BtDE5+/qJqk+sTSpOMBC9YLgv63EYdutiJVEB B61m3XfjpY25pZaYkaMeYQMkOdjIL+c+e3GJzRRo58lXff7T9IxcW1r9Dg2z3Ii9DfnU 5eexTFqRIh/06e8X5GmPNRCN/2RO6m4GXIXOG1GwEq7F0fTiwGkT2uuv+Q68KoAFdvrh F8jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YvReF5dZ; 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 xf11-20020a17090731cb00b0073d7ba692b3si43576ejb.375.2022.08.26.05.56.38; Fri, 26 Aug 2022 05:57:06 -0700 (PDT) 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=YvReF5dZ; 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 S230258AbiHZMSg (ORCPT + 99 others); Fri, 26 Aug 2022 08:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343967AbiHZMSF (ORCPT ); Fri, 26 Aug 2022 08:18:05 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEBCFDDB67; Fri, 26 Aug 2022 05:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661516283; x=1693052283; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ObzvQqeBoSBlsmWjwsS3zHDgHc5l4grO57A2Q8YN6wE=; b=YvReF5dZ3sojMNIi0FEJt7g5UQeIYSE7Rv0zhpQ6ZBAgKb/FUYE4YrE1 nU8/ItolLf1gKnBZeR38ojYz2M11gGnGvNTVLHl4vIBVpDg+9X63a4cjU kNwI8kpAUqF4GHhZJuZWWJFI4lPBiMtoF/af4hdMLSUWzIEodD808r6e1 2ub2eC/AD54qDt0R2xqtDwVBW6oIu2CEGo4QrZwLuFGlG1SXG5TevSEGm 6SOVnLzg01uZAf6mRrXAwziJS/2S8ghskyn0gK+xYE8x/o02Y04Nun7Hq ljGENgjOqR2CENOQ8Ss2ztkWD8ZXhhbPjdA2Dzz8G8s3CuaBVI0NeEEjp A==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="292072157" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="292072157" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 05:18:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="606747707" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga007.jf.intel.com with ESMTP; 26 Aug 2022 05:17:59 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Bjorn Helgaas , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Fenghua Yu , Vinod Koul Cc: Eric Auger , Liu Yi L , Jacob jun Pan , Zhangfei Gao , Zhu Tony , iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v12 09/17] iommu/vt-d: Add blocking domain support Date: Fri, 26 Aug 2022 20:11:33 +0800 Message-Id: <20220826121141.50743-10-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220826121141.50743-1-baolu.lu@linux.intel.com> References: <20220826121141.50743-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 The Intel IOMMU hardwares support blocking DMA transactions by clearing the translation table entries. This implements a real blocking domain to avoid using an empty UNMANAGED domain. The detach_dev callback of the domain ops is not used in any path. Remove it to avoid dead code as well. Signed-off-by: Lu Baolu Tested-by: Tony Zhu --- drivers/iommu/intel/iommu.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 64d30895a4c8..ffd1ff69bf25 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4127,12 +4127,30 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width) return 0; } +/* + * Intel IOMMU blocking domain support: + */ +static int blocking_domain_attach_dev(struct iommu_domain *domain, + struct device *dev) +{ + dmar_remove_one_dev_info(dev); + return 0; +} + +static struct iommu_domain blocking_domain = { + .ops = &(const struct iommu_domain_ops) { + .attach_dev = blocking_domain_attach_dev + } +}; + static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) { struct dmar_domain *dmar_domain; struct iommu_domain *domain; switch (type) { + case IOMMU_DOMAIN_BLOCKED: + return &blocking_domain; case IOMMU_DOMAIN_DMA: case IOMMU_DOMAIN_DMA_FQ: case IOMMU_DOMAIN_UNMANAGED: @@ -4239,12 +4257,6 @@ static int intel_iommu_attach_device(struct iommu_domain *domain, return domain_add_dev_info(to_dmar_domain(domain), dev); } -static void intel_iommu_detach_device(struct iommu_domain *domain, - struct device *dev) -{ - dmar_remove_one_dev_info(dev); -} - static int intel_iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t hpa, size_t size, int iommu_prot, gfp_t gfp) @@ -4767,7 +4779,6 @@ const struct iommu_ops intel_iommu_ops = { #endif .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = intel_iommu_attach_device, - .detach_dev = intel_iommu_detach_device, .map_pages = intel_iommu_map_pages, .unmap_pages = intel_iommu_unmap_pages, .iotlb_sync_map = intel_iommu_iotlb_sync_map, -- 2.25.1