From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Xen-devel <xen-devel@lists.xen.org>,
Wei Liu <wei.liu2@citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: Rats nest with domain pirq initialisation
Date: Wed, 5 Sep 2018 13:39:18 +0100 [thread overview]
Message-ID: <ba242be2-c3b5-c313-e416-29f29dd13ec1@citrix.com> (raw)
In-Reply-To: <5B8FCB2502000078001E58A9@prv1-mh.provo.novell.com>
On 05/09/18 13:25, Jan Beulich wrote:
>>>> On 05.09.18 at 14:04, <andrew.cooper3@citrix.com> wrote:
>> On 05/09/18 08:24, Jan Beulich wrote:
>>>>>> On 04.09.18 at 20:44, <andrew.cooper3@citrix.com> wrote:
>>>> On 13/08/18 11:01, Andrew Cooper wrote:
>>>>> This is in preparation to set up d->max_cpus and d->vcpu[] in domain_create(),
>>>>> and allow later parts of domain construction to have access to the values.
>>>>>
>>>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>>>> ---
>>>>> CC: Jan Beulich <JBeulich@suse.com>
>>>>> CC: Stefano Stabellini <sstabellini@kernel.org>
>>>>> CC: Julien Grall <julien.grall@arm.com>
>>>>> CC: Wei Liu <wei.liu2@citrix.com>
>>>>> ---
>>>>> xen/common/domain.c | 34 +++++++++++++++++-----------------
>>>>> 1 file changed, 17 insertions(+), 17 deletions(-)
>>>>>
>>>>> diff --git a/xen/common/domain.c b/xen/common/domain.c
>>>>> index be51426..0c44f27 100644
>>>>> --- a/xen/common/domain.c
>>>>> +++ b/xen/common/domain.c
>>>>> @@ -322,6 +322,23 @@ struct domain *domain_create(domid_t domid,
>>>>> else
>>>>> d->guest_type = guest_type_pv;
>>>>>
>>>>> + if ( !is_hardware_domain(d) )
>>>>> + d->nr_pirqs = nr_static_irqs + extra_domU_irqs;
>>>>> + else
>>>>> + d->nr_pirqs = extra_hwdom_irqs ? nr_static_irqs +
>> extra_hwdom_irqs
>>>>> + : arch_hwdom_irqs(domid);
>>>>> + if ( d->nr_pirqs > nr_irqs )
>>>>> + d->nr_pirqs = nr_irqs;
>>>>> +
>>>>> + radix_tree_init(&d->pirq_tree);
>>>>> + }
>>>>> +
>>>>> + if ( (err = arch_domain_create(d, config)) != 0 )
>>>>> + goto fail;
>>>>> + init_status |= INIT_arch;
>>>>> +
>>>>> + if ( !is_idle_domain(d) )
>>>>> + {
>>>>> watchdog_domain_init(d);
>>>>> init_status |= INIT_watchdog;
>>>>>
>>>>> @@ -352,16 +369,6 @@ struct domain *domain_create(domid_t domid,
>>>> Between these two hunks is:
>>>>
>>>> d->iomem_caps = rangeset_new(d, "I/O Memory",
>> RANGESETF_prettyprint_hex);
>>>> d->irq_caps = rangeset_new(d, "Interrupts", 0);
>>>>
>>>> which is important, because it turns out that x86's
>>>> arch_domain_destroy() depends on d->irq_caps already being initialised.
>>> Moving this up looks reasonable to me. "Simple" initialization can
>>> certainly be done early (i.e. before arch_domain_create()), don't
>>> you think?
>> No - that defeats the purpose of making the destroy path idempotent.
>> For us to remove the max_vcpus hypercall, _domain_destroy() must be
>> capable of correctly cleaning up a domain from any state of
>> initialisation, including if the relevant init calls haven't been made yet.
> I agree up to here.
>
>> These rangeset_new() calls cannot move earlier than the first action
>> which might fail (which is the XSM init call to get the security label
>> correct).
> But I must be overlooking something crucial here: If _domain_destroy()
> was idempotent, how does it matter at what point the rangesets get
> initialized?
_domain_destroy() is idempotent (for the very small quantity of state it
currently looks after). The problem is that arch_domain_destroy() is
not idempotent, and needs needs to become so, and moving the
rangeset_new() calls as you originally suggested is not a fix for
arch_domain_destroy()'s idempotency bug.
>
>>>> The path which blows up is:
>>>>
>>>> arch_domain_destroy()
>>>> free_domain_pirqs()
>>>> unmap_domain_pirq()
>>>> irq_deny_access()
>>>> rangeset_remove_singleton((d)->irq_caps, i)
>>> But what IRQ do we find to unmap here? There can't be any that have
>>> been mapped, when ->irq_caps is still NULL. IOW I don't currently see
>>> how domain_pirq_to_irq() would legitimately return a positive value at
>>> this point in time, yet that's what guards the calls to unmap_domain_pirq().
>> It is pirq 2 which explodes, which is the first of the redundant pirq
>> structures allocated for legacy routing.
>>
>> I'm not sure I understand this code well enough to comment on why
>> domain_pirq_to_irq() returns a positive value at this point, but I'm
>> going to go out on a limb and suggest it might be related to our
>> unnecessary(?) preallocation.
> I've meanwhile considered this as the reason, too. And iirc the
> pre-allocation is because guests (including Dom0) bypass some of
> the setup they would do for non-legacy IRQs. This may have been
> just a XenoLinux (mis)behavior, but even then I'm not convinced
> we could easily alter things.
Bypass which setup? One way or another they have to bind the irq before
it can be used, so I still don't see why any structure preallocation is
needed. (Reservation of legacy irq numbers, perahps.)
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-09-05 12:39 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 10:00 [PATCH v2 00/12] Improvements to domain creation Andrew Cooper
2018-08-13 10:00 ` [PATCH v2 01/12] tools/ocaml: Pass a full domctl_create_config into stub_xc_domain_create() Andrew Cooper
2018-08-13 10:00 ` [PATCH v2 02/12] tools: Rework xc_domain_create() to take a full xen_domctl_createdomain Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 03/12] xen/domctl: Merge set_max_evtchn into createdomain Andrew Cooper
2018-08-14 13:58 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 04/12] xen/evtchn: Pass max_evtchn_port into evtchn_init() Andrew Cooper
2018-08-14 14:07 ` Roger Pau Monné
2018-08-15 12:45 ` Jan Beulich
2018-08-15 12:57 ` Julien Grall
2018-08-13 10:01 ` [PATCH v2 05/12] tools: Pass grant table limits to XEN_DOMCTL_set_gnttab_limits Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 06/12] xen/gnttab: Pass max_{grant, maptrack}_frames into grant_table_create() Andrew Cooper
2018-08-14 14:17 ` Roger Pau Monné
2018-08-15 12:51 ` Jan Beulich
2018-08-15 13:04 ` Julien Grall
2018-08-15 13:08 ` Andrew Cooper
2018-08-15 13:32 ` Julien Grall
2018-08-15 19:03 ` Andrew Cooper
2018-08-16 8:59 ` Julien Grall
2018-08-29 9:38 ` [PATCH v3 6/12] " Andrew Cooper
2018-08-30 19:40 ` Julien Grall
2018-08-13 10:01 ` [PATCH v2 07/12] xen/domctl: Remove XEN_DOMCTL_set_gnttab_limits Andrew Cooper
2018-08-14 14:19 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 08/12] xen/gnttab: Fold grant_table_{create, set_limits}() into grant_table_init() Andrew Cooper
2018-08-14 14:31 ` Roger Pau Monné
2018-08-15 12:54 ` Jan Beulich
2018-08-13 10:01 ` [PATCH v2 09/12] xen/domain: Call arch_domain_create() as early as possible in domain_create() Andrew Cooper
2018-08-14 14:37 ` Roger Pau Monné
2018-08-15 12:56 ` Jan Beulich
2018-09-04 18:44 ` Rats nest with domain pirq initialisation Andrew Cooper
2018-09-05 7:24 ` Jan Beulich
2018-09-05 11:38 ` Jan Beulich
2018-09-05 12:04 ` Andrew Cooper
2018-09-05 12:25 ` Jan Beulich
2018-09-05 12:39 ` Andrew Cooper [this message]
2018-09-05 15:44 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 10/12] tools: Pass max_vcpus to XEN_DOMCTL_createdomain Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 11/12] xen/dom0: Arrange for dom0_cfg to contain the real max_vcpus value Andrew Cooper
2018-08-14 15:05 ` Roger Pau Monné
2018-08-15 12:59 ` Jan Beulich
2018-08-13 10:01 ` [PATCH v2 12/12] xen/domain: Allocate d->vcpu[] in domain_create() Andrew Cooper
2018-08-14 15:17 ` Roger Pau Monné
2018-08-15 13:17 ` Julien Grall
2018-08-15 13:50 ` Andrew Cooper
2018-08-15 13:52 ` Julien Grall
2018-08-15 13:56 ` Andrew Cooper
2018-08-15 13:11 ` Jan Beulich
2018-08-15 14:03 ` Andrew Cooper
2018-08-15 15:18 ` Jan Beulich
2018-08-29 10:36 ` Andrew Cooper
2018-08-29 12:10 ` Jan Beulich
2018-08-29 12:29 ` Andrew Cooper
2018-08-29 12:49 ` Jan Beulich
2018-08-29 14:40 ` [PATCH v3 " Andrew Cooper
2018-08-29 15:03 ` Jan Beulich
2018-08-31 10:33 ` Wei Liu
2018-08-31 10:42 ` Jan Beulich
2018-08-31 10:57 ` Julien Grall
2018-08-31 11:00 ` Juergen Gross
2018-08-31 10:58 ` Andrew Cooper
2018-08-30 19:46 ` Julien Grall
2018-08-30 20:04 ` Andrew Cooper
2018-08-14 13:12 ` [PATCH v2 00/12] Improvements to domain creation Christian Lindig
2018-08-14 13:34 ` Andrew Cooper
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=ba242be2-c3b5-c313-e416-29f29dd13ec1@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).