Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3232201ybc; Mon, 18 Nov 2019 11:43:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwyAPCBUlJsPGXVZW7MuqSdomD7SY34on1ThbJgD024BzFQVC3SrckhuwFPay+rdb3TlbpO X-Received: by 2002:a17:906:6043:: with SMTP id p3mr29001732ejj.103.1574106182539; Mon, 18 Nov 2019 11:43:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574106182; cv=none; d=google.com; s=arc-20160816; b=ZJNqZqs1l3VpjaLbUFBVGm9Pii5tvm/ET7E/9x65Tu6HtJD/NwgDbG6VmJMUEEYzXy 12pOc8EHHNqDPwFCDqP4lWgHgJZMMzNEfmQzy7/x/yfGy0F10Lcxy8y3qjJjgEa7l03P KWEkcsXTeghSkIgXx1JA22gy9+J4CLQUZVe4QFrdhtbQdXl6rf0GEnuPDv6aoRGDsR5M uso4rIGeLkLpsxWAlNMLNlVDQrsqHjNM3lrPuHXtoyO0tviG/SPWCn416twQBtrpcmjI 0qK8HkMlvKvk75oUpRg9trJbtN/1BP6ZSFfc62296q2Ig2ugCuGB3L0cm7TzBQIoXED2 tfFw== 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=ufYEZX034DCo3pDbg+WWmKuppmMFxCucPX0EdLfuuBI=; b=e07M9LaTuf4z0W5LaOnNuKsM3D8oocBjdNiFmUQXF0u6wQx3PI6NJS7UrUSfJoaT3m rEsd2/MbqrSuwR4yghDirzRlTtF01g12zA23o9qbgn93OfBmXT7KLeAHK0BH05JdnWIS TBBM6QmuIOA5jaY922d1nKrM52axAcO7fmNn7MEJ1aLQCs8P31+2px+GAvv1j6rZ4Hnx kdL5nsqam/HBFCDJHJUvDIYvxlaXFcErd3tMCf6z2+BtWO9e1F/S6ktNCJplHUsTJeQB OYmfgzUTJYfX38OfYL9aWJUQK3qilsuwoIGyJ9Ub6pCmjcszAggO84LYNb/JtOFL3VyV 896g== 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 w7si2839862ejv.235.2019.11.18.11.42.38; Mon, 18 Nov 2019 11:43:02 -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 S1726647AbfKRTi3 (ORCPT + 99 others); Mon, 18 Nov 2019 14:38:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:60271 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbfKRTiA (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="380760856" 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 04/10] iommu/vt-d: Match CPU and IOMMU paging mode Date: Mon, 18 Nov 2019 11:42:27 -0800 Message-Id: <1574106153-45867-5-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 When setting up first level page tables for sharing with CPU, we need to ensure IOMMU can support no less than the levels supported by the CPU. It is not adequate, as in the current code, to set up 5-level paging in PASID entry First Level Paging Mode(FLPM) solely based on CPU. Fixes: 437f35e1cd4c8 ("iommu/vt-d: Add first level page table interface") Signed-off-by: Jacob Pan Acked-by: Lu Baolu --- drivers/iommu/intel-pasid.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel-pasid.c b/drivers/iommu/intel-pasid.c index 040a445be300..e7cb0b8a7332 100644 --- a/drivers/iommu/intel-pasid.c +++ b/drivers/iommu/intel-pasid.c @@ -499,8 +499,16 @@ int intel_pasid_setup_first_level(struct intel_iommu *iommu, } #ifdef CONFIG_X86 - if (cpu_feature_enabled(X86_FEATURE_LA57)) - pasid_set_flpm(pte, 1); + /* Both CPU and IOMMU paging mode need to match */ + if (cpu_feature_enabled(X86_FEATURE_LA57)) { + if (cap_5lp_support(iommu->cap)) { + pasid_set_flpm(pte, 1); + } else { + pr_err("VT-d has no 5-level paging support for CPU\n"); + pasid_clear_entry(pte); + return -EINVAL; + } + } #endif /* CONFIG_X86 */ pasid_set_domain_id(pte, did); -- 2.7.4