Support for sparse physical address space on ARM
v3 cover Support for sparse physical address space on ARM
This series refactors the x86 "pdx" stuff (phys address space compression) into common code and makes use of it on ARM.
Since last time I've addressed some review comments, the biggest change is refactoring a bit more x86 code (the fill_mask stuff) into common code.
I'm still targeting this at 4.5.
The code is also available from
git://xenbits.xen.org/people/ianc/xen.git pdx-v3
Ian.
PATCH v3 1/3 xen: refactor physical address space compression support into common code
The "pdx compression" functionality will be useful on ARM as well.
Move the code to common code+header and introduce HAS_PDX to control when it is built. L2_PAGETABLE_SHIFT is x86 specific, so introduce PDX_GROUP_SHIFT to abstract it out.
ARM has no need for superpage compression (yet?) and lacks SUPERPAGE_SHIFT so those functions (spage_to_mfn et al) are not moved.
No affect on x86 and no change for ARM (yet).
---
v3:
- Really correct the comment.
v2:
- Correct closing guard comment in pdx.h
--- xen/Rules.mk | 1 + xen/arch/x86/Rules.mk | 1 + xen/arch/x86/mm.c | 3 -- xen/arch/x86/setup.c | 10 ---- xen/arch/x86/x86_64/mm.c | 53 -------------------- xen/common/Makefile | 1 + xen/common/pdx.c | 99 +++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/mm.h | 4 +- xen/include/asm-x86/page.h | 2 - xen/include/asm-x86/x86_64/page.h | 25 +--------- xen/include/xen/pdx.h | 47 ++++++++++++++++++ 11 files changed, 152 insertions(+), 94 deletions(-) create mode 100644 xen/common/pdx.c create mode 100644 xen/include/xen/pdx.h
xen/Rules.mk +1 -0
@@ -59,6 +59,7 @@ CFLAGS-$(HAS_PASSTHROUGH) += -DHAS_PASSTHROUGH CFLAGS-$(HAS_DEVICE_TREE) += -DHAS_DEVICE_TREE CFLAGS-$(HAS_PCI) += -DHAS_PCI CFLAGS-$(HAS_IOPORTS) += -DHAS_IOPORTS +CFLAGS-$(HAS_PDX) += -DHAS_PDX CFLAGS-$(frame_pointer) += -fno-omit-frame-pointer -DCONFIG_FRAME_POINTER ifneq ($(max_phys_cpus),)
xen/arch/x86/Rules.mk +1 -0
@@ -12,6 +12,7 @@ HAS_NS16550 := y HAS_EHCI := y HAS_KEXEC := y HAS_GDBSX := y +HAS_PDX := y xenoprof := y #
xen/arch/x86/mm.c +0 -3
@@ -147,9 +147,6 @@ struct domain *dom_xen, *dom_io, *dom_cow;unsigned long max_page;unsigned long total_pages; -unsigned long __read_mostly pdx_group_valid[BITS_TO_LONGS ( - (FRAMETABLE_NR +PDX_GROUP_COUNT -1 ) /PDX_GROUP_COUNT )] = { [0 ] =1 }; -bool_t __read_mostly machine_to_phys_mapping_valid =0 ;struct rangeset *__read_mostly mmio_ro_ranges;
xen/arch/x86/setup.c +0 -10
@@ -392,16 +392,6 @@ static void __init setup_max_pdx(unsigned long top_page) max_page =pdx_to_pfn (max_pdx -1 ) +1 ; } -void set_pdx_range (unsigned long smfn,unsigned long emfn) -{ -unsigned long idx, eidx; - - idx =pfn_to_pdx (smfn) /PDX_GROUP_COUNT ; - eidx = (pfn_to_pdx (emfn -1 ) +PDX_GROUP_COUNT ) /PDX_GROUP_COUNT ; -for ( ; idx < eidx; ++idx ) -__set_bit (idx, pdx_group_valid); -} -/* A temporary copy of the e820 map that we can mess with during bootstrap. */ static struct e820map __initdata boot_e820;
xen/arch/x86/x86_64/mm.c +0 -53
71 lines not on this page · raw message
xen/common/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-y += tmem_xen.o obj-y += radix-tree.o obj-y += rbtree.o obj-y += lzo.o +obj-$(HAS_PDX) += pdx.o obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 earlycpio,$(n).init.o)
xen/common/pdx.c new file +99 -0
99 lines not on this page · raw message
xen/include/asm-x86/mm.h +1 -3
@@ -280,9 +280,7 @@ extern unsigned long max_page;extern unsigned long total_pages;void init_frametable (void ); -#define PDX_GROUP_COUNT ((1 << L2_PAGETABLE_SHIFT) / \ - (sizeof(*frame_table) & -sizeof(*frame_table))) -extern unsigned long pdx_group_valid[]; +#define PDX_GROUP_SHIFT L2_PAGETABLE_SHIFT/* Convert between Xen-heap virtual addresses and page-info structures. */ static inline struct page_info *__virt_to_page (const void *v)
xen/include/asm-x86/page.h +0 -2
@@ -334,8 +334,6 @@ void *alloc_xen_pagetable(void);void free_xen_pagetable (void *v);l1_pgentry_t *virt_to_xen_l1e (unsigned long v); -extern void set_pdx_range (unsigned long smfn,unsigned long emfn); -/* Convert between PAT/PCD/PWT embedded in PTE flags and 3-bit cacheattr. */ static inline uint32_t pte_flags_to_cacheattr (uint32_t flags) {
xen/include/asm-x86/x86_64/page.h +2 -23
@@ -35,17 +35,10 @@#include <xen/config.h> #include <asm/types.h> -extern unsigned long xen_virt_end; +#include <xen/pdx.h> -extern unsigned long max_pdx; -extern unsigned long pfn_pdx_bottom_mask, ma_va_bottom_mask; -extern unsigned int pfn_pdx_hole_shift; -extern unsigned long pfn_hole_mask; -extern unsigned long pfn_top_mask, ma_top_mask; -extern void pfn_pdx_hole_setup (unsigned long ); +extern unsigned long xen_virt_end; -#define page_to_pdx (pg) ((pg) - frame_table) -#define pdx_to_page (pdx) (frame_table + (pdx))#define spage_to_pdx (spg) (((spg) - spage_table)<<(SUPERPAGE_SHIFT-PAGE_SHIFT))#define pdx_to_spage (pdx) (spage_table + ((pdx)>>(SUPERPAGE_SHIFT-PAGE_SHIFT)))/*
@@ -57,20 +50,6 @@ extern void pfn_pdx_hole_setup(unsigned long);#define pdx_to_virt (pdx) ((void *)(DIRECTMAP_VIRT_START + \ ((unsigned long)(pdx) << PAGE_SHIFT))) -extern int __mfn_valid (unsigned long mfn); - -static inline unsigned long pfn_to_pdx (unsigned long pfn) -{ -return (pfn & pfn_pdx_bottom_mask) | - ((pfn & pfn_top_mask) >> pfn_pdx_hole_shift); -} - -static inline unsigned long pdx_to_pfn (unsigned long pdx) -{ -return (pdx & pfn_pdx_bottom_mask) | - ((pdx << pfn_pdx_hole_shift) & pfn_top_mask); -} -static inline unsigned long pfn_to_sdx (unsigned long pfn) {return pfn_to_pdx (pfn) >> (SUPERPAGE_SHIFT -PAGE_SHIFT );
xen/include/xen/pdx.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 2/3 xen: add helpers for PDX mask initialisation calculations
In reply to Ian CampbellI wanted to make fill_mask a public function so I could use it on ARM, but it was actually easier to think of a (semi) reasonable public name for the users of it, so that is what I have done.
---
v3: New patch
--- xen/arch/x86/srat.c | 16 +++------------- xen/common/pdx.c | 18 ++++++++++++++++++ xen/include/xen/pdx.h | 3 +++ 3 files changed, 24 insertions(+), 13 deletions(-)
xen/arch/x86/srat.c +3 -13
@@ -339,13 +339,6 @@ void __init acpi_numa_arch_fixup(void) {}static u64 __initdata srat_region_mask; -static u64 __init fill_mask (u64 mask) -{ -while (mask & (mask +1 )) - mask |= mask +1 ; -return mask; -} -static int __init srat_parse_region (struct acpi_subtable_header *header,const unsigned long end) {
@@ -366,8 +359,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header, ma->base_address, ma->base_address + ma->length - 1); srat_region_mask |= ma->base_address | -fill_mask (ma->base_address ^ - (ma->base_address + ma->length -1 )); +pdx_region_mask (ma->base_address, ma->length);return 0 ; }
@@ -381,7 +373,7 @@ void __init srat_parse_regions(u64 addr) acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) return; - srat_region_mask =fill_mask (addr -1 ); + srat_region_mask =pdx_init_mask (addr);acpi_table_parse_srat (ACPI_SRAT_TYPE_MEMORY_AFFINITY , srat_parse_region,0 );
@@ -389,9 +381,7 @@ void __init srat_parse_regions(u64 addr)if (e820.map[i].type !=E820_RAM )continue ; -if (~mask & -fill_mask (e820.map[i].addr ^ - (e820.map[i].addr + e820.map[i].size -1 ))) +if (~mask &pdx_region_mask (e820.map[i].addr, e820.map[i].size)) mask =0 ; }
xen/common/pdx.c +18 -0
@@ -41,6 +41,24 @@ int __mfn_valid(unsigned long mfn) pdx_group_valid)); } +/* Sets all bits from the most-significant 1-bit down to the LSB */ +static u64 __init fill_mask (u64 mask) +{ +while (mask & (mask +1 )) + mask |= mask +1 ; +return mask; +} + +u64 pdx_init_mask (u64 base_addr) +{ +return fill_mask (base_addr -1 ); +} + +u64 pdx_region_mask (u64 base,u64 len) +{ +return fill_mask (base ^ (base + len -1 )); +} +void set_pdx_range (unsigned long smfn,unsigned long emfn) {unsigned long idx, eidx;
xen/include/xen/pdx.h +3 -0
@@ -13,6 +13,9 @@ extern unsigned long pfn_top_mask, ma_top_mask; (sizeof(*frame_table) & -sizeof(*frame_table)))extern unsigned long pdx_group_valid[]; +extern u64 pdx_init_mask (u64 base_addr); +extern u64 pdx_region_mask (u64 base,u64 len); +extern void set_pdx_range (unsigned long smfn,unsigned long emfn);#define page_to_pdx (pg) ((pg) - frame_table)
Signature · 1 line
1.7.10.4
Re: [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 17.09.14 at 23:21, <[email protected]> wrote:
I wanted to make
fill_maska public function so I could use it on ARM, but it was actually easier to think of a (semi) reasonable public name for the users
of it, so that is what I have done.Signed-off-by Ian Campbell <[email protected]>
Re: [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations
In reply to Ian CampbellHi Ian,
Quoted 9 lines · Ian Campbell
xen/common/pdx.c +9
-0+/* Sets all bits from the most-significant 1-bit down to the LSB */ +static u64 __init fill_mask (u64 mask) +{ +while (mask & (mask +1 )) + mask |= mask +1 ; +return mask; +} + +u64 pdx_init_mask (u64 base_addr)
[..]
Quoted 1 line
+u64
pdx_region_mask(u64 base, u64 len)
fill_mask is marked as __init. For consistency, those 2 functions should be marked too.
Regards,
Signature · 1 line
Julien Grall
Ian Campbell
Acked-by Jan BeulichRe: [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations
Quoted 4 lines · Julien Grall
Quoted 1 line
+u64
pdx_region_mask(u64 base, u64 len)
fill_maskis marked as__init. For consistency, those 2 functions should be marked too.
Just resending that one patch:
--------------------------
Quoted 1 line
From
6a554cc2d7dc076eb4f6ed6f922fa95eea113fa5Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Tue, 16 Sep 2014 21:01:41 +0100
Subject: [PATCH] xen: add helpers for PDX mask initialisation calculations
I wanted to make fill_mask a public function so I could use it on ARM, but it was actually easier to think of a (semi) reasonable public name for the users of it, so that is what I have done.
---
v3.1: Added __init to new functions.
v3: New patch
--- xen/arch/x86/srat.c | 16 +++------------- xen/common/pdx.c | 18 ++++++++++++++++++ xen/include/xen/pdx.h | 3 +++ 3 files changed, 24 insertions(+), 13 deletions(-)
xen/arch/x86/srat.c +3 -13
@@ -339,13 +339,6 @@ void __init acpi_numa_arch_fixup(void) {}static u64 __initdata srat_region_mask; -static u64 __init fill_mask (u64 mask) -{ -while (mask & (mask +1 )) - mask |= mask +1 ; -return mask; -} -static int __init srat_parse_region (struct acpi_subtable_header *header,const unsigned long end) {
@@ -366,8 +359,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header, ma->base_address, ma->base_address + ma->length - 1); srat_region_mask |= ma->base_address | -fill_mask (ma->base_address ^ - (ma->base_address + ma->length -1 )); +pdx_region_mask (ma->base_address, ma->length);return 0 ; }
@@ -381,7 +373,7 @@ void __init srat_parse_regions(u64 addr) acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) return; - srat_region_mask =fill_mask (addr -1 ); + srat_region_mask =pdx_init_mask (addr);acpi_table_parse_srat (ACPI_SRAT_TYPE_MEMORY_AFFINITY , srat_parse_region,0 );
@@ -389,9 +381,7 @@ void __init srat_parse_regions(u64 addr)if (e820.map[i].type !=E820_RAM )continue ; -if (~mask & -fill_mask (e820.map[i].addr ^ - (e820.map[i].addr + e820.map[i].size -1 ))) +if (~mask &pdx_region_mask (e820.map[i].addr, e820.map[i].size)) mask =0 ; }
xen/common/pdx.c +18 -0
@@ -41,6 +41,24 @@ int __mfn_valid(unsigned long mfn) pdx_group_valid)); } +/* Sets all bits from the most-significant 1-bit down to the LSB */ +static u64 __init fill_mask (u64 mask) +{ +while (mask & (mask +1 )) + mask |= mask +1 ; +return mask; +} + +u64 __init pdx_init_mask (u64 base_addr) +{ +return fill_mask (base_addr -1 ); +} + +u64 __init pdx_region_mask (u64 base,u64 len) +{ +return fill_mask (base ^ (base + len -1 )); +} +void set_pdx_range (unsigned long smfn,unsigned long emfn) {unsigned long idx, eidx;
xen/include/xen/pdx.h +3 -0
@@ -13,6 +13,9 @@ extern unsigned long pfn_top_mask, ma_top_mask; (sizeof(*frame_table) & -sizeof(*frame_table)))extern unsigned long pdx_group_valid[]; +extern u64 pdx_init_mask (u64 base_addr); +extern u64 pdx_region_mask (u64 base,u64 len); +extern void set_pdx_range (unsigned long smfn,unsigned long emfn);#define page_to_pdx (pg) ((pg) - frame_table)
Signature · 1 line
1.7.10.4
Julien Grall
Reviewed-byRe: [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations
Hi Ian,
Quoted 15 lines · Ian Campbell
Quoted 4 lines · Julien Grall
Quoted 1 line
+u64
pdx_region_mask(u64 base, u64 len)
fill_maskis marked as__init. For consistency, those 2 functions should be marked too.Just resending that one patch:
--------------------------
From
6a554cc2d7dc076eb4f6ed6f922fa95eea113fa5Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Tue, 16 Sep 2014 21:01:41 +0100
Subject: [PATCH] xen: add helpers for PDX mask initialisation calculations
Quoted 6 lines
I wanted to make
fill_maska public function so I could use it on ARM, but it was actually easier to think of a (semi) reasonable public name for the users of it, so that is what I have done.Signed-off-by Ian Campbell <[email protected]>Acked-by Jan Beulich <[email protected]>
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations
Quoted 18 lines · Julien Grall
Hi Ian,
Quoted 15 lines · Ian Campbell
Quoted 4 lines · Julien Grall
Quoted 1 line
+u64
pdx_region_mask(u64 base, u64 len)
fill_maskis marked as__init. For consistency, those 2 functions should be marked too.Just resending that one patch:
--------------------------
From
6a554cc2d7dc076eb4f6ed6f922fa95eea113fa5Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Tue, 16 Sep 2014 21:01:41 +0100
Subject: [PATCH] xen: add helpers for PDX mask initialisation calculations
Quoted 7 lines
Quoted 6 lines
I wanted to make
fill_maska public function so I could use it on ARM, but it was actually easier to think of a (semi) reasonable public name for the users of it, so that is what I have done.Signed-off-by Ian Campbell <[email protected]>Acked-by Jan Beulich <[email protected]>Reviewed-by Julien Grall <[email protected]>
Thanks. Applied the whole series.
Ian.
PATCH v3 3/3 xen: arm: Enable physical address space compression (PDX) on arm
In reply to Ian CampbellThis allows us to support sparse physical address maps which we previously could not because the frametable would end up taking up an enormous fraction of RAM.
On a fast model which has RAM at 0x80000000-0x100000000 and 0x880000000-0x900000000 this reduces the size of the frametable from 478M to 84M.
---
v3:
- Spelling in commit log and correct $SUBJ
- Remove stray trailing blank
- Drop nolonger required check that we use all banks
- Use new pdx_{init_mask,region_mask} functions
v2:
- Implement support for arm32 (tested on models).
- Simplify the arm64 stuff a bit
- Fixedsome bugs
--- xen/arch/arm/Rules.mk | 1 + xen/arch/arm/mm.c | 17 +++--- xen/arch/arm/setup.c | 132 ++++++++++++++++-------------------------- xen/include/asm-arm/config.h | 11 +++- xen/include/asm-arm/mm.h | 37 ++++++------ xen/include/asm-arm/numa.h | 2 +- 6 files changed, 89 insertions(+), 111 deletions(-)
xen/arch/arm/Rules.mk +1 -0
@@ -10,6 +10,7 @@ HAS_DEVICE_TREE := y HAS_VIDEO := y HAS_ARM_HDLCD := y HAS_PASSTHROUGH := y +HAS_PDX := y CFLAGS += -I$(BASEDIR)/include
xen/arch/arm/mm.c +9 -8
@@ -138,7 +138,7 @@ unsigned long xenheap_mfn_start __read_mostly = ~0UL;unsigned long xenheap_mfn_end__read_mostly ;unsigned long xenheap_virt_end__read_mostly ; -unsigned long frametable_base_mfn__read_mostly ; +unsigned long frametable_base_pdx__read_mostly ;unsigned long frametable_virt_end__read_mostly ;unsigned long max_page;
@@ -665,7 +665,7 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,/* Align to previous 1GB boundary */ base_mfn &= ~((FIRST_SIZE >>PAGE_SHIFT )-1 ); - offset = base_mfn - xenheap_mfn_start; + offset =pfn_to_pdx (base_mfn - xenheap_mfn_start); vaddr =DIRECTMAP_VIRT_START + offset*PAGE_SIZE ;while ( base_mfn < end_mfn )
@@ -716,7 +716,8 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,void __init setup_frametable_mappings (paddr_t ps,paddr_t pe) {unsigned long nr_pages = (pe - ps) >>PAGE_SHIFT ; -unsigned long frametable_size = nr_pages *sizeof (struct page_info ); +unsigned long nr_pdxs =pfn_to_pdx (nr_pages); +unsigned long frametable_size = nr_pdxs *sizeof (struct page_info );unsigned long base_mfn;#ifdef CONFIG_ARM_64 lpae_t *second, pte;
@@ -724,7 +725,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)int i;#endif - frametable_base_mfn = ps >>PAGE_SHIFT ; + frametable_base_pdx =pfn_to_pdx (ps >>PAGE_SHIFT );/* Round up to 32M boundary */ frametable_size = (frametable_size +0x1ffffff ) & ~0x1ffffff ;
@@ -745,11 +746,11 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)create_32mb_mappings (xen_second,FRAMETABLE_VIRT_START , base_mfn, frametable_size >>PAGE_SHIFT );#endif -memset (&frame_table[0 ],0 , nr_pages *sizeof (struct page_info )); -memset (&frame_table[nr_pages],-1 , - frametable_size - (nr_pages *sizeof (struct page_info ))); +memset (&frame_table[0 ],0 , nr_pdxs *sizeof (struct page_info )); +memset (&frame_table[nr_pdxs],-1 , + frametable_size - (nr_pdxs *sizeof (struct page_info ))); - frametable_virt_end =FRAMETABLE_VIRT_START + (nr_pages *sizeof (struct page_info )); + frametable_virt_end =FRAMETABLE_VIRT_START + (nr_pdxs *sizeof (struct page_info )); }void *__init arch_vmap_virt_end (void )
xen/arch/arm/setup.c +50 -82
179 lines not on this page · raw message
xen/include/asm-arm/config.h +9 -2
@@ -126,7 +126,12 @@#define CONFIG_SEPARATE_XENHEAP 1#define FRAMETABLE_VIRT_START _AT(vaddr_t,0x02000000) -#define VMAP_VIRT_START _AT(vaddr_t,0x10000000) +#define FRAMETABLE_SIZE MB(128-32) +#define FRAMETABLE_NR (FRAMETABLE_SIZE / sizeof(*frame_table)) +#define FRAMETABLE_VIRT_END (FRAMETABLE_VIRT_START + FRAMETABLE_SIZE - 1) + +#define VMAP_VIRT_START _AT(vaddr_t,0x10000000) +#define XENHEAP_VIRT_START _AT(vaddr_t,0x40000000)#define XENHEAP_VIRT_END _AT(vaddr_t,0x7fffffff)#define DOMHEAP_VIRT_START _AT(vaddr_t,0x80000000)
@@ -149,7 +154,9 @@#define VMAP_VIRT_END (VMAP_VIRT_START + GB(1) - 1)#define FRAMETABLE_VIRT_START GB(32) -#define FRAMETABLE_VIRT_END (FRAMETABLE_VIRT_START + GB(32) - 1) +#define FRAMETABLE_SIZE GB(32) +#define FRAMETABLE_NR (FRAMETABLE_SIZE / sizeof(*frame_table)) +#define FRAMETABLE_VIRT_END (FRAMETABLE_VIRT_START + FRAMETABLE_SIZE - 1)#define DIRECTMAP_VIRT_START SLOT0(256)#define DIRECTMAP_SIZE (SLOT0_ENTRY_SIZE * (265-256))
xen/include/asm-arm/mm.h +19 -18
@@ -6,6 +6,7 @@#include <asm/page.h> #include <public/xen.h> #include <xen/domain_page.h> +#include <xen/pdx.h> /* Align Xen to a 2 MiB boundary. */ #define XEN_PADDR_ALIGN (1 << 21)
@@ -140,12 +141,14 @@ extern void share_xen_page_with_privileged_guests( struct page_info *page, int readonly);#define frame_table ((struct page_info *)FRAMETABLE_VIRT_START) -/* MFN of the first page in the frame table. */ -extern unsigned long frametable_base_mfn; +/* PDX of the first page in the frame table. */ +extern unsigned long frametable_base_pdx;extern unsigned long max_page;extern unsigned long total_pages; +#define PDX_GROUP_SHIFT SECOND_SHIFT +/* Boot-time pagetable setup */ extern void setup_pagetables (unsigned long boot_phys_offset,paddr_t xen_paddr);/* Remove early mappings */
@@ -184,20 +187,15 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len)return ioremap_attr (start, len,PAGE_HYPERVISOR_WC ); } +/* XXX -- account for base */ #define mfn_valid (mfn) ({ \ unsigned long __m_f_n = (mfn); \ - likely(__m_f_n >= frametable_base_mfn && __m_f_n < max_page); \ + likely(pfn_to_pdx(__m_f_n) >= frametable_base_pdx && __mfn_valid(__m_f_n)); \ }) -#define max_pdx max_page -#define pfn_to_pdx (pfn) (pfn) -#define pdx_to_pfn (pdx) (pdx) -#define virt_to_pdx (va) virt_to_mfn(va) -#define pdx_to_virt (pdx) mfn_to_virt(pdx) -/* Convert between machine frame numbers and page-info structures. */ -#define mfn_to_page (mfn) (frame_table + (pfn_to_pdx(mfn) - frametable_base_mfn)) -#define page_to_mfn (pg) pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_mfn) +#define mfn_to_page (mfn) (frame_table + (pfn_to_pdx(mfn) - frametable_base_pdx)) +#define page_to_mfn (pg) pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_pdx)#define __page_to_mfn (pg) page_to_mfn(pg)#define __mfn_to_page (mfn) mfn_to_page(mfn)
@@ -230,9 +228,11 @@ static inline void *maddr_to_virt(paddr_t ma)#else static inline void *maddr_to_virt (paddr_t ma) { -ASSERT ((ma >>PAGE_SHIFT ) < (DIRECTMAP_SIZE >>PAGE_SHIFT )); - ma -=pfn_to_paddr (xenheap_mfn_start); -return (void *)(unsigned long ) ma +DIRECTMAP_VIRT_START ; +ASSERT (pfn_to_pdx (ma >>PAGE_SHIFT ) < (DIRECTMAP_SIZE >>PAGE_SHIFT )); +return (void *)(DIRECTMAP_VIRT_START - +pfn_to_paddr (xenheap_mfn_start) + + ((ma & ma_va_bottom_mask) | + ((ma & ma_top_mask) >> pfn_pdx_hole_shift))); }#endif
@@ -258,13 +258,14 @@ static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags)static inline struct page_info *virt_to_page (const void *v) {unsigned long va = (unsigned long )v; +unsigned long pdx; +ASSERT (va >=XENHEAP_VIRT_START );ASSERT (va < xenheap_virt_end); -return frame_table - + ((va -XENHEAP_VIRT_START ) >>PAGE_SHIFT ) - + xenheap_mfn_start - - frametable_base_mfn; + pdx = (va -XENHEAP_VIRT_START ) >>PAGE_SHIFT ; + pdx +=pfn_to_pdx (xenheap_mfn_start); +return frame_table + pdx - frametable_base_pdx; }static inline void *page_to_virt (const struct page_info *pg)
xen/include/asm-arm/numa.h +1 -1
@@ -12,7 +12,7 @@ static inline __attribute__((pure)) int phys_to_nid(paddr_t addr)/* XXX: implement NUMA support */ #define node_spanned_pages (nid) (total_pages) -#define node_start_pfn (nid) (frametable_base_mfn) +#define node_start_pfn (nid) (pdx_to_pfn(frametable_base_pdx))#define __node_distance (a, b) (20)#endif /* __ARCH_ARM_NUMA_H */
Signature · 1 line
1.7.10.4
Re: [PATCH for-4.5 v3 3/3] xen: arm: Enable physical address space compression (PDX) on arm
Hi Ian,
Quoted 9 lines · Ian Campbell
This allows us to support sparse physical address maps which we previously could not because the frametable would end up taking up an enormous fraction of RAM.
On a fast model which has RAM at 0x80000000-0x100000000 and 0x880000000-0x900000000 this reduces the size of the frametable from 478M to 84M.
Signed-off-by Ian Campbell <[email protected]>
Regards,
Signature · 1 line
Julien Grall
Quoted 7 lines · Ian Campbell
This series refactors the x86 "pdx" stuff (phys address space compression) into common code and makes use of it on ARM.
Since last time I've addressed some review comments, the biggest change is refactoring a bit more x86 code (the
fill_maskstuff) into common code.
Quoted 7 lines
I'm still targeting this at 4.5.
The code is also available from
git://xenbits.xen.org/people/ianc/xen.gitpdx-v3Ian.
This works for me on arm64, tested with my EFI boot patches on the FVP model with disjoint memory regions.
Roy