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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5302C433EF for ; Sun, 1 May 2022 11:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345855AbiEALbT (ORCPT ); Sun, 1 May 2022 07:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345774AbiEALbN (ORCPT ); Sun, 1 May 2022 07:31:13 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0849E6D1A2 for ; Sun, 1 May 2022 04:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651404468; x=1682940468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6JDcNykVMFEeo9gQEenBDZWl7d/DyNiEOKcrygbNnmA=; b=bWya1ZafWr6/hrbNWndBJedp6cjEH60MRaMy/MzXR+fUHr5EAbIem6yw HL72/6wn4CC9t2E346J0n9QB0KkYf3QY8UVLRbj2jacO+4VW4z5nhi8B1 yUSeprFsvSIew0mDEtZ8I7dTTmPcf9a7enw6+KJzgNuhVzSJDaoerT/f9 fW8IK8479OGBycwqv2rrzGcsoLuzxh7EJ8glHnFYHKqhAs15AtcnNW/o2 bLpYzMWlmJMKANdDHaw6sz0B3XFGZDdpcFnfT9VBVK5KmqZBw27fydTUL V1ov0eNL6uZRCSo7L7p5do1KYwSnl9NF8Ge405Jr/dxastW3LpYY/CW2I Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10333"; a="246912712" X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="246912712" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2022 04:27:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="545114784" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 01 May 2022 04:27:46 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Alex Williamson , Kevin Tian Cc: Jacob jun Pan , Liu Yi L , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 1/5] iommu/vt-d: Block force-snoop domain attaching if no SC support Date: Sun, 1 May 2022 19:24:30 +0800 Message-Id: <20220501112434.874236-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220501112434.874236-1-baolu.lu@linux.intel.com> References: <20220501112434.874236-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the attach_dev callback of the default domain ops, if the domain has been set force_snooping, but the iommu hardware of the device does not support SC(Snoop Control) capability, the callback should block it and return a corresponding error code. 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 cf43e8f9091b..d68f5bbf3e93 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4354,6 +4354,9 @@ static int prepare_domain_attach_device(struct iommu_domain *domain, if (!iommu) return -ENODEV; + if (dmar_domain->force_snooping && !ecap_sc_support(iommu->ecap)) + return -EOPNOTSUPP; + /* check if this iommu agaw is sufficient for max mapped address */ addr_width = agaw_to_width(iommu->agaw); if (addr_width > cap_mgaw(iommu->cap)) -- 2.25.1