setup.c 32 KB

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