Linux IOMMU Development
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: "Zhang, Tina" <tina.zhang@intel.com>
Cc: "iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>, "Sun, Yi" <yi.sun@intel.com>
Subject: Re: [PATCH] iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump
Date: Wed, 20 Jan 2021 19:37:21 +0800	[thread overview]
Message-ID: <9edd348d-71ae-a061-4a98-8267941b449f@linux.intel.com> (raw)
In-Reply-To: <BN7PR11MB278667C5A166460CE7CBBD4889A20@BN7PR11MB2786.namprd11.prod.outlook.com>

On 2021/1/20 16:41, Zhang, Tina wrote:
> 
> 
>> -----Original Message-----
>> From: Lu Baolu <baolu.lu@linux.intel.com>
>> Sent: Wednesday, January 20, 2021 10:35 AM
>> To: Zhang, Tina <tina.zhang@intel.com>
>> Cc: baolu.lu@linux.intel.com; iommu@lists.linux-foundation.org; Joerg
>> Roedel <joro@8bytes.org>; Mehta, Sohil <sohil.mehta@intel.com>; Jacob
>> Pan <jacob.jun.pan@linux.intel.com>; Sun, Yi <yi.sun@intel.com>
>> Subject: Re: [PATCH] iommu/vt-d: debugfs: Check irq_remapping_cap before
>> PI info dump
>>
>> On 1/20/21 2:25 AM, Tina Zhang wrote:
>>> irq_remapping_cap() was introduced to detect whether irq remapping
>>> supports new features, such as VT-d Posted-Interrupts", according to
>>> commit 959c870f7305 ("iommu, x86: Provide irq_remapping_cap()
>> interface").
>>>
>>> The VT-d Posted-Interrupts support can be disabled by the command line
>>> parameter "intremap=nopost".
>>>
>>> So, it's better to use irq_remapping_cap() to check if the VT-d
>>> Posted-Interrupts is enabled before any Posted Interrupt Descriptor
>>> info dump.
>>>
>>> Cc: Lu Baolu <baolu.lu@linux.intel.com>
>>> Cc: Joerg Roedel <joro@8bytes.org>
>>> Cc: Sohil Mehta <sohil.mehta@intel.com>
>>> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
>>> Reported-by: Yi Sun <yi.sun@intel.com>
>>> Signed-off-by: Tina Zhang <tina.zhang@intel.com>
>>> ---
>>>    drivers/iommu/intel/debugfs.c | 3 ++-
>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/iommu/intel/debugfs.c
>>> b/drivers/iommu/intel/debugfs.c index efea7f02abd9..87a4a76866f4
>>> 100644
>>> --- a/drivers/iommu/intel/debugfs.c
>>> +++ b/drivers/iommu/intel/debugfs.c
>>> @@ -516,7 +516,8 @@ static int ir_translation_struct_show(struct seq_file
>> *m, void *unused)
>>>    	seq_puts(m, "****\n\n");
>>>
>>>    	for_each_active_iommu(iommu, drhd) {
>>> -		if (!cap_pi_support(iommu->cap))
>>> +		if (!irq_remapping_cap(IRQ_POSTING_CAP) ||
>>> +		    !cap_pi_support(iommu->cap))
>>
>> With irq_remapping_cap(IRQ_POSTING_CAP), do you still need
>> cap_pi_support(iommu->cap)?
> 
> I guess yes. The "iommu->cap" value comes from the iommu reg. Current code seems to use cap_pi_suport() to check if the iommu hardware supports PI capability, meanwhile using irq_remapping_cap() to see if the vt-d PI support is enabled by user.
> 
> So, the problem here is if a user explicitly disables the vt-d PI support by "intremap=nopost", it would be very confused that the PI descriptor related info can still get dump.

I don't worry about dump hardware data even it's not enabled. But I do
care that the table is not allocated (due to not enabled) but the code
still tries to dump it, hence result in some kinds of NULL pointer or
wild pointer referencing.

Best regards,
baolu

> 
> Thanks,
> Tina
> 
>>
>>>    			continue;
>>>
>>>    		seq_printf(m, "Posted Interrupt supported on
>> IOMMU: %s\n",
>>>
>>
>> Best regards,
>> baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2021-01-20 11:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 18:25 [PATCH] iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump Tina Zhang
2021-01-20  2:34 ` Lu Baolu
2021-01-20  8:41   ` Zhang, Tina
2021-01-20 11:37     ` Lu Baolu [this message]
2021-01-20 12:21       ` Zhang, Tina

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=9edd348d-71ae-a061-4a98-8267941b449f@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=tina.zhang@intel.com \
    --cc=yi.sun@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