Message ID | 20200310124353.4337-1-paul@xen.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v5] x86: irq: Do not BUG_ON multiple unbind calls for shared pirqs | expand |
On 10.03.2020 13:43, paul@xen.org wrote: > v5: > - BUG_ON(!shareable) rather than ASSERT(shareable) > - Drop ASSERT on nr_guests Why drop, rather than move ... > --- a/xen/arch/x86/irq.c > +++ b/xen/arch/x86/irq.c > @@ -1680,9 +1680,22 @@ static irq_guest_action_t *__pirq_guest_unbind( > > BUG_ON(!(desc->status & IRQ_GUEST)); > > - for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) > - continue; > - BUG_ON(i == action->nr_guests); > + for ( i = 0; i < action->nr_guests; i++ ) > + if ( action->guest[i] == d ) > + break; > + > + if ( i == action->nr_guests ) /* No matching entry */ > + { ... back here? (This would be easy enough to take care of while committing, iff we decided to go with this variant.) Jan
> -----Original Message----- > From: Jan Beulich <jbeulich@suse.com> > Sent: 10 March 2020 13:57 > To: paul@xen.org > Cc: xen-devel@lists.xenproject.org; Varad Gautam <vrd@amazon.de>; Julien Grall <julien@xen.org>; Roger > Pau Monné <roger.pau@citrix.com>; Andrew Cooper <andrew.cooper3@citrix.com> > Subject: Re: [PATCH v5] x86: irq: Do not BUG_ON multiple unbind calls for shared pirqs > > On 10.03.2020 13:43, paul@xen.org wrote: > > v5: > > - BUG_ON(!shareable) rather than ASSERT(shareable) > > - Drop ASSERT on nr_guests > > Why drop, rather than move ... > > > --- a/xen/arch/x86/irq.c > > +++ b/xen/arch/x86/irq.c > > @@ -1680,9 +1680,22 @@ static irq_guest_action_t *__pirq_guest_unbind( > > > > BUG_ON(!(desc->status & IRQ_GUEST)); > > > > - for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) > > - continue; > > - BUG_ON(i == action->nr_guests); > > + for ( i = 0; i < action->nr_guests; i++ ) > > + if ( action->guest[i] == d ) > > + break; > > + > > + if ( i == action->nr_guests ) /* No matching entry */ > > + { > > ... back here? (This would be easy enough to take care of while > committing, iff we decided to go with this variant.) Ok, let's see how your alternative goes. Paul > > Jan
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index cc2eb8e925..a3701354e6 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1680,9 +1680,22 @@ static irq_guest_action_t *__pirq_guest_unbind( BUG_ON(!(desc->status & IRQ_GUEST)); - for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) - continue; - BUG_ON(i == action->nr_guests); + for ( i = 0; i < action->nr_guests; i++ ) + if ( action->guest[i] == d ) + break; + + if ( i == action->nr_guests ) /* No matching entry */ + { + /* + * In case the pirq was shared, unbound for this domain in an earlier + * call, but still existed on the domain's pirq_tree, we still reach + * here if there are any later unbind calls on the same pirq. Return + * if such an unbind happens. + */ + BUG_ON(!action->shareable); + return NULL; + } + memmove(&action->guest[i], &action->guest[i+1], (action->nr_guests-i-1) * sizeof(action->guest[0])); action->nr_guests--;