iommu/vt-d: debugfs: Check irq_remapping_cap before PI info dump
Subsystems (2)
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.
--- drivers/iommu/intel/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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))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
Lu Baolu
maintainerQuoted 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 commit959c870f7305("iommu, x86: Provideirq_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]>Reported-by Yi Sun <[email protected]>Signed-off-by Tina Zhang <[email protected]>--- drivers/iommu/intel/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iommu/intel/debugfs.c +0
-0
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
-0continue ; 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
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: Checkirq_remapping_capbefore PI info dumpQuoted 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 commit959c870f7305("iommu, x86: Provideirq_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]>Reported-by Yi Sun <[email protected]>Signed-off-by Tina Zhang <[email protected]>--- drivers/iommu/intel/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/iommu/intel/debugfs.cindexefea7f02abd9..87a4a76866f4100644drivers/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
-0seq_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
-1for_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 needcap_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
-0continue ; seq_printf(m, "Posted Interrupt supported onIOMMU: %s\n",
Quoted 1 line
Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerQuoted 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: Checkirq_remapping_capbefore PI info dumpQuoted 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 commit959c870f7305("iommu, x86: Provideirq_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]>Reported-by Yi Sun <[email protected]>Signed-off-by Tina Zhang <[email protected]>--- drivers/iommu/intel/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/iommu/intel/debugfs.cindexefea7f02abd9..87a4a76866f4100644drivers/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
-0seq_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
-1for_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 needcap_pi_support(iommu->cap)?
Quoted 3 lines
I guess yes. The "
iommu->cap" value comes from the iommu reg. Current code seems to usecap_pi_suport()to check if the iommu hardware supports PI capability, meanwhile usingirq_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,
TinaQuoted 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
-0continue ; seq_printf(m, "Posted Interrupt supported onIOMMU: %s\n",
Quoted 1 line
Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
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: Checkirq_remapping_capbefore PI info dumpQuoted 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: Checkirq_remapping_capbefore PI info dumpQuoted 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 commit959c870f7305("iommu, x86: Provideirq_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]>Reported-by Yi Sun <[email protected]>Signed-off-by Tina Zhang <[email protected]>--- drivers/iommu/intel/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/iommu/intel/debugfs.cindexefea7f02abd9..87a4a76866f4100644drivers/iommu/intel/debugfs.c +0
-0@@ -516,7 +516,8 @@ static int ir_translation_struct_show(structQuoted 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 needcap_pi_support(iommu->cap)?Quoted 1 line
I guess yes. The "
iommu->cap" value comes from the iommu reg. Currentcode seems to use
cap_pi_suport()to check if the iommu hardware supports PI capability, meanwhile usingirq_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,
baoluQuoted 13 lines
Thanks,
TinaQuoted 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