All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] xen/arm: Vmap allocator fails to allocate beyond 128M
@ 2015-02-17  6:07 Vijay Kilari
  2015-02-17  9:53 ` Jan Beulich
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Vijay Kilari @ 2015-02-17  6:07 UTC (permalink / raw)
  To: Ian Campbell, Stefano Stabellini, Stefano Stabellini,
	Julien Grall, xen-devel@lists.xen.org, Jan Beulich, Tim Deegan

In vmap_init, map_pages_to_xen() is called for mapping
vm_bitmap. Initially one page of vm_bitmap is allocated
and mapped using PAGE_HYPERVISOR attribute.
For the rest of vm_bitmap pages, MAP_SMALL_PAGES attribute
is used to map.

In ARM for both PAGE_HYPERVISOR and MAP_SMALL_PAGES, valid bit
is set to 1 in pte entry for these mapping.

In vma_alloc(), map_pages_to_xen() is failing for >128MB because
for this next vm_bitmap page the mapping is already set in vm_init()
with valid bit set in pte entry. So map_pages_to_xen() in
ARM returns error.

On x86, for the pages mapped with MAP_SMALL_PAGES attribute
valid bit is not set. So the common vmap code assumes the
same behaviour from arm. However this is not the case.

This patch will set valid bit to 0 in pte entry when
pages are mapped with MAP_SMALL_PAGES.

Signed-off-by: Vijaya Kumar K<Vijaya.Kumar@caviumnetworks.com>

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index c3ae184..f125cf9 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -827,7 +827,8 @@ static int create_xen_table(lpae_t *entry)

 enum xenmap_operation {
     INSERT,
-    REMOVE
+    REMOVE,
+    RESERVE
 };

 static int create_xen_entries(enum xenmap_operation op,
@@ -859,6 +860,7 @@ static int create_xen_entries(enum xenmap_operation op,

         switch ( op ) {
             case INSERT:
+            case RESERVE:
                 if ( third[third_table_offset(addr)].pt.valid )
                 {
                     printk("create_xen_entries: trying to replace an
existing mapping addr=%lx mfn=%lx\n",
@@ -866,6 +868,8 @@ static int create_xen_entries(enum xenmap_operation op,
                     return -EINVAL;
                 }
                 pte = mfn_to_xen_entry(mfn, ai);
+                if ( op == RESERVE )
+                    pte.pt.valid = 0;
                 pte.pt.table = 1;
                 write_pte(&third[third_table_offset(addr)], pte);
                 break;
@@ -896,7 +900,10 @@ int map_pages_to_xen(unsigned long virt,
                      unsigned long nr_mfns,
                      unsigned int flags)
 {
-    return create_xen_entries(INSERT, virt, mfn, nr_mfns, flags);
+    if ( flags  == MAP_SMALL_PAGES )
+        return create_xen_entries(RESERVE, virt, mfn, nr_mfns,
PAGE_HYPERVISOR);
+    else
+        return create_xen_entries(INSERT, virt, mfn, nr_mfns, flags);
 }
 void destroy_xen_mappings(unsigned long v, unsigned long e)
 {
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index 53d4b63..e704ac8 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -58,6 +58,7 @@
 #define WRITEBACK     0x3
 #define DEV_SHARED    0x4
 #define WRITEALLOC    0x7
+#define WRITEALLOC_INVALID    0xf
 #define DEV_NONSHARED DEV_SHARED
 #define DEV_WC        BUFFERABLE
 #define DEV_CACHED    WRITEBACK
@@ -65,7 +66,7 @@
 #define PAGE_HYPERVISOR         (WRITEALLOC)
 #define PAGE_HYPERVISOR_NOCACHE (DEV_SHARED)
 #define PAGE_HYPERVISOR_WC      (DEV_WC)
-#define MAP_SMALL_PAGES         PAGE_HYPERVISOR
+#define MAP_SMALL_PAGES         (WRITEALLOC_INVALID)

 /*
  * Stage 2 Memory Type.
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-02-24 10:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-17  6:07 [RFC PATCH] xen/arm: Vmap allocator fails to allocate beyond 128M Vijay Kilari
2015-02-17  9:53 ` Jan Beulich
2015-02-17 14:50 ` Julien Grall
2015-02-23 17:07   ` Ian Campbell
2015-02-23 21:45     ` Julien Grall
2015-02-24  8:49       ` Ian Campbell
2015-02-23 17:03 ` Ian Campbell
2015-02-23 17:10   ` Ian Campbell
2015-02-24 10:01   ` Jan Beulich
2015-02-24 10:20     ` Ian Campbell
2015-02-24 10:24       ` Jan Beulich

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.