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)
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
);
18 panic("Cannot allocate trampoline\n");
20 x86_trampoline_base
= __va(mem
);
21 memblock_reserve(mem
, size
);
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
);
42 arch_initcall(configure_trampolines
);