Merge branch 'akpm'
[linux-2.6/next.git] / arch / x86 / kernel / trampoline.c
bloba91ae7709b49ea17628aff1fc253899b4c9e4efa
1 #include <linux/io.h>
2 #include <linux/memblock.h>
4 #include <asm/trampoline.h>
5 #include <asm/cacheflush.h>
6 #include <asm/pgtable.h>
8 unsigned char *x86_trampoline_base;
10 void __init setup_trampolines(void)
12 phys_addr_t mem;
13 size_t size = PAGE_ALIGN(x86_trampoline_end - x86_trampoline_start);
15 /* Has to be in very low memory so we can execute real-mode AP code. */
16 mem = memblock_find_in_range(0, 1<<20, size, PAGE_SIZE);
17 if (mem == MEMBLOCK_ERROR)
18 panic("Cannot allocate trampoline\n");
20 x86_trampoline_base = __va(mem);
21 memblock_x86_reserve_range(mem, mem + size, "TRAMPOLINE");
23 printk(KERN_DEBUG "Base memory trampoline at [%p] %llx size %zu\n",
24 x86_trampoline_base, (unsigned long long)mem, size);
26 memcpy(x86_trampoline_base, x86_trampoline_start, size);
30 * setup_trampolines() gets called very early, to guarantee the
31 * availability of low memory. This is before the proper kernel page
32 * tables are set up, so we cannot set page permissions in that
33 * function. Thus, we use an arch_initcall instead.
35 static int __init configure_trampolines(void)
37 size_t size = PAGE_ALIGN(x86_trampoline_end - x86_trampoline_start);
39 set_memory_x((unsigned long)x86_trampoline_base, size >> PAGE_SHIFT);
40 return 0;
42 arch_initcall(configure_trampolines);