setup.c 32 KB

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