From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: tim@xen.org, stefano.stabellini@citrix.com,
Jan Beulich <JBeulich@suse.com>,
xen-devel@lists.xenproject.org, parth.dixit@linaro.org,
christoffer.dall@linaro.org
Subject: Re: [PATCH for-4.6 2/4] xen/arm: vgic: Keep track of vIRQ used by a domain
Date: Tue, 13 Jan 2015 17:35:23 +0000 [thread overview]
Message-ID: <54B5575B.8060900@linaro.org> (raw)
In-Reply-To: <1421169496.19103.173.camel@citrix.com>
On 13/01/15 17:18, Ian Campbell wrote:
> On Tue, 2015-01-13 at 16:57 +0000, Julien Grall wrote:
>> (CC Jan)
>
> I think you forget, I added him.
>
>>>>>> @@ -49,6 +49,21 @@ int domain_vtimer_init(struct domain *d)
>>>>>> {
>>>>>> d->arch.phys_timer_base.offset = NOW();
>>>>>> d->arch.virt_timer_base.offset = READ_SYSREG64(CNTPCT_EL0);
>>>>>> +
>>>>>> + /* At this stage vgic_reserve_virq can't fail */
>>>>>> + if ( is_hardware_domain(d) )
>>>>>> + {
>>>>>> + BUG_ON(!vgic_reserve_virq(d, timer_get_irq(TIMER_PHYS_SECURE_PPI)));
>>>>>> + BUG_ON(!vgic_reserve_virq(d, timer_get_irq(TIMER_PHYS_NONSECURE_PPI)));
>>>>>> + BUG_ON(!vgic_reserve_virq(d, timer_get_irq(TIMER_VIRT_PPI)));
>>>>>> + }
>>>>>> + else
>>>>>> + {
>>>>>> + BUG_ON(!vgic_reserve_virq(d, GUEST_TIMER_PHYS_S_PPI));
>>>>>> + BUG_ON(!vgic_reserve_virq(d, GUEST_TIMER_PHYS_NS_PPI));
>>>>>> + BUG_ON(!vgic_reserve_virq(d, GUEST_TIMER_VIRT_PPI));
>>>>>
>>>>> Although BUG_ON is not conditional on $debug I think we still should
>>>>> avoid side effects in the condition.
>>>>
>>>> I know, but this should never fail as it called during on domain
>>>> construction. If so we may have some other issue later if we decide to
>>>> assign PPI to a guest.
>>>>
>>>> I would prefer to keep the BUG_ON here
>>>
>>> I'm not objecting the the BUG_ON itself but to the fact that the
>>> condition has a side effect. Please use:
>>> if (!do_something())
>>> BUG()
>>> instead to avoid this.
>>
>> We have other place in the code where BUG_ON as a side-effect.
>
> If we do then it is a tiny minority of places, and they are IMHO wrong.
> I spotted one in the 600+ results of grepping for BUG_ON.
I spotted more. Anyway, I will move to a if (!do_smth()) BUG() form.
Regards,
--
Julien Grall
next prev parent reply other threads:[~2015-01-13 17:36 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 14:43 [PATCH for-4.6 0/4] Find automatically a PPI for the DOM0 even channel IRQ Julien Grall
2014-12-12 14:43 ` [PATCH for-4.6 1/4] xen/arm: vgic: Rename nr_lines into nr_spis Julien Grall
2015-01-13 15:38 ` Ian Campbell
2015-01-13 15:52 ` Julien Grall
2015-01-13 15:59 ` Ian Campbell
2014-12-12 14:43 ` [PATCH for-4.6 2/4] xen/arm: vgic: Keep track of vIRQ used by a domain Julien Grall
2014-12-15 15:32 ` Stefano Stabellini
2014-12-15 16:07 ` Julien Grall
2014-12-17 15:23 ` Julien Grall
2015-01-13 15:51 ` Ian Campbell
2015-01-13 16:27 ` Julien Grall
2015-01-13 16:46 ` Ian Campbell
2015-01-13 16:57 ` Julien Grall
2015-01-13 17:18 ` Ian Campbell
2015-01-13 17:35 ` Julien Grall [this message]
2015-01-13 17:22 ` Julien Grall
2015-01-13 17:34 ` Julien Grall
2014-12-12 14:43 ` [PATCH for-4.6 3/4] xen/arm: vgic: notice if the vIRQ is not allocated when the guest enable it Julien Grall
2015-01-13 15:55 ` Ian Campbell
2015-01-13 20:33 ` Julien Grall
2015-01-14 12:28 ` Ian Campbell
2015-01-14 12:42 ` Julien Grall
2015-01-15 13:27 ` Julien Grall
2015-01-15 13:31 ` Ian Campbell
2014-12-12 14:43 ` [PATCH for-4.6 4/4] xen/arm: Find automatically a PPI for the DOM0 event channel interrupt Julien Grall
2014-12-12 17:00 ` Julien Grall
2014-12-15 15:35 ` Stefano Stabellini
2014-12-15 16:09 ` Julien Grall
2015-01-13 15:58 ` Ian Campbell
2015-01-14 12:24 ` Julien Grall
2015-01-14 12:30 ` Ian Campbell
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=54B5575B.8060900@linaro.org \
--to=julien.grall@linaro.org \
--cc=Ian.Campbell@citrix.com \
--cc=JBeulich@suse.com \
--cc=christoffer.dall@linaro.org \
--cc=parth.dixit@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/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 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.