Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp781861ybc; Tue, 19 Nov 2019 09:10:20 -0800 (PST) X-Google-Smtp-Source: APXvYqz82HVB1EbprvN2DrlGegxiSun6utkcpr79ztzjDiKUr1kiZe3OLXva+MVst9zhb6LF2WPW X-Received: by 2002:a17:906:4019:: with SMTP id v25mr36965922ejj.11.1574183420193; Tue, 19 Nov 2019 09:10:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574183420; cv=none; d=google.com; s=arc-20160816; b=FA3I1c7vvV1UguJT1eXrWXdDQBY5FO5uUGTpjQKids0t5pT0fm/p1kkTOQ7npbCTu1 mnNHJD0jsfZGr3UsUZXk5g1AKrY1FuBYtJJ+zrSBVRFtpvAEqIdAzGtIjoFu3lGRcNbS 91mZQ+V7VIMmHGrSUBT6XbyihVH48CSAvM0p7cwJ153NAowWVPCHXNi+h37qxafCn5Ie jHI1gIy3zqUTzuCY0ox72kJCaC1Vt4O/0ahUu6b3LC8D9HyvJ5zq5mJKnyLMy/7DgVVo 0zC7i3bk4Ybnn+WN5E3XZJyOnj+wq99sjpQyiDI7iSQjq+qFX11lUByl3yqeuG6YWN13 /o1Q== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=AOaNnuZtlm8Qz5TisKBkZU10nx12uwJ23yE06B60Q5g=; b=KdK5joiLllt81njZvjy2Z8qvbHkNpWYNnw5vP7RHJ/K7rURDqU83e3qlBlhZrG5cAA 9XdATPU7UzpGL1uoMKaCNPGpmYoMtlS5NrAvGoFPV//W1sWIP9YR7V6Cishk0Bq7mkJr GVKdFyv/PyPGV0NCZnCkvXguVzEDoiKt9SjUscbftEad1S3IGw8eUKzWvlVW231tnq3Q GcwPbjuUeyD16lDkbkTrAbQEPdw2eQGycBpEf2QBrsM0hkGOy4mR1gTAPQt7bSDSugmK 9LiWUqncXt3mhnRUFB8n8hSePpsko9v5Ek1/AfT+BRKaYSwUA/0F/ZRQJJ8OZ5IKphdA d9GA== 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 k1si13817961ejb.304.2019.11.19.09.09.53; Tue, 19 Nov 2019 09:10:20 -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 S1728487AbfKSRIX convert rfc822-to-8bit (ORCPT + 99 others); Tue, 19 Nov 2019 12:08:23 -0500 Received: from mga11.intel.com ([192.55.52.93]:46152 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbfKSRIX (ORCPT ); Tue, 19 Nov 2019 12:08:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 09:08:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,218,1571727600"; d="scan'208";a="407819557" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by fmsmga006.fm.intel.com with ESMTP; 19 Nov 2019 09:08:06 -0800 Date: Tue, 19 Nov 2019 09:12:41 -0800 From: Jacob Pan To: Auger Eric Cc: Lu Baolu , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , "Tian, Kevin" , Raj Ashok , Yi Liu , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v2 04/10] iommu/vt-d: Match CPU and IOMMU paging mode Message-ID: <20191119091241.37c478c9@jacob-builder> In-Reply-To: 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> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 19 Nov 2019 09:04:10 +0100 Auger Eric wrote: > Hi Lu, Jacob, > > On 11/19/19 4:06 AM, Lu Baolu wrote: > > 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. > > OK. So maybe just add the rationale in the commit message? > OK. will do. I thought about Baolu's point as well then I thought the other use of first level map for replacing today's VFIO second level map in the guest, but that will have a different helper. Anyway, I will keep this one then. Thanks you both! > Thanks > > Eric > > > > Best regards, > > baolu > > > [Jacob Pan]