Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2375039ybc; Wed, 20 Nov 2019 13:11:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwuXjwALZ0kbRo2mxurfL5EGcv1DmqG9TlKZY/A3uz8e+OD84M0nkfF8fdj8I7XDbC+uqBl X-Received: by 2002:a17:906:7042:: with SMTP id r2mr7997161ejj.166.1574284298169; Wed, 20 Nov 2019 13:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574284298; cv=none; d=google.com; s=arc-20160816; b=KLVG6cf5t9VyRgLTV/CiZraE0hHpk37qwR/j7GqfoUaIm9Ikrrm6aSwvcaazDIEvh5 Ekd31ftdCWFC0hjU9WFAXz1SydgCvsge1/OeOlsXSuqKC2jkSY56mtjwSRI2eqr+xnXR 912SLc9LOwmowqn/vqiJ52WuW+z/Nzq5LGRH7aWToUVJBijL65HP0e7QYuwdSKEtNAEu 4kRjiO/TlGs3SdHSL9+bw0zbTQLy4ejKHiLWX5DP65xU2Hz2IHo8bwzV68KRfQCYqf91 g044ekDgANnPgJeE4qBtVD/NPTL/9ottYGbDObtHExX2rJtTOgNCOIhNKbmv2T1ZEzs8 QxiA== 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:cc:to:subject:dkim-signature; bh=IJ75uiFKE/vrS49xMrG/E26ErD3qo0pj2vUxc1owOuY=; b=JlfnqEaeeWCqPcHmAV+GS2PL35fXZFIG1t+xQ2B7dCxqwMiK7e36q+lYBRHz/zqJHL lfGT4pGpRM28tDVsbrzdTD1tudJz3cvuCNaQ1o+vbcBQWgkKJam/6/v01f51WUhHMzWw wX5TNfJ5XL0J3wueevcp6vFoUZAr+rRu/RT+MZYFyPdeYuIti6nYd11GsgdvXexmjQ8P P/Z/fdTG+qNRQFskMqwDaBUXvo+W0B1b4nt09Qpc2rMx3RU1ulImGvQ0kAZ5N999tyOJ Vx+cLXmFvjnki+L0vkBZp0/9dYtJcBA/MZtEkEEtAfHCAaEIyuaW2wkLf3prWS84Ll8L bfTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=emTOLPZL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si570457edj.310.2019.11.20.13.11.12; Wed, 20 Nov 2019 13:11:38 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=emTOLPZL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfKTVIv (ORCPT + 99 others); Wed, 20 Nov 2019 16:08:51 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53765 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725815AbfKTVIv (ORCPT ); Wed, 20 Nov 2019 16:08:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574284129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IJ75uiFKE/vrS49xMrG/E26ErD3qo0pj2vUxc1owOuY=; b=emTOLPZLN5pkA6VyWslcRK/EGULGMYn2MJ1XXEHrZX9+mQKH+28JIwOGCl7KkWvKT95Puh 3ksKix7Wsp6kCX6skep/9hYY20ZznAE9VnKRwwImZsO6BDMmxh5W5VbRaJ6Gz5UeZfy1GL Wjefa544xVANgSeR5VEN8Dl+ibCD17Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-FfsjWtENNTS3u6KdzdVaig-1; Wed, 20 Nov 2019 16:08:46 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A630BDB22; Wed, 20 Nov 2019 21:08:44 +0000 (UTC) Received: from [10.36.116.37] (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBA00348A2; Wed, 20 Nov 2019 21:08:41 +0000 (UTC) Subject: Re: [PATCH v3 2/8] iommu/vt-d: Match CPU and IOMMU paging mode To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Lu Baolu , David Woodhouse Cc: "Tian, Kevin" , Raj Ashok , Yi Liu , "Mehta, Sohil" References: <1574186193-30457-1-git-send-email-jacob.jun.pan@linux.intel.com> <1574186193-30457-3-git-send-email-jacob.jun.pan@linux.intel.com> From: Auger Eric Message-ID: Date: Wed, 20 Nov 2019 22:08:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1574186193-30457-3-git-send-email-jacob.jun.pan@linux.intel.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: FfsjWtENNTS3u6KdzdVaig-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, On 11/19/19 6:56 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. >=20 > 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. >=20 > Currently, intel_pasid_setup_first_level() is only used by native SVM > code which already checks paging mode matches. However, future use of > this helper function may not be limited to native SVM. > https://lkml.org/lkml/2019/11/18/1037 >=20 > Fixes: 437f35e1cd4c8 ("iommu/vt-d: Add first level page table > interface") > Signed-off-by: Jacob Pan > Acked-by: Lu Baolu Reviewed-by: Eric Auger Thanks Eric > --- > drivers/iommu/intel-pasid.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) >=20 > 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, > =09} > =20 > #ifdef CONFIG_X86 > -=09if (cpu_feature_enabled(X86_FEATURE_LA57)) > -=09=09pasid_set_flpm(pte, 1); > +=09/* Both CPU and IOMMU paging mode need to match */ > +=09if (cpu_feature_enabled(X86_FEATURE_LA57)) { > +=09=09if (cap_5lp_support(iommu->cap)) { > +=09=09=09pasid_set_flpm(pte, 1); > +=09=09} else { > +=09=09=09pr_err("VT-d has no 5-level paging support for CPU\n"); > +=09=09=09pasid_clear_entry(pte); > +=09=09=09return -EINVAL; > +=09=09} > +=09} > #endif /* CONFIG_X86 */ > =20 > =09pasid_set_domain_id(pte, did); >=20