arm: allow access to the xenheap and the boot pages.
PATCH 6/14 arm: allow access to the xenheap and the boot pages.
arm: allow access to the xenheap and the boot pages.
This patch collects machine page frames, creates frame table to allow access to the xenheap and the boot pages.
xen/arch/arm/xen/mm.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/xen/setup.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xen/common/page_alloc.c | 5 +++ xen/include/asm-arm/mm.h | 28 +++++++++++++++++++++ xen/include/asm-arm/mmu.h | 10 +++++++ xen/include/asm-arm/platform.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++
Signed-off-by Jaemin Ryu <[email protected]>
xen/arch/arm/xen/mm.c +65 -0
@@ -192,3 +192,68 @@ int page_is_ram_type(unsigned long mfn,return -EINVAL ; } + +#define PTS_PER_PAGE 4 + +/* +* 4 page tables per a page. +*/ +static inline void wire_page_tables (l1e_t *l1e,unsigned long tables) +{ + l1e = (l1e_t *)((unsigned long )l1e & ~(PTS_PER_PAGE -1 )); + + *(l1e +0 ) =MK_L1E (tables +0 ,L1E_GUEST_TABLE );pte_sync (l1e +0 ); + *(l1e +1 ) =MK_L1E (tables +1024 ,L1E_GUEST_TABLE );pte_sync (l1e +1 ); + *(l1e +2 ) =MK_L1E (tables +2048 ,L1E_GUEST_TABLE );pte_sync (l1e +2 ); + *(l1e +3 ) =MK_L1E (tables +3072 ,L1E_GUEST_TABLE );pte_sync (l1e +3 ); +} + +unsigned long alloc_page_tables (l1e_t *l1e) +{ +unsigned long page; + + page =alloc_clean_pages (1 ); +if (!page) { +return 0 ; + } + +// cache_clean_range(page, page + PAGE_SIZE, 0); + +wire_page_tables (l1e, page); + +return page; +} + + +int alloc_page_map (unsigned long virt,unsigned long phys,unsigned int size,unsigned int flags) +{ +l1e_t *l1e; +unsigned long vaddr =round_down (virt,PAGE_SIZE ); +unsigned long last = virt + size; + + l1e =l1_linear_offset_xen (vaddr); + +do { +l2e_t *l2e; +unsigned long end = (vaddr + (SECTION_SIZE *PTS_PER_PAGE )) & (SECTION_MASK ); + end = (end < last) ? end : last; + +if (!l1e_val (*l1e)) { +if (!alloc_page_tables (l1e)) { +return -ENOMEM ; + } + } + + l2e =l2_linear_offset (l1e, vaddr); +do { + *l2e =MK_L2E (phys, flags); +pte_sync (l2e); + + phys +=PAGE_SIZE ; + vaddr +=PAGE_SIZE ; + }while (l2e++, vaddr < end); + }while (l1e +=4 , vaddr < last); + +return 0 ; +} +
xen/arch/arm/xen/setup.c +115 -0
133 lines not on this page · raw message
xen/common/page_alloc.c +5 -0
@@ -146,6 +146,11 @@ static void __init bootmem_region_zap(un } } +void __init reserve_boot_pages (paddr_t ps,paddr_t pe) +{ +bootmem_region_zap (ps >>PAGE_SHIFT , pe >>PAGE_SHIFT ); +} +void __init init_boot_pages (paddr_t ps,paddr_t pe) {unsigned long bad_spfn, bad_epfn;
xen/include/asm-arm/mm.h +28 -0
@@ -108,6 +108,13 @@#define write_ptbase (v) cpu_switch_ttb((v)->arch.ctx.ttbr0) +#if 0 +#undef page_list_entry +struct page_list_entry +{ +unsigned long next, prev; +}; +#endif struct page_info {struct page_list_entry list;
@@ -187,6 +194,7 @@ extern unsigned long min_page, max_page;extern struct domain *dom_xen, *dom_io, *dom_cow;extern struct page_info *frame_table; +extern l1e_t *xen_translation_table;void memguard_guard_stack (void *p);void share_xen_page_with_guest (struct page_info *page,struct domain *d,int readonly);
@@ -214,6 +222,11 @@ long arch_memory_op(int op, XEN_GUEST_HAint map_pages_to_xen (unsigned long virt,unsigned long mfn,int nr,unsigned long flags); +unsigned long alloc_page_map_tables (l1e_t *l1e); + +int alloc_page_map (unsigned long virt,unsigned long phys,unsigned int size,unsigned int flags); + +static inline void put_page_and_type (struct page_info *page) {put_page_type (page);
@@ -234,4 +247,19 @@ static inline int get_page_and_type(stru return rc; } +/* +* TDB : Page owner setting. +*/ +#define alloc_pages (nr) \ + (alloc_boot_pages(nr, PAGE_SIZE) << PAGE_SHIFT) + +#define alloc_clean_pages (nr) \ +({ \ + unsigned long page; \ + page = alloc_pages(nr); \ + if (page) { \ + memset(page, 0, nr << PAGE_SHIFT); \ + } \ + page; \ +})#endif /* __ARM_MM_H__ */
xen/include/asm-arm/mmu.h +10 -0
@@ -140,6 +140,16 @@#define l1_linear_offset_xen (va) \ (l1_linear_offset((xen_translation_table), va)) +#define pte_sync (ptr) \ +do { \ + __asm__ __volatile__( \ + "mcr p15, 0, %0, c7, c10, 1 @ clean D entry \n" \ + : \ + : "r"(ptr), "r"(0) \ + : "memory"); \ +}while(0) + +typedef struct {unsigned long l2e; }l2e_t ;typedef struct {unsigned long l1e; }l1e_t ;
xen/include/asm-arm/platform.h new file +62 -0
62 lines not on this page · raw message
arm: allow access to the xenheap and the boot pages.
This patch collects machine page frames, creates frame table to allow access to the xenheap and the boot pages.
xen/arch/arm/xen/mm.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/xen/setup.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xen/common/page_alloc.c | 5 +++ xen/include/asm-arm/mm.h | 28 +++++++++++++++++++++ xen/include/asm-arm/mmu.h | 10 +++++++ xen/include/asm-arm/platform.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++
Signed-off-by Jaemin Ryu <[email protected]>
xen/arch/arm/xen/mm.c +65 -0
68 lines not on this page · raw message
xen/arch/arm/xen/setup.c +115 -0
133 lines not on this page · raw message
xen/common/page_alloc.c +5 -0
@@ -146,6 +146,11 @@ static void __init bootmem_region_zap(un } } +void __init reserve_boot_pages (paddr_t ps,paddr_t pe) +{ +bootmem_region_zap (ps >>PAGE_SHIFT , pe >>PAGE_SHIFT ); +} +void __init init_boot_pages (paddr_t ps,paddr_t pe) {unsigned long bad_spfn, bad_epfn;
xen/include/asm-arm/mm.h +28 -0
@@ -108,6 +108,13 @@#define write_ptbase (v) cpu_switch_ttb((v)->arch.ctx.ttbr0) +#if 0 +#undef page_list_entry +struct page_list_entry +{ +unsigned long next, prev; +}; +#endif struct page_info {struct page_list_entry list;
@@ -187,6 +194,7 @@ extern unsigned long min_page, max_page;extern struct domain *dom_xen, *dom_io, *dom_cow;extern struct page_info *frame_table; +extern l1e_t *xen_translation_table;void memguard_guard_stack (void *p);void share_xen_page_with_guest (struct page_info *page,struct domain *d,int readonly);
@@ -214,6 +222,11 @@ long arch_memory_op(int op, XEN_GUEST_HAint map_pages_to_xen (unsigned long virt,unsigned long mfn,int nr,unsigned long flags); +unsigned long alloc_page_map_tables (l1e_t *l1e); + +int alloc_page_map (unsigned long virt,unsigned long phys,unsigned int size,unsigned int flags); + +static inline void put_page_and_type (struct page_info *page) {put_page_type (page);
@@ -234,4 +247,19 @@ static inline int get_page_and_type(stru return rc; } +/* +* TDB : Page owner setting. +*/ +#define alloc_pages (nr) \ + (alloc_boot_pages(nr, PAGE_SIZE) << PAGE_SHIFT) + +#define alloc_clean_pages (nr) \ +({ \ + unsigned long page; \ + page = alloc_pages(nr); \ + if (page) { \ + memset(page, 0, nr << PAGE_SHIFT); \ + } \ + page; \ +})#endif /* __ARM_MM_H__ */
xen/include/asm-arm/mmu.h +10 -0
@@ -140,6 +140,16 @@#define l1_linear_offset_xen (va) \ (l1_linear_offset((xen_translation_table), va)) +#define pte_sync (ptr) \ +do { \ + __asm__ __volatile__( \ + "mcr p15, 0, %0, c7, c10, 1 @ clean D entry \n" \ + : \ + : "r"(ptr), "r"(0) \ + : "memory"); \ +}while(0) + +typedef struct {unsigned long l2e; }l2e_t ;typedef struct {unsigned long l1e; }l1e_t ;
xen/include/asm-arm/platform.h new file +62 -0
62 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel