setup_64.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  1. /*
  2. * Copyright (C) 1995 Linus Torvalds
  3. */
  4. /*
  5. * This file handles the architecture-dependent parts of initialization
  6. */
  7. #include <linux/errno.h>
  8. #include <linux/sched.h>
  9. #include <linux/kernel.h>
  10. #include <linux/mm.h>
  11. #include <linux/stddef.h>
  12. #include <linux/unistd.h>
  13. #include <linux/ptrace.h>
  14. #include <linux/slab.h>
  15. #include <linux/user.h>
  16. #include <linux/a.out.h>
  17. #include <linux/screen_info.h>
  18. #include <linux/ioport.h>
  19. #include <linux/delay.h>
  20. #include <linux/init.h>
  21. #include <linux/initrd.h>
  22. #include <linux/highmem.h>
  23. #include <linux/bootmem.h>
  24. #include <linux/module.h>
  25. #include <asm/processor.h>
  26. #include <linux/console.h>
  27. #include <linux/seq_file.h>
  28. #include <linux/crash_dump.h>
  29. #include <linux/root_dev.h>
  30. #include <linux/pci.h>
  31. #include <linux/efi.h>
  32. #include <linux/acpi.h>
  33. #include <linux/kallsyms.h>
  34. #include <linux/edd.h>
  35. #include <linux/mmzone.h>
  36. #include <linux/kexec.h>
  37. #include <linux/cpufreq.h>
  38. #include <linux/dmi.h>
  39. #include <linux/dma-mapping.h>
  40. #include <linux/ctype.h>
  41. #include <linux/uaccess.h>
  42. #include <asm/mtrr.h>
  43. #include <asm/uaccess.h>
  44. #include <asm/system.h>
  45. #include <asm/vsyscall.h>
  46. #include <asm/io.h>
  47. #include <asm/smp.h>
  48. #include <asm/msr.h>
  49. #include <asm/desc.h>
  50. #include <video/edid.h>
  51. #include <asm/e820.h>
  52. #include <asm/dma.h>
  53. #include <asm/gart.h>
  54. #include <asm/mpspec.h>
  55. #include <asm/mmu_context.h>
  56. #include <asm/proto.h>
  57. #include <asm/setup.h>
  58. #include <asm/mach_apic.h>
  59. #include <asm/numa.h>
  60. #include <asm/sections.h>
  61. #include <asm/dmi.h>
  62. #include <asm/cacheflush.h>
  63. #include <asm/mce.h>
  64. #include <asm/ds.h>
  65. #include <asm/topology.h>
  66. #ifdef CONFIG_PARAVIRT
  67. #include <asm/paravirt.h>
  68. #else
  69. #define ARCH_SETUP
  70. #endif
  71. /*
  72. * Machine setup..
  73. */
  74. struct cpuinfo_x86 boot_cpu_data __read_mostly;
  75. EXPORT_SYMBOL(boot_cpu_data);
  76. unsigned long mmu_cr4_features;
  77. /* Boot loader ID as an integer, for the benefit of proc_dointvec */
  78. int bootloader_type;
  79. unsigned long saved_video_mode;
  80. int force_mwait __cpuinitdata;
  81. /*
  82. * Early DMI memory
  83. */
  84. int dmi_alloc_index;
  85. char dmi_alloc_data[DMI_MAX_DATA];
  86. /*
  87. * Setup options
  88. */
  89. struct screen_info screen_info;
  90. EXPORT_SYMBOL(screen_info);
  91. struct sys_desc_table_struct {
  92. unsigned short length;
  93. unsigned char table[0];
  94. };
  95. struct edid_info edid_info;
  96. EXPORT_SYMBOL_GPL(edid_info);
  97. extern int root_mountflags;
  98. char __initdata command_line[COMMAND_LINE_SIZE];
  99. struct resource standard_io_resources[] = {
  100. { .name = "dma1", .start = 0x00, .end = 0x1f,
  101. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  102. { .name = "pic1", .start = 0x20, .end = 0x21,
  103. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  104. { .name = "timer0", .start = 0x40, .end = 0x43,
  105. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  106. { .name = "timer1", .start = 0x50, .end = 0x53,
  107. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  108. { .name = "keyboard", .start = 0x60, .end = 0x6f,
  109. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  110. { .name = "dma page reg", .start = 0x80, .end = 0x8f,
  111. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  112. { .name = "pic2", .start = 0xa0, .end = 0xa1,
  113. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  114. { .name = "dma2", .start = 0xc0, .end = 0xdf,
  115. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  116. { .name = "fpu", .start = 0xf0, .end = 0xff,
  117. .flags = IORESOURCE_BUSY | IORESOURCE_IO }
  118. };
  119. #define IORESOURCE_RAM (IORESOURCE_BUSY | IORESOURCE_MEM)
  120. static struct resource data_resource = {
  121. .name = "Kernel data",
  122. .start = 0,
  123. .end = 0,
  124. .flags = IORESOURCE_RAM,
  125. };
  126. static struct resource code_resource = {
  127. .name = "Kernel code",
  128. .start = 0,
  129. .end = 0,
  130. .flags = IORESOURCE_RAM,
  131. };
  132. static struct resource bss_resource = {
  133. .name = "Kernel bss",
  134. .start = 0,
  135. .end = 0,
  136. .flags = IORESOURCE_RAM,
  137. };
  138. static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c);
  139. #ifdef CONFIG_PROC_VMCORE
  140. /* elfcorehdr= specifies the location of elf core header
  141. * stored by the crashed kernel. This option will be passed
  142. * by kexec loader to the capture kernel.
  143. */
  144. static int __init setup_elfcorehdr(char *arg)
  145. {
  146. char *end;
  147. if (!arg)
  148. return -EINVAL;
  149. elfcorehdr_addr = memparse(arg, &end);
  150. return end > arg ? 0 : -EINVAL;
  151. }
  152. early_param("elfcorehdr", setup_elfcorehdr);
  153. #endif
  154. #ifndef CONFIG_NUMA
  155. static void __init
  156. contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
  157. {
  158. unsigned long bootmap_size, bootmap;
  159. bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
  160. bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size);
  161. if (bootmap == -1L)
  162. panic("Cannot find bootmem map of size %ld\n", bootmap_size);
  163. bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn);
  164. e820_register_active_regions(0, start_pfn, end_pfn);
  165. free_bootmem_with_active_regions(0, end_pfn);
  166. reserve_bootmem(bootmap, bootmap_size);
  167. }
  168. #endif
  169. #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
  170. struct edd edd;
  171. #ifdef CONFIG_EDD_MODULE
  172. EXPORT_SYMBOL(edd);
  173. #endif
  174. /**
  175. * copy_edd() - Copy the BIOS EDD information
  176. * from boot_params into a safe place.
  177. *
  178. */
  179. static inline void copy_edd(void)
  180. {
  181. memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
  182. sizeof(edd.mbr_signature));
  183. memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
  184. edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
  185. edd.edd_info_nr = boot_params.eddbuf_entries;
  186. }
  187. #else
  188. static inline void copy_edd(void)
  189. {
  190. }
  191. #endif
  192. #ifdef CONFIG_KEXEC
  193. static void __init reserve_crashkernel(void)
  194. {
  195. unsigned long long free_mem;
  196. unsigned long long crash_size, crash_base;
  197. int ret;
  198. free_mem =
  199. ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT;
  200. ret = parse_crashkernel(boot_command_line, free_mem,
  201. &crash_size, &crash_base);
  202. if (ret == 0 && crash_size) {
  203. if (crash_base > 0) {
  204. printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
  205. "for crashkernel (System RAM: %ldMB)\n",
  206. (unsigned long)(crash_size >> 20),
  207. (unsigned long)(crash_base >> 20),
  208. (unsigned long)(free_mem >> 20));
  209. crashk_res.start = crash_base;
  210. crashk_res.end = crash_base + crash_size - 1;
  211. reserve_bootmem(crash_base, crash_size);
  212. } else
  213. printk(KERN_INFO "crashkernel reservation failed - "
  214. "you have to specify a base address\n");
  215. }
  216. }
  217. #else
  218. static inline void __init reserve_crashkernel(void)
  219. {}
  220. #endif
  221. /* Overridden in paravirt.c if CONFIG_PARAVIRT */
  222. void __attribute__((weak)) __init memory_setup(void)
  223. {
  224. machine_specific_memory_setup();
  225. }
  226. void __init setup_arch(char **cmdline_p)
  227. {
  228. unsigned i;
  229. printk(KERN_INFO "Command line: %s\n", boot_command_line);
  230. ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
  231. screen_info = boot_params.screen_info;
  232. edid_info = boot_params.edid_info;
  233. saved_video_mode = boot_params.hdr.vid_mode;
  234. bootloader_type = boot_params.hdr.type_of_loader;
  235. #ifdef CONFIG_BLK_DEV_RAM
  236. rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
  237. rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
  238. rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
  239. #endif
  240. #ifdef CONFIG_EFI
  241. if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
  242. "EL64", 4))
  243. efi_enabled = 1;
  244. #endif
  245. ARCH_SETUP
  246. memory_setup();
  247. copy_edd();
  248. if (!boot_params.hdr.root_flags)
  249. root_mountflags &= ~MS_RDONLY;
  250. init_mm.start_code = (unsigned long) &_text;
  251. init_mm.end_code = (unsigned long) &_etext;
  252. init_mm.end_data = (unsigned long) &_edata;
  253. init_mm.brk = (unsigned long) &_end;
  254. code_resource.start = virt_to_phys(&_text);
  255. code_resource.end = virt_to_phys(&_etext)-1;
  256. data_resource.start = virt_to_phys(&_etext);
  257. data_resource.end = virt_to_phys(&_edata)-1;
  258. bss_resource.start = virt_to_phys(&__bss_start);
  259. bss_resource.end = virt_to_phys(&__bss_stop)-1;
  260. early_identify_cpu(&boot_cpu_data);
  261. strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
  262. *cmdline_p = command_line;
  263. parse_early_param();
  264. finish_e820_parsing();
  265. early_gart_iommu_check();
  266. e820_register_active_regions(0, 0, -1UL);
  267. /*
  268. * partially used pages are not usable - thus
  269. * we are rounding upwards:
  270. */
  271. end_pfn = e820_end_of_ram();
  272. /* update e820 for memory not covered by WB MTRRs */
  273. mtrr_bp_init();
  274. if (mtrr_trim_uncached_memory(end_pfn)) {
  275. e820_register_active_regions(0, 0, -1UL);
  276. end_pfn = e820_end_of_ram();
  277. }
  278. num_physpages = end_pfn;
  279. check_efer();
  280. init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
  281. if (efi_enabled)
  282. efi_init();
  283. dmi_scan_machine();
  284. io_delay_init();
  285. #ifdef CONFIG_SMP
  286. /* setup to use the early static init tables during kernel startup */
  287. x86_cpu_to_apicid_early_ptr = (void *)&x86_cpu_to_apicid_init;
  288. #ifdef CONFIG_NUMA
  289. x86_cpu_to_node_map_early_ptr = (void *)&x86_cpu_to_node_map_init;
  290. #endif
  291. x86_bios_cpu_apicid_early_ptr = (void *)&x86_bios_cpu_apicid_init;
  292. #endif
  293. #ifdef CONFIG_ACPI
  294. /*
  295. * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
  296. * Call this early for SRAT node setup.
  297. */
  298. acpi_boot_table_init();
  299. #endif
  300. /* How many end-of-memory variables you have, grandma! */
  301. max_low_pfn = end_pfn;
  302. max_pfn = end_pfn;
  303. high_memory = (void *)__va(end_pfn * PAGE_SIZE - 1) + 1;
  304. /* Remove active ranges so rediscovery with NUMA-awareness happens */
  305. remove_all_active_ranges();
  306. #ifdef CONFIG_ACPI_NUMA
  307. /*
  308. * Parse SRAT to discover nodes.
  309. */
  310. acpi_numa_init();
  311. #endif
  312. #ifdef CONFIG_NUMA
  313. numa_initmem_init(0, end_pfn);
  314. #else
  315. contig_initmem_init(0, end_pfn);
  316. #endif
  317. early_res_to_bootmem();
  318. #ifdef CONFIG_ACPI_SLEEP
  319. /*
  320. * Reserve low memory region for sleep support.
  321. */
  322. acpi_reserve_bootmem();
  323. #endif
  324. if (efi_enabled) {
  325. efi_map_memmap();
  326. efi_reserve_bootmem();
  327. }
  328. /*
  329. * Find and reserve possible boot-time SMP configuration:
  330. */
  331. find_smp_config();
  332. #ifdef CONFIG_BLK_DEV_INITRD
  333. if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
  334. unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
  335. unsigned long ramdisk_size = boot_params.hdr.ramdisk_size;
  336. unsigned long ramdisk_end = ramdisk_image + ramdisk_size;
  337. unsigned long end_of_mem = end_pfn << PAGE_SHIFT;
  338. if (ramdisk_end <= end_of_mem) {
  339. reserve_bootmem_generic(ramdisk_image, ramdisk_size);
  340. initrd_start = ramdisk_image + PAGE_OFFSET;
  341. initrd_end = initrd_start+ramdisk_size;
  342. } else {
  343. /* Assumes everything on node 0 */
  344. free_bootmem(ramdisk_image, ramdisk_size);
  345. printk(KERN_ERR "initrd extends beyond end of memory "
  346. "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
  347. ramdisk_end, end_of_mem);
  348. initrd_start = 0;
  349. }
  350. }
  351. #endif
  352. reserve_crashkernel();
  353. paging_init();
  354. map_vsyscall();
  355. early_quirks();
  356. /*
  357. * set this early, so we dont allocate cpu0
  358. * if MADT list doesnt list BSP first
  359. * mpparse.c/MP_processor_info() allocates logical cpu numbers.
  360. */
  361. cpu_set(0, cpu_present_map);
  362. #ifdef CONFIG_ACPI
  363. /*
  364. * Read APIC and some other early information from ACPI tables.
  365. */
  366. acpi_boot_init();
  367. #endif
  368. init_cpu_to_node();
  369. /*
  370. * get boot-time SMP configuration:
  371. */
  372. if (smp_found_config)
  373. get_smp_config();
  374. init_apic_mappings();
  375. ioapic_init_mappings();
  376. /*
  377. * We trust e820 completely. No explicit ROM probing in memory.
  378. */
  379. e820_reserve_resources(&code_resource, &data_resource, &bss_resource);
  380. e820_mark_nosave_regions();
  381. /* request I/O space for devices used on all i[345]86 PCs */
  382. for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
  383. request_resource(&ioport_resource, &standard_io_resources[i]);
  384. e820_setup_gap();
  385. #ifdef CONFIG_VT
  386. #if defined(CONFIG_VGA_CONSOLE)
  387. if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
  388. conswitchp = &vga_con;
  389. #elif defined(CONFIG_DUMMY_CONSOLE)
  390. conswitchp = &dummy_con;
  391. #endif
  392. #endif
  393. }
  394. static int __cpuinit get_model_name(struct cpuinfo_x86 *c)
  395. {
  396. unsigned int *v;
  397. if (c->extended_cpuid_level < 0x80000004)
  398. return 0;
  399. v = (unsigned int *) c->x86_model_id;
  400. cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
  401. cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
  402. cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
  403. c->x86_model_id[48] = 0;
  404. return 1;
  405. }
  406. static void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
  407. {
  408. unsigned int n, dummy, eax, ebx, ecx, edx;
  409. n = c->extended_cpuid_level;
  410. if (n >= 0x80000005) {
  411. cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
  412. printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), "
  413. "D cache %dK (%d bytes/line)\n",
  414. edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
  415. c->x86_cache_size = (ecx>>24) + (edx>>24);
  416. /* On K8 L1 TLB is inclusive, so don't count it */
  417. c->x86_tlbsize = 0;
  418. }
  419. if (n >= 0x80000006) {
  420. cpuid(0x80000006, &dummy, &ebx, &ecx, &edx);
  421. ecx = cpuid_ecx(0x80000006);
  422. c->x86_cache_size = ecx >> 16;
  423. c->x86_tlbsize += ((ebx >> 16) & 0xfff) + (ebx & 0xfff);
  424. printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n",
  425. c->x86_cache_size, ecx & 0xFF);
  426. }
  427. if (n >= 0x80000008) {
  428. cpuid(0x80000008, &eax, &dummy, &dummy, &dummy);
  429. c->x86_virt_bits = (eax >> 8) & 0xff;
  430. c->x86_phys_bits = eax & 0xff;
  431. }
  432. }
  433. #ifdef CONFIG_NUMA
  434. static int nearby_node(int apicid)
  435. {
  436. int i, node;
  437. for (i = apicid - 1; i >= 0; i--) {
  438. node = apicid_to_node[i];
  439. if (node != NUMA_NO_NODE && node_online(node))
  440. return node;
  441. }
  442. for (i = apicid + 1; i < MAX_LOCAL_APIC; i++) {
  443. node = apicid_to_node[i];
  444. if (node != NUMA_NO_NODE && node_online(node))
  445. return node;
  446. }
  447. return first_node(node_online_map); /* Shouldn't happen */
  448. }
  449. #endif
  450. /*
  451. * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
  452. * Assumes number of cores is a power of two.
  453. */
  454. static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
  455. {
  456. #ifdef CONFIG_SMP
  457. unsigned bits;
  458. #ifdef CONFIG_NUMA
  459. int cpu = smp_processor_id();
  460. int node = 0;
  461. unsigned apicid = hard_smp_processor_id();
  462. #endif
  463. bits = c->x86_coreid_bits;
  464. /* Low order bits define the core id (index of core in socket) */
  465. c->cpu_core_id = c->phys_proc_id & ((1 << bits)-1);
  466. /* Convert the APIC ID into the socket ID */
  467. c->phys_proc_id = phys_pkg_id(bits);
  468. #ifdef CONFIG_NUMA
  469. node = c->phys_proc_id;
  470. if (apicid_to_node[apicid] != NUMA_NO_NODE)
  471. node = apicid_to_node[apicid];
  472. if (!node_online(node)) {
  473. /* Two possibilities here:
  474. - The CPU is missing memory and no node was created.
  475. In that case try picking one from a nearby CPU
  476. - The APIC IDs differ from the HyperTransport node IDs
  477. which the K8 northbridge parsing fills in.
  478. Assume they are all increased by a constant offset,
  479. but in the same order as the HT nodeids.
  480. If that doesn't result in a usable node fall back to the
  481. path for the previous case. */
  482. int ht_nodeid = apicid - (cpu_data(0).phys_proc_id << bits);
  483. if (ht_nodeid >= 0 &&
  484. apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
  485. node = apicid_to_node[ht_nodeid];
  486. /* Pick a nearby node */
  487. if (!node_online(node))
  488. node = nearby_node(apicid);
  489. }
  490. numa_set_node(cpu, node);
  491. printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
  492. #endif
  493. #endif
  494. }
  495. static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
  496. {
  497. #ifdef CONFIG_SMP
  498. unsigned bits, ecx;
  499. /* Multi core CPU? */
  500. if (c->extended_cpuid_level < 0x80000008)
  501. return;
  502. ecx = cpuid_ecx(0x80000008);
  503. c->x86_max_cores = (ecx & 0xff) + 1;
  504. /* CPU telling us the core id bits shift? */
  505. bits = (ecx >> 12) & 0xF;
  506. /* Otherwise recompute */
  507. if (bits == 0) {
  508. while ((1 << bits) < c->x86_max_cores)
  509. bits++;
  510. }
  511. c->x86_coreid_bits = bits;
  512. #endif
  513. }
  514. #define ENABLE_C1E_MASK 0x18000000
  515. #define CPUID_PROCESSOR_SIGNATURE 1
  516. #define CPUID_XFAM 0x0ff00000
  517. #define CPUID_XFAM_K8 0x00000000
  518. #define CPUID_XFAM_10H 0x00100000
  519. #define CPUID_XFAM_11H 0x00200000
  520. #define CPUID_XMOD 0x000f0000
  521. #define CPUID_XMOD_REV_F 0x00040000
  522. /* AMD systems with C1E don't have a working lAPIC timer. Check for that. */
  523. static __cpuinit int amd_apic_timer_broken(void)
  524. {
  525. u32 lo, hi, eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE);
  526. switch (eax & CPUID_XFAM) {
  527. case CPUID_XFAM_K8:
  528. if ((eax & CPUID_XMOD) < CPUID_XMOD_REV_F)
  529. break;
  530. case CPUID_XFAM_10H:
  531. case CPUID_XFAM_11H:
  532. rdmsr(MSR_K8_ENABLE_C1E, lo, hi);
  533. if (lo & ENABLE_C1E_MASK)
  534. return 1;
  535. break;
  536. default:
  537. /* err on the side of caution */
  538. return 1;
  539. }
  540. return 0;
  541. }
  542. static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
  543. {
  544. early_init_amd_mc(c);
  545. /* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */
  546. if (c->x86_power & (1<<8))
  547. set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
  548. }
  549. static void __cpuinit init_amd(struct cpuinfo_x86 *c)
  550. {
  551. unsigned level;
  552. #ifdef CONFIG_SMP
  553. unsigned long value;
  554. /*
  555. * Disable TLB flush filter by setting HWCR.FFDIS on K8
  556. * bit 6 of msr C001_0015
  557. *
  558. * Errata 63 for SH-B3 steppings
  559. * Errata 122 for all steppings (F+ have it disabled by default)
  560. */
  561. if (c->x86 == 15) {
  562. rdmsrl(MSR_K8_HWCR, value);
  563. value |= 1 << 6;
  564. wrmsrl(MSR_K8_HWCR, value);
  565. }
  566. #endif
  567. /* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
  568. 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
  569. clear_bit(0*32+31, (unsigned long *)&c->x86_capability);
  570. /* On C+ stepping K8 rep microcode works well for copy/memset */
  571. level = cpuid_eax(1);
  572. if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) ||
  573. level >= 0x0f58))
  574. set_cpu_cap(c, X86_FEATURE_REP_GOOD);
  575. if (c->x86 == 0x10 || c->x86 == 0x11)
  576. set_cpu_cap(c, X86_FEATURE_REP_GOOD);
  577. /* Enable workaround for FXSAVE leak */
  578. if (c->x86 >= 6)
  579. set_cpu_cap(c, X86_FEATURE_FXSAVE_LEAK);
  580. level = get_model_name(c);
  581. if (!level) {
  582. switch (c->x86) {
  583. case 15:
  584. /* Should distinguish Models here, but this is only
  585. a fallback anyways. */
  586. strcpy(c->x86_model_id, "Hammer");
  587. break;
  588. }
  589. }
  590. display_cacheinfo(c);
  591. /* Multi core CPU? */
  592. if (c->extended_cpuid_level >= 0x80000008)
  593. amd_detect_cmp(c);
  594. if (c->extended_cpuid_level >= 0x80000006 &&
  595. (cpuid_edx(0x80000006) & 0xf000))
  596. num_cache_leaves = 4;
  597. else
  598. num_cache_leaves = 3;
  599. if (c->x86 == 0xf || c->x86 == 0x10 || c->x86 == 0x11)
  600. set_cpu_cap(c, X86_FEATURE_K8);
  601. /* MFENCE stops RDTSC speculation */
  602. set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC);
  603. if (amd_apic_timer_broken())
  604. disable_apic_timer = 1;
  605. }
  606. void __cpuinit detect_ht(struct cpuinfo_x86 *c)
  607. {
  608. #ifdef CONFIG_SMP
  609. u32 eax, ebx, ecx, edx;
  610. int index_msb, core_bits;
  611. cpuid(1, &eax, &ebx, &ecx, &edx);
  612. if (!cpu_has(c, X86_FEATURE_HT))
  613. return;
  614. if (cpu_has(c, X86_FEATURE_CMP_LEGACY))
  615. goto out;
  616. smp_num_siblings = (ebx & 0xff0000) >> 16;
  617. if (smp_num_siblings == 1) {
  618. printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
  619. } else if (smp_num_siblings > 1) {
  620. if (smp_num_siblings > NR_CPUS) {
  621. printk(KERN_WARNING "CPU: Unsupported number of "
  622. "siblings %d", smp_num_siblings);
  623. smp_num_siblings = 1;
  624. return;
  625. }
  626. index_msb = get_count_order(smp_num_siblings);
  627. c->phys_proc_id = phys_pkg_id(index_msb);
  628. smp_num_siblings = smp_num_siblings / c->x86_max_cores;
  629. index_msb = get_count_order(smp_num_siblings);
  630. core_bits = get_count_order(c->x86_max_cores);
  631. c->cpu_core_id = phys_pkg_id(index_msb) &
  632. ((1 << core_bits) - 1);
  633. }
  634. out:
  635. if ((c->x86_max_cores * smp_num_siblings) > 1) {
  636. printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
  637. c->phys_proc_id);
  638. printk(KERN_INFO "CPU: Processor Core ID: %d\n",
  639. c->cpu_core_id);
  640. }
  641. #endif
  642. }
  643. /*
  644. * find out the number of processor cores on the die
  645. */
  646. static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
  647. {
  648. unsigned int eax, t;
  649. if (c->cpuid_level < 4)
  650. return 1;
  651. cpuid_count(4, 0, &eax, &t, &t, &t);
  652. if (eax & 0x1f)
  653. return ((eax >> 26) + 1);
  654. else
  655. return 1;
  656. }
  657. static void srat_detect_node(void)
  658. {
  659. #ifdef CONFIG_NUMA
  660. unsigned node;
  661. int cpu = smp_processor_id();
  662. int apicid = hard_smp_processor_id();
  663. /* Don't do the funky fallback heuristics the AMD version employs
  664. for now. */
  665. node = apicid_to_node[apicid];
  666. if (node == NUMA_NO_NODE)
  667. node = first_node(node_online_map);
  668. numa_set_node(cpu, node);
  669. printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
  670. #endif
  671. }
  672. static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
  673. {
  674. if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
  675. (c->x86 == 0x6 && c->x86_model >= 0x0e))
  676. set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
  677. }
  678. static void __cpuinit init_intel(struct cpuinfo_x86 *c)
  679. {
  680. /* Cache sizes */
  681. unsigned n;
  682. init_intel_cacheinfo(c);
  683. if (c->cpuid_level > 9) {
  684. unsigned eax = cpuid_eax(10);
  685. /* Check for version and the number of counters */
  686. if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
  687. set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
  688. }
  689. if (cpu_has_ds) {
  690. unsigned int l1, l2;
  691. rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
  692. if (!(l1 & (1<<11)))
  693. set_cpu_cap(c, X86_FEATURE_BTS);
  694. if (!(l1 & (1<<12)))
  695. set_cpu_cap(c, X86_FEATURE_PEBS);
  696. }
  697. if (cpu_has_bts)
  698. ds_init_intel(c);
  699. n = c->extended_cpuid_level;
  700. if (n >= 0x80000008) {
  701. unsigned eax = cpuid_eax(0x80000008);
  702. c->x86_virt_bits = (eax >> 8) & 0xff;
  703. c->x86_phys_bits = eax & 0xff;
  704. /* CPUID workaround for Intel 0F34 CPU */
  705. if (c->x86_vendor == X86_VENDOR_INTEL &&
  706. c->x86 == 0xF && c->x86_model == 0x3 &&
  707. c->x86_mask == 0x4)
  708. c->x86_phys_bits = 36;
  709. }
  710. if (c->x86 == 15)
  711. c->x86_cache_alignment = c->x86_clflush_size * 2;
  712. if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
  713. (c->x86 == 0x6 && c->x86_model >= 0x0e))
  714. set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
  715. if (c->x86 == 6)
  716. set_cpu_cap(c, X86_FEATURE_REP_GOOD);
  717. set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
  718. c->x86_max_cores = intel_num_cpu_cores(c);
  719. srat_detect_node();
  720. }
  721. static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
  722. {
  723. char *v = c->x86_vendor_id;
  724. if (!strcmp(v, "AuthenticAMD"))
  725. c->x86_vendor = X86_VENDOR_AMD;
  726. else if (!strcmp(v, "GenuineIntel"))
  727. c->x86_vendor = X86_VENDOR_INTEL;
  728. else
  729. c->x86_vendor = X86_VENDOR_UNKNOWN;
  730. }
  731. struct cpu_model_info {
  732. int vendor;
  733. int family;
  734. char *model_names[16];
  735. };
  736. /* Do some early cpuid on the boot CPU to get some parameter that are
  737. needed before check_bugs. Everything advanced is in identify_cpu
  738. below. */
  739. static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
  740. {
  741. u32 tfms, xlvl;
  742. c->loops_per_jiffy = loops_per_jiffy;
  743. c->x86_cache_size = -1;
  744. c->x86_vendor = X86_VENDOR_UNKNOWN;
  745. c->x86_model = c->x86_mask = 0; /* So far unknown... */
  746. c->x86_vendor_id[0] = '\0'; /* Unset */
  747. c->x86_model_id[0] = '\0'; /* Unset */
  748. c->x86_clflush_size = 64;
  749. c->x86_cache_alignment = c->x86_clflush_size;
  750. c->x86_max_cores = 1;
  751. c->x86_coreid_bits = 0;
  752. c->extended_cpuid_level = 0;
  753. memset(&c->x86_capability, 0, sizeof c->x86_capability);
  754. /* Get vendor name */
  755. cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
  756. (unsigned int *)&c->x86_vendor_id[0],
  757. (unsigned int *)&c->x86_vendor_id[8],
  758. (unsigned int *)&c->x86_vendor_id[4]);
  759. get_cpu_vendor(c);
  760. /* Initialize the standard set of capabilities */
  761. /* Note that the vendor-specific code below might override */
  762. /* Intel-defined flags: level 0x00000001 */
  763. if (c->cpuid_level >= 0x00000001) {
  764. __u32 misc;
  765. cpuid(0x00000001, &tfms, &misc, &c->x86_capability[4],
  766. &c->x86_capability[0]);
  767. c->x86 = (tfms >> 8) & 0xf;
  768. c->x86_model = (tfms >> 4) & 0xf;
  769. c->x86_mask = tfms & 0xf;
  770. if (c->x86 == 0xf)
  771. c->x86 += (tfms >> 20) & 0xff;
  772. if (c->x86 >= 0x6)
  773. c->x86_model += ((tfms >> 16) & 0xF) << 4;
  774. if (c->x86_capability[0] & (1<<19))
  775. c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
  776. } else {
  777. /* Have CPUID level 0 only - unheard of */
  778. c->x86 = 4;
  779. }
  780. #ifdef CONFIG_SMP
  781. c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
  782. #endif
  783. /* AMD-defined flags: level 0x80000001 */
  784. xlvl = cpuid_eax(0x80000000);
  785. c->extended_cpuid_level = xlvl;
  786. if ((xlvl & 0xffff0000) == 0x80000000) {
  787. if (xlvl >= 0x80000001) {
  788. c->x86_capability[1] = cpuid_edx(0x80000001);
  789. c->x86_capability[6] = cpuid_ecx(0x80000001);
  790. }
  791. if (xlvl >= 0x80000004)
  792. get_model_name(c); /* Default name */
  793. }
  794. /* Transmeta-defined flags: level 0x80860001 */
  795. xlvl = cpuid_eax(0x80860000);
  796. if ((xlvl & 0xffff0000) == 0x80860000) {
  797. /* Don't set x86_cpuid_level here for now to not confuse. */
  798. if (xlvl >= 0x80860001)
  799. c->x86_capability[2] = cpuid_edx(0x80860001);
  800. }
  801. c->extended_cpuid_level = cpuid_eax(0x80000000);
  802. if (c->extended_cpuid_level >= 0x80000007)
  803. c->x86_power = cpuid_edx(0x80000007);
  804. switch (c->x86_vendor) {
  805. case X86_VENDOR_AMD:
  806. early_init_amd(c);
  807. break;
  808. case X86_VENDOR_INTEL:
  809. early_init_intel(c);
  810. break;
  811. }
  812. }
  813. /*
  814. * This does the hard work of actually picking apart the CPU stuff...
  815. */
  816. void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
  817. {
  818. int i;
  819. early_identify_cpu(c);
  820. init_scattered_cpuid_features(c);
  821. c->apicid = phys_pkg_id(0);
  822. /*
  823. * Vendor-specific initialization. In this section we
  824. * canonicalize the feature flags, meaning if there are
  825. * features a certain CPU supports which CPUID doesn't
  826. * tell us, CPUID claiming incorrect flags, or other bugs,
  827. * we handle them here.
  828. *
  829. * At the end of this section, c->x86_capability better
  830. * indicate the features this CPU genuinely supports!
  831. */
  832. switch (c->x86_vendor) {
  833. case X86_VENDOR_AMD:
  834. init_amd(c);
  835. break;
  836. case X86_VENDOR_INTEL:
  837. init_intel(c);
  838. break;
  839. case X86_VENDOR_UNKNOWN:
  840. default:
  841. display_cacheinfo(c);
  842. break;
  843. }
  844. select_idle_routine(c);
  845. detect_ht(c);
  846. /*
  847. * On SMP, boot_cpu_data holds the common feature set between
  848. * all CPUs; so make sure that we indicate which features are
  849. * common between the CPUs. The first time this routine gets
  850. * executed, c == &boot_cpu_data.
  851. */
  852. if (c != &boot_cpu_data) {
  853. /* AND the already accumulated flags with these */
  854. for (i = 0; i < NCAPINTS; i++)
  855. boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
  856. }
  857. #ifdef CONFIG_X86_MCE
  858. mcheck_init(c);
  859. #endif
  860. if (c != &boot_cpu_data)
  861. mtrr_ap_init();
  862. #ifdef CONFIG_NUMA
  863. numa_add_cpu(smp_processor_id());
  864. #endif
  865. }
  866. void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
  867. {
  868. if (c->x86_model_id[0])
  869. printk(KERN_INFO "%s", c->x86_model_id);
  870. if (c->x86_mask || c->cpuid_level >= 0)
  871. printk(KERN_CONT " stepping %02x\n", c->x86_mask);
  872. else
  873. printk(KERN_CONT "\n");
  874. }
  875. /*
  876. * Get CPU information for use by the procfs.
  877. */
  878. static int show_cpuinfo(struct seq_file *m, void *v)
  879. {
  880. struct cpuinfo_x86 *c = v;
  881. int cpu = 0, i;
  882. /*
  883. * These flag bits must match the definitions in <asm/cpufeature.h>.
  884. * NULL means this bit is undefined or reserved; either way it doesn't
  885. * have meaning as far as Linux is concerned. Note that it's important
  886. * to realize there is a difference between this table and CPUID -- if
  887. * applications want to get the raw CPUID data, they should access
  888. * /dev/cpu/<cpu_nr>/cpuid instead.
  889. */
  890. static const char *const x86_cap_flags[] = {
  891. /* Intel-defined */
  892. "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
  893. "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
  894. "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
  895. "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
  896. /* AMD-defined */
  897. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  898. NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
  899. NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL,
  900. NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm",
  901. "3dnowext", "3dnow",
  902. /* Transmeta-defined */
  903. "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
  904. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  905. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  906. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  907. /* Other (Linux-defined) */
  908. "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
  909. NULL, NULL, NULL, NULL,
  910. "constant_tsc", "up", NULL, "arch_perfmon",
  911. "pebs", "bts", NULL, "sync_rdtsc",
  912. "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  913. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  914. /* Intel-defined (#2) */
  915. "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
  916. "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
  917. NULL, NULL, "dca", "sse4_1", "sse4_2", NULL, NULL, "popcnt",
  918. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  919. /* VIA/Cyrix/Centaur-defined */
  920. NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
  921. "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
  922. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  923. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  924. /* AMD-defined (#2) */
  925. "lahf_lm", "cmp_legacy", "svm", "extapic",
  926. "cr8_legacy", "abm", "sse4a", "misalignsse",
  927. "3dnowprefetch", "osvw", "ibs", "sse5",
  928. "skinit", "wdt", NULL, NULL,
  929. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  930. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  931. /* Auxiliary (Linux-defined) */
  932. "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  933. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  934. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  935. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  936. };
  937. static const char *const x86_power_flags[] = {
  938. "ts", /* temperature sensor */
  939. "fid", /* frequency id control */
  940. "vid", /* voltage id control */
  941. "ttp", /* thermal trip */
  942. "tm",
  943. "stc",
  944. "100mhzsteps",
  945. "hwpstate",
  946. "", /* tsc invariant mapped to constant_tsc */
  947. /* nothing */
  948. };
  949. #ifdef CONFIG_SMP
  950. cpu = c->cpu_index;
  951. #endif
  952. seq_printf(m, "processor\t: %u\n"
  953. "vendor_id\t: %s\n"
  954. "cpu family\t: %d\n"
  955. "model\t\t: %d\n"
  956. "model name\t: %s\n",
  957. (unsigned)cpu,
  958. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  959. c->x86,
  960. (int)c->x86_model,
  961. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  962. if (c->x86_mask || c->cpuid_level >= 0)
  963. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  964. else
  965. seq_printf(m, "stepping\t: unknown\n");
  966. if (cpu_has(c, X86_FEATURE_TSC)) {
  967. unsigned int freq = cpufreq_quick_get((unsigned)cpu);
  968. if (!freq)
  969. freq = cpu_khz;
  970. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  971. freq / 1000, (freq % 1000));
  972. }
  973. /* Cache size */
  974. if (c->x86_cache_size >= 0)
  975. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  976. #ifdef CONFIG_SMP
  977. if (smp_num_siblings * c->x86_max_cores > 1) {
  978. seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
  979. seq_printf(m, "siblings\t: %d\n",
  980. cpus_weight(per_cpu(cpu_core_map, cpu)));
  981. seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
  982. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  983. }
  984. #endif
  985. seq_printf(m,
  986. "fpu\t\t: yes\n"
  987. "fpu_exception\t: yes\n"
  988. "cpuid level\t: %d\n"
  989. "wp\t\t: yes\n"
  990. "flags\t\t:",
  991. c->cpuid_level);
  992. for (i = 0; i < 32*NCAPINTS; i++)
  993. if (cpu_has(c, i) && x86_cap_flags[i] != NULL)
  994. seq_printf(m, " %s", x86_cap_flags[i]);
  995. seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
  996. c->loops_per_jiffy/(500000/HZ),
  997. (c->loops_per_jiffy/(5000/HZ)) % 100);
  998. if (c->x86_tlbsize > 0)
  999. seq_printf(m, "TLB size\t: %d 4K pages\n", c->x86_tlbsize);
  1000. seq_printf(m, "clflush size\t: %d\n", c->x86_clflush_size);
  1001. seq_printf(m, "cache_alignment\t: %d\n", c->x86_cache_alignment);
  1002. seq_printf(m, "address sizes\t: %u bits physical, %u bits virtual\n",
  1003. c->x86_phys_bits, c->x86_virt_bits);
  1004. seq_printf(m, "power management:");
  1005. for (i = 0; i < 32; i++) {
  1006. if (c->x86_power & (1 << i)) {
  1007. if (i < ARRAY_SIZE(x86_power_flags) &&
  1008. x86_power_flags[i])
  1009. seq_printf(m, "%s%s",
  1010. x86_power_flags[i][0]?" ":"",
  1011. x86_power_flags[i]);
  1012. else
  1013. seq_printf(m, " [%d]", i);
  1014. }
  1015. }
  1016. seq_printf(m, "\n\n");
  1017. return 0;
  1018. }
  1019. static void *c_start(struct seq_file *m, loff_t *pos)
  1020. {
  1021. if (*pos == 0) /* just in case, cpu 0 is not the first */
  1022. *pos = first_cpu(cpu_online_map);
  1023. if ((*pos) < NR_CPUS && cpu_online(*pos))
  1024. return &cpu_data(*pos);
  1025. return NULL;
  1026. }
  1027. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  1028. {
  1029. *pos = next_cpu(*pos, cpu_online_map);
  1030. return c_start(m, pos);
  1031. }
  1032. static void c_stop(struct seq_file *m, void *v)
  1033. {
  1034. }
  1035. struct seq_operations cpuinfo_op = {
  1036. .start = c_start,
  1037. .next = c_next,
  1038. .stop = c_stop,
  1039. .show = show_cpuinfo,
  1040. };