All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] xen/arm: Do not allocate pte entries for MAP_SMALL_PAGES
@ 2015-02-18 12:56 vijay.kilari
  2015-02-18 13:03 ` Julien Grall
  0 siblings, 1 reply; 16+ messages in thread
From: vijay.kilari @ 2015-02-18 12:56 UTC (permalink / raw)
  To: Ian.Campbell, julien.grall, stefano.stabellini,
	stefano.stabellini, tim, xen-devel
  Cc: Prasun.Kapoor, Vijaya Kumar K, manish.jaggi, vijay.kilari

From: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>

On x86, for the pages mapped with PAGE_HYPERVISOR attribute
non-leaf page tables are allocated with valid pte entries.
and with MAP_SMALL_PAGES attribute only non-leaf page tables are
allocated with invalid (valid bit set to 0) pte entries.
However on arm this is not the case. On arm for the pages
mapped with PAGE_HYPERVISOR and MAP_SMALL_PAGES both
non-leaf and leaf level page table are allocated with valid bit
in pte entries.

This behaviour in arm makes common vmap code fail to
allocate memory beyond 128MB as described below.

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.

With this patch, MAP_SMALL_PAGES attribute will only allocate
non-leaf page tables only.

Here we use bit[16] in the attribute flag to know if leaf page
tables should be allocated or not.

This bit is set only for MAP_SMALL_PAGES attribute.

Signed-off-by: Vijaya Kumar K<Vijaya.Kumar@caviumnetworks.com>
---
 xen/arch/arm/mm.c          |    9 ++++++---
 xen/include/asm-arm/page.h |    8 +++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 7d4ba0c..a12f3f5 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -865,9 +865,12 @@ static int create_xen_entries(enum xenmap_operation op,
                            addr, mfn);
                     return -EINVAL;
                 }
-                pte = mfn_to_xen_entry(mfn, ai);
-                pte.pt.table = 1;
-                write_pte(&third[third_table_offset(addr)], pte);
+                if ( !(ai & PTE_INVALID) )
+                {
+                    pte = mfn_to_xen_entry(mfn, (ai & 0xffff));
+                    pte.pt.table = 1;
+                    write_pte(&third[third_table_offset(addr)], pte);
+                }
                 break;
             case REMOVE:
                 if ( !third[third_table_offset(addr)].pt.valid )
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index 3e7b0ae..80415b3 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -61,10 +61,16 @@
 #define DEV_WC        BUFFERABLE
 #define DEV_CACHED    WRITEBACK
 
+/* bit 16 in the Attribute index can be used to know if
+ * PTE entry should be added or not. This is useful
+ * when ONLY non-leaf page table entries need to allocated
+ */
+#define PTE_INVALID   (0x1 << 16)
+
 #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         (PAGE_HYPERVISOR | (PTE_INVALID))
 
 /*
  * Stage 2 Memory Type.
-- 
1.7.9.5

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

end of thread, other threads:[~2015-03-03 11:57 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-18 12:56 [PATCH v1] xen/arm: Do not allocate pte entries for MAP_SMALL_PAGES vijay.kilari
2015-02-18 13:03 ` Julien Grall
2015-02-24  9:31   ` Ian Campbell
2015-02-24  9:38     ` Julien Grall
2015-02-24 10:17       ` Jan Beulich
2015-02-24 10:26       ` Ian Campbell
2015-02-24 12:59         ` Julien Grall
2015-02-24 13:13           ` Ian Campbell
2015-02-24 13:47             ` Julien Grall
2015-02-24 13:54               ` Jan Beulich
2015-03-03  7:58           ` Vijay Kilari
2015-03-03 10:27             ` Ian Campbell
2015-03-03 11:17               ` Julien Grall
2015-03-03 11:47                 ` Ian Campbell
2015-03-03 11:51                   ` Julien Grall
2015-03-03 11:57                     ` Ian Campbell

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.