From: Yinghai Lu <yinghai@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86, irq: Check if irq is remapped before freeing irte
Date: Mon, 18 Oct 2010 15:47:31 -0700 [thread overview]
Message-ID: <4CBCCE83.3040008@kernel.org> (raw)
In-Reply-To: <alpine.LFD.2.00.1010190029180.6815@localhost6.localdomain6>
On 10/18/2010 03:31 PM, Thomas Gleixner wrote:
> On Mon, 18 Oct 2010, Yinghai Lu wrote:
>
>> On 10/18/2010 02:17 PM, Thomas Gleixner wrote:
>>>
>>>
>>> On Mon, 18 Oct 2010, Thomas Gleixner wrote:
>>>
>>>> On Mon, 18 Oct 2010, Yinghai Lu wrote:
>>>>>
>>>>> Index: linux-2.6/drivers/pci/intr_remapping.c
>>>>> ===================================================================
>>>>> --- linux-2.6.orig/drivers/pci/intr_remapping.c
>>>>> +++ linux-2.6/drivers/pci/intr_remapping.c
>>>>> @@ -60,7 +60,7 @@ int get_irte(int irq, struct irte *entry
>>>>> unsigned long flags;
>>>>> int index;
>>>>>
>>>>> - if (!entry || !irq_iommu)
>>>>> + if (!entry || !irq_iommu || !irq_iommu->iommu)
>>>>> return -1;
>>>>
>>>> Hmm, why do we need this? This is only called from
>>>> ir_ioapic_set_affinity() and ir_msi_set_affinity().
>
> That does not answer that question !
we don't need that checking there.
>
>>>> We should never end up there when intr_remapping=off, right ?
>>>
>>> Thinking more about it, this check is actively bogus. The call sites do:
>>>
>>> struct irte irte;
>>>
>>> if (get_irte(irq, &irte))
>>> return -1;
>>>
>>> So entry _CANNOT_ be NULL.
>>>
>>> And in fact we should change get_irte() to
>>>
>>> get_irte(struct irq_2_iommu *irq_iommu, struct irte *entry)
>>>
>>> The call site already knows about it. No need to lookup irq_iommu
>>> based on the irq number.
>>
>> looks like all irq-irte related API could replace "int irq" to "struct irq_2_iommu *irq_iommu"
>>
>> extern int get_irte(int irq, struct irte *entry);
>> extern int modify_irte(int irq, struct irte *irte_modified);
>> extern int alloc_irte(struct intel_iommu *iommu, int irq, u16 count);
>> extern int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index,
>> u16 sub_handle);
>> extern int map_irq_to_irte_handle(int irq, u16 *sub_handle);
>> extern int free_irte(int irq);
>
> Probably, but we need to figure out which functions need which checks
> instead of having either redundant or superflous ones there.
>
only free_irte().
because other have have protection from intr_remapping_enabled or irq_remapped(get_irq_chip_data(irq)) or with ir related chip.
this one works too.
---
arch/x86/kernel/apic/io_apic.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: linux-2.6/arch/x86/kernel/apic/io_apic.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/apic/io_apic.c
+++ linux-2.6/arch/x86/kernel/apic/io_apic.c
@@ -3109,7 +3109,8 @@ void destroy_irq(unsigned int irq)
irq_set_status_flags(irq, IRQ_NOREQUEST|IRQ_NOPROBE);
- free_irte(irq);
+ if (intr_remapping_enabled)
+ free_irte(irq);
raw_spin_lock_irqsave(&vector_lock, flags);
__clear_irq_vector(irq, cfg);
raw_spin_unlock_irqrestore(&vector_lock, flags);
next prev parent reply other threads:[~2010-10-18 22:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-18 20:47 [PATCH] x86, irq: Check if irq is remapped before freeing irte Yinghai Lu
2010-10-18 21:09 ` Thomas Gleixner
2010-10-18 21:17 ` Thomas Gleixner
2010-10-18 21:28 ` Yinghai
2010-10-18 22:22 ` Yinghai Lu
2010-10-18 22:31 ` Thomas Gleixner
2010-10-18 22:47 ` Yinghai Lu [this message]
2010-10-19 7:28 ` [tip:irq/core] x86: ioapic: Call free_irte only if interrupt remapping enabled tip-bot for Yinghai Lu
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=4CBCCE83.3040008@kernel.org \
--to=yinghai@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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