* [PATCH] linux: mor assign_irq_vector() adjustments
@ 2006-04-25 12:38 Jan Beulich
2006-04-25 12:48 ` Keir Fraser
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2006-04-25 12:38 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
Instead of adding locking to also protect irq_vector[] in xenlinux, this patch adds verification that the vector passed
up from Xen for a certain IRQ is matching a potential previously obtained value. Besides that, two minor cleanup hunks.
Jan
[-- Attachment #2: xenlinux-x86-assign_irq_vector.patch --]
[-- Type: text/plain, Size: 1827 bytes --]
Index: head-2006-04-24/arch/i386/kernel/io_apic-xen.c
===================================================================
--- head-2006-04-24.orig/arch/i386/kernel/io_apic-xen.c 2006-04-25 12:14:36.000000000 +0200
+++ head-2006-04-24/arch/i386/kernel/io_apic-xen.c 2006-04-25 13:11:31.000000000 +0200
@@ -1207,7 +1207,7 @@ int assign_irq_vector(int irq)
{
physdev_op_t op;
- BUG_ON(irq >= NR_IRQ_VECTORS);
+ BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS);
if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0)
return IO_APIC_VECTOR(irq);
@@ -1217,8 +1217,11 @@ int assign_irq_vector(int irq)
return -ENOSPC;
vector_irq[op.u.irq_op.vector] = irq;
- if (irq != AUTO_ASSIGN)
- IO_APIC_VECTOR(irq) = op.u.irq_op.vector;
+ if (irq != AUTO_ASSIGN) {
+ u8 vector = cmpxchg(&IO_APIC_VECTOR(irq), 0, op.u.irq_op.vector);
+
+ BUG_ON(vector && vector != op.u.irq_op.vector);
+ }
return op.u.irq_op.vector;
}
Index: head-2006-04-24/arch/x86_64/kernel/io_apic-xen.c
===================================================================
--- head-2006-04-24.orig/arch/x86_64/kernel/io_apic-xen.c 2006-04-25 12:14:36.000000000 +0200
+++ head-2006-04-24/arch/x86_64/kernel/io_apic-xen.c 2006-04-25 13:11:31.000000000 +0200
@@ -881,14 +881,17 @@ int assign_irq_vector(int irq)
return -ENOSPC;
vector_irq[op.u.irq_op.vector] = irq;
- if (irq != AUTO_ASSIGN)
- IO_APIC_VECTOR(irq) = op.u.irq_op.vector;
+ if (irq != AUTO_ASSIGN) {
+ u8 vector = cmpxchg(&IO_APIC_VECTOR(irq), 0, op.u.irq_op.vector);
+
+ BUG_ON(vector && vector != op.u.irq_op.vector);
+ }
return op.u.irq_op.vector;
}
-extern void (*interrupt[NR_IRQS])(void);
#ifndef CONFIG_XEN
+extern void (*interrupt[NR_IRQS])(void);
static struct hw_interrupt_type ioapic_level_type;
static struct hw_interrupt_type ioapic_edge_type;
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] linux: mor assign_irq_vector() adjustments
2006-04-25 12:38 [PATCH] linux: mor assign_irq_vector() adjustments Jan Beulich
@ 2006-04-25 12:48 ` Keir Fraser
0 siblings, 0 replies; 3+ messages in thread
From: Keir Fraser @ 2006-04-25 12:48 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel
On 25 Apr 2006, at 13:38, Jan Beulich wrote:
> Instead of adding locking to also protect irq_vector[] in xenlinux,
> this patch adds verification that the vector passed
> up from Xen for a certain IRQ is matching a potential previously
> obtained value. Besides that, two minor cleanup hunks.
I think the extra checking here adds pointless complexity. If the check
fails then you are totally screwed -- you're just going to have to
trust Xen here.
-- Keir
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] linux: mor assign_irq_vector() adjustments
@ 2006-04-26 3:09 Tian, Kevin
0 siblings, 0 replies; 3+ messages in thread
From: Tian, Kevin @ 2006-04-26 3:09 UTC (permalink / raw)
To: Jan Beulich, xen-devel
>From: Jan Beulich
>Sent: 2006年4月25日 20:39
>
>Instead of adding locking to also protect irq_vector[] in xenlinux, this
>patch adds verification that the vector passed
>up from Xen for a certain IRQ is matching a potential previously obtained
>value. Besides that, two minor cleanup hunks.
>
>Jan
Is it useful to add that type of detect in xenlinux? Since lock has
been added into xen, it's always the first one holding lock to trigger
allocation process while the latter one getting cached vector returned
directly. In this case, xen promises the consistence and it's always
safe even two paths are writing irq_vector table simultaneously since
two paths see same value...
Thanks,
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-26 3:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-25 12:38 [PATCH] linux: mor assign_irq_vector() adjustments Jan Beulich
2006-04-25 12:48 ` Keir Fraser
-- strict thread matches above, loose matches on Subject: below --
2006-04-26 3:09 Tian, Kevin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.