xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Sergej Proskurin <proskurin@sec.in.tum.de>
To: Julien Grall <julien.grall@arm.com>, xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v2 04/25] arm/altp2m: Move hostp2m init/teardown to individual functions.
Date: Fri, 5 Aug 2016 09:26:25 +0200	[thread overview]
Message-ID: <13c16938-9035-c1c7-451c-04a3be418d69@sec.in.tum.de> (raw)
In-Reply-To: <bddf8823-3109-9ac9-e3fd-f7febb620336@arm.com>

Hi Julien,


On 08/03/2016 07:40 PM, Julien Grall wrote:
> Hello Sergej,
>
> Title: s/altp2m/p2m/ and please drop the full stop.

Ok.

>
> On 01/08/16 18:10, Sergej Proskurin wrote:
>> This commit pulls out generic init/teardown functionality out of
>> p2m_init and p2m_teardown into p2m_init_one, p2m_free_one, and
>> p2m_flush_table functions.  This allows our future implementation to
>> reuse existing code for the initialization/teardown of altp2m views.
>
> Please avoid to mix-up code movement and new additions. This makes the
> code more difficult to review.

I will remove unnecessary code movements.

>
> Also, you don't mention the new changes in the commit message.

Since this patch is new to the patch series (the patch that got split is
#07, where I have commented the changes), I did not add any but rather
described the patch without being specific to the patch version.

>
> After reading the patch, it should really be divided and explain why
> you split like that.
>

Ok.

>>
>> Signed-off-by: Sergej Proskurin <proskurin@sec.in.tum.de>
>> ---
>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>> Cc: Julien Grall <julien.grall@arm.com>
>> ---
>> v2: Added the function p2m_flush_table to the previous version.
>> ---
>>  xen/arch/arm/p2m.c        | 74
>> +++++++++++++++++++++++++++++++++++++----------
>>  xen/include/asm-arm/p2m.h | 11 +++++++
>>  2 files changed, 70 insertions(+), 15 deletions(-)
>>
>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>> index cbc64a1..17f3299 100644
>> --- a/xen/arch/arm/p2m.c
>> +++ b/xen/arch/arm/p2m.c
>> @@ -1360,50 +1360,94 @@ static void p2m_free_vmid(struct domain *d)
>>      spin_unlock(&vmid_alloc_lock);
>>  }
>>
>> -void p2m_teardown(struct domain *d)
>> +/* Reset this p2m table to be empty */
>> +void p2m_flush_table(struct p2m_domain *p2m)
>
> Any function exported should have its prototype in an header within
> the same patch.
>

I will change that.

>>  {
>> -    struct p2m_domain *p2m = &d->arch.p2m;
>> -    struct page_info *pg;
>> +    struct page_info *page, *pg;
>> +    unsigned int i;
>> +
>> +    page = p2m->root;
>
>
> This function can be called with p2m->root equal to NULL. (see the
> check in p2m_free_one.
>

I will add the check, thank you.

>> +
>> +    /* Clear all concatenated first level pages */
>> +    for ( i = 0; i < P2M_ROOT_PAGES; i++ )
>> +        clear_and_clean_page(page + i);
>>
>> +    /* Free the rest of the trie pages back to the paging pool */
>>      while ( (pg = page_list_remove_head(&p2m->pages)) )
>>          free_domheap_page(pg);
>> +}
>> +
>> +static inline void p2m_free_one(struct p2m_domain *p2m)
>
> Why inline here? Also, it seems that you export the function later.
> Why don't you do it here?
>

I will do that. Thank you.

> Finally, I think this function should be rename p2m_teardown_one to
> match the callers' name.
>

Ok.

>> +{
>> +    p2m_flush_table(p2m);
>> +
>> +    /* Free VMID and reset VTTBR */
>> +    p2m_free_vmid(p2m->domain);
>
> Why do you move the call to p2m_free_vmid?
>

When flushing a table, I did not want to free the associated VMID, as it
would need to be allocated right afterwards (see altp2m_propagate_change
and altp2m_reset). Since this would need to be done also in functions
like p2m_altp2m_reset, I moved this call to p2m_free_one. I believe
there is no need to free the VMIDs if the associated p2m is not freed as
well.

>> +    p2m->vttbr.vttbr = INVALID_VTTBR;
>
> Why do you reset vttbr, the p2m will never be used afterwards.
>

Fair. I did that just for the sake of completeness.

>>
>>      if ( p2m->root )
>>          free_domheap_pages(p2m->root, P2M_ROOT_ORDER);
>>
>>      p2m->root = NULL;
>>
>> -    p2m_free_vmid(d);
>> -
>>      radix_tree_destroy(&p2m->mem_access_settings, NULL);
>>  }
>>
>> -int p2m_init(struct domain *d)
>> +int p2m_init_one(struct domain *d, struct p2m_domain *p2m)
>
> Any function exported should have its prototype in an header within
> the same patch.
>

I will change that, thank you.

>>  {
>> -    struct p2m_domain *p2m = &d->arch.p2m;
>>      int rc = 0;
>>
>>      rwlock_init(&p2m->lock);
>>      INIT_PAGE_LIST_HEAD(&p2m->pages);
>>
>> -    p2m->vmid = INVALID_VMID;
>> -
>
> Why this is dropped?
>

This will be shown in patch #07. We reuse altp2m views and check whether
a p2m was flushed by checking for a valid VMID.

>>      rc = p2m_alloc_vmid(d);
>>      if ( rc != 0 )
>>          return rc;
>>
>> -    p2m->max_mapped_gfn = _gfn(0);
>> -    p2m->lowest_mapped_gfn = _gfn(ULONG_MAX);
>> -
>> -    p2m->default_access = p2m_access_rwx;
>> +    p2m->domain = d;
>> +    p2m->access_required = false;
>>      p2m->mem_access_enabled = false;
>> +    p2m->default_access = p2m_access_rwx;
>> +    p2m->root = NULL;
>> +    p2m->max_mapped_gfn = _gfn(0);
>> +    p2m->lowest_mapped_gfn = INVALID_GFN;
>
> Please don't move code when it is not necessary. This make the code
> review more difficult to read.
>

Ok.

>> +    p2m->vttbr.vttbr = INVALID_VTTBR;
>>      radix_tree_init(&p2m->mem_access_settings);
>>
>> -    rc = p2m_alloc_table(d);
>> -
>
> The function p2m_init_one should fully initialize the p2m (i.e
> allocate the table).
>

The function p2m_init_one is currently called also for initializing the
hostp2m, which is not dynamically allocated. Since we are sharing code
between the hostp2m and altp2m initialization, I solved it that way. We
could always allocate the hostp2m dynamically, that would solve it quite
easily without additional checks. The other solution can simply check,
whether the p2m is NULL and perform additional p2m allocation. What do
you think?

> Why altp2m_destroy_by_id don't free the p2m entirely?
> This would simply a lot this series and avoid to spread p2m
> initialization everywhere.
>

Same reason. I will change that accordingly, thank you.

>>      return rc;
>>  }
>>
>> +static void p2m_teardown_hostp2m(struct domain *d)
>> +{
>> +    struct p2m_domain *p2m = p2m_get_hostp2m(d);
>> +
>> +    p2m_free_one(p2m);
>> +}
>> +
>> +void p2m_teardown(struct domain *d)
>> +{
>> +    p2m_teardown_hostp2m(d);
>> +}
>> +
>> +static int p2m_init_hostp2m(struct domain *d)
>> +{
>> +    int rc;
>> +    struct p2m_domain *p2m = p2m_get_hostp2m(d);
>> +
>> +    p2m->p2m_class = p2m_host;
>> +
>> +    rc = p2m_init_one(d, p2m);
>> +    if ( rc )
>> +        return rc;
>> +
>> +    return p2m_alloc_table(d);
>> +}
>> +
>> +int p2m_init(struct domain *d)
>> +{
>> +    return p2m_init_hostp2m(d);
>> +}
>> +
>>  int relinquish_p2m_mapping(struct domain *d)
>>  {
>>      struct p2m_domain *p2m = &d->arch.p2m;
>> diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
>> index 5c7cd1a..1f9c370 100644
>> --- a/xen/include/asm-arm/p2m.h
>> +++ b/xen/include/asm-arm/p2m.h
>> @@ -18,6 +18,11 @@ struct domain;
>>
>>  extern void memory_type_changed(struct domain *);
>>
>> +typedef enum {
>> +    p2m_host,
>> +    p2m_alternate,
>> +} p2m_class_t;
>> +
>
> This addition should really be in a separate patch.
>

The function p2m_init_hostp2m uses p2m_host for initialization. I can
introduce a patch before this one, however to make it easier for the
reviewer.

>>  /* Per-p2m-table state */
>>  struct p2m_domain {
>>      /* Lock that protects updates to the p2m */
>> @@ -78,6 +83,12 @@ struct p2m_domain {
>>       * enough available bits to store this information.
>>       */
>>      struct radix_tree_root mem_access_settings;
>> +
>> +    /* Choose between: host/alternate */
>> +    p2m_class_t p2m_class;
>> +
>> +    /* Back pointer to domain */
>> +    struct domain *domain;
>
> Same here. With justification why we want it.
>

Ok.

>>  };
>>
>>  /*
>>

Thank you very much.

Best regards,
~Sergej


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-08-05  7:26 UTC|newest]

Thread overview: 159+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-01 17:10 [PATCH v2 00/25] arm/altp2m: Introducing altp2m to ARM Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 01/25] arm/altp2m: Add first altp2m HVMOP stubs Sergej Proskurin
2016-08-03 16:54   ` Julien Grall
2016-08-04 16:01     ` Sergej Proskurin
2016-08-04 16:04       ` Julien Grall
2016-08-04 16:22         ` Sergej Proskurin
2016-08-04 16:51           ` Julien Grall
2016-08-05  6:55             ` Sergej Proskurin
2016-08-09 19:16     ` Tamas K Lengyel
2016-08-10  9:52       ` Julien Grall
2016-08-10 14:49         ` Tamas K Lengyel
2016-08-11  8:17           ` Julien Grall
2016-08-11 14:41             ` Tamas K Lengyel
2016-08-12  8:10               ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 02/25] arm/altp2m: Add HVMOP_altp2m_get_domain_state Sergej Proskurin
2016-08-01 17:21   ` Andrew Cooper
2016-08-01 17:34     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 03/25] arm/altp2m: Add struct vttbr Sergej Proskurin
2016-08-03 17:04   ` Julien Grall
2016-08-03 17:05     ` Julien Grall
2016-08-04 16:11       ` Sergej Proskurin
2016-08-04 16:15         ` Julien Grall
2016-08-06  8:54           ` Sergej Proskurin
2016-08-06 13:20             ` Julien Grall
2016-08-06 13:48               ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 04/25] arm/altp2m: Move hostp2m init/teardown to individual functions Sergej Proskurin
2016-08-03 17:40   ` Julien Grall
2016-08-05  7:26     ` Sergej Proskurin [this message]
2016-08-05  9:16       ` Julien Grall
2016-08-06  8:43         ` Sergej Proskurin
2016-08-06 13:26           ` Julien Grall
2016-08-06 13:50             ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 05/25] arm/altp2m: Rename and extend p2m_alloc_table Sergej Proskurin
2016-08-03 17:57   ` Julien Grall
2016-08-06  8:57     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 06/25] arm/altp2m: Cosmetic fixes - function prototypes Sergej Proskurin
2016-08-03 18:02   ` Julien Grall
2016-08-06  9:00     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 07/25] arm/altp2m: Add altp2m init/teardown routines Sergej Proskurin
2016-08-03 18:12   ` Julien Grall
2016-08-05  6:53     ` Sergej Proskurin
2016-08-05  9:20       ` Julien Grall
2016-08-06  8:30         ` Sergej Proskurin
2016-08-09  9:44       ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 08/25] arm/altp2m: Add HVMOP_altp2m_set_domain_state Sergej Proskurin
2016-08-03 18:41   ` Julien Grall
2016-08-06  9:03     ` Sergej Proskurin
2016-08-06  9:36     ` Sergej Proskurin
2016-08-06 14:18       ` Julien Grall
2016-08-06 14:21       ` Julien Grall
2016-08-11  9:08       ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 09/25] arm/altp2m: Add altp2m table flushing routine Sergej Proskurin
2016-08-03 18:44   ` Julien Grall
2016-08-06  9:45     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 10/25] arm/altp2m: Add HVMOP_altp2m_create_p2m Sergej Proskurin
2016-08-03 18:48   ` Julien Grall
2016-08-06  9:46     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 11/25] arm/altp2m: Add HVMOP_altp2m_destroy_p2m Sergej Proskurin
2016-08-04 11:46   ` Julien Grall
2016-08-06  9:54     ` Sergej Proskurin
2016-08-06 13:36       ` Julien Grall
2016-08-06 13:51         ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 12/25] arm/altp2m: Add HVMOP_altp2m_switch_p2m Sergej Proskurin
2016-08-04 11:51   ` Julien Grall
2016-08-06 10:13     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 13/25] arm/altp2m: Make p2m_restore_state ready for altp2m Sergej Proskurin
2016-08-04 11:55   ` Julien Grall
2016-08-06 10:20     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 14/25] arm/altp2m: Make get_page_from_gva " Sergej Proskurin
2016-08-04 11:59   ` Julien Grall
2016-08-06 10:38     ` Sergej Proskurin
2016-08-06 13:45       ` Julien Grall
2016-08-06 16:58         ` Sergej Proskurin
2016-08-11  8:33           ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 15/25] arm/altp2m: Extend __p2m_lookup Sergej Proskurin
2016-08-04 12:04   ` Julien Grall
2016-08-06 10:44     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 16/25] arm/altp2m: Make p2m_mem_access_check ready for altp2m Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 17/25] arm/altp2m: Cosmetic fixes - function prototypes Sergej Proskurin
2016-08-04 12:06   ` Julien Grall
2016-08-06 10:46     ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 18/25] arm/altp2m: Add HVMOP_altp2m_set_mem_access Sergej Proskurin
2016-08-04 14:19   ` Julien Grall
2016-08-06 11:03     ` Sergej Proskurin
2016-08-06 14:26       ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 19/25] arm/altp2m: Add altp2m_propagate_change Sergej Proskurin
2016-08-04 14:50   ` Julien Grall
2016-08-06 11:26     ` Sergej Proskurin
2016-08-06 13:52       ` Julien Grall
2016-08-06 17:06         ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 20/25] arm/altp2m: Add altp2m paging mechanism Sergej Proskurin
2016-08-04 13:50   ` Julien Grall
2016-08-06 12:51     ` Sergej Proskurin
2016-08-06 14:14       ` Julien Grall
2016-08-06 17:28         ` Sergej Proskurin
2016-08-04 16:59   ` Julien Grall
2016-08-06 12:57     ` Sergej Proskurin
2016-08-06 14:21       ` Julien Grall
2016-08-06 17:35         ` Sergej Proskurin
2016-08-10  9:32         ` Sergej Proskurin
2016-08-11  8:47           ` Julien Grall
2016-08-11 17:13             ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 21/25] arm/altp2m: Add HVMOP_altp2m_change_gfn Sergej Proskurin
2016-08-04 14:04   ` Julien Grall
2016-08-06 13:45     ` Sergej Proskurin
2016-08-06 14:34       ` Julien Grall
2016-08-06 17:42         ` Sergej Proskurin
2016-08-11  9:21           ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 22/25] arm/altp2m: Adjust debug information to altp2m Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 23/25] arm/altp2m: Extend libxl to activate altp2m on ARM Sergej Proskurin
2016-08-02 11:59   ` Wei Liu
2016-08-02 14:07     ` Sergej Proskurin
2016-08-11 16:00       ` Wei Liu
2016-08-15 16:07         ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 24/25] arm/altp2m: Extend xen-access for " Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 25/25] arm/altp2m: Add test of xc_altp2m_change_gfn Sergej Proskurin
2016-08-02  9:14   ` Razvan Cojocaru
2016-08-02  9:50     ` Sergej Proskurin
2016-08-01 18:15 ` [PATCH v2 00/25] arm/altp2m: Introducing altp2m to ARM Julien Grall
2016-08-01 19:20   ` Tamas K Lengyel
2016-08-01 19:55     ` Julien Grall
2016-08-01 20:35       ` Sergej Proskurin
2016-08-01 20:41       ` Tamas K Lengyel
2016-08-02  7:38         ` Julien Grall
2016-08-02 11:17           ` George Dunlap
2016-08-02 15:48             ` Tamas K Lengyel
2016-08-02 16:05               ` George Dunlap
2016-08-02 16:09                 ` Tamas K Lengyel
2016-08-02 16:40                 ` Julien Grall
2016-08-02 17:01                   ` Tamas K Lengyel
2016-08-02 17:22                   ` Tamas K Lengyel
2016-08-02 16:00           ` Tamas K Lengyel
2016-08-02 16:11             ` Julien Grall
2016-08-02 16:22               ` Tamas K Lengyel
2016-08-01 23:14   ` Andrew Cooper
2016-08-02  7:34     ` Julien Grall
2016-08-02 16:08       ` Andrew Cooper
2016-08-02 16:30         ` Tamas K Lengyel
2016-08-03 11:53         ` Julien Grall
2016-08-03 12:00           ` Andrew Cooper
2016-08-03 12:13             ` Julien Grall
2016-08-03 12:18               ` Andrew Cooper
2016-08-03 12:45                 ` Sergej Proskurin
2016-08-03 14:08                   ` Julien Grall
2016-08-03 14:17                     ` Sergej Proskurin
2016-08-03 16:01                     ` Tamas K Lengyel
2016-08-03 16:24                       ` Julien Grall
2016-08-03 16:42                         ` Tamas K Lengyel
2016-08-03 16:51                           ` Julien Grall
2016-08-03 17:30                             ` Andrew Cooper
2016-08-03 17:43                               ` Tamas K Lengyel
2016-08-03 17:45                                 ` Julien Grall
2016-08-03 17:51                                   ` Tamas K Lengyel
2016-08-03 17:56                                     ` Julien Grall
2016-08-03 18:11                                       ` Tamas K Lengyel
2016-08-03 18:16                                         ` Julien Grall
2016-08-03 18:21                                           ` Tamas K Lengyel
2016-08-04 11:13                                             ` George Dunlap
2016-08-08  4:44                                               ` Tamas K Lengyel

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=13c16938-9035-c1c7-451c-04a3be418d69@sec.in.tum.de \
    --to=proskurin@sec.in.tum.de \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.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 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).