head32.c (69ba866db281c768d5ecca909361ea4c4e71d57e) head32.c (4c585af7180c147062c636a927a2fc2b6a7072f5)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/arch/i386/kernel/head32.c -- prepare to run common code
4 *
5 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
6 * Copyright (C) 2007 Eric Biederman <ebiederm@xmission.com>
7 */
8

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

24
25static void __init i386_default_early_setup(void)
26{
27 /* Initialize 32bit specific setup functions */
28 x86_init.resources.reserve_resources = i386_reserve_resources;
29 x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
30}
31
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/arch/i386/kernel/head32.c -- prepare to run common code
4 *
5 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
6 * Copyright (C) 2007 Eric Biederman <ebiederm@xmission.com>
7 */
8

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

24
25static void __init i386_default_early_setup(void)
26{
27 /* Initialize 32bit specific setup functions */
28 x86_init.resources.reserve_resources = i386_reserve_resources;
29 x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
30}
31
32#ifdef CONFIG_MICROCODE_INITRD32
33unsigned long __initdata initrd_start_early;
34static pte_t __initdata *initrd_pl2p_start, *initrd_pl2p_end;
35
36static void zap_early_initrd_mapping(void)
37{
38 pte_t *pl2p = initrd_pl2p_start;
39
40 for (; pl2p < initrd_pl2p_end; pl2p++) {
41 *pl2p = (pte_t){ .pte = 0 };
42
43 if (!IS_ENABLED(CONFIG_X86_PAE))
44 *(pl2p + ((PAGE_OFFSET >> PGDIR_SHIFT))) = (pte_t) {.pte = 0};
45 }
46}
47#else
48static inline void zap_early_initrd_mapping(void) { }
49#endif
50
32asmlinkage __visible void __init __noreturn i386_start_kernel(void)
33{
34 /* Make sure IDT is set up before any exception happens */
35 idt_setup_early_handler();
36
51asmlinkage __visible void __init __noreturn i386_start_kernel(void)
52{
53 /* Make sure IDT is set up before any exception happens */
54 idt_setup_early_handler();
55
56 /* load_ucode_bsp() */
57 zap_early_initrd_mapping();
58
37 cr4_init_shadow();
38
39 sanitize_boot_params(&boot_params);
40
41 x86_early_init_platform_quirks();
42
43 /* Call the subarch specific early setup function */
44 switch (boot_params.hdr.hardware_subarch) {

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

100 (*pl2p)++;
101 }
102 return pte;
103}
104
105void __init __no_stack_protector mk_early_pgtbl_32(void)
106{
107 /* Enough space to fit pagetables for the low memory linear map */
59 cr4_init_shadow();
60
61 sanitize_boot_params(&boot_params);
62
63 x86_early_init_platform_quirks();
64
65 /* Call the subarch specific early setup function */
66 switch (boot_params.hdr.hardware_subarch) {

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

122 (*pl2p)++;
123 }
124 return pte;
125}
126
127void __init __no_stack_protector mk_early_pgtbl_32(void)
128{
129 /* Enough space to fit pagetables for the low memory linear map */
108 const unsigned long limit = __pa_nodebug(_end) +
109 (PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT);
130 unsigned long limit = __pa_nodebug(_end) + (PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT);
110 pte_t pte, *ptep = (pte_t *)__pa_nodebug(__brk_base);
131 pte_t pte, *ptep = (pte_t *)__pa_nodebug(__brk_base);
132 struct boot_params __maybe_unused *params;
111 pl2_t *pl2p = (pl2_t *)__pa_nodebug(pl2_base);
112 unsigned long *ptr;
113
114 pte.pte = PTE_IDENT_ATTR;
115 pte = init_map(pte, &ptep, &pl2p, limit);
116
117 ptr = (unsigned long *)__pa_nodebug(&max_pfn_mapped);
118 /* Can't use pte_pfn() since it's a call with CONFIG_PARAVIRT */
119 *ptr = (pte.pte & PTE_PFN_MASK) >> PAGE_SHIFT;
120
121 ptr = (unsigned long *)__pa_nodebug(&_brk_end);
122 *ptr = (unsigned long)ptep + PAGE_OFFSET;
133 pl2_t *pl2p = (pl2_t *)__pa_nodebug(pl2_base);
134 unsigned long *ptr;
135
136 pte.pte = PTE_IDENT_ATTR;
137 pte = init_map(pte, &ptep, &pl2p, limit);
138
139 ptr = (unsigned long *)__pa_nodebug(&max_pfn_mapped);
140 /* Can't use pte_pfn() since it's a call with CONFIG_PARAVIRT */
141 *ptr = (pte.pte & PTE_PFN_MASK) >> PAGE_SHIFT;
142
143 ptr = (unsigned long *)__pa_nodebug(&_brk_end);
144 *ptr = (unsigned long)ptep + PAGE_OFFSET;
145
146#ifdef CONFIG_MICROCODE_INITRD32
147 /* Running on a hypervisor? */
148 if (native_cpuid_ecx(1) & BIT(31))
149 return;
150
151 params = (struct boot_params *)__pa_nodebug(&boot_params);
152 if (!params->hdr.ramdisk_size || !params->hdr.ramdisk_image)
153 return;
154
155 /* Save the virtual start address */
156 ptr = (unsigned long *)__pa_nodebug(&initrd_start_early);
157 *ptr = (pte.pte & PTE_PFN_MASK) + PAGE_OFFSET;
158 *ptr += ((unsigned long)params->hdr.ramdisk_image) & ~PAGE_MASK;
159
160 /* Save PLP2 for cleanup */
161 ptr = (unsigned long *)__pa_nodebug(&initrd_pl2p_start);
162 *ptr = (unsigned long)pl2p + PAGE_OFFSET;
163
164 limit = (unsigned long)params->hdr.ramdisk_image;
165 pte.pte = PTE_IDENT_ATTR | PFN_ALIGN(limit);
166 limit = (unsigned long)params->hdr.ramdisk_image + params->hdr.ramdisk_size;
167
168 init_map(pte, &ptep, &pl2p, limit);
169
170 ptr = (unsigned long *)__pa_nodebug(&initrd_pl2p_end);
171 *ptr = (unsigned long)pl2p + PAGE_OFFSET;
172#endif
123}
173}