1. May 02, 2021
  2. Apr 26, 2021
  3. Apr 17, 2021
    • Alexander Egorenkov's avatar
      arm: do not copy magic 4 bytes of appended DTB in zImage · 9817ec81
      Alexander Egorenkov authored
      
      
      If the passed zImage happens to have a DTB appended, then the magic 4 bytes
      of the DTB are copied together with the kernel image. This leads to
      failed kexec boots because the decompressor finds the aforementioned
      DTB magic and falsely tries to replace the DTB passed in the register r2
      with the non-existent appended one.
      
      Signed-off-by: default avatarAlexander Egorenkov <egorenar-dev@posteo.net>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      9817ec81
    • Eric W. Biederman's avatar
      kexec: Remove the error prone kernel_version function · bb6f6f10
      Eric W. Biederman authored
      
      
      During kexec there are two kernel versions at play.  The version of
      the running kernel and the version of the kernel that will be booted.
      
      On powerpc it appears people have been using the version of the
      running kernel to attempt to detect properties of the kernel to be
      booted which is just wrong.  As the linux kernel version that is being
      detected is a no longer supported kernel just remove that buggy and
      confused code.
      
      On x86_64 the kernel_version is used to compute the starting virtual
      address of the running kernel so a proper core dump may be generated.
      Using the kernel_version stopped working a while ago when the starting
      virtual address  became randomized.
      
      The old code was kept for the case where the kernel was not built with
      randomization support, but there is nothing in reading /proc/kcore
      that won't work to detect the starting virtual address even there.
      In fact /proc/kcore must have the starting virtual address or a
      debugger can not make sense of the running kernel.
      
      So just make computing the starting virtual address on x86_64
      unconditional.  With a hard coded fallback just in case something went
      wrong.
      
      Doing something with kernel_version() has become important as recent
      stable kernels have seen the minor version to > 255.  Just removing
      kernel_version() looks like the best option.
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      bb6f6f10
  4. Apr 08, 2021
  5. Apr 02, 2021
    • Simon Horman's avatar
      github: initial workflow · 28b0491b
      Simon Horman authored
      
      
      Initial github workflow which builds kexec on a range of architectures.
      
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      28b0491b
    • Simon Horman's avatar
      build: add distcheck target · e0a17a20
      Simon Horman authored
      
      
      Add distcheck target which aims to exercise build, install and uninstall
      using distribution tarball.
      
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      e0a17a20
    • Simon Horman's avatar
      build: simplify uninstall target · 0eb01542
      Simon Horman authored
      
      
      This appears to have been copied from some generated code.
      Simplify it by rolling repetitive operations into a for loop.
      
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      0eb01542
    • Simon Horman's avatar
      build: use DESTDIR in uninstall target · 93c1e9d8
      Simon Horman authored
      
      
      For symmetry with the install target, also use DESTDIR in the uninstall
      target.
      
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      93c1e9d8
    • Simon Horman's avatar
      build: uninstall kexec_test · fa1d7d53
      Simon Horman authored
      
      
      kexec_test is installed but not uninstalled.
      Correct this oversight.
      
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      fa1d7d53
    • Simon Horman's avatar
      build: add dist make target · 66d2b1a6
      Simon Horman authored
      
      
      This provides a familiar alias for the existing tarball target.
      The result is a tar.gz file.
      
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      66d2b1a6
    • Simon Horman's avatar
      build: create tarball without self-referential hard links · 41b77eda
      Simon Horman authored
      
      
      The current method of creating the tarball, which is to the hard-link
      the source directory to the target directory, results in self-referential
      hardlinks which can be observed using tar xf.
      
      This patch resolves this by using an intermediate tarball, held in memory,
      which collects files to be distributed. This is then unpacked in the target
      directory which is finally packed into the distribution tarball, a file.
      
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      41b77eda
    • David Hildenbrand's avatar
      crashdump/x86: increase CRASH_MAX_MEMORY_RANGES to 32k · 1bc7bc76
      David Hildenbrand authored
      
      
      virtio-mem in Linux adds/removes individual memory blocks (e.g., 128 MB
      each). Linux merges adjacent memory blocks added by virtio-mem devices, but
      we can still end up with a very sparse memory layout when unplugging
      memory in corner cases.
      
      Let's increase the maximum number of crash memory ranges from ~2k to 32k.
      32k should be sufficient for a very long time.
      
      e_phnum field in the header is 16 bits wide, so we can fit a maximum of
      ~64k entries in there, shared with other entries (i.e., CPU). Therefore,
      using up to 32k memory ranges is fine. (if we ever need more than ~64k,
      we can switch to the sh_info field)
      
      Move the temporary xen ranges off the stack, dynamically allocating
      memory for them.
      
      Note: We don't have to increase MAX_MEMORY_RANGES, because virtio-mem
      added memory is driver managed and always detected and added by a
      driver in the kexec'ed kernel; for ordinary kexec, we must not expose
      these ranges in the firmware-provided memmap.
      
      Cc: Simon Horman <horms@verge.net.au>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      1bc7bc76
    • David Hildenbrand's avatar
      crashdump/x86: iterate only over actual crash memory ranges · 77ff3d6f
      David Hildenbrand authored
      
      
      No need to iterate over empty entries.
      
      Cc: Simon Horman <horms@verge.net.au>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      77ff3d6f
    • David Hildenbrand's avatar
      crashdump/x86: dump any kind of "System RAM" · 71758596
      David Hildenbrand authored
      Traditionally, we had "System RAM" only on the top level of in the
      kernel resource tree (-> /proc/iomem). Nowadays, we can also have
      "System RAM" on lower levels of the tree -- driver-managed device memory
      that is always detected and added via drivers. Current examples are
      memory added via dax/kmem -- ("System RAM (kmem)") and virtio-mem ("System
      RAM (virtio_mem)"). Note that in some kernel versions "System RAM
      (kmem)" was exposed as "System RAM", but similarly, on lower levels of
      the resource tree.
      
      Let's add anything that contains "System RAM" to the elf core header, so
      it will be dumped for kexec_load(). Handling kexec_file_load() in the
      kernel is similarly getting fixed [1].
      
      Loading a kdump kernel via "kexec -p -c" ... will result in the kdump
      kernel to also dump dax/kmem and virtio-mem added System RAM now.
      
      Note: We only want to dump this memory, we don't want to add this memory to
      the memmap of an ordinary kexec'ed kernel ("fast system reboot").
      
      [1] https://lkml.kernel.org/r/20210322160200.19633-1-david@redhat.com
      
      
      
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      71758596
    • Raphael Ning's avatar
      kexec-xen: Use correct image type for Live Update · 85721bdd
      Raphael Ning authored
      
      
      Unlike xen_kexec_load(), xen_kexec_unload() and xen_kexec_status()
      fail to distinguish between normal kexec and Xen Live Update image
      types.
      
      Fix that by introducing a new helper function that maps internal
      flags to KEXEC_TYPE_*, and using it throughout kexec-xen.c.
      
      Signed-off-by: default avatarRaphael Ning <raphning@amazon.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      85721bdd
    • Raphael Ning's avatar
      kexec: Make --status work with normal kexec images · 4b97ff97
      Raphael Ning authored
      
      
      According to kexec(8) manpage, --status (-S) works with both
      normal kexec (loaded by -l) and crash kernel (loaded by -p) image
      types, and defaults to the latter. However, the implementation does
      not match the description: `kexec -l -S` queries the -p image type
      as if -l were not specified. This is because there is no internal
      flag defined for the normal kexec type, and -S treats the zero flag
      as the trigger for the default behaviour (-p).
      
      Fix that by making sure the default behaviour for -S is not applied
      when the -l option is present.
      
      Signed-off-by: default avatarRaphael Ning <raphning@amazon.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      4b97ff97
    • Raphael Ning's avatar
      kexec: Fix description of --status exit code · 2c30aa5c
      Raphael Ning authored
      
      
      On both Linux and Xen, an exit code of 0 from `kexec --status`
      indicates that the kexec image being queried is NOT loaded, which
      is contrary to what the man page and usage() say.
      
      Signed-off-by: default avatarRaphael Ning <raphning@amazon.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      2c30aa5c
    • Geert Uytterhoeven's avatar
      printk: Use %zu to format size_t · 82f7de27
      Geert Uytterhoeven authored
      When compiling for 32-bit:
      
          util_lib/elf_info.c: In function ‘dump_dmesg_lockless’:
          util_lib/elf_info.c:1095:39: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
           1095 |   fprintf(stderr, "Failed to malloc %lu bytes for prb: %s\n",
      	  |                                     ~~^
      	  |                                       |
      	  |                                       long unsigned int
      	  |                                     %u
           1096 |    printk_ringbuffer_sz, strerror(errno));
      	  |    ~~~~~~~~~~~~~~~~~~~~
      	  |    |
      	  |    size_t {aka unsigned int}
          util_lib/elf_info.c:1101:49: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
           1101 |   fprintf(stderr, "Failed to read prb of size %lu bytes: %s\n",
      	  |                                               ~~^
      	  |                                                 |
      	  |                                                 long unsigned int
      	  |                                               %u
           1102 |    printk_ringbuffer_sz, strerror(errno));
      	  |    ~~~~~~~~~~~~~~~~~~~~
      	  |    |
      	  |    size_t {aka unsigned int}
      
      Indeed, "size_t" is "unsigned int" on 32-bit platforms, and "unsigned
      long" on 64-bit platforms.
      
      Fix this by formatting using "%zu".
      
      Fixes: 4149df90
      
       ("printk: add support for lockless ringbuffer")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarJohn Ogness <john.ogness@linutronix.de>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      82f7de27
    • Geert Uytterhoeven's avatar
      printk: Use ULL suffix for 64-bit constants · 07b272a0
      Geert Uytterhoeven authored
      When compiling for 32-bit:
      
          util_lib/elf_info.c: In function ‘get_desc_state’:
          util_lib/elf_info.c:923:31: warning: left shift count >= width of type [-Wshift-count-overflow]
            923 | #define DESC_FLAGS_MASK  (3UL << DESC_FLAGS_SHIFT)
      	  |                               ^~
          util_lib/elf_info.c:925:25: note: in expansion of macro ‘DESC_FLAGS_MASK’
            925 | #define DESC_ID_MASK  (~DESC_FLAGS_MASK)
      	  |                         ^~~~~~~~~~~~~~~
          util_lib/elf_info.c:926:30: note: in expansion of macro ‘DESC_ID_MASK’
            926 | #define DESC_ID(sv)  ((sv) & DESC_ID_MASK)
      	  |                              ^~~~~~~~~~~~
          util_lib/elf_info.c:947:12: note: in expansion of macro ‘DESC_ID’
            947 |  if (id != DESC_ID(state_val))
      	  |            ^~~~~~~
          util_lib/elf_info.c: In function ‘id_inc’:
          util_lib/elf_info.c:923:31: warning: left shift count >= width of type [-Wshift-count-overflow]
            923 | #define DESC_FLAGS_MASK...
      07b272a0
    • Geert Uytterhoeven's avatar
      kexec: Use %llu/%llx and casts to format uint64_t · 8519b01f
      Geert Uytterhoeven authored
      When compiling for 32-bit:
      
          kexec/kexec.c: In function ‘cmdline_add_liveupdate’:
          kexec/kexec.c:1192:30: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
           1192 |  sprintf(buf, " liveupdate=%luM@0x%lx", lu_sizeM, lu_start);
      	  |                            ~~^          ~~~~~~~~
      	  |                              |          |
      	  |                              |          uint64_t {aka long long unsigned int}
      	  |                              long unsigned int
      	  |                            %llu
          kexec/kexec.c:1192:37: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
           1192 |  sprintf(buf, " liveupdate=%luM@0x%lx", lu_sizeM, lu_start);
      	  |                                   ~~^             ~~~~~~~~
      	  |                ...
      8519b01f
    • Youling Tang's avatar
      mips: Fix the increased mem parameter size · 84a6ef00
      Youling Tang authored
      The added "mem=size@start" parameter actually corresponds to
      "crashkernel=YM@XM", but 1 byte is missing when calculating
      the size, so 1 byte should be added.
      
      For example, when using crashkernel=108M@64M (110592K@65536K):
      Without this patch:
      	the mem parameter added is: mem=110591K@65536K
      
      With this patch:
      	the mem parameter added is: mem=110592K@65536K
      
      Fixes: 0eac6405
      
       ("kexec: mips: Fix mem parameters")
      
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      84a6ef00
    • Federico Pellegrin's avatar
      i386: fix build on pre 4.4 kernels · d73822b8
      Federico Pellegrin authored
      
      
      kexec build will fail on older kernels (pre 4.4) as the define
      VIDEO_CAPABILITY_64BIT_BASE was not present at that time.
      
      This patch adds it, as per linux/include/uapi/linux/screen_info.h,
      if not present.
      
      Signed-off-by: default avatarFederico Pellegrin <fede@evolware.org>
      Reviewed-by: default avatarKairui Song <kasong@redhat.com>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      d73822b8
    • Youling Tang's avatar
      mips: Fix typo in comment · 60935322
      Youling Tang authored
      
      
      Fix typo in comment.
      
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      60935322
    • Youling Tang's avatar
      mips: Add '--reuse-cmdline' optional parameter support · 15ee19f1
      Youling Tang authored
      
      
      This patch adds an option "--reuse-cmdline" for people that are lazy
      in typing --append="$(cat /proc/cmdline)", which will directly use the
      command line of the currently running system.
      
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      15ee19f1
  6. Dec 17, 2020
  7. Dec 09, 2020
  8. Dec 01, 2020
  9. Nov 16, 2020