direct-io.hg

view linux-2.6-xen-sparse/arch/x86_64/kernel/head64-xen.c @ 14668:4a873ab4e261

[LINUX] Make sure to initialiase the xen features bitmap before first use on x86_64.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Fri Mar 30 14:13:53 2007 +0100 (2007-03-30)
parents f1833268b28f
children
line source
1 /*
2 * linux/arch/x86_64/kernel/head64.c -- prepare to run common code
3 *
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5 *
6 * Jun Nakajima <jun.nakajima@intel.com>
7 * Modified for Xen.
8 */
10 #include <linux/init.h>
11 #include <linux/linkage.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15 #include <linux/percpu.h>
16 #include <linux/module.h>
18 #include <asm/processor.h>
19 #include <asm/proto.h>
20 #include <asm/smp.h>
21 #include <asm/bootsetup.h>
22 #include <asm/setup.h>
23 #include <asm/desc.h>
24 #include <asm/pgtable.h>
25 #include <asm/sections.h>
27 unsigned long start_pfn;
29 /* Don't add a printk in there. printk relies on the PDA which is not initialized
30 yet. */
31 #if 0
32 static void __init clear_bss(void)
33 {
34 memset(__bss_start, 0,
35 (unsigned long) __bss_stop - (unsigned long) __bss_start);
36 }
37 #endif
39 #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
40 #define OLD_CL_MAGIC_ADDR 0x90020
41 #define OLD_CL_MAGIC 0xA33F
42 #define OLD_CL_BASE_ADDR 0x90000
43 #define OLD_CL_OFFSET 0x90022
45 extern char saved_command_line[];
47 static void __init copy_bootdata(char *real_mode_data)
48 {
49 #ifndef CONFIG_XEN
50 int new_data;
51 char * command_line;
53 memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
54 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
55 if (!new_data) {
56 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
57 printk("so old bootloader that it does not support commandline?!\n");
58 return;
59 }
60 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
61 printk("old bootloader convention, maybe loadlin?\n");
62 }
63 command_line = (char *) ((u64)(new_data));
64 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
65 #else
66 int max_cmdline;
68 if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
69 max_cmdline = COMMAND_LINE_SIZE;
70 memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
71 saved_command_line[max_cmdline-1] = '\0';
72 #endif
73 printk("Bootdata ok (command line is %s)\n", saved_command_line);
74 }
76 static void __init setup_boot_cpu_data(void)
77 {
78 unsigned int dummy, eax;
80 /* get vendor info */
81 cpuid(0, (unsigned int *)&boot_cpu_data.cpuid_level,
82 (unsigned int *)&boot_cpu_data.x86_vendor_id[0],
83 (unsigned int *)&boot_cpu_data.x86_vendor_id[8],
84 (unsigned int *)&boot_cpu_data.x86_vendor_id[4]);
86 /* get cpu type */
87 cpuid(1, &eax, &dummy, &dummy,
88 (unsigned int *) &boot_cpu_data.x86_capability);
89 boot_cpu_data.x86 = (eax >> 8) & 0xf;
90 boot_cpu_data.x86_model = (eax >> 4) & 0xf;
91 boot_cpu_data.x86_mask = eax & 0xf;
92 }
94 #include <xen/interface/memory.h>
95 unsigned long *machine_to_phys_mapping;
96 EXPORT_SYMBOL(machine_to_phys_mapping);
97 unsigned int machine_to_phys_order;
98 EXPORT_SYMBOL(machine_to_phys_order);
100 void __init x86_64_start_kernel(char * real_mode_data)
101 {
102 struct xen_machphys_mapping mapping;
103 unsigned long machine_to_phys_nr_ents;
104 char *s;
105 int i;
107 setup_xen_features();
109 xen_start_info = (struct start_info *)real_mode_data;
110 if (!xen_feature(XENFEAT_auto_translated_physmap))
111 phys_to_machine_mapping =
112 (unsigned long *)xen_start_info->mfn_list;
113 start_pfn = (__pa(xen_start_info->pt_base) >> PAGE_SHIFT) +
114 xen_start_info->nr_pt_frames;
116 machine_to_phys_mapping = (unsigned long *)MACH2PHYS_VIRT_START;
117 machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
118 if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
119 machine_to_phys_mapping = (unsigned long *)mapping.v_start;
120 machine_to_phys_nr_ents = mapping.max_mfn + 1;
121 }
122 while ((1UL << machine_to_phys_order) < machine_to_phys_nr_ents )
123 machine_to_phys_order++;
125 #if 0
126 for (i = 0; i < 256; i++)
127 set_intr_gate(i, early_idt_handler);
128 asm volatile("lidt %0" :: "m" (idt_descr));
129 #endif
131 /*
132 * This must be called really, really early:
133 */
134 lockdep_init();
136 for (i = 0; i < NR_CPUS; i++)
137 cpu_pda(i) = &boot_cpu_pda[i];
139 pda_init(0);
140 copy_bootdata(real_mode_data);
141 #ifdef CONFIG_SMP
142 cpu_set(0, cpu_online_map);
143 #endif
144 s = strstr(saved_command_line, "earlyprintk=");
145 if (s != NULL)
146 setup_early_printk(strchr(s, '=') + 1);
147 #ifdef CONFIG_NUMA
148 s = strstr(saved_command_line, "numa=");
149 if (s != NULL)
150 numa_setup(s+5);
151 #endif
152 #ifdef CONFIG_X86_IO_APIC
153 if (strstr(saved_command_line, "disableapic"))
154 disable_apic = 1;
155 #endif
156 /* You need early console to see that */
157 if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
158 panic("Kernel too big for kernel mapping\n");
160 setup_boot_cpu_data();
161 start_kernel();
162 }