linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>, Joerg Roedel <joro@8bytes.org>
Cc: baolu.lu@linux.intel.com, "Raj, Ashok" <ashok.raj@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] iommu/vt-d: Check FL and SL capability sanity in scalable mode
Date: Mon, 27 Sep 2021 09:39:48 +0800	[thread overview]
Message-ID: <3237dbe8-089b-a159-2c40-4e6a04f0ae8d@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB5433AF7EE90A4A406E8B1D6E8CA79@BN9PR11MB5433.namprd11.prod.outlook.com>

On 9/27/21 9:33 AM, Tian, Kevin wrote:
>> From: Tian, Kevin
>> Sent: Monday, September 27, 2021 9:30 AM
>>
>>> From: Tian, Kevin
>>> Sent: Monday, September 27, 2021 9:12 AM
>>>
>>>> From: Lu Baolu <baolu.lu@linux.intel.com>
>>>> Sent: Sunday, September 26, 2021 7:46 PM
>>>>
>>>> An iommu domain could be allocated and mapped before it's attached to
>>>> any
>>>> device. This requires that in scalable mode, when the domain is allocated,
>>>> the format (FL or SL) of the page table must be determined. In order to
>>>> achieve this, the platform should support consistent SL or FL capabilities
>>>> on all IOMMU's. This adds a check for this and aborts IOMMU probing if it
>>>> doesn't meet this requirement.
>>>
>>> Is this a must? Looks the requirement comes from how the current code
>>> is implemented. It sets DOMAIN_FLAG_USE_FIRST_LEVEL flag in
>>> alloc_domain. But actually the pgtable is not allocated until the 1st device
>>> is attached. If this understanding is correct, you can also postpone the flag
>>> setting until pgtable is actually allocated.
>>
>> Baolu explained to me that RMRR regions are mapped before device
>> attach. So this check is necessary
>>
>>>
>>> of course how to handle inconsistent IOMMU capabilities is another
>>> orthogonal problem. Addressing it should not be only applied to SL/FL
>>> difference. especially this patch doesn't check consistency. it just
>>> checks that an IOMMU must support either SL or FL which doesn't
>>> match the commit msg here.
>>
>> and the overall inconsistency check mechanism is already in place.
>> and the logic here just extends it to cover SL/FL. Given that,
>>
>> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
>>
>>
>>>
>>>>
>>>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>>>> ---
>>>>   drivers/iommu/intel/cap_audit.h |  1 +
>>>>   drivers/iommu/intel/cap_audit.c | 13 +++++++++++++
>>>>   2 files changed, 14 insertions(+)
>>>>
>>>> diff --git a/drivers/iommu/intel/cap_audit.h
>>>> b/drivers/iommu/intel/cap_audit.h
>>>> index 74cfccae0e81..d07b75938961 100644
>>>> --- a/drivers/iommu/intel/cap_audit.h
>>>> +++ b/drivers/iommu/intel/cap_audit.h
>>>> @@ -111,6 +111,7 @@ bool intel_cap_smts_sanity(void);
>>>>   bool intel_cap_pasid_sanity(void);
>>>>   bool intel_cap_nest_sanity(void);
>>>>   bool intel_cap_flts_sanity(void);
>>>> +bool intel_cap_slts_sanity(void);
>>>>
>>>>   static inline bool scalable_mode_support(void)
>>>>   {
>>>> diff --git a/drivers/iommu/intel/cap_audit.c
>>>> b/drivers/iommu/intel/cap_audit.c
>>>> index b12e421a2f1a..040e4ae0e42b 100644
>>>> --- a/drivers/iommu/intel/cap_audit.c
>>>> +++ b/drivers/iommu/intel/cap_audit.c
>>>> @@ -163,6 +163,14 @@ static int cap_audit_static(struct intel_iommu
>>>> *iommu, enum cap_audit_type type)
>>>>   			check_irq_capabilities(iommu, i);
>>>>   	}
>>>>
>>>> +	/*
>>>> +	 * If the system is sane to support scalable mode, either SL or FL
>>>> +	 * should be sane.
>>>> +	 */
>>>> +	if (intel_cap_smts_sanity() &&
>>>> +	    !intel_cap_flts_sanity() && !intel_cap_slts_sanity())
>>>> +		return -EFAULT;
> 
> btw this should not be -EFAULT.

Agreed. I will change it to -ENOTSUPP.

Best regards,
baolu

> 
>>>> +
>>>>   out:
>>>>   	rcu_read_unlock();
>>>>   	return 0;
>>>> @@ -203,3 +211,8 @@ bool intel_cap_flts_sanity(void)
>>>>   {
>>>>   	return ecap_flts(intel_iommu_ecap_sanity);
>>>>   }
>>>> +
>>>> +bool intel_cap_slts_sanity(void)
>>>> +{
>>>> +	return ecap_slts(intel_iommu_ecap_sanity);
>>>> +}
>>>> --
>>>> 2.25.1
> 

  reply	other threads:[~2021-09-27  1:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 11:45 [PATCH v2 0/3] iommu/t-d: Use SL for GPA->HPA translation Lu Baolu
2021-09-26 11:45 ` [PATCH v2 1/3] iommu/vt-d: Remove duplicate identity domain flag Lu Baolu
2021-09-27  1:02   ` Tian, Kevin
2021-09-26 11:45 ` [PATCH v2 2/3] iommu/vt-d: Check FL and SL capability sanity in scalable mode Lu Baolu
2021-09-27  1:12   ` Tian, Kevin
2021-09-27  1:30   ` Tian, Kevin
2021-09-27  1:33   ` Tian, Kevin
2021-09-27  1:39     ` Lu Baolu [this message]
2021-09-26 11:45 ` [PATCH v2 3/3] iommu/vt-d: Use second level for GPA->HPA translation Lu Baolu
2021-09-27  1:31   ` Tian, Kevin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3237dbe8-089b-a159-2c40-4e6a04f0ae8d@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=ashok.raj@intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).