Skip to contentSkip to conversation

iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump

PATCH In review Tina Zhang 2 participants 5 messages Jan 19, 2021 – Jan 20, 2021

Subsystems (2)
lore
Share & tools
lore

Tina Zhang

author
#0 lore raw

PATCH 1/1 iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump

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 <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Sohil Mehta <[email protected]>
Cc Jacob Pan <[email protected]>
---
 drivers/iommu/intel/debugfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/intel/debugfs.c +2 -1
index efea7f02abd9..87a4a76866f4 100644
@@ -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))
 			continue;
 
 		seq_printf(m, "Posted Interrupt supported on IOMMU: %s\n",
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer
#1 lore raw
Quoted 26 lines · Tina Zhang

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 <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Sohil Mehta <[email protected]>
Cc Jacob Pan <[email protected]>
---
  drivers/iommu/intel/debugfs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/intel/debugfs.c +0 -0
index efea7f02abd9..87a4a76866f4 100644

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused) · line 520

Quoted 6 lines
drivers/iommu/intel/debugfs.c +2 -1
@@ -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)?

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused) · line 523

Quoted 4 lines
drivers/iommu/intel/debugfs.c +0 -0
  			continue;
 
  		seq_printf(m, "Posted Interrupt supported on IOMMU: %s\n",

Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#2 lore raw
Quoted 44 lines

-----Original Message-----
From: Lu Baolu <[email protected]>
Sent: Wednesday, January 20, 2021 10:35 AM
To: Zhang, Tina <[email protected]>
Cc: [email protected]; [email protected]; Joerg Roedel <[email protected]>; Mehta, Sohil <[email protected]>; Jacob Pan <[email protected]>; Sun, Yi <[email protected]>
Subject: Re: [PATCH] iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump

Quoted 3 lines · Tina Zhang

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").

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file

Quoted 24 lines

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 <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Sohil Mehta <[email protected]>
Cc Jacob Pan <[email protected]>
---
  drivers/iommu/intel/debugfs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/iommu/intel/debugfs.c index efea7f02abd9..87a4a76866f4 100644

drivers/iommu/intel/debugfs.c +0 -0
@@ -516,7 +516,8 @@ static int ir_translation_struct_show(struct seq_file

*m, void *unused)

Quoted 2 lines
drivers/iommu/intel/debugfs.c +0 -0
  	seq_puts(m, "****\n\n");
 
Quoted 7 lines

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused) · line 520

Quoted 4 lines
drivers/iommu/intel/debugfs.c +2 -1
  	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.

Thanks,
Tina

Quoted 9 lines

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused)

Quoted 4 lines
drivers/iommu/intel/debugfs.c +0 -0
  			continue;
 
  		seq_printf(m, "Posted Interrupt supported on

IOMMU: %s\n",

Quoted 1 line

Best regards,
baolu

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer
#3 lore raw
Quoted 52 lines · Tina
Quoted 44 lines

-----Original Message-----
From: Lu Baolu <[email protected]>
Sent: Wednesday, January 20, 2021 10:35 AM
To: Zhang, Tina <[email protected]>
Cc: [email protected]; [email protected]; Joerg Roedel <[email protected]>; Mehta, Sohil <[email protected]>; Jacob Pan <[email protected]>; Sun, Yi <[email protected]>
Subject: Re: [PATCH] iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump

Quoted 3 lines · Tina Zhang

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").

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file

Quoted 24 lines

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 <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Sohil Mehta <[email protected]>
Cc Jacob Pan <[email protected]>
---
   drivers/iommu/intel/debugfs.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/iommu/intel/debugfs.c index efea7f02abd9..87a4a76866f4 100644

drivers/iommu/intel/debugfs.c +0 -0
@@ -516,7 +516,8 @@ static int ir_translation_struct_show(struct seq_file

*m, void *unused)

Quoted 2 lines
drivers/iommu/intel/debugfs.c +0 -0
   	seq_puts(m, "****\n\n");
 
Quoted 7 lines

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused) · line 520

Quoted 4 lines
drivers/iommu/intel/debugfs.c +2 -1
   	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)?

Quoted 3 lines

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

Quoted 13 lines

Thanks,
Tina

Quoted 9 lines

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused)

Quoted 4 lines
drivers/iommu/intel/debugfs.c +0 -0
   			continue;
 
   		seq_printf(m, "Posted Interrupt supported on

IOMMU: %s\n",

Quoted 1 line

Best regards,
baolu

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#4 lore raw
Quoted 71 lines

-----Original Message-----
From: Lu Baolu <[email protected]>
Sent: Wednesday, January 20, 2021 7:37 PM
To: Zhang, Tina <[email protected]>
Cc: [email protected]; [email protected]; Joerg Roedel <[email protected]>; Mehta, Sohil <[email protected]>; Jacob Pan <[email protected]>; Sun, Yi <[email protected]>
Subject: Re: [PATCH] iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump

Quoted 53 lines · Tina
Quoted 45 lines

-----Original Message-----
From: Lu Baolu <[email protected]>
Sent: Wednesday, January 20, 2021 10:35 AM
To: Zhang, Tina <[email protected]>
Cc: [email protected]; [email protected]; Joerg Roedel <[email protected]>; Mehta, Sohil <[email protected]>; Jacob Pan <[email protected]>; Sun, Yi <[email protected]>
Subject: Re: [PATCH] iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump

Quoted 3 lines · Tina Zhang

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").

Quoted 24 lines

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 <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Sohil Mehta <[email protected]>
Cc Jacob Pan <[email protected]>
---
   drivers/iommu/intel/debugfs.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/iommu/intel/debugfs.c index efea7f02abd9..87a4a76866f4 100644

drivers/iommu/intel/debugfs.c +0 -0
@@ -516,7 +516,8 @@ static int ir_translation_struct_show(struct
Quoted 1 line

seq_file

*m, void *unused)

Quoted 2 lines
   	seq_puts(m, "****\n\n");
Quoted 7 lines

drivers/iommu/intel/debugfs.c static int ir_translation_struct_show(struct seq_file *m, void *unused) · line 520

Quoted 4 lines
   	for_each_active_iommu(iommu, drhd) {
drivers/iommu/intel/debugfs.c +2 -1
-		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)?

Quoted 1 line

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.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

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.

Oh, I see.

BR,
Tina

Quoted 17 lines

Best regards,
baolu

Quoted 13 lines

Thanks,
Tina

Quoted 9 lines
Quoted 4 lines

continue;

seq_printf(m, "Posted Interrupt supported on

IOMMU: %s\n",

Quoted 1 line

Best regards,
baolu

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu