x86,aarch64,arm

Ciro Santilli 31fa73327b Inird hardcoded, TODO add run option 7 år sedan
buildroot @ 8ce27bb9fe 12abf43b78 Attempt migration to Buildroot 2017.08 + kernel 4.12. 7 år sedan
buildroot_patches 5ad68edd00 Linux 4.12, buildroot 2017.08, Ubuntu 17.10. 7 år sedan
global_patch_dir 5393299433 Make global_patch_dir empty 7 år sedan
hello_host bb10d0e914 Improve hello_host readme 7 år sedan
kernel_module dc495f9334 Linux v4.15 7 år sedan
linux @ 225d02dc63 dc495f9334 Linux v4.15 7 år sedan
qemu @ 09fa182a4e 9ec43c4e88 lkmc_platform_device read example 7 år sedan
rootfs_overlay c771b40913 rand_check_poweroff.sh + random stuff 7 år sedan
.gitignore 8ddefa940e gem5 7 år sedan
.gitmodules 23eddfb2a2 Shallow clone to save clone time and disk space 7 år sedan
.travis.yml 2f82f78589 build without sdl for travis 7 år sedan
CONTRIBUTING.md c771b40913 rand_check_poweroff.sh + random stuff 7 år sedan
LICENSE.txt 36cd620dd2 license 7 år sedan
README.md dc495f9334 Linux v4.15 7 år sedan
S99 4727fadcc8 procfs example, S99 symlink 7 år sedan
bibliography.md 6b0f89a8b4 aosp 7 år sedan
build f5a0111c3e Fix kernel_config_fragment that was getting ignored after gem5 addition 7 år sedan
build-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 år sedan
buildroot_config_fragment 31fa73327b Inird hardcoded, TODO add run option 7 år sedan
buildroot_config_fragment_x11 fa5c64a0b0 Make X11 optional 7 år sedan
buildroot_override 9133fe023c qemu and linux as submodlues, S98 vs S99, readme benefits of Ctrl + C 7 år sedan
busybox_config_fragment 8d668d6ed3 Use busybox devmem 7 år sedan
configure cf063ad8d2 Bail out of shallow cloning if it fails, and do full clone instead 7 år sedan
configure-gem5 8ddefa940e gem5 7 år sedan
count-boot-instructions.md 6c51ecaf7b split build and run scripts due to option conflicts 7 år sedan
device-tree.md 2ff3648e8f device tree info 7 år sedan
ftrace.md f80957cc40 frace docs an mmap minor improvements 7 år sedan
gdb-step-debugging.md c052a83205 nokaslr, thanks to @dakami at close #12 7 år sedan
gdbserver.md 027bca7927 Update gdbserver.md 7 år sedan
gem5.md 3a34f9f2a5 gem5 kernel command line arguments 7 år sedan
getting-started.md 03f418b53e document how to clean the build in getting started 7 år sedan
init.md 920afba40a Disable networking on image with command line option ./build -p -n 7 år sedan
kernel_config_arm-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 år sedan
kernel_config_fragment 31fa73327b Inird hardcoded, TODO add run option 7 år sedan
kernel_config_x86_64-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 år sedan
kgdb.md 6c51ecaf7b split build and run scripts due to option conflicts 7 år sedan
kmod.md fa0a7e150d Less converstaion 7 år sedan
maintainers.md 7bd1508c98 Improve maintainer guideline on Linux updates 7 år sedan
modprobe.md fa0a7e150d Less converstaion 7 år sedan
other-architectures.md 6c51ecaf7b split build and run scripts due to option conflicts 7 år sedan
qemu-user-mode.md 21da1e9b76 QEMU user mode fun 7 år sedan
qemumonitor a8e11e6de9 qemumonitor helper, extra_append from CLI, pci_rescan.sh 7 år sedan
record-and-replay.md a070486855 Mention rr on record and replay 7 år sedan
rootfs_post_build_script 920afba40a Disable networking on image with command line option ./build -p -n 7 år sedan
run 31fa73327b Inird hardcoded, TODO add run option 7 år sedan
run-on-host.md c7bbc6029a Merge branch 'master' of github.com:cirosantilli/linux-kernel-module-cheat 7 år sedan
rungdb c052a83205 nokaslr, thanks to @dakami at close #12 7 år sedan
rungdb-user 52c3ee15dc Userland without gdbserver 7 år sedan
rungdbserver b89ba9b799 gdbserver shared library 7 år sedan
rungem5 3a34f9f2a5 gem5 kernel command line arguments 7 år sedan
rungem5-shell 8ddefa940e gem5 7 år sedan
screenshot.png 53c1b61879 screenshot, vm to description, qemu debug non intrusive 7 år sedan
user_table b2459d07f5 Add a non-root user user0 password "a" 7 år sedan
x11.md 6c51ecaf7b split build and run scripts due to option conflicts 7 år sedan
x11.png 01f6ca24e5 x11 screenshot and link to insmod C 7 år sedan

README.md

Linux Kernel Module Cheat

Run one command, get a QEMU Buildroot BusyBox virtual machine built from source with several minimal Linux kernel 4.15 module development example tutorials with GDB and KGDB step debugging and minimal educational hardware models. Limited GEM5 full system support. "Tested" in x86, ARM and MIPS guests, Ubuntu 17.10 host.

Reserve 12Gb of disk and run:

git clone https://github.com/cirosantilli/linux-kernel-module-cheat
cd linux-kernel-module-cheat
./configure && ./build && ./run

The first build will take a while (GCC, Linux kernel), e.g.:

  • 2 hours on a mid end 2012 laptop
  • 30 minutes on a high end 2017 desktop

If you don't want to wait, you could also try to compile the examples and run them on your host computer as explained on the "Run on host" section, but as explained on that section, that is dangerous, limited, and will likely not work.

After QEMU opens up, you can start playing with the kernel modules:

root
insmod /hello.ko
insmod /hello2.ko
rmmod hello
rmmod hello2

This should print to the screen:

hello init
hello2 init
hello cleanup
hello2 cleanup

which are printk messages from init and cleanup methods of those modules.

All available modules can be found in the kernel_module directory.

See the getting started section for further details.

  1. Getting started
  2. Action
    1. Step debugging
      1. GDB step debugging
      2. KGDB
      3. gdbserver
    2. Other architectures
    3. modprobe
    4. X11
    5. Count boot instructions
    6. GEM5
    7. ftrace
    8. QEMU user mode
  3. Failed action
    1. Record and replay
  4. Insane action
    1. Run on host
    2. Hello host
  5. Conversation
    1. kmod
    2. Device tree
    3. Maintainers
    4. Bibliography