xen: remove memory limits from pv-domains
Subsystems (3)
Juergen Gross
maintainercover xen: remove 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 initial memory size 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.
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 | 15 ++- arch/x86/xen/mmu.c | 116 +++++++++++++++-- arch/x86/xen/setup.c | 65 +++++----- arch/x86/xen/xen-head.S | 5 + include/xen/interface/elfnote.h | 102 ++++++++++++++- include/xen/interface/xen.h | 272 ++++++++++++++++++++++++++++++++++++---- 6 files changed, 512 insertions(+), 63 deletions(-)
Signature · 1 line
1.8.4.5
Juergen Gross
maintainerPATCH 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 | 102 ++++++++++++++- include/xen/interface/xen.h | 272 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 348 insertions(+), 26 deletions(-)
include/xen/interface/elfnote.h +100 -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,65 @@*/ #define XEN_ELFNOTE_SUPPORTED_FEATURES 17 +/* +* The number of the highest elfnote defined. +*/ +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES + +/* +* System information exported through crash notes. +* +* The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO +* note in case of a system crash. This note will contain various +* information about the system, see xen/include/xen/elfcore.h. +*/ +#define XEN_ELFNOTE_CRASH_INFO 0x1000001 + +/* +* System registers exported through crash notes. +* +* The kexec / kdump code will create one XEN_ELFNOTE_CRASH_REGS +* note per cpu in case of a system crash. This note is architecture +* specific and will contain registers not saved in the "CORE" note. +* See xen/include/xen/elfcore.h for more information. +*/ +#define XEN_ELFNOTE_CRASH_REGS 0x1000002 + + +/* +* xen dump-core none note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_NONE +* in its dump file to indicate that the file is xen dump-core +* file. This note doesn't have any other information. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_NONE 0x2000000 + +/* +* xen dump-core header note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_HEADER +* in its dump file. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_HEADER 0x2000001 + +/* +* xen dump-core xen version note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_XEN_VERSION +* in its dump file. It contains the xen version obtained via the +* XENVER hypercall. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_XEN_VERSION 0x2000002 + +/* +* xen dump-core format version note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION +* in its dump file. It contains a format version identifier. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION 0x2000003 +#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
Re: [PATCH 1/3] xen: sync some headers with xen tree
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 14:38, <"[email protected]".non-mime.internet> wrote:
As the KEXEC and DUMPCORE related ELFNOTES are not relevant for the kernel they are omitted from
elfnote.h.
But the defines are still in the patch:
Quoted 56 lines
include/xen/interface/elfnote.h +52
-0@@ -153,6 +192,65 @@*/ #define XEN_ELFNOTE_SUPPORTED_FEATURES 17 +/* +* The number of the highest elfnote defined. +*/ +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES + +/* +* System information exported through crash notes. +* +* The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO +* note in case of a system crash. This note will contain various +* information about the system, see xen/include/xen/elfcore.h. +*/ +#define XEN_ELFNOTE_CRASH_INFO 0x1000001 + +/* +* System registers exported through crash notes. +* +* The kexec / kdump code will create one XEN_ELFNOTE_CRASH_REGS +* note per cpu in case of a system crash. This note is architecture +* specific and will contain registers not saved in the "CORE" note. +* See xen/include/xen/elfcore.h for more information. +*/ +#define XEN_ELFNOTE_CRASH_REGS 0x1000002 + + +/* +* xen dump-core none note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_NONE +* in its dump file to indicate that the file is xen dump-core +* file. This note doesn't have any other information. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_NONE 0x2000000 + +/* +* xen dump-core header note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_HEADER +* in its dump file. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_HEADER 0x2000001 + +/* +* xen dump-core xen version note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_XEN_VERSION +* in its dump file. It contains the xen version obtained via the +* XENVER hypercall. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_XEN_VERSION 0x2000002 + +/*
include/xen/interface/elfnote.h line 256
Quoted 10 lines
include/xen/interface/elfnote.h +7
-0+* xen dump-core format version note. +* xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION +* in its dump file. It contains a format version identifier. +* See tools/libxc/xc_core.h for more information. +*/ +#define XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION 0x2000003 +#endif /* __XEN_PUBLIC_ELFNOTE_H__ */ /*
Jan
Juergen Gross
maintainerRe: [PATCH 1/3] xen: sync some headers with xen tree
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 14:38, <"[email protected]".non-mime.internet> wrote:
As the KEXEC and DUMPCORE related ELFNOTES are not relevant for the kernel they are omitted from
elfnote.h.But the defines are still in the patch:
Oops, old header version. I'll correct it.
Juergen
Juergen Gross
maintainerPATCH 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 | 15 +++++++++++++-- arch/x86/xen/xen-head.S | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-)
arch/x86/xen/enlighten.c +13 -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,20 @@ 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 +#ifdef CONFIG_X86_32 +BUG_ON (xen_start_info->flags &SIF_MOD_START_PFN ); +#else +if (xen_start_info->flags &SIF_MOD_START_PFN ) + initrd_start =PFN_PHYS (xen_start_info->mod_start); +#endif +#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 +3 -0
@@ -124,6 +124,9 @@ 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) +#ifdef CONFIG_X86_64 + ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) +#endif 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: [PATCH 2/3] xen: eliminate scalability issues from initrd handling
Quoted 4 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.
[...]
Quoted 2 lines
arch/x86/xen/enlighten.c +0
-0
[...]
Quoted 4 lines
arch/x86/xen/enlighten.c +0
-0@@ -1667,10 +1668,20 @@ asmlinkage __visible void __init xen_start_kernel(void) new_cpu_data.x86_capability[0 ] =cpuid_edx (1 );#endif
arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1680
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+if (xen_start_info->mod_start) + initrd_start =__pa (xen_start_info->mod_start); +#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_X86_32 +BUG_ON (xen_start_info->flags &SIF_MOD_START_PFN ); +#else +if (xen_start_info->flags &SIF_MOD_START_PFN ) + initrd_start =PFN_PHYS (xen_start_info->mod_start); +#endif +#endif
Remove these unnecessary #ifdefs and the BUG_ON(). We can trust Xen to not set SIF_MOD_START_PFN if we haven't asked for it.
arch/x86/xen/xen-head.S NEXT_HYPERCALL(arch_6) · line 129
Quoted 9 lines
arch/x86/xen/xen-head.S +3
-0@@ -124,6 +124,9 @@ 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) +#ifdef CONFIG_X86_64 + ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) +#endif
Why X86_64 only? If there's a good reason the commit message needs to explain why.
David
Re: [PATCH 2/3] xen: eliminate scalability issues from initrd handling
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 14:52, <[email protected]> wrote:
arch/x86/xen/xen-head.S NEXT_HYPERCALL(arch_6) · line 129
Quoted 9 lines · Juergen Gross
arch/x86/xen/xen-head.S +3
-0@@ -124,6 +124,9 @@ 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) +#ifdef CONFIG_X86_64 + ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) +#endifWhy
X86_64only? If there's a good reason the commit message needs to explain why.
Does native 32-bit support huge initrd?
Jan
Re: [Xen-devel] [PATCH 2/3] xen: eliminate scalability issues from initrd handling
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 14:52, <[email protected]> wrote:
arch/x86/xen/xen-head.S NEXT_HYPERCALL(arch_6) · line 129
Quoted 9 lines · Juergen Gross
arch/x86/xen/xen-head.S +3
-0@@ -124,6 +124,9 @@ 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) +#ifdef CONFIG_X86_64 + ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) +#endifWhy
X86_64only? If there's a good reason the commit message needs to explain why.
Quoted 1 line
Does native 32-bit support huge initrd?
Does that matter? If the MOD_START_PFN options works with a 32-bit guest then it should use it, regardless of whether it is essential or not. Because this reduces the #ifdef'ery.
David
Juergen Gross
maintainerRe: [Xen-devel] [PATCH 2/3] xen: eliminate scalability issues from initrd handling
Quoted 16 lines · David Vrabel
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 14:52, <[email protected]> wrote:
arch/x86/xen/xen-head.S NEXT_HYPERCALL(arch_6) · line 129
Quoted 9 lines · Juergen Gross
arch/x86/xen/xen-head.S +3
-0@@ -124,6 +124,9 @@ 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) +#ifdef CONFIG_X86_64 + ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) +#endifWhy
X86_64only? If there's a good reason the commit message needs to explain why.
Quoted 5 lines
Quoted 1 line
Does native 32-bit support huge initrd?
Does that matter? If the
MOD_START_PFNoptions works with a 32-bit guest then it should use it, regardless of whether it is essential or not. Because this reduces the #ifdef'ery.
Okay, I'll verify it's working on 32-bit, too.
Juergen
Juergen Gross
maintainerPATCH 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 | 116 +++++++++++++++++++++++++++++++++++++++++++++--- arch/x86/xen/setup.c | 65 +++++++++++++++------------ arch/x86/xen/xen-head.S | 2 + 3 files changed, 148 insertions(+), 35 deletions(-)
arch/x86/xen/mmu.c +109 -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 */
@@ -1885,7 +1976,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;
@@ -1928,6 +2022,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)copy_page (level2_fixmap_pgt, l2);/* Note that we don't do anything with level1_fixmap_pgt which * we don't need. */ + +/* 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 );
@@ -1967,6 +2067,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: [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 4 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.
The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
David
Re: [Xen-devel] [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 9 lines · David Vrabel
Quoted 4 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.The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
David
Any increase of the p2m beyond 3 levels will need to come with substantial libxc changes first. 3 level p2ms are hard coded throughout all the PV build and migrate code.
~Andrew
Re: [Xen-devel] [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 15:02, <[email protected]> wrote:
Quoted 5 lines · David Vrabel
Quoted 4 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 6 lines
Quoted 2 lines
The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
Any increase of the p2m beyond 3 levels will need to come with substantial libxc changes first. 3 level p2ms are hard coded throughout all the PV build and migrate code.
No, there no such dependency - the kernel could use 4 levels at any time (sacrificing being able to get migrated), making sure it only exposes the 3 levels hanging off the fourth level (or not exposing this information at all) to external entities making this wrong assumption.
Jan
Re: [Xen-devel] [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 12 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 15:02, <[email protected]> wrote:
Quoted 5 lines · David Vrabel
Quoted 4 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 5 lines
Quoted 2 lines
The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
Any increase of the p2m beyond 3 levels will need to come with substantial libxc changes first. 3 level p2ms are hard coded throughout all the PV build and migrate code.
Quoted 8 lines
No, there no such dependency - the kernel could use 4 levels at any time (sacrificing being able to get migrated), making sure it only exposes the 3 levels hanging off the fourth level (or not exposing this information at all) to external entities making this wrong assumption.
Jan
That would require that the PV kernel must start with a 3 level p2m and fudge things afterwards.
At a minimum, I would expect a patch to libxc to detect a 4 level PV guest and fail with a meaningful error, rather than an obscure "m2p doesn't match p2m for mfn/pfn X".
~Andrew
Juergen Gross
maintainerRe: [Xen-devel] [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 19 lines · Andrew Cooper
Quoted 18 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 15:02, <[email protected]> wrote:
Quoted 5 lines · David Vrabel
Quoted 4 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 5 lines
Quoted 2 lines
The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
Any increase of the p2m beyond 3 levels will need to come with substantial libxc changes first. 3 level p2ms are hard coded throughout all the PV build and migrate code.
No, there no such dependency - the kernel could use 4 levels at any time (sacrificing being able to get migrated), making sure it only exposes the 3 levels hanging off the fourth level (or not exposing this information at all) to external entities making this wrong assumption.
Quoted 5 lines
Quoted 2 lines
Jan
That would require that the PV kernel must start with a 3 level p2m and fudge things afterwards.
I always thought the 3 level p2m is constructed by the kernel, not by the tools.
It starts with the linear p2m list anchored at xen_start_info->mfn_list, constructs the p2m tree and writes the p2m_top_mfn mfn to HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list
See comment in the kernel source arch/x86/xen/p2m.c
So booting with a larger p2m list can be handled completely by the kernel itself.
Quoted 4 lines
At a minimum, I would expect a patch to libxc to detect a 4 level PV guest and fail with a meaningful error, rather than an obscure "m2p doesn't match p2m for mfn/pfn X".
I'd rather fix it in a clean way.
I think the best way to do it would be an indicator in the p2m array anchor, e.g. setting 1<<61 in pfn_to_mfn_frame_list_list. This will result in an early error with old tools:
"Couldn't map p2m_frame_list_list"
Juergen
Re: [Xen-devel] [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 31 lines · Juergen Gross
Quoted 21 lines · Andrew Cooper
Quoted 20 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 15:02, <[email protected]> wrote:
Quoted 5 lines · David Vrabel
Quoted 4 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
Quoted 3 lines
The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
Any increase of the p2m beyond 3 levels will need to come with substantial libxc changes first. 3 level p2ms are hard coded throughout
all the PV build and migrate code.No, there no such dependency - the kernel could use 4 levels at any time (sacrificing being able to get migrated), making sure it only exposes the 3 levels hanging off the fourth level (or not exposing this information at all) to external entities making this wrong assumption.
Quoted 5 lines
Quoted 2 lines
Jan
That would require that the PV kernel must start with a 3 level p2m and fudge things afterwards.
I always thought the 3 level p2m is constructed by the kernel, not by the tools.
Quoted 8 lines
It starts with the linear p2m list anchored at
xen_start_info->mfn_list, constructs the p2m tree and writes thep2m_top_mfnmfn toHYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_listSee comment in the kernel source
arch/x86/xen/p2m.cSo booting with a larger p2m list can be handled completely by the kernel itself.
Ah yes - I remember now. All the toolstack does is create the linear p2m. In which case building such a domain will be fine.
Quoted 6 lines
Quoted 5 lines
At a minimum, I would expect a patch to libxc to detect a 4 level PV guest and fail with a meaningful error, rather than an obscure "m2p doesn't match p2m for mfn/pfn X".
Quoted 6 lines
I'd rather fix it in a clean way.
I think the best way to do it would be an indicator in the p2m array anchor, e.g. setting 1<<61 in
pfn_to_mfn_frame_list_list. This will result in an early error with old tools:
"Couldn't mapp2m_frame_list_list"
No it wont. The is_mapped() macro in the toolstack is quite broken. It stems from a lack of Design/API/ABI concerning things like the p2m. In particular, INVALID_MFN is not an ABI constant, nor is any notion of mapped vs unmapped.
Its current implementation is a relic of 32bit days, and only checks bit
31. It also means that it is impossible to migrate a PV VM with pfns above the 43bit limit; a restriction which is lifted by my migration v2 series. A lot of the other migration constructs are in a similar state, which is why they are being deleted by the v2 series.
The clean way to fix this is to leave pfn_to_mfn_frame_list_list as INVALID_MFN. Introduce two new fields beside it named p2m_levels and p2m_root, which then caters for levels greater than 4 in a compatible manner.
~Andrew
Juergen Gross
maintainerRe: [Xen-devel] [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
Quoted 57 lines · Andrew Cooper
Quoted 31 lines · Juergen Gross
Quoted 21 lines · Andrew Cooper
Quoted 20 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 15:02, <[email protected]> wrote:
Quoted 5 lines · David Vrabel
Quoted 4 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
Quoted 3 lines
The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
Any increase of the p2m beyond 3 levels will need to come with substantial libxc changes first. 3 level p2ms are hard coded throughout
all the PV build and migrate code.No, there no such dependency - the kernel could use 4 levels at any time (sacrificing being able to get migrated), making sure it only exposes the 3 levels hanging off the fourth level (or not exposing this information at all) to external entities making this wrong assumption.
Quoted 5 lines
Quoted 2 lines
Jan
That would require that the PV kernel must start with a 3 level p2m and fudge things afterwards.
I always thought the 3 level p2m is constructed by the kernel, not by the tools.
Quoted 8 lines
It starts with the linear p2m list anchored at
xen_start_info->mfn_list, constructs the p2m tree and writes thep2m_top_mfnmfn toHYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_listSee comment in the kernel source
arch/x86/xen/p2m.cSo booting with a larger p2m list can be handled completely by the kernel itself.
Ah yes - I remember now. All the toolstack does is create the linear p2m. In which case building such a domain will be fine.
Quoted 6 lines
Quoted 5 lines
At a minimum, I would expect a patch to libxc to detect a 4 level PV guest and fail with a meaningful error, rather than an obscure "m2p doesn't match p2m for mfn/pfn X".
Quoted 6 lines
I'd rather fix it in a clean way.
I think the best way to do it would be an indicator in the p2m array anchor, e.g. setting 1<<61 in
pfn_to_mfn_frame_list_list. This will result in an early error with old tools:
"Couldn't mapp2m_frame_list_list"
Quoted 4 lines
No it wont. The
is_mapped()macro in the toolstack is quite broken. It stems from a lack of Design/API/ABI concerning things like the p2m. In particular,INVALID_MFNis not an ABI constant, nor is any notion of mapped vs unmapped.
That's not relevant here. map_frame_list_list() in xc_domain_save.c reads pfn_to_mfn_frame_list_list and tries to map that mfn directly. This will fail and result in above error message.
Quoted 10 lines
Its current implementation is a relic of 32bit days, and only checks bit
31. It also means that it is impossible to migrate a PV VM with pfns above the 43bit limit; a restriction which is lifted by my migration v2 series. A lot of the other migration constructs are in a similar state, which is why they are being deleted by the v2 series.The clean way to fix this is to leave
pfn_to_mfn_frame_list_listasINVALID_MFN. Introduce two new fields beside it namedp2m_levelsandp2m_root, which then caters for levels greater than 4 in a compatible manner.
I don't mind doing it this way.
Juergen
Re: [Xen-devel] [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
In reply to Jan BeulichQuoted 14 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.09.14 at 15:02, <[email protected]> wrote:
Quoted 5 lines · David Vrabel
Quoted 4 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 6 lines
Quoted 2 lines
The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
Any increase of the p2m beyond 3 levels will need to come with substantial libxc changes first. 3 level p2ms are hard coded throughout all the PV build and migrate code.
Quoted 5 lines
No, there no such dependency - the kernel could use 4 levels at any time (sacrificing being able to get migrated), making sure it only exposes the 3 levels hanging off the fourth level (or not exposing this information at all) to external entities making this wrong assumption.
I don't think we want a kernel that may or may not be saved or migrated based on how much memory it has.
Nor do we want a kernel that has even more differences between dom0 and domU.
David
Juergen Gross
maintainerRe: [PATCH 3/3] xen: eliminate scalability issues from initial mapping setup
In reply to David VrabelQuoted 8 lines · David Vrabel
Quoted 4 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.The three level p2m limits memory to 512 GiB on x86-64 but this patch doesn't seem to address this limit and thus seems a bit useless to me.
Yeah, there seem to be some bits missing...
I'll add another patch to support a 4 level p2m scheme in the kernel. For the Xen tools I'll do it, too.
Juergen