Skip to content
Snippets Groups Projects
Select Git revision
  • b959ed6c73845aebf51afb8f76bb74b9388344d2
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

init.c

Blame
  • init.c 18.60 KiB
    #include <linux/gfp.h>
    #include <linux/initrd.h>
    #include <linux/ioport.h>
    #include <linux/swap.h>
    #include <linux/memblock.h>
    #include <linux/bootmem.h>	/* for max_low_pfn */
    
    #include <asm/cacheflush.h>
    #include <asm/e820.h>
    #include <asm/init.h>
    #include <asm/page.h>
    #include <asm/page_types.h>
    #include <asm/sections.h>
    #include <asm/setup.h>
    #include <asm/tlbflush.h>
    #include <asm/tlb.h>
    #include <asm/proto.h>
    #include <asm/dma.h>		/* for MAX_DMA_PFN */
    #include <asm/microcode.h>
    
    #include "mm_internal.h"
    
    static unsigned long __initdata pgt_buf_start;
    static unsigned long __initdata pgt_buf_end;
    static unsigned long __initdata pgt_buf_top;
    
    static unsigned long min_pfn_mapped;
    
    static bool __initdata can_use_brk_pgt = true;
    
    /*
     * Pages returned are already directly mapped.
     *
     * Changing that is likely to break Xen, see commit:
     *
     *    279b706 x86,xen: introduce x86_init.mapping.pagetable_reserve
     *
     * for detailed information.
     */
    __ref void *alloc_low_pages(unsigned int num)
    {
    	unsigned long pfn;
    	int i;
    
    	if (after_bootmem) {
    		unsigned int order;
    
    		order = get_order((unsigned long)num << PAGE_SHIFT);
    		return (void *)__get_free_pages(GFP_ATOMIC | __GFP_NOTRACK |
    						__GFP_ZERO, order);
    	}
    
    	if ((pgt_buf_end + num) > pgt_buf_top || !can_use_brk_pgt) {
    		unsigned long ret;
    		if (min_pfn_mapped >= max_pfn_mapped)
    			panic("alloc_low_page: ran out of memory");
    		ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT,
    					max_pfn_mapped << PAGE_SHIFT,
    					PAGE_SIZE * num , PAGE_SIZE);
    		if (!ret)
    			panic("alloc_low_page: can not alloc memory");
    		memblock_reserve(ret, PAGE_SIZE * num);
    		pfn = ret >> PAGE_SHIFT;
    	} else {
    		pfn = pgt_buf_end;
    		pgt_buf_end += num;
    		printk(KERN_DEBUG "BRK [%#010lx, %#010lx] PGTABLE\n",
    			pfn << PAGE_SHIFT, (pgt_buf_end << PAGE_SHIFT) - 1);
    	}