xen: remove some memory limits from pv-domains
Subsystems (3)
Juergen Gross
maintainerv2 cover xen: remove some memory limits from pv-domains
When a Xen pv-domain is booted the initial memory map contains multiple objects in the top 2 GB including the initrd and the p2m list. This limits the supported maximum size of the initrd and the maximum memory size the p2m list can span is limited to about 500 GB.
Xen however supports loading the initrd without mapping it and the initial p2m list can be mapped by Xen to an arbitrary selected virtual address. The following patches activate those options and thus remove the limitations.
It should be noted that the p2m list limitation isn't only affecting the amount of memory a pv domain can use, but it also hinders Dom0 to be started on physical systems with larger memory without reducing it's memory via a Xen boot parameter. By mapping the initial p2m list to an area not in the top 2 GB it is now possible to boot Dom0 on such systems.
It would be desirable to be able to use more than 512 GB in a pv domain, but this would require a reorganization of the p2m tree built by the kernel at boot time. As this reorganization would affect the Xen tools and kexec, too, it is not included in this patch set. This topic can be addressed later.
Juergen Gross (3):
xen: sync some headers with xen tree
xen: eliminate scalability issues from initrd handling
xen: eliminate scalability issues from initial mapping setup
arch/x86/xen/enlighten.c | 11 +- arch/x86/xen/mmu.c | 115 +++++++++++++++-- arch/x86/xen/setup.c | 65 +++++----- arch/x86/xen/xen-head.S | 3 + include/xen/interface/elfnote.h | 48 ++++++- include/xen/interface/xen.h | 272 ++++++++++++++++++++++++++++++++++++---- 6 files changed, 451 insertions(+), 63 deletions(-)
Signature · 1 line
1.8.4.5
Juergen Gross
maintainerPATCH v2 1/3 xen: sync some headers with xen tree
To be able to use an initially unmapped initrd with xen the following header files must be synced to a newer version from the xen tree:
include/xen/interface/elfnote.hinclude/xen/interface/xen.h
As the KEXEC and DUMPCORE related ELFNOTES are not relevant for the kernel they are omitted from elfnote.h.
--- include/xen/interface/elfnote.h | 48 ++++++- include/xen/interface/xen.h | 272 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 294 insertions(+), 26 deletions(-)
include/xen/interface/elfnote.h +46 -2
@@ -3,6 +3,24 @@* * Definitions used for the Xen ELF notes. * +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* * Copyright (c) 2006, Ian Campbell, XenSource Ltd. */
@@ -18,12 +36,13 @@* * LEGACY indicated the fields in the legacy __xen_guest string which * this a note type replaces. +* +* String values (for non-legacy) are NULL terminated ASCII, also known +* as ASCIZ type. */ /* * NAME=VALUE pair (string). -* -* LEGACY: FEATURES and PAE */ #define XEN_ELFNOTE_INFO 0
@@ -137,10 +156,30 @@/* * Whether or not the guest supports cooperative suspend cancellation. +* This is a numeric value. +* +* Default is 0 */ #define XEN_ELFNOTE_SUSPEND_CANCEL 14/* +* The (non-default) location the initial phys-to-machine map should be +* placed at by the hypervisor (Dom0) or the tools (DomU). +* The kernel must be prepared for this mapping to be established using +* large pages, despite such otherwise not being available to guests. +* The kernel must also be able to handle the page table pages used for +* this mapping not being accessible through the initial mapping. +* (Only x86-64 supports this at present.) +*/ +#define XEN_ELFNOTE_INIT_P2M 15 + +/* +* Whether or not the guest can deal with being passed an initrd not +* mapped through its initial page tables. +*/ +#define XEN_ELFNOTE_MOD_START_PFN 16 + +/* * The features supported by this kernel (numeric). * * Other than XEN_ELFNOTE_FEATURES on pre-4.2 Xen, this note allows a
@@ -153,6 +192,11 @@*/ #define XEN_ELFNOTE_SUPPORTED_FEATURES 17 +/* +* The number of the highest elfnote defined. +*/ +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES +#endif /* __XEN_PUBLIC_ELFNOTE_H__ */ /*
include/xen/interface/xen.h +248 -24
373 lines not on this page · raw message
Signature · 1 line
1.8.4.5
Juergen Gross
maintainerPATCH v2 2/3 xen: eliminate scalability issues from initrd handling
In reply to Juergen GrossSize restrictions native kernels wouldn't have resulted from the initrd getting mapped into the initial mapping. The kernel doesn't really need the initrd to be mapped, so use infrastructure available in Xen to avoid the mapping and hence the restriction.
--- arch/x86/xen/enlighten.c | 11 +++++++++-- arch/x86/xen/xen-head.S | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)
arch/x86/xen/enlighten.c +9 -2
@@ -1519,6 +1519,7 @@ static void __init xen_pvh_early_guest_init(void) asmlinkage __visible void __init xen_start_kernel(void) {struct physdev_set_iopl set_iopl; +unsigned long initrd_start =0 ;int rc;if (!xen_start_info)
@@ -1667,10 +1668,16 @@ asmlinkage __visible void __init xen_start_kernel(void) new_cpu_data.x86_capability[0 ] =cpuid_edx (1 );#endif +if (xen_start_info->mod_start) + initrd_start =__pa (xen_start_info->mod_start); +#ifdef CONFIG_BLK_DEV_INITRD +if (xen_start_info->flags &SIF_MOD_START_PFN ) + initrd_start =PFN_PHYS (xen_start_info->mod_start); +#endif +/* Poke various useful things into boot_params */ boot_params.hdr.type_of_loader = (9 <<4 ) |0 ; - boot_params.hdr.ramdisk_image = xen_start_info->mod_start - ?__pa (xen_start_info->mod_start) :0 ; + boot_params.hdr.ramdisk_image = initrd_start; boot_params.hdr.ramdisk_size = xen_start_info->mod_len; boot_params.hdr.cmd_line_ptr =__pa (xen_start_info->cmd_line);
arch/x86/xen/xen-head.S +1 -0
@@ -124,6 +124,7 @@ NEXT_HYPERCALL(arch_6) ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad _PAGE_PRESENT; .quad _PAGE_PRESENT) ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1) + ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START) ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
Signature · 1 line
1.8.4.5
Re: [Xen-devel] [PATCH V2 2/3] xen: eliminate scalability issues from initrd handling
Quoted 24 lines · Juergen Gross
Size restrictions native kernels wouldn't have resulted from the initrd getting mapped into the initial mapping. The kernel doesn't really need the initrd to be mapped, so use infrastructure available in Xen to avoid the mapping and hence the restriction.
Signed-off-by Juergen Gross <[email protected]>--- arch/x86/xen/enlighten.c | 11 +++++++++-- arch/x86/xen/xen-head.S | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)arch/x86/xen/enlighten.c +1
-0@@ -1519,6 +1519,7 @@ static void __init xen_pvh_early_guest_init(void) asmlinkage __visible void __init xen_start_kernel(void) {struct physdev_set_iopl set_iopl; +unsigned long initrd_start =0 ;int rc;if (!xen_start_info)
arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1676
Quoted 9 lines
arch/x86/xen/enlighten.c +6
-0@@ -1667,10 +1668,16 @@ asmlinkage __visible void __init xen_start_kernel(void) new_cpu_data.x86_capability[0 ] =cpuid_edx (1 );#endif +if (xen_start_info->mod_start) + initrd_start =__pa (xen_start_info->mod_start); +#ifdef CONFIG_BLK_DEV_INITRD +if (xen_start_info->flags &SIF_MOD_START_PFN ) + initrd_start =PFN_PHYS (xen_start_info->mod_start); +#endif
Why the #ifdef?
I'll fix this up to be:
if (xen_start_info->mod_start) {
if (xen_start_info->flags & SIF_MOD_START_PFN)
initrd_start = PFN_PHYS_(xen_start_info->mod_start);
else
initrd_start = __pa(xen_start_info->mod_start);
}Unless you object.
David
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V2 2/3] xen: eliminate scalability issues from initrd handling
Quoted 39 lines · David Vrabel
Quoted 24 lines · Juergen Gross
Size restrictions native kernels wouldn't have resulted from the initrd getting mapped into the initial mapping. The kernel doesn't really need the initrd to be mapped, so use infrastructure available in Xen to avoid the mapping and hence the restriction.
Signed-off-by Juergen Gross <[email protected]>--- arch/x86/xen/enlighten.c | 11 +++++++++-- arch/x86/xen/xen-head.S | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)arch/x86/xen/enlighten.c +1
-0@@ -1519,6 +1519,7 @@ static void __init xen_pvh_early_guest_init(void) asmlinkage __visible void __init xen_start_kernel(void) {struct physdev_set_iopl set_iopl; +unsigned long initrd_start =0 ;int rc;if (!xen_start_info)arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1676
Quoted 9 lines
arch/x86/xen/enlighten.c +6
-0@@ -1667,10 +1668,16 @@ asmlinkage __visible void __init xen_start_kernel(void) new_cpu_data.x86_capability[0 ] =cpuid_edx (1 );#endif +if (xen_start_info->mod_start) + initrd_start =__pa (xen_start_info->mod_start); +#ifdef CONFIG_BLK_DEV_INITRD +if (xen_start_info->flags &SIF_MOD_START_PFN ) + initrd_start =PFN_PHYS (xen_start_info->mod_start); +#endif Why the #ifdef?
I'll fix this up to be:
Quoted 8 lines
if (xen_start_info->mod_start) { if (xen_start_info->flags & SIF_MOD_START_PFN) initrd_start = PFN_PHYS_(xen_start_info->mod_start); else initrd_start = __pa(xen_start_info->mod_start); }Unless you object.
Yeah, you are right. This seems to be okay.
Juergen
Juergen Gross
maintainerPATCH v2 3/3 xen: eliminate scalability issues from initial mapping setup
In reply to Juergen GrossDirect Xen to place the initial P->M table outside of the initial mapping, as otherwise the 1G (implementation) / 2G (theoretical) restriction on the size of the initial mapping limits the amount of memory a domain can be handed initially.
As the initial P->M table is copied rather early during boot to domain private memory and it's initial virtual mapping is dropped, the easiest way to avoid virtual address conflicts with other addresses in the kernel is to use a user address area for the virtual address of the initial P->M table. This allows us to just throw away the page tables of the initial mapping after the copy without having to care about address invalidation.
--- arch/x86/xen/mmu.c | 115 +++++++++++++++++++++++++++++++++++++++++++++--- arch/x86/xen/setup.c | 65 +++++++++++++++------------ arch/x86/xen/xen-head.S | 2 + 3 files changed, 147 insertions(+), 35 deletions(-)
arch/x86/xen/mmu.c +108 -7
@@ -1198,6 +1198,76 @@ static void __init xen_cleanhighmap(unsigned long vaddr,* instead of somewhere later and be confusing. */ xen_mc_flush (); } + +/* +* Make a page range writeable and free it. +*/ +static void __init xen_free_ro_pages (unsigned long paddr,unsigned long size) +{ +void *vaddr =__va (paddr); +void *vaddr_end = vaddr + size; + +for (; vaddr < vaddr_end; vaddr +=PAGE_SIZE ) +make_lowmem_page_readwrite (vaddr); + +memblock_free (paddr, size); +} + +/* +* Since it is well isolated we can (and since it is perhaps large we should) +* also free the page tables mapping the initial P->M table. +*/ +static void __init xen_cleanmfnmap (unsigned long vaddr) +{ +unsigned long va = vaddr &PMD_MASK ; +unsigned long pa; +pgd_t *pgd =pgd_offset_k (va); +pud_t *pud_page =pud_offset (pgd,0 ); +pud_t *pud; +pmd_t *pmd; +pte_t *pte; +unsigned int i; + +set_pgd (pgd,__pgd (0 )); +do { + pud = pud_page +pud_index (va); +if (pud_none (*pud)) { + va +=PUD_SIZE ; + }else if (pud_large (*pud)) { + pa =pud_val (*pud) &PHYSICAL_PAGE_MASK ; +xen_free_ro_pages (pa,PUD_SIZE ); + va +=PUD_SIZE ; + }else { + pmd =pmd_offset (pud, va); +if (pmd_large (*pmd)) { + pa =pmd_val (*pmd) &PHYSICAL_PAGE_MASK ; +xen_free_ro_pages (pa,PMD_SIZE ); + }else if (!pmd_none (*pmd)) { + pte =pte_offset_kernel (pmd, va); +for (i =0 ; i <PTRS_PER_PTE ; ++i) { +if (pte_none (pte[i])) +break ; + pa =pte_pfn (pte[i]) <<PAGE_SHIFT ; +xen_free_ro_pages (pa,PAGE_SIZE ); + } + pa =__pa (pte) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE ); + } + va +=PMD_SIZE ; +if (pmd_index (va)) +continue ; + pa =__pa (pmd) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE ); + } + + }while (pud_index (va) ||pmd_index (va)); + pa =__pa (pud_page) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE ); +} +static void __init xen_pagetable_p2m_copy (void ) {unsigned long size;
@@ -1217,18 +1287,23 @@ static void __init xen_pagetable_p2m_copy(void)/* using __ka address and sticking INVALID_P2M_ENTRY! */ memset ((void *)xen_start_info->mfn_list,0xff , size); -/* We should be in __ka space. */ -BUG_ON (xen_start_info->mfn_list < __START_KERNEL_map); addr = xen_start_info->mfn_list; -/* We roundup to the PMD, which means that if anybody at this stage is +/* We could be in __ka space. +* We roundup to the PMD, which means that if anybody at this stage is * using the __ka address of xen_start_info or xen_start_info->shared_info * they are in going to crash. Fortunatly we have already revectored * in xen_setup_kernel_pagetable and in xen_setup_shared_info. */ size =roundup (size,PMD_SIZE ); -xen_cleanhighmap (addr, addr + size); - size =PAGE_ALIGN (xen_start_info->nr_pages *sizeof (unsigned long )); -memblock_free (__pa (xen_start_info->mfn_list), size); +if (addr >= __START_KERNEL_map) { +xen_cleanhighmap (addr, addr + size); + size =PAGE_ALIGN (xen_start_info->nr_pages * +sizeof (unsigned long )); +memblock_free (__pa (addr), size); + }else { +xen_cleanmfnmap (addr); + } +/* And revector! Bye bye old array */ xen_start_info->mfn_list = new_mfn_list;
@@ -1529,6 +1604,22 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)#else /* CONFIG_X86_64 */ static pte_t __init mask_rw_pte (pte_t *ptep,pte_t pte) { +unsigned long pfn; + +if (xen_feature (XENFEAT_writable_page_tables) || +xen_feature (XENFEAT_auto_translated_physmap) || + xen_start_info->mfn_list >= __START_KERNEL_map) +return pte; + +/* +* Pages belonging to the initial p2m list mapped outside the default +* address range must be mapped read-only. +*/ + pfn =pte_pfn (pte); +if (pfn >= xen_start_info->first_p2m_pfn && + pfn < xen_start_info->first_p2m_pfn + xen_start_info->nr_p2m_frames) + pte =__pte_ma (pte_val_ma (pte) & ~_PAGE_RW); +return pte; }#endif /* CONFIG_X86_64 */
@@ -1884,7 +1975,10 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)* mappings. Considering that on Xen after the kernel mappings we * have the mappings of some pages that don't exist in pfn space, we * set max_pfn_mapped to the last real pfn mapped. */ - max_pfn_mapped =PFN_DOWN (__pa (xen_start_info->mfn_list)); +if (xen_start_info->mfn_list < __START_KERNEL_map) + max_pfn_mapped = xen_start_info->first_p2m_pfn; +else + max_pfn_mapped =PFN_DOWN (__pa (xen_start_info->mfn_list)); pt_base =PFN_DOWN (__pa (xen_start_info->pt_base)); pt_end = pt_base + xen_start_info->nr_pt_frames;
@@ -1924,6 +2018,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)/* Graft it onto L4[511][510] */ copy_page (level2_kernel_pgt, l2); +/* Copy the initial P->M table mappings if necessary. */ + i =pgd_index (xen_start_info->mfn_list); +if (i && i <pgd_index (__START_KERNEL_map)) + init_level4_pgt[i] = ((pgd_t *)xen_start_info->pt_base)[i]; +if (!xen_feature (XENFEAT_auto_translated_physmap)) {/* Make pagetable pieces RO */ set_page_prot (init_level4_pgt,PAGE_KERNEL_RO );
@@ -1964,6 +2063,8 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)/* Our (by three pages) smaller Xen pagetable that we are using */ memblock_reserve (PFN_PHYS (pt_base), (pt_end - pt_base) *PAGE_SIZE ); +/* protect xen_start_info */ +memblock_reserve (__pa (xen_start_info),PAGE_SIZE );/* Revector the xen_start_info */ xen_start_info = (struct start_info *)__va (__pa (xen_start_info)); }
arch/x86/xen/setup.c +37 -28
83 lines not on this page · raw message
arch/x86/xen/xen-head.S +2 -0
@@ -112,6 +112,8 @@ NEXT_HYPERCALL(arch_6) ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET) #else ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map) + /* Map the p2m table to a 512GB-aligned user address. */ + ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad PGDIR_SIZE) #endif ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen) ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
Signature · 1 line
1.8.4.5
Re: [Xen-devel] [PATCH V2 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 5 lines · Juergen Gross
Direct Xen to place the initial
P->Mtable outside of the initial mapping, as otherwise the 1G (implementation) / 2G (theoretical) restriction on the size of the initial mapping limits the amount of memory a domain can be handed initially.
Quoted 7 lines
As the initial
P->Mtable is copied rather early during boot to domain private memory and it's initial virtual mapping is dropped, the easiest way to avoid virtual address conflicts with other addresses in the kernel is to use a user address area for the virtual address of the initialP->Mtable. This allows us to just throw away the page tables of the initial mapping after the copy without having to care about address invalidation.
This needs an additional paragraph like:
"This does not increase the amount of memory the guest can use. This
is still limited to 512 GiB by the 3-level p2m."
Quoted 3 lines
arch/x86/xen/mmu.c +0
-0@@ -1198,6 +1198,76 @@ static void __init xen_cleanhighmap(unsigned long vaddr,
[...]
Quoted 14 lines
arch/x86/xen/mmu.c +14
-0+/* +* Since it is well isolated we can (and since it is perhaps large we should) +* also free the page tables mapping the initial P->M table. +*/ +static void __init xen_cleanmfnmap (unsigned long vaddr) +{ +unsigned long va = vaddr &PMD_MASK ; +unsigned long pa; +pgd_t *pgd =pgd_offset_k (va); +pud_t *pud_page =pud_offset (pgd,0 ); +pud_t *pud; +pmd_t *pmd; +pte_t *pte; +unsigned int i;
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1239
Quoted 10 lines
arch/x86/xen/mmu.c +10
-0+ +set_pgd (pgd,__pgd (0 )); + do { + pud = pud_page + pud_index(va); + if (pud_none(*pud)) { + va += PUD_SIZE; + } else if (pud_large(*pud)) { + pa = pud_val(*pud) & PHYSICAL_PAGE_MASK; + xen_free_ro_pages(pa, PUD_SIZE); + va += PUD_SIZE;
Are you missing a ClearPagePinned(..) here?
Quoted 7 lines
arch/x86/xen/mmu.c +7
-0+ }else { + pmd =pmd_offset (pud, va); +if (pmd_large (*pmd)) { + pa =pmd_val (*pmd) &PHYSICAL_PAGE_MASK ; +xen_free_ro_pages (pa,PMD_SIZE ); + }else if (!pmd_none (*pmd)) { + pte =pte_offset_kernel (pmd, va);
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1255
Quoted 10 lines
arch/x86/xen/mmu.c +9
-0+for (i =0 ; i <PTRS_PER_PTE ; ++i) { +if (pte_none (pte[i])) +break ; + pa =pte_pfn (pte[i]) <<PAGE_SHIFT ; +xen_free_ro_pages (pa,PAGE_SIZE ); + } + pa =__pa (pte) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE );
Put this into a helper function? It's used here...
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1262
Quoted 7 lines
arch/x86/xen/mmu.c +7
-0+ } + va +=PMD_SIZE ; +if (pmd_index (va)) +continue ; + pa =__pa (pmd) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE );
...and here...
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1268
Quoted 6 lines
arch/x86/xen/mmu.c +6
-0+ } + + }while (pud_index (va) ||pmd_index (va)); + pa =__pa (pud_page) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE );
... and here.
Quoted 4 lines
arch/x86/xen/mmu.c +0
-0@@ -1529,6 +1604,22 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)#else /* CONFIG_X86_64 */ static pte_t __init mask_rw_pte (pte_t *ptep,pte_t pte) {
arch/x86/xen/mmu.c static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte) · line 1616
Quoted 10 lines
arch/x86/xen/mmu.c +10
-0+unsigned long pfn; + +if (xen_feature (XENFEAT_writable_page_tables) || +xen_feature (XENFEAT_auto_translated_physmap) || + xen_start_info->mfn_list >= __START_KERNEL_map) +return pte; + +/* +* Pages belonging to the initial p2m list mapped outside the default +* address range must be mapped read-only.
Why? I didn't think was anything special about these MFNs.
David
Re: [PATCH V2 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 17.09.14 at 16:07, <[email protected]> wrote:
Quoted 14 lines · Juergen Gross
arch/x86/xen/mmu.c +14
-0+static void __init xen_cleanmfnmap (unsigned long vaddr) +{ +unsigned long va = vaddr &PMD_MASK ; +unsigned long pa; +pgd_t *pgd =pgd_offset_k (va); +pud_t *pud_page =pud_offset (pgd,0 ); +pud_t *pud; +pmd_t *pmd; +pte_t *pte; +unsigned int i; + +set_pgd (pgd,__pgd (0 )); + do { + pud = pud_page + pud_index(va);
Quoted 8 lines
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1239
Quoted 6 lines
arch/x86/xen/mmu.c +6
-0+if (pud_none (*pud)) { + va +=PUD_SIZE ; + }else if (pud_large (*pud)) { + pa =pud_val (*pud) &PHYSICAL_PAGE_MASK ; +xen_free_ro_pages (pa,PUD_SIZE ); + va +=PUD_SIZE ;Are you missing a ClearPagePinned(..) here?
No, this is a 1Gb data page, not a page table one.
Jan
Re: [Xen-devel] [PATCH V2 3/3] xen: eliminate scalability issues from initial mapping setup
In reply to David VrabelQuoted 16 lines
Quoted 1 line
Quoted 1 line · On 17.09.14 at 16:07, <[email protected]> wrote:
Quoted 14 lines · Juergen Gross
arch/x86/xen/mmu.c +14
-0+static void __init xen_cleanmfnmap (unsigned long vaddr) +{ +unsigned long va = vaddr &PMD_MASK ; +unsigned long pa; +pgd_t *pgd =pgd_offset_k (va); +pud_t *pud_page =pud_offset (pgd,0 ); +pud_t *pud; +pmd_t *pmd; +pte_t *pte; +unsigned int i; + +set_pgd (pgd,__pgd (0 )); + do { + pud = pud_page + pud_index(va);
Quoted 8 lines
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1239
Quoted 6 lines
arch/x86/xen/mmu.c +6
-0+if (pud_none (*pud)) { + va +=PUD_SIZE ; + }else if (pud_large (*pud)) { + pa =pud_val (*pud) &PHYSICAL_PAGE_MASK ; +xen_free_ro_pages (pa,PUD_SIZE ); + va +=PUD_SIZE ;Are you missing a ClearPagePinned(..) here?
No, this is a 1Gb data page, not a page table one.
Jan
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V2 3/3] xen: eliminate scalability issues from initial mapping setup
In reply to David VrabelQuoted 41 lines · David Vrabel
Quoted 5 lines · Juergen Gross
Direct Xen to place the initial
P->Mtable outside of the initial mapping, as otherwise the 1G (implementation) / 2G (theoretical) restriction on the size of the initial mapping limits the amount of memory a domain can be handed initially.Quoted 7 lines
As the initial
P->Mtable is copied rather early during boot to domain private memory and it's initial virtual mapping is dropped, the easiest way to avoid virtual address conflicts with other addresses in the kernel is to use a user address area for the virtual address of the initialP->Mtable. This allows us to just throw away the page tables of the initial mapping after the copy without having to care about address invalidation.This needs an additional paragraph like:
"This does not increase the amount of memory the guest can use. This
is still limited to 512 GiB by the 3-level p2m."Quoted 3 lines
arch/x86/xen/mmu.c +0
-0@@ -1198,6 +1198,76 @@ static void __init xen_cleanhighmap(unsigned long vaddr,[...]
Quoted 18 lines
arch/x86/xen/mmu.c +18
-0+/* +* Since it is well isolated we can (and since it is perhaps large we should) +* also free the page tables mapping the initial P->M table. +*/ +static void __init xen_cleanmfnmap (unsigned long vaddr) +{ +unsigned long va = vaddr &PMD_MASK ; +unsigned long pa; +pgd_t *pgd =pgd_offset_k (va); +pud_t *pud_page =pud_offset (pgd,0 ); +pud_t *pud; +pmd_t *pmd; +pte_t *pte; +unsigned int i; + +set_pgd (pgd,__pgd (0 )); + do { + pud = pud_page + pud_index(va);
Quoted 8 lines
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1239
Quoted 6 lines
arch/x86/xen/mmu.c +6
-0+if (pud_none (*pud)) { + va +=PUD_SIZE ; + }else if (pud_large (*pud)) { + pa =pud_val (*pud) &PHYSICAL_PAGE_MASK ; +xen_free_ro_pages (pa,PUD_SIZE ); + va +=PUD_SIZE ;Are you missing a ClearPagePinned(..) here?
Probably, yes.
Quoted 15 lines
Quoted 14 lines
arch/x86/xen/mmu.c +13
-0+ }else { + pmd =pmd_offset (pud, va); +if (pmd_large (*pmd)) { + pa =pmd_val (*pmd) &PHYSICAL_PAGE_MASK ; +xen_free_ro_pages (pa,PMD_SIZE ); + }else if (!pmd_none (*pmd)) { + pte =pte_offset_kernel (pmd, va); +for (i =0 ; i <PTRS_PER_PTE ; ++i) { +if (pte_none (pte[i])) +break ; + pa =pte_pfn (pte[i]) <<PAGE_SHIFT ; +xen_free_ro_pages (pa,PAGE_SIZE ); + }
Quoted 5 lines
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1255
Quoted 3 lines
arch/x86/xen/mmu.c +3
-0+ pa =__pa (pte) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE );Put this into a helper function? It's used here...
Good idea.
Quoted 20 lines
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1262
Quoted 8 lines
arch/x86/xen/mmu.c +7
-0+ } + va +=PMD_SIZE ; +if (pmd_index (va)) +continue ; + pa =__pa (pmd) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE );...and here...
arch/x86/xen/mmu.c static void __init xen_cleanhighmap(unsigned long vaddr, · line 1268
Quoted 6 lines
arch/x86/xen/mmu.c +6
-0+ } + + }while (pud_index (va) ||pmd_index (va)); + pa =__pa (pud_page) &PHYSICAL_PAGE_MASK ; +ClearPagePinned (virt_to_page (__va (pa))); +xen_free_ro_pages (pa,PAGE_SIZE );... and here.
Quoted 16 lines
Quoted 4 lines
arch/x86/xen/mmu.c +0
-0@@ -1529,6 +1604,22 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)#else /* CONFIG_X86_64 */ static pte_t __init mask_rw_pte (pte_t *ptep,pte_t pte) {arch/x86/xen/mmu.c static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte) · line 1616
Quoted 10 lines
arch/x86/xen/mmu.c +10
-0+unsigned long pfn; + +if (xen_feature (XENFEAT_writable_page_tables) || +xen_feature (XENFEAT_auto_translated_physmap) || + xen_start_info->mfn_list >= __START_KERNEL_map) +return pte; + +/* +* Pages belonging to the initial p2m list mapped outside the default +* address range must be mapped read-only. Why? I didn't think was anything special about these MFNs.
The hypervisor complained when I did otherwise. I think the main reason is that the hypervisor will set up some more page tables to be able to map then mfn_list outside the "normal" address range. They are located in the range starting at xen_start_info->first_p2m_pfn (otherwise the info in first_p2m_pfn and nr_p2m_frames wouldn't be needed).
And page tables must be mapped read-only.
Juergen
Re: [Xen-devel] [PATCH V2 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 6 lines · Juergen Gross
Quoted 3 lines · David Vrabel
Are you missing a ClearPagePinned(..) here?
Probably, yes.
Jan pointed out that this is not needed.
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
arch/x86/xen/mmu.c +5
-0@@ -1529,6 +1604,22 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)#else /* CONFIG_X86_64 */ static pte_t __init mask_rw_pte (pte_t *ptep,pte_t pte) { +unsigned long pfn; + +if (xen_feature (XENFEAT_writable_page_tables) || +xen_feature (XENFEAT_auto_translated_physmap) || + xen_start_info->mfn_list >= __START_KERNEL_map)Quoted 8 lines
Quoted 6 lines
arch/x86/xen/mmu.c +4
-0+return pte; + +/* +* Pages belonging to the initial p2m list mapped outside the default
+ * address range must be mapped read-only.Why? I didn't think was anything special about these MFNs.
Quoted 5 lines
The hypervisor complained when I did otherwise. I think the main reason is that the hypervisor will set up some more page tables to be able to map then
mfn_listoutside the "normal" address range. They are located in the range starting atxen_start_info->first_p2m_pfn(otherwise the info infirst_p2m_pfnandnr_p2m_frameswouldn't be needed).
Ok. Can you expand the comment to say this?
David
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V2 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 29 lines · David Vrabel
Quoted 6 lines · Juergen Gross
Quoted 3 lines · David Vrabel
Are you missing a ClearPagePinned(..) here?
Probably, yes.
Jan pointed out that this is not needed.
Quoted 19 lines
Quoted 18 lines
Quoted 14 lines
arch/x86/xen/mmu.c +9
-0@@ -1529,6 +1604,22 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)#else /* CONFIG_X86_64 */ static pte_t __init mask_rw_pte (pte_t *ptep,pte_t pte) { +unsigned long pfn; + +if (xen_feature (XENFEAT_writable_page_tables) || +xen_feature (XENFEAT_auto_translated_physmap) || + xen_start_info->mfn_list >= __START_KERNEL_map) +return pte; + +/* +* Pages belonging to the initial p2m list mapped outside the Quoted 2 lines
default
+ * address range must be mapped read-only.Why? I didn't think was anything special about these MFNs.
Quoted 7 lines
Quoted 5 lines
The hypervisor complained when I did otherwise. I think the main reason is that the hypervisor will set up some more page tables to be able to map then
mfn_listoutside the "normal" address range. They are located in the range starting atxen_start_info->first_p2m_pfn(otherwise the info infirst_p2m_pfnandnr_p2m_frameswouldn't be needed).Ok. Can you expand the comment to say this?
Already did. :-)
Juergen
David Vrabel
AppliedQuoted 23 lines · Juergen Gross
When a Xen pv-domain is booted the initial memory map contains multiple objects in the top 2 GB including the initrd and the p2m list. This limits the supported maximum size of the initrd and the maximum memory size the p2m list can span is limited to about 500 GB.
Xen however supports loading the initrd without mapping it and the initial p2m list can be mapped by Xen to an arbitrary selected virtual address. The following patches activate those options and thus remove the limitations.
It should be noted that the p2m list limitation isn't only affecting the amount of memory a pv domain can use, but it also hinders Dom0 to be started on physical systems with larger memory without reducing it's memory via a Xen boot parameter. By mapping the initial p2m list to an area not in the top 2 GB it is now possible to boot Dom0 on such systems.
It would be desirable to be able to use more than 512 GB in a pv domain, but this would require a reorganization of the p2m tree built by the kernel at boot time. As this reorganization would affect the Xen tools and kexec, too, it is not included in this patch set. This topic can be addressed later.
Quoted 3 lines
Juergen Gross (3):
xen: sync some headers with xen tree
xen: eliminate scalability issues from initrd handling
I've applied these two to devel/for-linus-3.18.
Thanks.
David
Juergen Gross
maintainerQuoted 24 lines · David Vrabel
Quoted 23 lines · Juergen Gross
When a Xen pv-domain is booted the initial memory map contains multiple objects in the top 2 GB including the initrd and the p2m list. This limits the supported maximum size of the initrd and the maximum memory size the p2m list can span is limited to about 500 GB.
Xen however supports loading the initrd without mapping it and the initial p2m list can be mapped by Xen to an arbitrary selected virtual address. The following patches activate those options and thus remove the limitations.
It should be noted that the p2m list limitation isn't only affecting the amount of memory a pv domain can use, but it also hinders Dom0 to be started on physical systems with larger memory without reducing it's memory via a Xen boot parameter. By mapping the initial p2m list to an area not in the top 2 GB it is now possible to boot Dom0 on such systems.
It would be desirable to be able to use more than 512 GB in a pv domain, but this would require a reorganization of the p2m tree built by the kernel at boot time. As this reorganization would affect the Xen tools and kexec, too, it is not included in this patch set. This topic can be addressed later.
Quoted 7 lines
Quoted 3 lines
Juergen Gross (3):
xen: sync some headers with xen tree
xen: eliminate scalability issues from initrd handlingI've applied these two to devel/for-linus-3.18.
Thanks.
Thanks, too. :-)
Juergen