Skip to content

Kexec as loadable kernel module for Linux AMD64 kernels

License

Notifications You must be signed in to change notification settings

TheTruePerson/kexec-amd64

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

please read

This is an extremely clunky kernel module in the pre-alpha stage. It doesn't even compile lol. Please make any pull requests to improve this program! (sorry for my horrible commit format, I did this entirely locally before creating this repo. and git would not work on my life)

AMD64 kernels already have the kexec functionality built in. This only exists for cases where

  • the kernel has kexec disabled (custom built)
  • it cannot be rebuilt

The most notable example of this is shimboot.

kexec-mod-amd64

Kexec as loadable kernel module for Linux AMD64 kernels based on kexec-mod, which is an ARM64 port.

Purpose

This loadable kernel module enables users of Linux kernels without built-in Kexec support to still make use of Kexec functionality. For instance, you may use this module to boot to a more recent kernel if you are unable to replace the boot image.

Building

(Due to issues with the code, at the moment it fails to build.) The project is comprised of two parts:

  • kernel/ contains the Linux kernel module that exposes Kexec functionality via /dev/kexec.
  • user/ contains a helper library that allows the use of an unpatched kexec-tools.

Pre-requisites

Make sure you have installed the necessary packages for building Linux kernel modules on your system (e.g., make and gcc).

Kernel module

Enter the kernel directory and export the path to the Linux kernel sources against you wish to build:

cd kernel/

Then, build the module using make:

make KDIR=/path/to/linux

This will build kexec_mod.ko and kexec_mod_$ARCH.ko which can be loaded into the Linux kernel.

User-space helper

Enter the user directory and build the helper as follows:

make

This will build redir.so that acts as an LD_PRELOAD interposer for Kexec syscalls, allowing the use of unpatched kexec-tools.

Usage

Make sure you have built the module and user-space helper. Also check whether you have installed kexec-tools. Then, you can use kexec-tools as follows:

LD_PRELOAD=/root/redir.so kexec -l /boot/vmlinuz --reuse-cmdline
LD_PRELOAD=/root/redir.so kexec -e

License

The code is released under the GPLv2 license. See COPYING.txt.

About

Kexec as loadable kernel module for Linux AMD64 kernels

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 85.9%
  • Assembly 12.1%
  • Makefile 2.0%