summaryrefslogtreecommitdiff
path: root/build/kernel_vm.sh
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 11:49:22 -0300
committerGabriel Schneider <[email protected]>2026-11-10 12:19:06 -0300
commit297943b01e18bb3d1dd41a8d3e220811de25228b (patch)
tree4938e643abada811d3ab28b14c0e31dc94ebda62 /build/kernel_vm.sh
parentdb923fa823354270217362db06356f2b1a41315e (diff)
downloadcomputeranim-297943b01e18bb3d1dd41a8d3e220811de25228b.tar.gz
computeranim-297943b01e18bb3d1dd41a8d3e220811de25228b.zip
ztrace probe: BPF on syscalls, scheduling, kprobes, uprobes and USDT
Programs built as instruction arrays for one process (no compiler, no libbpf), writing Events into a BPF ring buffer; a drop counter in a map; task_struct offsets from the kernel's BTF; a USDT probe's arguments read in the kernel at the probe. Without CAP_BPF and CAP_PERFMON it says so; --dry-run builds and lists everything. Tested offline by running the programs in a small BPF machine, and for real by test-kernel-vm, which boots this kernel in QEMU where we are root. ztrace perf: moments are no longer cut per event unless --cut; --max-size, and a full recording stops the target and says so. perf.Sorted merges two backends' events by time. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'build/kernel_vm.sh')
-rw-r--r--build/kernel_vm.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/build/kernel_vm.sh b/build/kernel_vm.sh
new file mode 100644
index 0000000..ac7c576
--- /dev/null
+++ b/build/kernel_vm.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# usage: kernel_vm.sh INIT COMMANDS FILE...
+# Boots this machine's kernel in QEMU on an initramfs of the files given
+# (and the C library, for the dynamic ones): INIT is its /init and runs each
+# line of COMMANDS as root. What the console says goes to stdout.
+set -e
+stage=$(mktemp -d)
+trap 'rm -rf "$stage" "$stage.cpio"' EXIT
+mkdir -p "$stage/proc" "$stage/sys" "$stage/dev" "$stage/lib64" "$stage/usr/lib"
+cp "$1" "$stage/init"
+cp "$2" "$stage/commands"
+shift 2
+cp "$@" "$stage/"
+cp /lib64/ld-linux-x86-64.so.2 "$stage/lib64/"
+cp /usr/lib/libc.so.6 "$stage/usr/lib/"
+(cd "$stage" && find . | cpio -o -H newc --quiet) >"$stage.cpio"
+timeout 120 qemu-system-x86_64 -enable-kvm -cpu host -m 512 -display none -serial stdio -no-reboot \
+ -kernel "/usr/lib/modules/$(uname -r)/vmlinuz" -initrd "$stage.cpio" \
+ -append "console=ttyS0 quiet panic=-1"