[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH v2] xen/arm: p2m: Populate pages for GICv2 mapping in arch_domain_create()


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Fri, 14 Oct 2022 11:19:31 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VKeH86N2pPjp35fhhl/nBPKsW6jJKRt2H1dEOdWCLaM=; b=YlQAe6420+HWKXbPp8HY7TwczGK/6lxFECD4Zya7k60ZcmxM+/yKO/1TX0MzG/s46KpiX7GClmWHOUGbHX85X2AzCg2TinxrDjV8yCGkAHA+7ktajODHZfgvC0/VcWL14eucKD3lNMv1zYZTmiFieCoCJpQCKRSwAnPUtU4vlYa4HTWfXMUQewt4W5E1Er7vK/03sMkqYFn3oRdf8ZW9w7SlCEWZGsY1qvP3OsP3mJ5/Tsiuo74kuijjZaAMDnn5l903bFSovW43BnGS41sBr3/qdoomGVy3UzCVEm2seYQjLxPW7WegJgQMzC2abBGSEQ3UGpC7MFmWMTxHK/oi1g==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VKeH86N2pPjp35fhhl/nBPKsW6jJKRt2H1dEOdWCLaM=; b=K1wtFNkKo0Pg6SwypyJQyXLYjfdnK9WQ5i3V3qiJNHbb8Q1iXNvA9ScPH7SbEAX6kZxnJOE1l951ETBVkJ+4bwqamKQXorp9QoyBVj3hBkYv9aZCdDw7rIpvb5DhiBbJnF453mfouvNf4BaEZ4j9UEMQuZ4GLIlmL/9dIxdDUSdYl2IZkhPfzzMiyLl2bt27qlvum16VTd/Bcdy49UIIugH9obwUX9nic+BZgNX9NNS5C1DU2droQ3zrNetev+AiwzcQ7alzcMLLP8cmP1blP8MsRPKb00wNJohD2ulREUWab944uPYxjGVaS5Z/4Upz+JZT7ezu20CxfzF0/t9pqA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=bUbA4VRLYaUMdCuev2kIgYvjoAe24wWFzinxQGSKE5o+vtnhlM2UlDbydns0wQEaEoaMpybS53gi749IxbXkSd+WF04DebA9Ch9otpUCFlmKXUwScYHnDYwrDwM9IUMp9RjGHCF3V5fS1BdtohhDcG88/yCUYVcUcHk2aApcCmd3XHjRNH3ime4r9Smw0s+WcNBE9X+3LBqQplMym3mSNvVJ9UBoaHsLsqVHGn3eGztoOFoD0qguTiVXxVOaL5coUNDATYv6fmIo/oCwy9cTkmPXHkPJMJoSJf2RfDMZnMjjo/AYZFpAa5ABreAquoathwOLtjMqh/UL4yaYIt+0wQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JYR1CNtoq3osnDAwwDEpfxQQGdZ+E4SVpg7iI71Kin2OnU2yUTEZbjbwtIBBaACncJO9yA8CAQh050nPCDzOd3Nt+ms6j/6FbcBoi2Kpb9GNjN7R9ZFrfhUW1wY5dTxkF+LWcvllsX3f+C+2t02I8wAkVscRrYI0eoufdRNLQ7XtPHny4i2BsfuWoZShNZSXxYQRKEalevYNuDQMchibVGRpCZFXXWBS3Ml5wNOtBmWZ8c8yyelljsqHSY6Yl7BWTBptDsbf+HJ/q/ymxn3PZGHwRSbWP07DBZVa2/Dm+oJUVYovUGS00T7VT7jSW8SW7Z7xWBs7FzN5oDA/pEFECw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 14 Oct 2022 11:19:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHY36RSrOIThkYtnEq9RrtWc+uYX64NsO2AgAACdYA=
  • Thread-topic: [PATCH v2] xen/arm: p2m: Populate pages for GICv2 mapping in arch_domain_create()

Hi Julien,

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
>
> Subject: Re: [PATCH v2] xen/arm: p2m: Populate pages for GICv2 mapping in
> arch_domain_create()
> 
> Hi Henry,
> 
> >
> > -int p2m_teardown(struct domain *d)
> > +int p2m_teardown(struct domain *d, bool allow_preemption)
> >   {
> I think the part to clean & invalidate the root should not be necessary
> if the domain is not scheduled. Similarly, I think we might only need to
> do once by domain (rather than for every call). So I would consider to
> move the logic outside of the function.
> 
> That's not for 4.17 thought.

Sure, I can prepare the follow up patch after 4.17 as (1) I am also worried
about if this patch would become bigger and bigger (2) I checked you also
want other things in your below comment.

> 
> >       struct p2m_domain *p2m = p2m_get_hostp2m(d);
> >       unsigned long count = 0;
> > @@ -1716,7 +1716,7 @@ int p2m_teardown(struct domain *d)
> >           p2m_free_page(p2m->domain, pg);
> >           count++;
> >           /* Arbitrarily preempt every 512 iterations */
> > -        if ( !(count % 512) && hypercall_preempt_check() )
> > +        if ( allow_preemption && !(count % 512) &&
> hypercall_preempt_check() )
> >           {
> >               rc = -ERESTART;
> >               break;
> > @@ -1736,6 +1736,17 @@ void p2m_final_teardown(struct domain *d)
> >       if ( !p2m->domain )
> >           return;
> >
> > +    if ( !page_list_empty(&p2m->pages) )
> 
> Did you add this check to avoid the clean & invalidate if the list is empty?

Yep. I think we only need the p2m_teardown() if we actually have something
in p2m->pages list.

> 
> > +        p2m_teardown(d, false);
> 
> Today, it should be fine to ignore p2m_teardown(). But I would prefer if
> we add an ASSERT()/BUG_ON() (or else) to make confirm this is the case.

Sorry I do not really understand why we can ignore the p2m_teardown()
probably because of my English. Let's talk a bit more in C if you don't mind :))
Do you mean p2m_teardown() should be called here unconditionally without
the if ( !page_list_empty(&p2m->pages) ) check?

> 
> This also wants to be documented on top of p2m_teardown() as it would be
> easier to know that the function should always return 0 when
> !allow_preemption is not set.

Ok, will do.

> 
> I also noticed that relinquish_p2m_mapping() is not called. This should
> be fine for us because arch_domain_create() should never create a
> mapping that requires p2m_put_l3_page() to be called.
> 
> I think it would be good to check it in __p2m_set_entry(). So we don't
> end up to add such mappings by mistake.

I thought for a while but failed to translate the above requirements
to proper if conditions in __p2m_set_entry()...

> 
> I would have suggested to add a comment only for version and send a
> follow-up patch. But I don't exactly know where to put it.

...how about p2m_final_teardown(), we can use a TODO to explain why
we don't need to call relinquish_p2m_mapping() and a following patch
can fix this?

> 
> > +
> > +    if ( d->arch.paging.p2m_total_pages != 0 )
> > +    {
> > +        spin_lock(&d->arch.paging.lock);
> > +        p2m_set_allocation(d, 0, NULL);
> > +        spin_unlock(&d->arch.paging.lock);
> > +        ASSERT(d->arch.paging.p2m_total_pages == 0);
> > +    }
> > +
> >       ASSERT(page_list_empty(&p2m->pages));
> 
> I would move this assert between the two ifs you added.

Sure, will do in v3.

Kind regards,
Henry

> 
> >       ASSERT(page_list_empty(&d->arch.paging.p2m_freelist));
> >
> 
> Cheers,
> 
> --
> Julien Grall

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.