setup.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  1. /*
  2. * Copyright (C) 1995 Linus Torvalds
  3. *
  4. * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
  5. *
  6. * Memory region support
  7. * David Parsons <orc@pell.chi.il.us>, July-August 1999
  8. *
  9. * Added E820 sanitization routine (removes overlapping memory regions);
  10. * Brian Moyle <bmoyle@mvista.com>, February 2001
  11. *
  12. * Moved CPU detection code to cpu/${cpu}.c
  13. * Patrick Mochel <mochel@osdl.org>, March 2002
  14. *
  15. * Provisions for empty E820 memory regions (reported by certain BIOSes).
  16. * Alex Achenbach <xela@slit.de>, December 2002.
  17. *
  18. */
  19. /*
  20. * This file handles the architecture-dependent parts of initialization
  21. */
  22. #include <linux/sched.h>
  23. #include <linux/mm.h>
  24. #include <linux/mmzone.h>
  25. #include <linux/screen_info.h>
  26. #include <linux/ioport.h>
  27. #include <linux/acpi.h>
  28. #include <linux/sfi.h>
  29. #include <linux/apm_bios.h>
  30. #include <linux/initrd.h>
  31. #include <linux/bootmem.h>
  32. #include <linux/memblock.h>
  33. #include <linux/seq_file.h>
  34. #include <linux/console.h>
  35. #include <linux/root_dev.h>
  36. #include <linux/highmem.h>
  37. #include <linux/export.h>
  38. #include <linux/efi.h>
  39. #include <linux/init.h>
  40. #include <linux/edd.h>
  41. #include <linux/iscsi_ibft.h>
  42. #include <linux/nodemask.h>
  43. #include <linux/kexec.h>
  44. #include <linux/dmi.h>
  45. #include <linux/pfn.h>
  46. #include <linux/pci.h>
  47. #include <asm/pci-direct.h>
  48. #include <linux/init_ohci1394_dma.h>
  49. #include <linux/kvm_para.h>
  50. #include <linux/dma-contiguous.h>
  51. #include <linux/errno.h>
  52. #include <linux/kernel.h>
  53. #include <linux/stddef.h>
  54. #include <linux/unistd.h>
  55. #include <linux/ptrace.h>
  56. #include <linux/user.h>
  57. #include <linux/delay.h>
  58. #include <linux/kallsyms.h>
  59. #include <linux/cpufreq.h>
  60. #include <linux/dma-mapping.h>
  61. #include <linux/ctype.h>
  62. #include <linux/uaccess.h>
  63. #include <linux/percpu.h>
  64. #include <linux/crash_dump.h>
  65. #include <linux/tboot.h>
  66. #include <linux/jiffies.h>
  67. #include <video/edid.h>
  68. #include <asm/mtrr.h>
  69. #include <asm/apic.h>
  70. #include <asm/realmode.h>
  71. #include <asm/e820.h>
  72. #include <asm/mpspec.h>
  73. #include <asm/setup.h>
  74. #include <asm/efi.h>
  75. #include <asm/timer.h>
  76. #include <asm/i8259.h>
  77. #include <asm/sections.h>
  78. #include <asm/io_apic.h>
  79. #include <asm/ist.h>
  80. #include <asm/setup_arch.h>
  81. #include <asm/bios_ebda.h>
  82. #include <asm/cacheflush.h>
  83. #include <asm/processor.h>
  84. #include <asm/bugs.h>
  85. #include <asm/kasan.h>
  86. #include <asm/vsyscall.h>
  87. #include <asm/cpu.h>
  88. #include <asm/desc.h>
  89. #include <asm/dma.h>
  90. #include <asm/iommu.h>
  91. #include <asm/gart.h>
  92. #include <asm/mmu_context.h>
  93. #include <asm/proto.h>
  94. #include <asm/paravirt.h>
  95. #include <asm/hypervisor.h>
  96. #include <asm/olpc_ofw.h>
  97. #include <asm/percpu.h>
  98. #include <asm/topology.h>
  99. #include <asm/apicdef.h>
  100. #include <asm/amd_nb.h>
  101. #include <asm/mce.h>
  102. #include <asm/alternative.h>
  103. #include <asm/prom.h>
  104. #include <asm/microcode.h>
  105. #include <asm/mmu_context.h>
  106. #include <asm/kaslr.h>
  107. /*
  108. * max_low_pfn_mapped: highest direct mapped pfn under 4GB
  109. * max_pfn_mapped: highest direct mapped pfn over 4GB
  110. *
  111. * The direct mapping only covers E820_RAM regions, so the ranges and gaps are
  112. * represented by pfn_mapped
  113. */
  114. unsigned long max_low_pfn_mapped;
  115. unsigned long max_pfn_mapped;
  116. #ifdef CONFIG_DMI
  117. RESERVE_BRK(dmi_alloc, 65536);
  118. #endif
  119. static __initdata unsigned long _brk_start = (unsigned long)__brk_base;
  120. unsigned long _brk_end = (unsigned long)__brk_base;
  121. #ifdef CONFIG_X86_64
  122. int default_cpu_present_to_apicid(int mps_cpu)
  123. {
  124. return __default_cpu_present_to_apicid(mps_cpu);
  125. }
  126. int default_check_phys_apicid_present(int phys_apicid)
  127. {
  128. return __default_check_phys_apicid_present(phys_apicid);
  129. }
  130. #endif
  131. struct boot_params boot_params;
  132. /*
  133. * Machine setup..
  134. */
  135. static struct resource data_resource = {
  136. .name = "Kernel data",
  137. .start = 0,
  138. .end = 0,
  139. .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
  140. };
  141. static struct resource code_resource = {
  142. .name = "Kernel code",
  143. .start = 0,
  144. .end = 0,
  145. .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
  146. };
  147. static struct resource bss_resource = {
  148. .name = "Kernel bss",
  149. .start = 0,
  150. .end = 0,
  151. .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
  152. };
  153. #ifdef CONFIG_X86_32
  154. /* cpu data as detected by the assembly code in head.S */
  155. struct cpuinfo_x86 new_cpu_data = {
  156. .wp_works_ok = -1,
  157. };
  158. /* common cpu data for all cpus */
  159. struct cpuinfo_x86 boot_cpu_data __read_mostly = {
  160. .wp_works_ok = -1,
  161. };
  162. EXPORT_SYMBOL(boot_cpu_data);
  163. unsigned int def_to_bigsmp;
  164. /* for MCA, but anyone else can use it if they want */
  165. unsigned int machine_id;
  166. unsigned int machine_submodel_id;
  167. unsigned int BIOS_revision;
  168. struct apm_info apm_info;
  169. EXPORT_SYMBOL(apm_info);
  170. #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
  171. defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
  172. struct ist_info ist_info;
  173. EXPORT_SYMBOL(ist_info);
  174. #else
  175. struct ist_info ist_info;
  176. #endif
  177. #else
  178. struct cpuinfo_x86 boot_cpu_data __read_mostly = {
  179. .x86_phys_bits = MAX_PHYSMEM_BITS,
  180. };
  181. EXPORT_SYMBOL(boot_cpu_data);
  182. #endif
  183. #if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
  184. __visible unsigned long mmu_cr4_features __ro_after_init;
  185. #else
  186. __visible unsigned long mmu_cr4_features __ro_after_init = X86_CR4_PAE;
  187. #endif
  188. /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
  189. int bootloader_type, bootloader_version;
  190. /*
  191. * Setup options
  192. */
  193. struct screen_info screen_info;
  194. EXPORT_SYMBOL(screen_info);
  195. struct edid_info edid_info;
  196. EXPORT_SYMBOL_GPL(edid_info);
  197. extern int root_mountflags;
  198. unsigned long saved_video_mode;
  199. #define RAMDISK_IMAGE_START_MASK 0x07FF
  200. #define RAMDISK_PROMPT_FLAG 0x8000
  201. #define RAMDISK_LOAD_FLAG 0x4000
  202. static char __initdata command_line[COMMAND_LINE_SIZE];
  203. #ifdef CONFIG_CMDLINE_BOOL
  204. static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
  205. #endif
  206. #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
  207. struct edd edd;
  208. #ifdef CONFIG_EDD_MODULE
  209. EXPORT_SYMBOL(edd);
  210. #endif
  211. /**
  212. * copy_edd() - Copy the BIOS EDD information
  213. * from boot_params into a safe place.
  214. *
  215. */
  216. static inline void __init copy_edd(void)
  217. {
  218. memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
  219. sizeof(edd.mbr_signature));
  220. memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
  221. edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
  222. edd.edd_info_nr = boot_params.eddbuf_entries;
  223. }
  224. #else
  225. static inline void __init copy_edd(void)
  226. {
  227. }
  228. #endif
  229. void * __init extend_brk(size_t size, size_t align)
  230. {
  231. size_t mask = align - 1;
  232. void *ret;
  233. BUG_ON(_brk_start == 0);
  234. BUG_ON(align & mask);
  235. _brk_end = (_brk_end + mask) & ~mask;
  236. BUG_ON((char *)(_brk_end + size) > __brk_limit);
  237. ret = (void *)_brk_end;
  238. _brk_end += size;
  239. memset(ret, 0, size);
  240. return ret;
  241. }
  242. #ifdef CONFIG_X86_32
  243. static void __init cleanup_highmap(void)
  244. {
  245. }
  246. #endif
  247. static void __init reserve_brk(void)
  248. {
  249. if (_brk_end > _brk_start)
  250. memblock_reserve(__pa_symbol(_brk_start),
  251. _brk_end - _brk_start);
  252. /* Mark brk area as locked down and no longer taking any
  253. new allocations */
  254. _brk_start = 0;
  255. }
  256. u64 relocated_ramdisk;
  257. #ifdef CONFIG_BLK_DEV_INITRD
  258. static u64 __init get_ramdisk_image(void)
  259. {
  260. u64 ramdisk_image = boot_params.hdr.ramdisk_image;
  261. ramdisk_image |= (u64)boot_params.ext_ramdisk_image << 32;
  262. return ramdisk_image;
  263. }
  264. static u64 __init get_ramdisk_size(void)
  265. {
  266. u64 ramdisk_size = boot_params.hdr.ramdisk_size;
  267. ramdisk_size |= (u64)boot_params.ext_ramdisk_size << 32;
  268. return ramdisk_size;
  269. }
  270. static void __init relocate_initrd(void)
  271. {
  272. /* Assume only end is not page aligned */
  273. u64 ramdisk_image = get_ramdisk_image();
  274. u64 ramdisk_size = get_ramdisk_size();
  275. u64 area_size = PAGE_ALIGN(ramdisk_size);
  276. /* We need to move the initrd down into directly mapped mem */
  277. relocated_ramdisk = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
  278. area_size, PAGE_SIZE);
  279. if (!relocated_ramdisk)
  280. panic("Cannot find place for new RAMDISK of size %lld\n",
  281. ramdisk_size);
  282. /* Note: this includes all the mem currently occupied by
  283. the initrd, we rely on that fact to keep the data intact. */
  284. memblock_reserve(relocated_ramdisk, area_size);
  285. initrd_start = relocated_ramdisk + PAGE_OFFSET;
  286. initrd_end = initrd_start + ramdisk_size;
  287. printk(KERN_INFO "Allocated new RAMDISK: [mem %#010llx-%#010llx]\n",
  288. relocated_ramdisk, relocated_ramdisk + ramdisk_size - 1);
  289. copy_from_early_mem((void *)initrd_start, ramdisk_image, ramdisk_size);
  290. printk(KERN_INFO "Move RAMDISK from [mem %#010llx-%#010llx] to"
  291. " [mem %#010llx-%#010llx]\n",
  292. ramdisk_image, ramdisk_image + ramdisk_size - 1,
  293. relocated_ramdisk, relocated_ramdisk + ramdisk_size - 1);
  294. }
  295. static void __init early_reserve_initrd(void)
  296. {
  297. /* Assume only end is not page aligned */
  298. u64 ramdisk_image = get_ramdisk_image();
  299. u64 ramdisk_size = get_ramdisk_size();
  300. u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size);
  301. if (!boot_params.hdr.type_of_loader ||
  302. !ramdisk_image || !ramdisk_size)
  303. return; /* No initrd provided by bootloader */
  304. memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
  305. }
  306. static void __init reserve_initrd(void)
  307. {
  308. /* Assume only end is not page aligned */
  309. u64 ramdisk_image = get_ramdisk_image();
  310. u64 ramdisk_size = get_ramdisk_size();
  311. u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size);
  312. u64 mapped_size;
  313. if (!boot_params.hdr.type_of_loader ||
  314. !ramdisk_image || !ramdisk_size)
  315. return; /* No initrd provided by bootloader */
  316. initrd_start = 0;
  317. mapped_size = memblock_mem_size(max_pfn_mapped);
  318. if (ramdisk_size >= (mapped_size>>1))
  319. panic("initrd too large to handle, "
  320. "disabling initrd (%lld needed, %lld available)\n",
  321. ramdisk_size, mapped_size>>1);
  322. printk(KERN_INFO "RAMDISK: [mem %#010llx-%#010llx]\n", ramdisk_image,
  323. ramdisk_end - 1);
  324. if (pfn_range_is_mapped(PFN_DOWN(ramdisk_image),
  325. PFN_DOWN(ramdisk_end))) {
  326. /* All are mapped, easy case */
  327. initrd_start = ramdisk_image + PAGE_OFFSET;
  328. initrd_end = initrd_start + ramdisk_size;
  329. return;
  330. }
  331. relocate_initrd();
  332. memblock_free(ramdisk_image, ramdisk_end - ramdisk_image);
  333. }
  334. #else
  335. static void __init early_reserve_initrd(void)
  336. {
  337. }
  338. static void __init reserve_initrd(void)
  339. {
  340. }
  341. #endif /* CONFIG_BLK_DEV_INITRD */
  342. static void __init parse_setup_data(void)
  343. {
  344. struct setup_data *data;
  345. u64 pa_data, pa_next;
  346. pa_data = boot_params.hdr.setup_data;
  347. while (pa_data) {
  348. u32 data_len, data_type;
  349. data = early_memremap(pa_data, sizeof(*data));
  350. data_len = data->len + sizeof(struct setup_data);
  351. data_type = data->type;
  352. pa_next = data->next;
  353. early_memunmap(data, sizeof(*data));
  354. switch (data_type) {
  355. case SETUP_E820_EXT:
  356. parse_e820_ext(pa_data, data_len);
  357. break;
  358. case SETUP_DTB:
  359. add_dtb(pa_data);
  360. break;
  361. case SETUP_EFI:
  362. parse_efi_setup(pa_data, data_len);
  363. break;
  364. default:
  365. break;
  366. }
  367. pa_data = pa_next;
  368. }
  369. }
  370. static void __init e820_reserve_setup_data(void)
  371. {
  372. struct setup_data *data;
  373. u64 pa_data;
  374. pa_data = boot_params.hdr.setup_data;
  375. if (!pa_data)
  376. return;
  377. while (pa_data) {
  378. data = early_memremap(pa_data, sizeof(*data));
  379. e820_update_range(pa_data, sizeof(*data)+data->len,
  380. E820_RAM, E820_RESERVED_KERN);
  381. pa_data = data->next;
  382. early_memunmap(data, sizeof(*data));
  383. }
  384. sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
  385. memcpy(e820_saved, e820, sizeof(struct e820map));
  386. printk(KERN_INFO "extended physical RAM map:\n");
  387. e820_print_map("reserve setup_data");
  388. }
  389. static void __init memblock_x86_reserve_range_setup_data(void)
  390. {
  391. struct setup_data *data;
  392. u64 pa_data;
  393. pa_data = boot_params.hdr.setup_data;
  394. while (pa_data) {
  395. data = early_memremap(pa_data, sizeof(*data));
  396. memblock_reserve(pa_data, sizeof(*data) + data->len);
  397. pa_data = data->next;
  398. early_memunmap(data, sizeof(*data));
  399. }
  400. }
  401. /*
  402. * --------- Crashkernel reservation ------------------------------
  403. */
  404. #ifdef CONFIG_KEXEC_CORE
  405. /* 16M alignment for crash kernel regions */
  406. #define CRASH_ALIGN (16 << 20)
  407. /*
  408. * Keep the crash kernel below this limit. On 32 bits earlier kernels
  409. * would limit the kernel to the low 512 MiB due to mapping restrictions.
  410. * On 64bit, old kexec-tools need to under 896MiB.
  411. */
  412. #ifdef CONFIG_X86_32
  413. # define CRASH_ADDR_LOW_MAX (512 << 20)
  414. # define CRASH_ADDR_HIGH_MAX (512 << 20)
  415. #else
  416. # define CRASH_ADDR_LOW_MAX (896UL << 20)
  417. # define CRASH_ADDR_HIGH_MAX MAXMEM
  418. #endif
  419. static int __init reserve_crashkernel_low(void)
  420. {
  421. #ifdef CONFIG_X86_64
  422. unsigned long long base, low_base = 0, low_size = 0;
  423. unsigned long total_low_mem;
  424. int ret;
  425. total_low_mem = memblock_mem_size(1UL << (32 - PAGE_SHIFT));
  426. /* crashkernel=Y,low */
  427. ret = parse_crashkernel_low(boot_command_line, total_low_mem, &low_size, &base);
  428. if (ret) {
  429. /*
  430. * two parts from lib/swiotlb.c:
  431. * -swiotlb size: user-specified with swiotlb= or default.
  432. *
  433. * -swiotlb overflow buffer: now hardcoded to 32k. We round it
  434. * to 8M for other buffers that may need to stay low too. Also
  435. * make sure we allocate enough extra low memory so that we
  436. * don't run out of DMA buffers for 32-bit devices.
  437. */
  438. low_size = max(swiotlb_size_or_default() + (8UL << 20), 256UL << 20);
  439. } else {
  440. /* passed with crashkernel=0,low ? */
  441. if (!low_size)
  442. return 0;
  443. }
  444. low_base = memblock_find_in_range(low_size, 1ULL << 32, low_size, CRASH_ALIGN);
  445. if (!low_base) {
  446. pr_err("Cannot reserve %ldMB crashkernel low memory, please try smaller size.\n",
  447. (unsigned long)(low_size >> 20));
  448. return -ENOMEM;
  449. }
  450. ret = memblock_reserve(low_base, low_size);
  451. if (ret) {
  452. pr_err("%s: Error reserving crashkernel low memblock.\n", __func__);
  453. return ret;
  454. }
  455. pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (System low RAM: %ldMB)\n",
  456. (unsigned long)(low_size >> 20),
  457. (unsigned long)(low_base >> 20),
  458. (unsigned long)(total_low_mem >> 20));
  459. crashk_low_res.start = low_base;
  460. crashk_low_res.end = low_base + low_size - 1;
  461. insert_resource(&iomem_resource, &crashk_low_res);
  462. #endif
  463. return 0;
  464. }
  465. static void __init reserve_crashkernel(void)
  466. {
  467. unsigned long long crash_size, crash_base, total_mem;
  468. bool high = false;
  469. int ret;
  470. total_mem = memblock_phys_mem_size();
  471. /* crashkernel=XM */
  472. ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base);
  473. if (ret != 0 || crash_size <= 0) {
  474. /* crashkernel=X,high */
  475. ret = parse_crashkernel_high(boot_command_line, total_mem,
  476. &crash_size, &crash_base);
  477. if (ret != 0 || crash_size <= 0)
  478. return;
  479. high = true;
  480. }
  481. /* 0 means: find the address automatically */
  482. if (crash_base <= 0) {
  483. /*
  484. * kexec want bzImage is below CRASH_KERNEL_ADDR_MAX
  485. */
  486. crash_base = memblock_find_in_range(CRASH_ALIGN,
  487. high ? CRASH_ADDR_HIGH_MAX
  488. : CRASH_ADDR_LOW_MAX,
  489. crash_size, CRASH_ALIGN);
  490. if (!crash_base) {
  491. pr_info("crashkernel reservation failed - No suitable area found.\n");
  492. return;
  493. }
  494. } else {
  495. unsigned long long start;
  496. start = memblock_find_in_range(crash_base,
  497. crash_base + crash_size,
  498. crash_size, 1 << 20);
  499. if (start != crash_base) {
  500. pr_info("crashkernel reservation failed - memory is in use.\n");
  501. return;
  502. }
  503. }
  504. ret = memblock_reserve(crash_base, crash_size);
  505. if (ret) {
  506. pr_err("%s: Error reserving crashkernel memblock.\n", __func__);
  507. return;
  508. }
  509. if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) {
  510. memblock_free(crash_base, crash_size);
  511. return;
  512. }
  513. pr_info("Reserving %ldMB of memory at %ldMB for crashkernel (System RAM: %ldMB)\n",
  514. (unsigned long)(crash_size >> 20),
  515. (unsigned long)(crash_base >> 20),
  516. (unsigned long)(total_mem >> 20));
  517. crashk_res.start = crash_base;
  518. crashk_res.end = crash_base + crash_size - 1;
  519. insert_resource(&iomem_resource, &crashk_res);
  520. }
  521. #else
  522. static void __init reserve_crashkernel(void)
  523. {
  524. }
  525. #endif
  526. static struct resource standard_io_resources[] = {
  527. { .name = "dma1", .start = 0x00, .end = 0x1f,
  528. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  529. { .name = "pic1", .start = 0x20, .end = 0x21,
  530. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  531. { .name = "timer0", .start = 0x40, .end = 0x43,
  532. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  533. { .name = "timer1", .start = 0x50, .end = 0x53,
  534. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  535. { .name = "keyboard", .start = 0x60, .end = 0x60,
  536. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  537. { .name = "keyboard", .start = 0x64, .end = 0x64,
  538. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  539. { .name = "dma page reg", .start = 0x80, .end = 0x8f,
  540. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  541. { .name = "pic2", .start = 0xa0, .end = 0xa1,
  542. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  543. { .name = "dma2", .start = 0xc0, .end = 0xdf,
  544. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  545. { .name = "fpu", .start = 0xf0, .end = 0xff,
  546. .flags = IORESOURCE_BUSY | IORESOURCE_IO }
  547. };
  548. void __init reserve_standard_io_resources(void)
  549. {
  550. int i;
  551. /* request I/O space for devices used on all i[345]86 PCs */
  552. for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
  553. request_resource(&ioport_resource, &standard_io_resources[i]);
  554. }
  555. static __init void reserve_ibft_region(void)
  556. {
  557. unsigned long addr, size = 0;
  558. addr = find_ibft_region(&size);
  559. if (size)
  560. memblock_reserve(addr, size);
  561. }
  562. static bool __init snb_gfx_workaround_needed(void)
  563. {
  564. #ifdef CONFIG_PCI
  565. int i;
  566. u16 vendor, devid;
  567. static const __initconst u16 snb_ids[] = {
  568. 0x0102,
  569. 0x0112,
  570. 0x0122,
  571. 0x0106,
  572. 0x0116,
  573. 0x0126,
  574. 0x010a,
  575. };
  576. /* Assume no if something weird is going on with PCI */
  577. if (!early_pci_allowed())
  578. return false;
  579. vendor = read_pci_config_16(0, 2, 0, PCI_VENDOR_ID);
  580. if (vendor != 0x8086)
  581. return false;
  582. devid = read_pci_config_16(0, 2, 0, PCI_DEVICE_ID);
  583. for (i = 0; i < ARRAY_SIZE(snb_ids); i++)
  584. if (devid == snb_ids[i])
  585. return true;
  586. #endif
  587. return false;
  588. }
  589. /*
  590. * Sandy Bridge graphics has trouble with certain ranges, exclude
  591. * them from allocation.
  592. */
  593. static void __init trim_snb_memory(void)
  594. {
  595. static const __initconst unsigned long bad_pages[] = {
  596. 0x20050000,
  597. 0x20110000,
  598. 0x20130000,
  599. 0x20138000,
  600. 0x40004000,
  601. };
  602. int i;
  603. if (!snb_gfx_workaround_needed())
  604. return;
  605. printk(KERN_DEBUG "reserving inaccessible SNB gfx pages\n");
  606. /*
  607. * Reserve all memory below the 1 MB mark that has not
  608. * already been reserved.
  609. */
  610. memblock_reserve(0, 1<<20);
  611. for (i = 0; i < ARRAY_SIZE(bad_pages); i++) {
  612. if (memblock_reserve(bad_pages[i], PAGE_SIZE))
  613. printk(KERN_WARNING "failed to reserve 0x%08lx\n",
  614. bad_pages[i]);
  615. }
  616. }
  617. /*
  618. * Here we put platform-specific memory range workarounds, i.e.
  619. * memory known to be corrupt or otherwise in need to be reserved on
  620. * specific platforms.
  621. *
  622. * If this gets used more widely it could use a real dispatch mechanism.
  623. */
  624. static void __init trim_platform_memory_ranges(void)
  625. {
  626. trim_snb_memory();
  627. }
  628. static void __init trim_bios_range(void)
  629. {
  630. /*
  631. * A special case is the first 4Kb of memory;
  632. * This is a BIOS owned area, not kernel ram, but generally
  633. * not listed as such in the E820 table.
  634. *
  635. * This typically reserves additional memory (64KiB by default)
  636. * since some BIOSes are known to corrupt low memory. See the
  637. * Kconfig help text for X86_RESERVE_LOW.
  638. */
  639. e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED);
  640. /*
  641. * special case: Some BIOSen report the PC BIOS
  642. * area (640->1Mb) as ram even though it is not.
  643. * take them out.
  644. */
  645. e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
  646. sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
  647. }
  648. /* called before trim_bios_range() to spare extra sanitize */
  649. static void __init e820_add_kernel_range(void)
  650. {
  651. u64 start = __pa_symbol(_text);
  652. u64 size = __pa_symbol(_end) - start;
  653. /*
  654. * Complain if .text .data and .bss are not marked as E820_RAM and
  655. * attempt to fix it by adding the range. We may have a confused BIOS,
  656. * or the user may have used memmap=exactmap or memmap=xxM$yyM to
  657. * exclude kernel range. If we really are running on top non-RAM,
  658. * we will crash later anyways.
  659. */
  660. if (e820_all_mapped(start, start + size, E820_RAM))
  661. return;
  662. pr_warn(".text .data .bss are not marked as E820_RAM!\n");
  663. e820_remove_range(start, size, E820_RAM, 0);
  664. e820_add_region(start, size, E820_RAM);
  665. }
  666. static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
  667. static int __init parse_reservelow(char *p)
  668. {
  669. unsigned long long size;
  670. if (!p)
  671. return -EINVAL;
  672. size = memparse(p, &p);
  673. if (size < 4096)
  674. size = 4096;
  675. if (size > 640*1024)
  676. size = 640*1024;
  677. reserve_low = size;
  678. return 0;
  679. }
  680. early_param("reservelow", parse_reservelow);
  681. static void __init trim_low_memory_range(void)
  682. {
  683. memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE));
  684. }
  685. /*
  686. * Dump out kernel offset information on panic.
  687. */
  688. static int
  689. dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
  690. {
  691. if (kaslr_enabled()) {
  692. pr_emerg("Kernel Offset: 0x%lx from 0x%lx (relocation range: 0x%lx-0x%lx)\n",
  693. kaslr_offset(),
  694. __START_KERNEL,
  695. __START_KERNEL_map,
  696. MODULES_VADDR-1);
  697. } else {
  698. pr_emerg("Kernel Offset: disabled\n");
  699. }
  700. return 0;
  701. }
  702. /*
  703. * Determine if we were loaded by an EFI loader. If so, then we have also been
  704. * passed the efi memmap, systab, etc., so we should use these data structures
  705. * for initialization. Note, the efi init code path is determined by the
  706. * global efi_enabled. This allows the same kernel image to be used on existing
  707. * systems (with a traditional BIOS) as well as on EFI systems.
  708. */
  709. /*
  710. * setup_arch - architecture-specific boot-time initializations
  711. *
  712. * Note: On x86_64, fixmaps are ready for use even before this is called.
  713. */
  714. void __init setup_arch(char **cmdline_p)
  715. {
  716. memblock_reserve(__pa_symbol(_text),
  717. (unsigned long)__bss_stop - (unsigned long)_text);
  718. early_reserve_initrd();
  719. /*
  720. * At this point everything still needed from the boot loader
  721. * or BIOS or kernel text should be early reserved or marked not
  722. * RAM in e820. All other memory is free game.
  723. */
  724. #ifdef CONFIG_X86_32
  725. memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
  726. /*
  727. * copy kernel address range established so far and switch
  728. * to the proper swapper page table
  729. */
  730. clone_pgd_range(swapper_pg_dir + KERNEL_PGD_BOUNDARY,
  731. initial_page_table + KERNEL_PGD_BOUNDARY,
  732. KERNEL_PGD_PTRS);
  733. load_cr3(swapper_pg_dir);
  734. /*
  735. * Note: Quark X1000 CPUs advertise PGE incorrectly and require
  736. * a cr3 based tlb flush, so the following __flush_tlb_all()
  737. * will not flush anything because the cpu quirk which clears
  738. * X86_FEATURE_PGE has not been invoked yet. Though due to the
  739. * load_cr3() above the TLB has been flushed already. The
  740. * quirk is invoked before subsequent calls to __flush_tlb_all()
  741. * so proper operation is guaranteed.
  742. */
  743. __flush_tlb_all();
  744. #else
  745. printk(KERN_INFO "Command line: %s\n", boot_command_line);
  746. #endif
  747. /*
  748. * If we have OLPC OFW, we might end up relocating the fixmap due to
  749. * reserve_top(), so do this before touching the ioremap area.
  750. */
  751. olpc_ofw_detect();
  752. early_trap_init();
  753. early_cpu_init();
  754. early_ioremap_init();
  755. setup_olpc_ofw_pgd();
  756. ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
  757. screen_info = boot_params.screen_info;
  758. edid_info = boot_params.edid_info;
  759. #ifdef CONFIG_X86_32
  760. apm_info.bios = boot_params.apm_bios_info;
  761. ist_info = boot_params.ist_info;
  762. #endif
  763. saved_video_mode = boot_params.hdr.vid_mode;
  764. bootloader_type = boot_params.hdr.type_of_loader;
  765. if ((bootloader_type >> 4) == 0xe) {
  766. bootloader_type &= 0xf;
  767. bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
  768. }
  769. bootloader_version = bootloader_type & 0xf;
  770. bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
  771. #ifdef CONFIG_BLK_DEV_RAM
  772. rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
  773. rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
  774. rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
  775. #endif
  776. #ifdef CONFIG_EFI
  777. if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
  778. EFI32_LOADER_SIGNATURE, 4)) {
  779. set_bit(EFI_BOOT, &efi.flags);
  780. } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
  781. EFI64_LOADER_SIGNATURE, 4)) {
  782. set_bit(EFI_BOOT, &efi.flags);
  783. set_bit(EFI_64BIT, &efi.flags);
  784. }
  785. if (efi_enabled(EFI_BOOT))
  786. efi_memblock_x86_reserve_range();
  787. #endif
  788. x86_init.oem.arch_setup();
  789. iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
  790. setup_memory_map();
  791. parse_setup_data();
  792. copy_edd();
  793. if (!boot_params.hdr.root_flags)
  794. root_mountflags &= ~MS_RDONLY;
  795. init_mm.start_code = (unsigned long) _text;
  796. init_mm.end_code = (unsigned long) _etext;
  797. init_mm.end_data = (unsigned long) _edata;
  798. init_mm.brk = _brk_end;
  799. mpx_mm_init(&init_mm);
  800. code_resource.start = __pa_symbol(_text);
  801. code_resource.end = __pa_symbol(_etext)-1;
  802. data_resource.start = __pa_symbol(_etext);
  803. data_resource.end = __pa_symbol(_edata)-1;
  804. bss_resource.start = __pa_symbol(__bss_start);
  805. bss_resource.end = __pa_symbol(__bss_stop)-1;
  806. #ifdef CONFIG_CMDLINE_BOOL
  807. #ifdef CONFIG_CMDLINE_OVERRIDE
  808. strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
  809. #else
  810. if (builtin_cmdline[0]) {
  811. /* append boot loader cmdline to builtin */
  812. strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
  813. strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
  814. strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
  815. }
  816. #endif
  817. #endif
  818. strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
  819. *cmdline_p = command_line;
  820. /*
  821. * x86_configure_nx() is called before parse_early_param() to detect
  822. * whether hardware doesn't support NX (so that the early EHCI debug
  823. * console setup can safely call set_fixmap()). It may then be called
  824. * again from within noexec_setup() during parsing early parameters
  825. * to honor the respective command line option.
  826. */
  827. x86_configure_nx();
  828. parse_early_param();
  829. #ifdef CONFIG_MEMORY_HOTPLUG
  830. /*
  831. * Memory used by the kernel cannot be hot-removed because Linux
  832. * cannot migrate the kernel pages. When memory hotplug is
  833. * enabled, we should prevent memblock from allocating memory
  834. * for the kernel.
  835. *
  836. * ACPI SRAT records all hotpluggable memory ranges. But before
  837. * SRAT is parsed, we don't know about it.
  838. *
  839. * The kernel image is loaded into memory at very early time. We
  840. * cannot prevent this anyway. So on NUMA system, we set any
  841. * node the kernel resides in as un-hotpluggable.
  842. *
  843. * Since on modern servers, one node could have double-digit
  844. * gigabytes memory, we can assume the memory around the kernel
  845. * image is also un-hotpluggable. So before SRAT is parsed, just
  846. * allocate memory near the kernel image to try the best to keep
  847. * the kernel away from hotpluggable memory.
  848. */
  849. if (movable_node_is_enabled())
  850. memblock_set_bottom_up(true);
  851. #endif
  852. x86_report_nx();
  853. /* after early param, so could get panic from serial */
  854. memblock_x86_reserve_range_setup_data();
  855. if (acpi_mps_check()) {
  856. #ifdef CONFIG_X86_LOCAL_APIC
  857. disable_apic = 1;
  858. #endif
  859. setup_clear_cpu_cap(X86_FEATURE_APIC);
  860. }
  861. #ifdef CONFIG_PCI
  862. if (pci_early_dump_regs)
  863. early_dump_pci_devices();
  864. #endif
  865. /* update the e820_saved too */
  866. e820_reserve_setup_data();
  867. finish_e820_parsing();
  868. if (efi_enabled(EFI_BOOT))
  869. efi_init();
  870. dmi_scan_machine();
  871. dmi_memdev_walk();
  872. dmi_set_dump_stack_arch_desc();
  873. /*
  874. * VMware detection requires dmi to be available, so this
  875. * needs to be done after dmi_scan_machine, for the BP.
  876. */
  877. init_hypervisor_platform();
  878. x86_init.resources.probe_roms();
  879. /* after parse_early_param, so could debug it */
  880. insert_resource(&iomem_resource, &code_resource);
  881. insert_resource(&iomem_resource, &data_resource);
  882. insert_resource(&iomem_resource, &bss_resource);
  883. e820_add_kernel_range();
  884. trim_bios_range();
  885. #ifdef CONFIG_X86_32
  886. if (ppro_with_ram_bug()) {
  887. e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
  888. E820_RESERVED);
  889. sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
  890. printk(KERN_INFO "fixed physical RAM map:\n");
  891. e820_print_map("bad_ppro");
  892. }
  893. #else
  894. early_gart_iommu_check();
  895. #endif
  896. /*
  897. * partially used pages are not usable - thus
  898. * we are rounding upwards:
  899. */
  900. max_pfn = e820_end_of_ram_pfn();
  901. /* update e820 for memory not covered by WB MTRRs */
  902. mtrr_bp_init();
  903. if (mtrr_trim_uncached_memory(max_pfn))
  904. max_pfn = e820_end_of_ram_pfn();
  905. max_possible_pfn = max_pfn;
  906. /*
  907. * Define random base addresses for memory sections after max_pfn is
  908. * defined and before each memory section base is used.
  909. */
  910. kernel_randomize_memory();
  911. #ifdef CONFIG_X86_32
  912. /* max_low_pfn get updated here */
  913. find_low_pfn_range();
  914. #else
  915. check_x2apic();
  916. /* How many end-of-memory variables you have, grandma! */
  917. /* need this before calling reserve_initrd */
  918. if (max_pfn > (1UL<<(32 - PAGE_SHIFT)))
  919. max_low_pfn = e820_end_of_low_ram_pfn();
  920. else
  921. max_low_pfn = max_pfn;
  922. high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
  923. #endif
  924. /*
  925. * Find and reserve possible boot-time SMP configuration:
  926. */
  927. find_smp_config();
  928. reserve_ibft_region();
  929. early_alloc_pgt_buf();
  930. /*
  931. * Need to conclude brk, before memblock_x86_fill()
  932. * it could use memblock_find_in_range, could overlap with
  933. * brk area.
  934. */
  935. reserve_brk();
  936. cleanup_highmap();
  937. memblock_set_current_limit(ISA_END_ADDRESS);
  938. memblock_x86_fill();
  939. reserve_bios_regions();
  940. if (efi_enabled(EFI_MEMMAP)) {
  941. efi_fake_memmap();
  942. efi_find_mirror();
  943. efi_esrt_init();
  944. /*
  945. * The EFI specification says that boot service code won't be
  946. * called after ExitBootServices(). This is, in fact, a lie.
  947. */
  948. efi_reserve_boot_services();
  949. }
  950. /* preallocate 4k for mptable mpc */
  951. early_reserve_e820_mpc_new();
  952. #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
  953. setup_bios_corruption_check();
  954. #endif
  955. #ifdef CONFIG_X86_32
  956. printk(KERN_DEBUG "initial memory mapped: [mem 0x00000000-%#010lx]\n",
  957. (max_pfn_mapped<<PAGE_SHIFT) - 1);
  958. #endif
  959. reserve_real_mode();
  960. trim_platform_memory_ranges();
  961. trim_low_memory_range();
  962. init_mem_mapping();
  963. early_trap_pf_init();
  964. /*
  965. * Update mmu_cr4_features (and, indirectly, trampoline_cr4_features)
  966. * with the current CR4 value. This may not be necessary, but
  967. * auditing all the early-boot CR4 manipulation would be needed to
  968. * rule it out.
  969. */
  970. mmu_cr4_features = __read_cr4();
  971. memblock_set_current_limit(get_max_mapped());
  972. /*
  973. * NOTE: On x86-32, only from this point on, fixmaps are ready for use.
  974. */
  975. #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
  976. if (init_ohci1394_dma_early)
  977. init_ohci1394_dma_on_all_controllers();
  978. #endif
  979. /* Allocate bigger log buffer */
  980. setup_log_buf(1);
  981. reserve_initrd();
  982. acpi_table_upgrade();
  983. vsmp_init();
  984. io_delay_init();
  985. /*
  986. * Parse the ACPI tables for possible boot-time SMP configuration.
  987. */
  988. acpi_boot_table_init();
  989. early_acpi_boot_init();
  990. initmem_init();
  991. dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT);
  992. /*
  993. * Reserve memory for crash kernel after SRAT is parsed so that it
  994. * won't consume hotpluggable memory.
  995. */
  996. reserve_crashkernel();
  997. memblock_find_dma_reserve();
  998. #ifdef CONFIG_KVM_GUEST
  999. kvmclock_init();
  1000. #endif
  1001. x86_init.paging.pagetable_init();
  1002. kasan_init();
  1003. #ifdef CONFIG_X86_32
  1004. /* sync back kernel address range */
  1005. clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
  1006. swapper_pg_dir + KERNEL_PGD_BOUNDARY,
  1007. KERNEL_PGD_PTRS);
  1008. /*
  1009. * sync back low identity map too. It is used for example
  1010. * in the 32-bit EFI stub.
  1011. */
  1012. clone_pgd_range(initial_page_table,
  1013. swapper_pg_dir + KERNEL_PGD_BOUNDARY,
  1014. min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
  1015. #endif
  1016. tboot_probe();
  1017. map_vsyscall();
  1018. generic_apic_probe();
  1019. early_quirks();
  1020. /*
  1021. * Read APIC and some other early information from ACPI tables.
  1022. */
  1023. acpi_boot_init();
  1024. sfi_init();
  1025. x86_dtb_init();
  1026. /*
  1027. * get boot-time SMP configuration:
  1028. */
  1029. get_smp_config();
  1030. /*
  1031. * Systems w/o ACPI and mptables might not have it mapped the local
  1032. * APIC yet, but prefill_possible_map() might need to access it.
  1033. */
  1034. init_apic_mappings();
  1035. prefill_possible_map();
  1036. init_cpu_to_node();
  1037. io_apic_init_mappings();
  1038. kvm_guest_init();
  1039. e820_reserve_resources();
  1040. e820_mark_nosave_regions(max_low_pfn);
  1041. x86_init.resources.reserve_resources();
  1042. e820_setup_gap();
  1043. #ifdef CONFIG_VT
  1044. #if defined(CONFIG_VGA_CONSOLE)
  1045. if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
  1046. conswitchp = &vga_con;
  1047. #elif defined(CONFIG_DUMMY_CONSOLE)
  1048. conswitchp = &dummy_con;
  1049. #endif
  1050. #endif
  1051. x86_init.oem.banner();
  1052. x86_init.timers.wallclock_init();
  1053. mcheck_init();
  1054. arch_init_ideal_nops();
  1055. register_refined_jiffies(CLOCK_TICK_RATE);
  1056. #ifdef CONFIG_EFI
  1057. if (efi_enabled(EFI_BOOT))
  1058. efi_apply_memmap_quirks();
  1059. #endif
  1060. }
  1061. #ifdef CONFIG_X86_32
  1062. static struct resource video_ram_resource = {
  1063. .name = "Video RAM area",
  1064. .start = 0xa0000,
  1065. .end = 0xbffff,
  1066. .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  1067. };
  1068. void __init i386_reserve_resources(void)
  1069. {
  1070. request_resource(&iomem_resource, &video_ram_resource);
  1071. reserve_standard_io_resources();
  1072. }
  1073. #endif /* CONFIG_X86_32 */
  1074. static struct notifier_block kernel_offset_notifier = {
  1075. .notifier_call = dump_kernel_offset
  1076. };
  1077. static int __init register_kernel_offset_dumper(void)
  1078. {
  1079. atomic_notifier_chain_register(&panic_notifier_list,
  1080. &kernel_offset_notifier);
  1081. return 0;
  1082. }
  1083. __initcall(register_kernel_offset_dumper);
  1084. void arch_show_smap(struct seq_file *m, struct vm_area_struct *vma)
  1085. {
  1086. if (!boot_cpu_has(X86_FEATURE_OSPKE))
  1087. return;
  1088. seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma));
  1089. }