Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3229231ybc; Mon, 18 Nov 2019 11:39:49 -0800 (PST) X-Google-Smtp-Source: APXvYqy3dpVJ56xLxmXVA6hXPm6rMS+VaALUFrSV9v4lFq193BAj798hi82pwkv7q24S6VpJh5Er X-Received: by 2002:a7b:c549:: with SMTP id j9mr1070449wmk.88.1574105989068; Mon, 18 Nov 2019 11:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574105989; cv=none; d=google.com; s=arc-20160816; b=kp3YWXXYAtL8nPdtTQpFm+GTBIjNgKx3dJGVc/QwOHHwnV/d5wXKwUoRpMoTRK8SyB cc6T2WMiS8xn/r31RBm4jHOMTIRRReAYjNLy6MNJQmwe3dCD52g2RkJFzAnm+Hlas1OR Yc31MOmhBZpD9HF5f3pqRlpX3wFF20MzUkM9eM0NsGxJ3F0MVWwJeFNGr+rPwfoF+lUn fYBrOuzW8ZR3XLqv0OQl9oTEPSiuvwBCD+G0yCrH4+pQ9xW6LjWv3wfASVLmHzw9uVPO OX6SFbK7Mlzf+th/1b166QrGlkS2HC7+PleudwlmY1W/tHqmKOwennrXRkeRXQ7PdoF/ 1gpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=psOFE0++ogBWiywrMUSim9+OFt9FjWUirsvTwco85J4=; b=vg0U3UGVQARxWeT0Rsz3ces68N5hv4+67LdbabzQe7VLBuuBVhSdeOjtgu9RnI0BKJ 5zYUcMwczgoULfIydkRDNVaGBo5mSFr+moRwuYbibNMs7wmvLk8pXe7oTfd/B4J45Q2a /+Lk9UxOMNmcWqGVDvyWsI8hS0NdyP2XfSZUwDAL0C43KkqJXY3QdSEql0N/NCTAUnOM cM5Kg2AO8WQjw4+7Lt9LBFifzbEsjcKryQzuMtMMhvnHviBoZg4pblSvHNWHJDKIvIJY AjOugru3V8a1OEVl2r+DTEAecDOLnR2P5u7I/aKIc0/r2rCFTSPSiIf/ri37jXqA0dgy a0hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d10si16592029edn.266.2019.11.18.11.39.24; Mon, 18 Nov 2019 11:39:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726895AbfKRTiC (ORCPT + 99 others); Mon, 18 Nov 2019 14:38:02 -0500 Received: from mga02.intel.com ([134.134.136.20]:60276 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbfKRTiA (ORCPT ); Mon, 18 Nov 2019 14:38:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2019 11:37:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,321,1569308400"; d="scan'208";a="380760852" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga005.jf.intel.com with ESMTP; 18 Nov 2019 11:37:59 -0800 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , "Lu Baolu" , David Woodhouse Cc: "Tian, Kevin" , Raj Ashok , "Yi Liu" , Eric Auger , Jacob Pan Subject: [PATCH v2 03/10] iommu/vt-d: Reject SVM bind for failed capability check Date: Mon, 18 Nov 2019 11:42:26 -0800 Message-Id: <1574106153-45867-4-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574106153-45867-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1574106153-45867-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a check during SVM bind to ensure CPU and IOMMU hardware capabilities are met. Signed-off-by: Jacob Pan Acked-by: Lu Baolu --- drivers/iommu/intel-svm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 716c543488f6..74df10a39dfc 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -238,6 +238,9 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ if (!iommu || dmar_disabled) return -EINVAL; + if (!intel_svm_capable(iommu)) + return -ENOTSUPP; + if (dev_is_pci(dev)) { pasid_max = pci_max_pasids(to_pci_dev(dev)); if (pasid_max < 0) -- 2.7.4