Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp17607ybc; Mon, 18 Nov 2019 19:14:03 -0800 (PST) X-Google-Smtp-Source: APXvYqx4NQco4M7uPbGTOZsd5GFCKqvq1EzhkoJ2kobJ24y6H5fCQk5z8XIMwMoXIWCjRvySvYPP X-Received: by 2002:a17:906:1611:: with SMTP id m17mr32041376ejd.281.1574133243876; Mon, 18 Nov 2019 19:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574133243; cv=none; d=google.com; s=arc-20160816; b=MNkbAADSUlBFUKzr3xGGJb6fI75Eu7CX4vXy/bnAKnP/pTF7hOK3xALKGyAjjL/c7K k0PW1AjI34aG7QAWRLm2qwgmbQPZWRUjNs/XWjL1/s3Rst2qjPYndVfBdBk5KFLifIYg S9AI8GyKpR5o+tRxJrYPeTgw5kXUcO1e5axp9cM2sM6uAuSlHbH2QM+iofhIieZMjT3f IGMY4TI7gX3Lw2E9ECOpsfFTMZUnGtrKqdPnlXwF6PdZVCP8vRLuLrmDXpfAWAJ+GXTW 6f+gLMZ+o00rfaQVRlP4nxZGaKVHofHf9NGiX73KxkQaJKapra+lcpXbxJvWga/BXErE ekEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc; bh=YG0+NMtMX4mjwMdfFsSKUIpoR59FufY/Lke//ezyt9w=; b=fVYrH/wHSu039MWJ3GD7sQrsZcwdXKlGZtuskPT2KLiXmRX3pscfWrsTAYLCE8DKtH 4/Ciug0tqhgrcNvMNTuddBI3y+Fvugd36mxhtrfIUMbcPHRjml5JM2Hb99fZr/d7AZOS 0bLitdllyojmE+FMt/yw5XjiRRLhGHRtB5JavFaRMXvCHD6p4rtE33Nm/n5neNB9TNnQ 8odgqLzEmjzKs+F4hFpbsHs5qkFBGsE7wd4XD7bf1wjoJwV0lQ1Sg8OdrM7MHOnM73od dlYwMPib5z2q+uaUWW7SxrlWi24kpLozeIBUQmYQaIDyes6OqlU/49wikJcauZsUpCuG NZfA== 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 d6si14855752ede.119.2019.11.18.19.13.39; Mon, 18 Nov 2019 19:14:03 -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 S1727517AbfKSDJQ (ORCPT + 99 others); Mon, 18 Nov 2019 22:09:16 -0500 Received: from mga02.intel.com ([134.134.136.20]:21052 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbfKSDJP (ORCPT ); Mon, 18 Nov 2019 22:09:15 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2019 19:09:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,322,1569308400"; d="scan'208";a="204265404" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by fmsmga008.fm.intel.com with ESMTP; 18 Nov 2019 19:09:13 -0800 Cc: baolu.lu@linux.intel.com, iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , "Tian, Kevin" , Raj Ashok , Yi Liu Subject: Re: [PATCH v2 04/10] iommu/vt-d: Match CPU and IOMMU paging mode To: Jacob Pan , Auger Eric References: <1574106153-45867-1-git-send-email-jacob.jun.pan@linux.intel.com> <1574106153-45867-5-git-send-email-jacob.jun.pan@linux.intel.com> <601ca9c3-9f83-3d95-8d26-d4f46eee82ba@redhat.com> <20191118135238.49f5d957@jacob-builder> From: Lu Baolu Message-ID: Date: Tue, 19 Nov 2019 11:06:10 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191118135238.49f5d957@jacob-builder> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric and Jacob, On 11/19/19 5:52 AM, Jacob Pan wrote: > On Mon, 18 Nov 2019 21:55:03 +0100 > Auger Eric wrote: > >> Hi Jacob, >> >> On 11/18/19 8:42 PM, Jacob Pan wrote: >>> 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; >> Can it happen? If I am not wrong intel_pasid_setup_first_level() only >> seems to be called from intel_svm_bind_mm which now checks the >> SVM_CAPABLE flag. >> > You are right, this check is not needed any more. I will drop the patch. >> Thanks I'd suggest to keep this. This helper is not only for svm, although currently svm is the only caller. For first level pasid setup, let's set an assumption that hardware should never report mismatching paging modes, this is helpful especially when running vIOMMU in VM guests. Best regards, baolu