setup.c 32 KB

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