index.rst 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. .. SPDX-License-Identifier: GPL-2.0-or-later
  2. .. _kho-concepts:
  3. ========================
  4. Kexec Handover Subsystem
  5. ========================
  6. Overview
  7. ========
  8. Kexec HandOver (KHO) is a mechanism that allows Linux to preserve memory
  9. regions, which could contain serialized system states, across kexec.
  10. KHO uses :ref:`flattened device tree (FDT) <kho_fdt>` to pass information about
  11. the preserved state from pre-exec kernel to post-kexec kernel and :ref:`scratch
  12. memory regions <kho_scratch>` to ensure integrity of the preserved memory.
  13. .. _kho_fdt:
  14. KHO FDT
  15. =======
  16. Every KHO kexec carries a KHO specific flattened device tree (FDT) blob that
  17. describes the preserved state. The FDT includes properties describing preserved
  18. memory regions and nodes that hold subsystem specific state.
  19. The preserved memory regions contain either serialized subsystem states, or
  20. in-memory data that shall not be touched across kexec. After KHO, subsystems
  21. can retrieve and restore the preserved state from KHO FDT.
  22. Subsystems participating in KHO can define their own format for state
  23. serialization and preservation.
  24. KHO FDT and structures defined by the subsystems form an ABI between pre-kexec
  25. and post-kexec kernels. This ABI is defined by header files in
  26. ``include/linux/kho/abi`` directory.
  27. .. toctree::
  28. :maxdepth: 1
  29. abi.rst
  30. .. _kho_scratch:
  31. Scratch Regions
  32. ===============
  33. To boot into kexec, we need to have a physically contiguous memory range that
  34. contains no handed over memory. Kexec then places the target kernel and initrd
  35. into that region. The new kernel exclusively uses this region for memory
  36. allocations before during boot up to the initialization of the page allocator.
  37. We guarantee that we always have such regions through the scratch regions: On
  38. first boot KHO allocates several physically contiguous memory regions. Since
  39. after kexec these regions will be used by early memory allocations, there is a
  40. scratch region per NUMA node plus a scratch region to satisfy allocations
  41. requests that do not require particular NUMA node assignment.
  42. By default, size of the scratch region is calculated based on amount of memory
  43. allocated during boot. The ``kho_scratch`` kernel command line option may be
  44. used to explicitly define size of the scratch regions.
  45. The scratch regions are declared as CMA when page allocator is initialized so
  46. that their memory can be used during system lifetime. CMA gives us the
  47. guarantee that no handover pages land in that region, because handover pages
  48. must be at a static physical memory location and CMA enforces that only
  49. movable pages can be located inside.
  50. After KHO kexec, we ignore the ``kho_scratch`` kernel command line option and
  51. instead reuse the exact same region that was originally allocated. This allows
  52. us to recursively execute any amount of KHO kexecs. Because we used this region
  53. for boot memory allocations and as target memory for kexec blobs, some parts
  54. of that memory region may be reserved. These reservations are irrelevant for
  55. the next KHO, because kexec can overwrite even the original kernel.
  56. .. _kho-finalization-phase:
  57. KHO finalization phase
  58. ======================
  59. To enable user space based kexec file loader, the kernel needs to be able to
  60. provide the FDT that describes the current kernel's state before
  61. performing the actual kexec. The process of generating that FDT is
  62. called serialization. When the FDT is generated, some properties
  63. of the system may become immutable because they are already written down
  64. in the FDT. That state is called the KHO finalization phase.
  65. See Also
  66. ========
  67. - :doc:`/admin-guide/mm/kho`