From: "Jan Beulich" Subject: Re: [PATCH] x86-64 linux: unmap temporary mappings established for setup of 1:1 mappings Date: Fri, 02 Jun 2006 09:29:47 +0200 Message-ID: <4480050A.76E4.0078.0@novell.com> References: <447DB394.76E4.0078.0@novell.com> <368ae6e00389bbd4d2b4fdd55ddc5411@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part406576FB.1__=" Return-path: In-Reply-To: <368ae6e00389bbd4d2b4fdd55ddc5411@cl.cam.ac.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part406576FB.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline >>> Keir Fraser 01.06.06 20:21 >>> > >On 31 May 2006, at 14:17, Jan Beulich wrote: > >> The temporary mappings needed to set up the 1:1 mappings must be torn >> down after use; otherwise they may trigger the >> WARN_ON() in vmap_pte_range() (namely if the chunk allocated to hold >> kernel and initial page tables gets close to or >> exceeds 128Mb, or if a sufficiently high mem= argument causes the >> static allocations to grow beyond 128Mb, which in >> either case means these mappings extend into the modules area). > >I've applied this to -unstable, but in this patch I only see code to >destroy the extended init mappings. What happens if you have a really >big initrd (for example)? That will push the initial pagetables up into >the modules area -- is that handled correctly now or is more fixup >required? The initrd mappings, as I read it, get destroyed in setup_arch(). The thing that also came to my mind were the Xen-created page tables, which might need taking care of. The main issue here will be to precisely determine the boundary of where to start destruction - does Xen make any guarantees regarding the ordering of things within the initial allocation? >Also your patch didn't apply to 3.0-testing. You'll need to supply a >version specifically for -testing if you want it applied there. Yes, that patch would look different. As we have our own patch anyway, I don't think we insist on this being applied to 3.0-testing, but in case you want it I'm attaching the patch we have (one of its hunks applies with fuzz 1 only, but I think that should be okay). Jan --=__Part406576FB.1__= Content-Type: text/plain; name="xen-x86_64-unmap-early.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen-x86_64-unmap-early.patch" From: jbeulich@novell.com Subject: Unmap temporary mappings established for setup of 1:1 mappings. References: 175787 Index: head-2006-05-26/arch/x86_64/mm/init-xen.c =================================================================== --- head-2006-05-26.orig/arch/x86_64/mm/init-xen.c 2006-05-31 14:23:51.000000000 +0200 +++ head-2006-05-26/arch/x86_64/mm/init-xen.c 2006-05-31 14:30:12.000000000 +0200 @@ -56,6 +56,8 @@ struct dma_mapping_ops* dma_ops; EXPORT_SYMBOL(dma_ops); +int after_bootmem; + extern unsigned long *contiguous_bitmap; #ifndef CONFIG_XEN @@ -76,7 +78,7 @@ extern unsigned long start_pfn; (((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) + \ __START_KERNEL_map))) -static void early_make_page_readonly(void *va, unsigned int feature) +static void __meminit early_make_page_readonly(void *va, unsigned int feature) { unsigned long addr, _va = (unsigned long)va; pte_t pte, *ptep; @@ -85,6 +87,11 @@ static void early_make_page_readonly(voi if (xen_feature(feature)) return; + if (after_bootmem) { + make_page_readonly(va, feature); + return; + } + addr = (unsigned long) page[pgd_index(_va)]; addr_to_page(addr, page); @@ -200,10 +207,6 @@ void show_mem(void) printk(KERN_INFO "%lu pages swap cached\n",cached); } -/* References to section boundaries */ - -int after_bootmem; - static void *spp_getpage(void) { void *ptr; @@ -372,7 +375,8 @@ void __set_fixmap_user (enum fixed_addre set_pte_phys(address, phys, prot, SET_FIXMAP_USER); } -unsigned long __initdata table_start, tables_space; +unsigned long __initdata table_start; +static unsigned long __initdata tables_space; unsigned long get_machine_pfn(unsigned long addr) { @@ -444,9 +448,9 @@ phys_pmd_init(pmd_t *pmd, unsigned long pte = alloc_static_page(&pte_phys); pte_save = pte; for (k = 0; k < PTRS_PER_PTE; pte++, k++, address += PTE_SIZE) { - if ((address >= end) || - ((address >> PAGE_SHIFT) >= - xen_start_info->nr_pages)) { + if (address >= (after_bootmem + ? end + : xen_start_info->nr_pages << PAGE_SHIFT)) { __set_pte(pte, __pte(0)); continue; } @@ -546,7 +550,7 @@ void __init xen_init_pt(void) mk_kernel_pgd(__pa_symbol(level3_user_pgt))); } -void __init extend_init_mapping(void) +static void __init extend_init_mapping(void) { unsigned long va = __START_KERNEL_map; unsigned long phys, addr, *pte_page; @@ -617,7 +621,8 @@ static void __init find_early_table_spac table_start = start_pfn; early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n", - end, table_start << PAGE_SHIFT, start_pfn << PAGE_SHIFT); + end, table_start << PAGE_SHIFT, + (table_start << PAGE_SHIFT) + tables_space); } /* Setup the direct mapping of the physical memory at PAGE_OFFSET. @@ -662,7 +667,18 @@ void __meminit init_memory_mapping(unsig set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys)); } - BUG_ON(!after_bootmem && start_pfn != table_start + (tables_space >> PAGE_SHIFT)); + if (!after_bootmem) { + BUG_ON(start_pfn != table_start + (tables_space >> PAGE_SHIFT)); + + /* Destroy the temporary mappings created above. */ + start = __START_KERNEL_map + (table_start << PAGE_SHIFT); + end = start + tables_space; + for (; start < end; start += PAGE_SIZE) { + /* Should also clear out and reclaim any page table + pages no longer needed... */ + WARN_ON(HYPERVISOR_update_va_mapping(start, __pte_ma(0), 0)); + } + } __flush_tlb_all(); } --=__Part406576FB.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part406576FB.1__=--