x86,aarch64,arm

Ciro Santilli 六四事件 法轮功 包卓轩 6b0f89a8b4 aosp 7 年之前
buildroot @ 8ce27bb9fe 12abf43b78 Attempt migration to Buildroot 2017.08 + kernel 4.12. 7 年之前
buildroot_patches 5ad68edd00 Linux 4.12, buildroot 2017.08, Ubuntu 17.10. 7 年之前
global_patch_dir 5393299433 Make global_patch_dir empty 7 年之前
hello_host bb10d0e914 Improve hello_host readme 7 年之前
kernel_module 12abf43b78 Attempt migration to Buildroot 2017.08 + kernel 4.12. 7 年之前
linux @ d4160b40c5 eebcca4e69 You know what? v4.14 7 年之前
qemu @ 09fa182a4e 9ec43c4e88 lkmc_platform_device read example 7 年之前
rootfs_overlay 69eb98b5ab Document debugfs directory created automatically 7 年之前
.gitignore 8ddefa940e gem5 7 年之前
.gitmodules 23eddfb2a2 Shallow clone to save clone time and disk space 7 年之前
.travis.yml 2f82f78589 build without sdl for travis 7 年之前
CONTRIBUTING.md 6c51ecaf7b split build and run scripts due to option conflicts 7 年之前
LICENSE.txt 36cd620dd2 license 7 年之前
README.md 04d2d69623 Update README.md 7 年之前
S99 4727fadcc8 procfs example, S99 symlink 7 年之前
bibliography.md 6b0f89a8b4 aosp 7 年之前
build f5a0111c3e Fix kernel_config_fragment that was getting ignored after gem5 addition 7 年之前
build-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 年之前
buildroot_config_fragment 21da1e9b76 QEMU user mode fun 7 年之前
buildroot_config_fragment_x11 fa5c64a0b0 Make X11 optional 7 年之前
buildroot_override 9133fe023c qemu and linux as submodlues, S98 vs S99, readme benefits of Ctrl + C 7 年之前
busybox_config_fragment 8d668d6ed3 Use busybox devmem 7 年之前
configure 1be85b6dc2 configure: install automake 7 年之前
configure-gem5 8ddefa940e gem5 7 年之前
count-boot-instructions.md 6c51ecaf7b split build and run scripts due to option conflicts 7 年之前
device-tree.md 2ff3648e8f device tree info 7 年之前
ftrace.md f80957cc40 frace docs an mmap minor improvements 7 年之前
gdb-step-debugging.md c7bbc6029a Merge branch 'master' of github.com:cirosantilli/linux-kernel-module-cheat 7 年之前
gdbserver.md 027bca7927 Update gdbserver.md 7 年之前
gem5.md 3a34f9f2a5 gem5 kernel command line arguments 7 年之前
getting-started.md 03f418b53e document how to clean the build in getting started 7 年之前
init.md 920afba40a Disable networking on image with command line option ./build -p -n 7 年之前
kernel_config_arm-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 年之前
kernel_config_fragment 2e04c96fad MODULE_VERSION and srcversion 7 年之前
kernel_config_x86_64-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 年之前
kgdb.md 6c51ecaf7b split build and run scripts due to option conflicts 7 年之前
kmod.md fa0a7e150d Less converstaion 7 年之前
maintainers.md 32c4ce0291 Further improve gem5 documentation 7 年之前
modprobe.md fa0a7e150d Less converstaion 7 年之前
other-architectures.md 6c51ecaf7b split build and run scripts due to option conflicts 7 年之前
qemu-user-mode.md 21da1e9b76 QEMU user mode fun 7 年之前
qemumonitor a8e11e6de9 qemumonitor helper, extra_append from CLI, pci_rescan.sh 7 年之前
record-and-replay.md a070486855 Mention rr on record and replay 7 年之前
rootfs_post_build_script 920afba40a Disable networking on image with command line option ./build -p -n 7 年之前
run 6c51ecaf7b split build and run scripts due to option conflicts 7 年之前
run-on-host.md c7bbc6029a Merge branch 'master' of github.com:cirosantilli/linux-kernel-module-cheat 7 年之前
rungdb b3b1df5560 bak 7 年之前
rungdb-user 52c3ee15dc Userland without gdbserver 7 年之前
rungdbserver b89ba9b799 gdbserver shared library 7 年之前
rungem5 3a34f9f2a5 gem5 kernel command line arguments 7 年之前
rungem5-shell 8ddefa940e gem5 7 年之前
screenshot.png 53c1b61879 screenshot, vm to description, qemu debug non intrusive 7 年之前
user_table b2459d07f5 Add a non-root user user0 password "a" 7 年之前
x11.md 6c51ecaf7b split build and run scripts due to option conflicts 7 年之前
x11.png 01f6ca24e5 x11 screenshot and link to insmod C 7 年之前

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.14 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