diff mbox series

[Xen-devel,for-4.12,3/8] xen/arm: p2m: Introduce an helper to allocate the root page-table

Message ID 20181128164939.8329-4-julien.grall@arm.com
State Superseded
Headers show
Series xen/arm: Workaround for Cortex-A76 erratum 1165522 | expand

Commit Message

Julien Grall Nov. 28, 2018, 4:49 p.m. UTC
A follow-up patch will require to allocate the root page-table without
having a domain in hand.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/p2m.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Andrii Anisov Dec. 21, 2018, 2:35 p.m. UTC | #1
On 28.11.18 18:49, Julien Grall wrote:
> A follow-up patch will require to allocate the root page-table without
> having a domain in hand.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Andrii Anisov <andrii_anisov@epam.com>
Stefano Stabellini Jan. 23, 2019, 11:29 p.m. UTC | #2
On Wed, 28 Nov 2018, Julien Grall wrote:
> A follow-up patch will require to allocate the root page-table without
> having a domain in hand.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

> ---
>  xen/arch/arm/p2m.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index 8ebf1e8dba..e8bacab9d2 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -1136,21 +1136,29 @@ int guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn,
>      return p2m_remove_mapping(d, gfn, (1 << page_order), mfn);
>  }
>  
> -static int p2m_alloc_table(struct domain *d)
> +static struct page_info *p2m_allocate_root(void)
>  {
> -    struct p2m_domain *p2m = p2m_get_hostp2m(d);
>      struct page_info *page;
>      unsigned int i;
>  
>      page = alloc_domheap_pages(NULL, P2M_ROOT_ORDER, 0);
>      if ( page == NULL )
> -        return -ENOMEM;
> +        return NULL;
>  
>      /* Clear both first level pages */
>      for ( i = 0; i < P2M_ROOT_PAGES; i++ )
>          clear_and_clean_page(page + i);
>  
> -    p2m->root = page;
> +    return page;
> +}
> +
> +static int p2m_alloc_table(struct domain *d)
> +{
> +    struct p2m_domain *p2m = p2m_get_hostp2m(d);
> +
> +    p2m->root = p2m_allocate_root();
> +    if ( !p2m->root )
> +        return -ENOMEM;
>  
>      p2m->vttbr = generate_vttbr(p2m->vmid, page_to_mfn(p2m->root));
>  
> -- 
> 2.11.0
>
diff mbox series

Patch

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 8ebf1e8dba..e8bacab9d2 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1136,21 +1136,29 @@  int guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn,
     return p2m_remove_mapping(d, gfn, (1 << page_order), mfn);
 }
 
-static int p2m_alloc_table(struct domain *d)
+static struct page_info *p2m_allocate_root(void)
 {
-    struct p2m_domain *p2m = p2m_get_hostp2m(d);
     struct page_info *page;
     unsigned int i;
 
     page = alloc_domheap_pages(NULL, P2M_ROOT_ORDER, 0);
     if ( page == NULL )
-        return -ENOMEM;
+        return NULL;
 
     /* Clear both first level pages */
     for ( i = 0; i < P2M_ROOT_PAGES; i++ )
         clear_and_clean_page(page + i);
 
-    p2m->root = page;
+    return page;
+}
+
+static int p2m_alloc_table(struct domain *d)
+{
+    struct p2m_domain *p2m = p2m_get_hostp2m(d);
+
+    p2m->root = p2m_allocate_root();
+    if ( !p2m->root )
+        return -ENOMEM;
 
     p2m->vttbr = generate_vttbr(p2m->vmid, page_to_mfn(p2m->root));