函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\kexec-bzimage64.c Create Date:2022-07-27 09:37:02
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:bzImage64_load

函数原型:static void *bzImage64_load(struct kimage *image, char *kernel, unsigned long kernel_len, char *initrd, unsigned long initrd_len, char *cmdline, unsigned long cmdline_len)

返回类型:void

参数:

类型参数名称
struct kimage *image
char *kernel
unsigned longkernel_len
char *initrd
unsigned longinitrd_len
char *cmdline
unsigned longcmdline_len
342  ret等于0
349  setup_hdr_offset等于offsetof(structboot_params, hdr)
351  struct kexec_buf kbuf = {image = image, buf_max = ULONG_MAX, top_down = true}
353  struct kexec_buf pbuf = {image = image, buf_min = Defines lowest physical address for various segments. Not sure where* exactly these limits came from. Current bzimage64 loader in kexec-tools* uses these so I am retaining it. It can be changed over time as we gain* more insight., buf_max = ULONG_MAX, top_down = true}
356  header等于kernelsetup_hdr_offset
357  setup_sects等于安装信息设置标志
358  如果setup_sects恒等于0则setup_sects等于4
361  kern16_size等于setup_sects加1的和乘512
362  如果kernel_len小于kern16_size
363  打印错误信息("bzImage truncated\n")
364  返回:错误号
367  如果cmdline_len大于命令行长度
368  打印错误信息("Kernel command line too long\n")
369  返回:错误号
376  如果cmdline_lenlfcorehdr=0x<64bit-value> 大于命令行长度
377  pr_debug("Appending elfcorehdr=<addr> to command line exceeds maximum allowed length\n")
378  返回:错误号
382  如果 Flags to indicate special processing 恒等于KEXEC_TYPE_CRASH
383  ret等于crash_load_segments(image)
384  如果ret则返回:错误号
392  ret等于kexec_load_purgatory(image, & pbuf)
393  如果ret
394  打印错误信息("Loading purgatory failed\n")
395  返回:错误号
398  pr_debug("Loaded purgatory at 0x%lx\n", mem)
409  efi_map_sz等于efi_get_runtime_map_size()
410  params_cmdline_sz等于boot_params的长度加cmdline_lenlfcorehdr=0x<64bit-value>
412  params_cmdline_sz等于@a is a power of 2 value (params_cmdline_sz, 16)
413  bufsz等于params_cmdline_sz@a is a power of 2 value (efi_map_sz, 16)加sizeof(structsetup_data)加sizeof(structefi_setup_data)
417  params等于分配内存并置零
418  如果非params则返回:错误号
420  efi_map_offset等于params_cmdline_sz
421  efi_setup_data_offset等于efi_map_offset@a is a power of 2 value (efi_map_sz, 16)
424  setup_header_size等于0x0202加kernel[0x0201]减setup_hdr_offset
427  memcpy( & 启动头, (kernel + setup_hdr_offset), setup_header_size)
429  buffer等于params
430  memsz等于bufsz
431  buf_align等于16
432  buf_min等于MIN_BOOTPARAM_ADDR
433  ret等于kexec_add_buffer( & kbuf)
434  如果ret则转到:out_free_params
436  bootparam_load_addr等于mem
437  pr_debug("Loaded boot_param, command line and misc at 0x%lx bufsz=0x%lx memsz=0x%lx\n", bootparam_load_addr, bufsz, bufsz)
441  buffer等于kernelkern16_size
442  bufsz等于kernel_lenkern16_size
443  memsz等于 align the pointer to the (next) page boundary (初始程序大小)
444  buf_align等于内核对齐值
445  buf_min等于MIN_KERNEL_LOAD_ADDR
446  mem等于If kexec_buf.mem is set to this value, kexec_locate_mem_hole()* will try to allocate free memory. Arch may overwrite it.
447  ret等于kexec_add_buffer( & kbuf)
448  如果ret则转到:out_free_params
450  kernel_load_addr等于mem
452  pr_debug("Loaded 64bit kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n", kernel_load_addr, bufsz, memsz)
456  如果initrd
457  buffer等于initrd
458  bufsz等于memsz等于initrd_len
459  buf_align等于PAGE_SIZE
460  buf_min等于MIN_INITRD_LOAD_ADDR
461  mem等于If kexec_buf.mem is set to this value, kexec_locate_mem_hole()* will try to allocate free memory. Arch may overwrite it.
462  ret等于kexec_add_buffer( & kbuf)
463  如果ret则转到:out_free_params
465  initrd_load_addr等于mem
467  pr_debug("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n", initrd_load_addr, initrd_len, initrd_len)
470  setup_initrd(params, initrd_load_addr, initrd_len)
473  setup_cmdline(image, params, bootparam_load_addr, boot_params的长度, cmdline, cmdline_len)
477  内核载入类型等于0x0D左移4位
478  内核载入标志等于0
481  ret等于kexec_purgatory_get_set_symbol(image, "entry64_regs", & regs64, regs64的长度, 1)
483  如果ret则转到:out_free_params
486  rbx等于0
487  rsi等于bootparam_load_addr
488  rip等于kernel_load_addr加0x200
489  stack等于kexec_purgatory_get_symbol_addr(image, "stack_end")
490  如果是错误
491  打印错误信息("Could not find address of symbol stack_end\n")
492  ret等于负EINVAL
493  转到:out_free_params
496  rsp等于stack
497  ret等于kexec_purgatory_get_set_symbol(image, "entry64_regs", & regs64, regs64的长度, 0)
499  如果ret则转到:out_free_params
502  ret等于setup_boot_parameters(image, params, bootparam_load_addr, efi_map_offset, efi_map_sz, efi_setup_data_offset)
505  如果ret则转到:out_free_params
509  ldata等于分配内存并置零
510  如果非ldata
511  ret等于负ENOMEM
512  转到:out_free_params
520  Temporary buffer to hold bootparams buffer. This should be* freed once the bootparam segment has been loaded.等于params
521  返回:ldata
523  out_free_params :
524  释放内存
525  返回:错误号