head64.c (1e02ce4cccdcb9688386e5b8d2c9fa4660b45389) head64.c (ef7f0d6a6ca8c9e4b27d78895af86c2fbfaeedb2)
1/*
2 * prepare to run common code
3 *
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5 */
6
7#include <linux/init.h>
8#include <linux/linkage.h>

--- 13 unchanged lines hidden (view full) ---

22#include <asm/pgtable.h>
23#include <asm/tlbflush.h>
24#include <asm/sections.h>
25#include <asm/kdebug.h>
26#include <asm/e820.h>
27#include <asm/bios_ebda.h>
28#include <asm/bootparam_utils.h>
29#include <asm/microcode.h>
1/*
2 * prepare to run common code
3 *
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5 */
6
7#include <linux/init.h>
8#include <linux/linkage.h>

--- 13 unchanged lines hidden (view full) ---

22#include <asm/pgtable.h>
23#include <asm/tlbflush.h>
24#include <asm/sections.h>
25#include <asm/kdebug.h>
26#include <asm/e820.h>
27#include <asm/bios_ebda.h>
28#include <asm/bootparam_utils.h>
29#include <asm/microcode.h>
30#include <asm/kasan.h>
30
31/*
32 * Manage page tables very early on.
33 */
34extern pgd_t early_level4_pgt[PTRS_PER_PGD];
35extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];
36static unsigned int __initdata next_early_pgt = 2;
37pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);
38
39/* Wipe all early page tables except for the kernel symbol map */
40static void __init reset_early_page_tables(void)
41{
42 unsigned long i;
43
44 for (i = 0; i < PTRS_PER_PGD-1; i++)
45 early_level4_pgt[i].pgd = 0;
46
47 next_early_pgt = 0;
48
31
32/*
33 * Manage page tables very early on.
34 */
35extern pgd_t early_level4_pgt[PTRS_PER_PGD];
36extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];
37static unsigned int __initdata next_early_pgt = 2;
38pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);
39
40/* Wipe all early page tables except for the kernel symbol map */
41static void __init reset_early_page_tables(void)
42{
43 unsigned long i;
44
45 for (i = 0; i < PTRS_PER_PGD-1; i++)
46 early_level4_pgt[i].pgd = 0;
47
48 next_early_pgt = 0;
49
49 write_cr3(__pa(early_level4_pgt));
50 write_cr3(__pa_nodebug(early_level4_pgt));
50}
51
52/* Create a new PMD entry */
53int __init early_make_pgtable(unsigned long address)
54{
55 unsigned long physaddr = address - __PAGE_OFFSET;
56 unsigned long i;
57 pgdval_t pgd, *pgd_p;
58 pudval_t pud, *pud_p;
59 pmdval_t pmd, *pmd_p;
60
61 /* Invalid address or early pgt is done ? */
51}
52
53/* Create a new PMD entry */
54int __init early_make_pgtable(unsigned long address)
55{
56 unsigned long physaddr = address - __PAGE_OFFSET;
57 unsigned long i;
58 pgdval_t pgd, *pgd_p;
59 pudval_t pud, *pud_p;
60 pmdval_t pmd, *pmd_p;
61
62 /* Invalid address or early pgt is done ? */
62 if (physaddr >= MAXMEM || read_cr3() != __pa(early_level4_pgt))
63 if (physaddr >= MAXMEM || read_cr3() != __pa_nodebug(early_level4_pgt))
63 return -1;
64
65again:
66 pgd_p = &early_level4_pgt[pgd_index(address)].pgd;
67 pgd = *pgd_p;
68
69 /*
70 * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is

--- 79 unchanged lines hidden (view full) ---

150 BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
151 BUILD_BUG_ON((__START_KERNEL_map & ~PMD_MASK) != 0);
152 BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
153 BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
154 BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
155 (__START_KERNEL & PGDIR_MASK)));
156 BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END);
157
64 return -1;
65
66again:
67 pgd_p = &early_level4_pgt[pgd_index(address)].pgd;
68 pgd = *pgd_p;
69
70 /*
71 * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is

--- 79 unchanged lines hidden (view full) ---

151 BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
152 BUILD_BUG_ON((__START_KERNEL_map & ~PMD_MASK) != 0);
153 BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
154 BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
155 BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
156 (__START_KERNEL & PGDIR_MASK)));
157 BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END);
158
158 cr4_init_shadow();
159
160 /* Kill off the identity-map trampoline */
161 reset_early_page_tables();
162
159 /* Kill off the identity-map trampoline */
160 reset_early_page_tables();
161
162 kasan_map_early_shadow(early_level4_pgt);
163
163 /* clear bss before set_intr_gate with early_idt_handler */
164 clear_bss();
165
166 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
167 set_intr_gate(i, early_idt_handlers[i]);
168 load_idt((const struct desc_ptr *)&idt_descr);
169
170 copy_bootdata(__va(real_mode_data));

--- 5 unchanged lines hidden (view full) ---

176
177 if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
178 early_printk("Kernel alive\n");
179
180 clear_page(init_level4_pgt);
181 /* set init_level4_pgt kernel high mapping*/
182 init_level4_pgt[511] = early_level4_pgt[511];
183
164 /* clear bss before set_intr_gate with early_idt_handler */
165 clear_bss();
166
167 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
168 set_intr_gate(i, early_idt_handlers[i]);
169 load_idt((const struct desc_ptr *)&idt_descr);
170
171 copy_bootdata(__va(real_mode_data));

--- 5 unchanged lines hidden (view full) ---

177
178 if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
179 early_printk("Kernel alive\n");
180
181 clear_page(init_level4_pgt);
182 /* set init_level4_pgt kernel high mapping*/
183 init_level4_pgt[511] = early_level4_pgt[511];
184
185 kasan_map_early_shadow(init_level4_pgt);
186
184 x86_64_start_reservations(real_mode_data);
185}
186
187void __init x86_64_start_reservations(char *real_mode_data)
188{
189 /* version is always not zero if it is copied */
190 if (!boot_params.hdr.version)
191 copy_bootdata(__va(real_mode_data));
192
193 reserve_ebda_region();
194
195 start_kernel();
196}
187 x86_64_start_reservations(real_mode_data);
188}
189
190void __init x86_64_start_reservations(char *real_mode_data)
191{
192 /* version is always not zero if it is copied */
193 if (!boot_params.hdr.version)
194 copy_bootdata(__va(real_mode_data));
195
196 reserve_ebda_region();
197
198 start_kernel();
199}